[-] BO : #PSCFV-731 : change type int by string for zipcode_from and zipcode_to

&& check this zip codes
 && display errors
 && normalize

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@15187 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
lLefevre
2012-05-10 15:50:44 +00:00
parent 172a330268
commit bf17db5463
8 changed files with 137 additions and 115 deletions
+10 -14
View File
@@ -149,23 +149,19 @@ class AddressControllerCore extends FrontController
{
if (($postcode = Tools::getValue('postcode')) && $zip_code_format)
{
$zip_regexp = '/^'.$zip_code_format.'$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
if (!preg_match($zip_regexp, $postcode))
$this->errors[] = '<strong>'.Tools::displayError('Zip / Postal code').'</strong> '
.Tools::displayError('is invalid.').'<br />'.Tools::displayError('Must be typed as follows:')
.' '.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
if (!$country->checkZipCode($postcode))
$this->errors[] = sprintf(
Tools::displayError('Zip / Postal code is invalid. Must be typed as follows: %s'),
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
);
}
else if ($zip_code_format)
$this->errors[] = '<strong>'.Tools::displayError('Zip / Postal code').'</strong> '.Tools::displayError('is required.');
$this->errors[] = Tools::displayError('Zip / Postal code is required.');
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
$this->errors[] = '<strong>'.Tools::displayError('Zip / Postal code').'</strong> '.Tools::displayError('is invalid.')
.'<br />'.Tools::displayError('Must be typed as follows:').' '
.str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
$this->errors[] = sprintf(
Tools::displayError('Zip / Postal code is invalid. Must be typed as follows: %s'),
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $country->zip_code_format)))
);
}
// Check country DNI