Ejemplo n.º 1
0
 public function remap_list_country($name, $value)
 {
     $country_code_list = AECToolbox::getCountryCodeList();
     $code_list = array();
     foreach ($country_code_list as $country) {
         $code_list[] = JHTML::_('select.option', $country, JText::_('COUNTRYCODE_' . $country));
     }
     $this->lists[$name] = JHTML::_('select.genericlist', $code_list, $name . '[]', 'size="10" multiple="multiple"', 'value', 'text', $value);
     return 'list';
 }
 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;
 }