/** * @param string $format */ static function getCountryCodeList($format = null) { global $aecConfig; $regular = AECToolbox::getISO3166_1a2_codes(); if (!empty($aecConfig->cfg['countries_available'])) { $countries = $aecConfig->cfg['countries_available']; } else { $countries = $regular; } if (!empty($aecConfig->cfg['countries_top'])) { // Merge top countries to beginning of list $countries = array_merge($aecConfig->cfg['countries_top'], array(null), $countries); } if ($format) { switch ($format) { case 'a2': return $countries; break; default: $conversion = AECToolbox::ISO3166_conversiontable('a2', $format); $newlist = array(); foreach ($countries as $c) { $newlist[] = $conversion[$c]; } return $newlist; break; } } else { return $countries; } }
public function checkVatNumber($number, $country, $vatlist) { if (!$this->settings['vat_validation']) { return true; } if (strlen($country) == 2) { $conversion = AECToolbox::ISO3166_conversiontable('a2', 'a3'); $country = $conversion[$country]; } $check = false; if (array_key_exists($country, $vatlist)) { $check = preg_match($vatlist[$country]["regex"], $number); $countrycode = substr($vatlist[$country]["regex"], 3, 2); } else { $match = false; foreach ($vatlist as $ccode => $cc) { if (!$match) { $match = preg_match($cc["regex"], $number); if ($match) { $check = true; $countrycode = substr($cc["regex"], 3, 2); } } } } if ($this->settings['vat_validation'] == 2 && $check) { return $this->viesValidation(substr($number, 2), $countrycode); } else { return $check; } }
public function getUserform($var = array(), $values = null, $metaUser = null, $content = array()) { $lang = JFactory::getLanguage(); global $aecConfig; if (empty($values)) { $values = array('firstname', 'lastname'); } $name = array('', ''); if (is_object($metaUser)) { if (isset($metaUser->cmsUser->name)) { $name = explode(' ', $metaUser->cmsUser->name); if (empty($content['firstname'])) { $content['firstname'] = $name[0]; } if (empty($content['lastname']) && isset($name[1])) { $content['lastname'] = $name[1]; } else { $content['lastname'] = ''; } } } $fieldlist = explode("\n", AECToolbox::rewriteEngine($aecConfig->cfg['user_checkout_prefill'], $metaUser)); $cfgarray = array(); foreach ($fieldlist as $fcontent) { $c = explode('=', $fcontent, 2); if (!is_array($c)) { continue; } if (empty($c[0])) { continue; } if (!empty($c[1])) { $cfgarray[$c[0]] = trim($c[1]); } else { $cfgarray[$c[0]] = ""; } } $translatelist = array('firstname' => 'billFirstName', 'lastname' => 'billLastName', 'address' => 'billAddress', 'address2' => 'billAddress2', 'city' => 'billCity', 'nonus' => 'billNonUs', 'state' => 'billState', 'state_us' => 'billState', 'state_usca' => 'billState', 'zip' => 'billZip', 'country_list' => 'billCountry', 'country3_list' => 'billCountry', 'country' => 'billCountry', 'phone' => 'billPhone', 'fax' => 'billFax', 'company' => 'billCompany'); $cfgtranslatelist = array('state_us' => 'state', 'state_usca' => 'state', 'country_list' => 'country', 'country3_list' => 'country'); foreach ($values as $value) { if (strpos($value, '*')) { $pf = '*'; $value = substr($value, 0, -1); } else { $pf = ''; } $vcontent = ''; if (isset($content[$value])) { $vcontent = $content[$value]; } elseif (isset($translatelist[$value])) { if (isset($content[$translatelist[$value]])) { $vcontent = $content[$translatelist[$value]]; } } if (empty($vcontent)) { if (isset($cfgtranslatelist[$value])) { $xvalue = $cfgtranslatelist[$value]; } else { $xvalue = $value; } if (!empty($cfgarray[strtolower($xvalue)])) { $vcontent = $cfgarray[strtolower($xvalue)]; } } switch (strtolower($value)) { case 'firstname': $var['params']['billFirstName'] = array('inputC', JText::_('AEC_USERFORM_BILLFIRSTNAME_NAME') . $pf, JText::_('AEC_USERFORM_BILLFIRSTNAME_DESC'), $vcontent); break; case 'lastname': $var['params']['billLastName'] = array('inputC', JText::_('AEC_USERFORM_BILLLASTNAME_NAME') . $pf, JText::_('AEC_USERFORM_BILLLASTNAME_DESC'), $vcontent); break; case 'address': $var['params']['billAddress'] = array('inputC', JText::_('AEC_USERFORM_BILLADDRESS_NAME') . $pf, JText::_('AEC_USERFORM_BILLADDRESS_DESC'), $vcontent); break; case 'address2': $var['params']['billAddress2'] = array('inputC', JText::_('AEC_USERFORM_BILLADDRESS2_NAME') . $pf, JText::_('AEC_USERFORM_BILLADDRESS2_DESC'), $vcontent); break; case 'city': $var['params']['billCity'] = array('inputC', JText::_('AEC_USERFORM_BILLCITY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCITY_DESC'), $vcontent); break; case 'nonus': $var['params']['billNonUs'] = array('checkbox', JText::_('AEC_USERFORM_BILLNONUS_NAME') . $pf, JText::_('AEC_USERFORM_BILLNONUS_DESC'), $vcontent, 1); break; case 'state': $var['params']['billState'] = array('inputC', JText::_('AEC_USERFORM_BILLSTATE_NAME') . $pf, JText::_('AEC_USERFORM_BILLSTATE_DESC'), $vcontent); break; case 'state_us': $states = array('', '--- United States ---', 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY', 'AA', 'AE', 'AP', 'AS', 'FM', 'GU', 'MH', 'MP', 'PR', 'PW', 'VI'); $statelist = array(); foreach ($states as $state) { if (strpos($state, '---') !== false) { $statelist[] = JHTML::_('select.option', 'NONSELECT', $state, 'value', 'text', true); } else { $statelist[] = JHTML::_('select.option', $state, $state); } } $var['params']['lists']['billState'] = JHTML::_('select.genericlist', $statelist, 'billState', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLSTATE_DESC') . '"', 'value', 'text', $vcontent); $var['params']['billState'] = array('list', JText::_('AEC_USERFORM_BILLSTATE_NAME') . $pf, JText::_('AEC_USERFORM_BILLSTATE_DESC')); break; case 'state_usca': $states = array('', '--- United States ---', 'AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY', 'AA', 'AE', 'AP', 'AS', 'FM', 'GU', 'MH', 'MP', 'PR', 'PW', 'VI', '--- Canada ---', 'AB', 'BC', 'MB', 'NB', 'NL', 'NT', 'NS', 'NU', 'ON', 'PE', 'QC', 'SK', 'YT'); $statelist = array(); foreach ($states as $state) { if (strpos($state, '---') !== false) { $statelist[] = JHTML::_('select.option', 'NONSELECT', $state, 'value', 'text', true); } else { $statelist[] = JHTML::_('select.option', $state, $state); } } $var['params']['lists']['billState'] = JHTML::_('select.genericlist', $statelist, 'billState', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLSTATEPROV_DESC') . '"', 'value', 'text', $vcontent); $var['params']['billState'] = array('list', JText::_('AEC_USERFORM_BILLSTATEPROV_NAME') . $pf, JText::_('AEC_USERFORM_BILLSTATEPROV_DESC')); break; case 'zip': $var['params']['billZip'] = array('inputC', JText::_('AEC_USERFORM_BILLZIP_NAME') . $pf, JText::_('AEC_USERFORM_BILLZIP_DESC'), $vcontent); break; case 'country_list': $countries = AECToolbox::getCountryCodeList(); $countrylist[] = JHTML::_('select.option', '', JText::_('COUNTRYCODE_SELECT'), 'value', 'text', true); if (empty($vcontent)) { $vcontent = 'US'; } $countrylist = array(); foreach ($countries as $country) { if (!empty($country)) { $cname = JText::_('COUNTRYCODE_' . $country); if ($vcontent == $cname) { $vcontent = $country; } $countrylist[] = JHTML::_('select.option', $country, $cname); } } $var['params']['lists']['billCountry'] = JHTML::_('select.genericlist', $countrylist, 'billCountry', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLCOUNTRY_DESC') . '"', 'value', 'text', $vcontent); $var['params']['billCountry'] = array('list', JText::_('AEC_USERFORM_BILLCOUNTRY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOUNTRY_DESC')); break; case 'country3_list': $countries = AECToolbox::getCountryCodeList('num'); if (empty($vcontent)) { $vcontent = 826; } $conversion = AECToolbox::ISO3166_conversiontable('num', 'a2'); $countrylist = array(); $countrylist[] = JHTML::_('select.option', '', JText::_('COUNTRYCODE_SELECT'), 'value', 'text', true); foreach ($countries as $country) { if ($lang->hasKey('COUNTRYCODE_' . $conversion[$country])) { $cname = JText::_('COUNTRYCODE_' . $conversion[$country]); if ($vcontent == $cname) { $vcontent = $country; } $countrylist[] = JHTML::_('select.option', $country, $cname); } elseif (is_null($country)) { $countrylist[] = JHTML::_('select.option', '', " -- -- -- -- -- -- ", 'value', 'text', true); } } $var['params']['lists']['billCountry'] = JHTML::_('select.genericlist', $countrylist, 'billCountry', 'size="1" class="aec_formfield" title="' . JText::_('AEC_USERFORM_BILLCOUNTRY_DESC') . '"', 'value', 'text', $vcontent); $var['params']['billCountry'] = array('list', JText::_('AEC_USERFORM_BILLCOUNTRY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOUNTRY_DESC')); break; case 'country': $var['params']['billCountry'] = array('inputC', JText::_('AEC_USERFORM_BILLCOUNTRY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOUNTRY_DESC'), $vcontent); break; case 'phone': $var['params']['billPhone'] = array('inputC', JText::_('AEC_USERFORM_BILLPHONE_NAME') . $pf, JText::_('AEC_USERFORM_BILLPHONE_DESC'), $vcontent); break; case 'fax': $var['params']['billFax'] = array('inputC', JText::_('AEC_USERFORM_BILLFAX_NAME') . $pf, JText::_('AEC_USERFORM_BILLFAX_DESC'), $vcontent); break; case 'company': $var['params']['billCompany'] = array('inputC', JText::_('AEC_USERFORM_BILLCOMPANY_NAME') . $pf, JText::_('AEC_USERFORM_BILLCOMPANY_DESC'), $vcontent); break; } } return $var; }