Hi,
I am still stuck with Joomla! 1.0.x, so the contribution goes to the 2.3.9 component and 0.6 mambot.
Hopefully this can be reused somehow in the 3.0 branch.
This hack preserves existing classes of form elements used by the validation. So that the build of the html part of the form can be done more cleanly.
This hack will also allow for the element to be broken by newlines.
e.g.:
<input
type="text"
name="email" />
Caveats (also presents in the original code):
- class tag will have " and not ' (or whatever the one used before).
- it won't check for php code, so mixing php inside the element can be dangerous.
This is located in chronocontact.php around line 79 for the component and around line 70 in the mambot:
Replace both with this:
-enjoy
rsd
I am still stuck with Joomla! 1.0.x, so the contribution goes to the 2.3.9 component and 0.6 mambot.
Hopefully this can be reused somehow in the 3.0 branch.
This hack preserves existing classes of form elements used by the validation. So that the build of the html part of the form can be done more cleanly.
This hack will also allow for the element to be broken by newlines.
e.g.:
<input
type="text"
name="email" />
Caveats (also presents in the original code):
- class tag will have " and not ' (or whatever the one used before).
- it won't check for php code, so mixing php inside the element can be dangerous.
This is located in chronocontact.php around line 79 for the component and around line 70 in the mambot:
if( trim($paramsvalues->validate) == 'Yes'){
// Easy Validation //
preg_match_all('/name=("|\').*?("|\')/i', $htmlstring, $matches);
$arr_required = explode(",", str_replace(" ","",$paramsvalues->val_required));
$arr_validate_number = explode(",", str_replace(" ","",$paramsvalues->val_validate_number));
$arr_validate_digits = explode(",", str_replace(" ","",$paramsvalues->val_validate_digits));
$arr_validate_alpha = explode(",", str_replace(" ","",$paramsvalues->val_validate_alpha));
$arr_validate_alphanum = explode(",", str_replace(" ","",$paramsvalues->val_validate_alphanum));
$arr_validate_date = explode(",", str_replace(" ","",$paramsvalues->val_validate_date));
$arr_validate_email = explode(",", str_replace(" ","",$paramsvalues->val_validate_email));
$arr_validate_url = explode(",", str_replace(" ","",$paramsvalues->val_validate_url));
$arr_validate_date_au = explode(",", str_replace(" ","",$paramsvalues->val_validate_date_au));
$arr_validate_currency_dollar = explode(",", str_replace(" ","",$paramsvalues->val_validate_currency_dollar));
$arr_validate_selection = explode(",", str_replace(" ","",$paramsvalues->val_validate_selection));
$arr_validate_one_required = explode(",", str_replace(" ","",$paramsvalues->val_validate_one_required));
$arr_all = array_merge($arr_required, $arr_validate_number, $arr_validate_digits, $arr_validate_alpha, $arr_validate_alphanum, $arr_validate_date, $arr_validate_email, $arr_validate_url, $arr_validate_date_au,
$arr_validate_currency_dollar, $arr_validate_selection, $arr_validate_one_required);
foreach ($matches[0] as $match)
{
$new_match = preg_replace('/name=("|\')/i', '', $match);
$new_match2 = preg_replace('/("|\')/', '', $new_match);
$name = preg_replace('/name=("|\')/', '', $new_match2);
$class_array = array();
if(in_array($name,$arr_all)){
if(in_array($name,$arr_required)){
$class_array[] = "required";
}
if(in_array($name,$arr_validate_number)){
$class_array[] = "validate-number";
}
if(in_array($name,$arr_validate_digits)){
$class_array[] = "validate-digits";
}
if(in_array($name,$arr_validate_alpha)){
$class_array[] = "validate-alpha";
}
if(in_array($name,$arr_validate_alphanum)){
$class_array[] = "validate-alphanum";
}
if(in_array($name,$arr_validate_date)){
$class_array[] = "validate-date";
}
if(in_array($name,$arr_validate_email)){
$class_array[] = "validate-email";
}
if(in_array($name,$arr_validate_url)){
$class_array[] = "validate-url";
}
if(in_array($name,$arr_validate_date_au)){
$class_array[] = "validate-date-au";
}
if(in_array($name,$arr_validate_currency_dollar)){
$class_array[] = "validate-currency-dollar";
}
if(in_array($name,$arr_validate_selection)){
$class_array[] = "validate-selection";
}
if(in_array($name,$arr_validate_one_required)){
$class_array[] = "validate-one-required";
}
$class_string = implode(" ",$class_array);
$htmlstring = str_replace($match,$match.' class="'.$class_string.'"',$htmlstring);
}
}
Replace both with this:
if( trim($paramsvalues->validate) == 'Yes'){
// Easy Validation //
preg_match_all('/<.*?\n*?[^<.]*?name=("|\').*?("|\')[^>.]*?\n*?.*?>/iu', $htmlstring, $matches);
$arr_required = explode(",", str_replace(" ","",$paramsvalues->val_required));
$arr_validate_number = explode(",", str_replace(" ","",$paramsvalues->val_validate_number));
$arr_validate_digits = explode(",", str_replace(" ","",$paramsvalues->val_validate_digits));
$arr_validate_alpha = explode(",", str_replace(" ","",$paramsvalues->val_validate_alpha));
$arr_validate_alphanum = explode(",", str_replace(" ","",$paramsvalues->val_validate_alphanum));
$arr_validate_date = explode(",", str_replace(" ","",$paramsvalues->val_validate_date));
$arr_validate_email = explode(",", str_replace(" ","",$paramsvalues->val_validate_email));
$arr_validate_url = explode(",", str_replace(" ","",$paramsvalues->val_validate_url));
$arr_validate_date_au = explode(",", str_replace(" ","",$paramsvalues->val_validate_date_au));
$arr_validate_currency_dollar = explode(",", str_replace(" ","",$paramsvalues->val_validate_currency_dollar));
$arr_validate_selection = explode(",", str_replace(" ","",$paramsvalues->val_validate_selection));
$arr_validate_one_required = explode(",", str_replace(" ","",$paramsvalues->val_validate_one_required));
$arr_all = array_merge($arr_required, $arr_validate_number, $arr_validate_digits, $arr_validate_alpha, $arr_validate_alphanum, $arr_validate_date, $arr_validate_email, $arr_validate_url, $arr_validate_date_au,
$arr_validate_currency_dollar, $arr_validate_selection, $arr_validate_one_required);
foreach ($matches[0] as $tag)
{
$class_array = array();
preg_match('/name=("|\')(.*?)("|\')/iu', $tag, $matches2);
$name = $matches2[2];
if (!strlen($name))
continue;
/* get existing class */
preg_match('/class=("|\')(.*?)("|\')/iu', $tag, $matches2);
$class = $matches2[2];
if (strlen($class))
$class_array[] = $class;
if(in_array($name,$arr_all)){
if(in_array($name,$arr_required)){
$class_array[] = "required";
}
if(in_array($name,$arr_validate_number)){
$class_array[] = "validate-number";
}
if(in_array($name,$arr_validate_digits)){
$class_array[] = "validate-digits";
}
if(in_array($name,$arr_validate_alpha)){
$class_array[] = "validate-alpha";
}
if(in_array($name,$arr_validate_alphanum)){
$class_array[] = "validate-alphanum";
}
if(in_array($name,$arr_validate_date)){
$class_array[] = "validate-date";
}
if(in_array($name,$arr_validate_email)){
$class_array[] = "validate-email";
}
if(in_array($name,$arr_validate_url)){
$class_array[] = "validate-url";
}
if(in_array($name,$arr_validate_date_au)){
$class_array[] = "validate-date-au";
}
if(in_array($name,$arr_validate_currency_dollar)){
$class_array[] = "validate-currency-dollar";
}
if(in_array($name,$arr_validate_selection)){
$class_array[] = "validate-selection";
}
if(in_array($name,$arr_validate_one_required)){
$class_array[] = "validate-one-required";
}
}
$class_string = implode(" ",$class_array);
$new_tag = preg_replace('/class=("|\').*?("|\')/i', '', $tag);
$new_tag = preg_replace('/name/i', 'class="' . $class_string . '" name', $new_tag);
$htmlstring = str_replace($tag,$new_tag,$htmlstring);
}
-enjoy
rsd