Technology Tools for Ministry

Community

Web-Empowered Church User Community
All Categories > Ministry Tools > Servant Matcher Extension > Fault in HTML Syntax in check_for_valid_fields
Total Posts: 4 - Pages (1): [1]
Author: Jonathan Uhlmann
Posted: Jun 18 2007 - 08:31 AM
Subject: Fault in HTML Syntax in check_for_valid_fields
Hello everyone

I've found a fault in the HTML-Parsing in the function "check_for_valid_fields" (Found in class.tx_wecservant_pi1.php on line 1573)
This function check fpr valid fields and generate a list with the errors. The Problem is that the list look like that:

<li>Error #1, <br/>
<li>Error #2, <br/>
<li>Error #3, <br/>

But it should like like this:

<ul>
<li>Error #1</li>
<li>Error #2</li>
<li>Error #3</li>
</ul>

I changed the function "check_for_valid_fields" in "class.tx_wecservant_pi1.php" on line 1573

function check_for_valid_fields() {
$error = "";
if (is_array($this->config['required_formfields']) && count($this->config['required_formfields'])>0) {
$whichOne = 0;
foreach ($this->config['required_formfields'] AS $req_field) {
if (empty($this->postvars[$req_field])) {
// Comment out if ($whichOne++ > 0)
// Comment out $error .= ", ";
$error .= '<li> "'.ucfirst($this->pi_getLL('form_'.$req_field.'_label')).'" '.$this->pi_getLL('form_required_blank')."</li>n";
}
}
// Comment out if ($whichOne > 0) $error .= ".<br>";
}
// check if optional one is required
foreach ($this->postvars as $fieldName => $fieldValue) {
$lastCh = substr($fieldName,strlen($fieldName)-1,1);
if ($lastCh == '+') { // required marker
$shortFieldName = substr($fieldName,0,strlen($fieldName)-1);
$altFieldValue = 0;
if ($this->postvars[$shortFieldName]) {
$altFieldValue = $this->postvars[$shortFieldName];
}
if (!$altFieldValue && (!strlen($fieldValue) || empty($fieldValue))) {
$fieldName = substr($fieldName,0,strlen($fieldName)-1);
$fieldName = strtr($fieldName,'_',' ');
$error .= '<li> "'.ucfirst($fieldName).'" '.$this->pi_getLL('form_required_blank')."</li>n";
}
}
}
if (!empty($this->postvars['email'])) {
if (t3lib_div::validEmail($this->postvars['email']) == false) {
$error .= '<li>"'.$this->pi_getLL('form_email_label').'" ('.$this->pi_getLL('form_invalid_field').")</li>n";
}
}
if (strlen($error) == 0)
return 0;
else
return "<ul>". $error ."</ul>";
}


Like that the list is parsed properly.

Greetings from Switzerland
Jonathan Uhlmann

Author: Dave Slayback
Posted: Jun 18 2007 - 08:52 AM
Subject: re: Fault in HTML Syntax in check_for_valid_fields
Hi Jonathan,

Thanks for reporting this. I will fix the problem in the next update of the Servant extension.

-Dave
Author: Jonathan Uhlmann
Posted: Jul 02 2007 - 05:33 AM
Subject: re: re: Fault in HTML Syntax in check_for_valid_fields
Hi Dave

There's still an error in the syntax: You have to wrap the list with <ul> </ul>.

In line 1698 in the file class.tx_wecservant_pi1 you wrote:

########## CODE START ##################
if (strlen($error) == 0)
return 0;
else
return $error;
############ CODE END ##################

But this generates a list without the ul-tags

So i make a change in line 1701:

########## CODE START ##################
if (strlen($error) == 0)
return 0;
else
return "<ul>". $error ."</ul>";
############ CODE END ##################


Regards,
Jonathan
Author: Dave Slayback
Posted: Jul 02 2007 - 10:40 AM
Subject: re: Fault in HTML Syntax in check_for_valid_fields
Good point. The <li>...</li> works for me in the HTML output but to be semantically correct, it should have the <ul>...</ul> too.

So that has been fixed and will be in latest version.

-Dave
Total Posts: 4 - Pages (1): [1]
You must login to post a message to this conference.