public function remap_list_country_full($name, $value) { $country_code_list = AECToolbox::getISO3166_1a2_codes(); $code_list = array(); foreach ($country_code_list as $country) { $code_list[] = JHTML::_('select.option', $country, $country . " - " . JText::_('COUNTRYCODE_' . $country)); } $this->lists[$name] = JHTML::_('select.genericlist', $code_list, $name . '[]', 'size="10" multiple="multiple"', 'value', 'text', $value); return 'list'; }
public function getMIform($request, $checkout = true, $alwayspermit = false, $useredit = false) { global $aecConfig; $language_array = AECToolbox::getISO3166_1a2_codes(); $language_code_list = array(); foreach ($language_array as $language) { $language_code_list[] = JHTML::_('select.option', $language, JText::_('COUNTRYCODE_' . $language)); } $settings = array(); $lists = array(); $hasregistration = true; if (!empty($request->metaUser->cmsUser)) { if (count($request->metaUser->cmsUser) < 4) { $hasregistration = false; } } else { $hasregistration = false; } $settings['validation'] = array(); $settings['validation']['rules'] = array(); $settings['formatting'] = array(); if (!empty($this->settings['emulate_reg']) && (empty($request->metaUser->userid) && !$hasregistration || !$checkout)) { if (defined('JPATH_MANIFESTS')) { // Joomla 1.6+ Registration $lang = JFactory::getLanguage(); $lang->load('com_users', JPATH_SITE, 'en-GB', true); $lang->load('com_users', JPATH_SITE, $lang->get('tag'), true); $settings['name'] = array('inputC', JText::_('COM_USERS_PROFILE_NAME_LABEL'), 'name', ''); $settings['username'] = array('inputC', JText::_('COM_USERS_PROFILE_USERNAME_LABEL'), 'username', ''); $settings['email'] = array('inputC', JText::_('COM_USERS_PROFILE_EMAIL1_LABEL'), 'email', ''); $settings['email2'] = array('inputC', JText::_('COM_USERS_PROFILE_EMAIL2_LABEL'), 'email', ''); $settings['password'] = array('password', JText::_('COM_USERS_REGISTER_PASSWORD1_LABEL'), 'password', ''); $settings['password2'] = array('password', JText::_('COM_USERS_REGISTER_PASSWORD2_LABEL'), 'password2', ''); $settings['validation']['rules']['name'] = array('minlength' => 2, 'required' => true); $settings['validation']['rules']['username'] = array('minlength' => 3, 'alphanumericwhitespace' => true, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=usernameexists"); $settings['validation']['rules']['email'] = array('nowhitespace' => true, 'email' => true, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=emailexists"); $settings['validation']['rules']['email2'] = array('nowhitespace' => true, 'email' => true, 'required' => true, 'equalTo' => '#mi_' . $this->id . '_email'); $settings['validation']['rules']['password'] = array('minlength' => 6, 'maxlength' => 98, 'required' => true); $settings['validation']['rules']['password2'] = array('minlength' => 6, 'maxlength' => 98, 'required' => true, 'equalTo' => '#mi_' . $this->id . '_password'); } else { // Joomla 1.5 Registration $settings['name'] = array('inputC', JText::_('Name'), 'name', ''); $settings['username'] = array('inputC', JText::_('User name'), 'username', ''); $settings['email'] = array('inputC', JText::_('Email'), 'email', ''); $settings['password'] = array('password', JText::_('Password'), 'password', ''); $settings['password2'] = array('password', JText::_('Verify Password'), 'password2', ''); $settings['validation']['rules']['name'] = array('minlength' => 2, 'required' => true); $settings['validation']['rules']['username'] = array('minlength' => 3, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=usernameexists"); $settings['validation']['rules']['email'] = array('email' => true, 'required' => true, 'remote' => "index.php?option=com_acctexp&task=emailexists"); $settings['validation']['rules']['password'] = array('minlength' => 2, 'required' => true); $settings['validation']['rules']['password2'] = array('minlength' => 2, 'required' => true, 'equalTo' => '#mi_' . $this->id . '_password'); } if (!$checkout) { foreach ($settings as $s => $v) { if ($s == 'validation' || strpos($s, 'password') !== false) { continue; } $v[3] = $request->metaUser->cmsUser->{str_replace("2", "", $s)}; $settings[$s] = $v; } } if ($aecConfig->cfg['use_recaptcha'] && !empty($aecConfig->cfg['recaptcha_publickey']) && $checkout) { require_once JPATH_SITE . '/components/com_acctexp/lib/recaptcha/recaptchalib.php'; $settings['recaptcha'] = array('passthrough', 'ReCAPTCHA', 'recaptcha', recaptcha_get_html($aecConfig->cfg['recaptcha_publickey'])); } } elseif (!empty($this->settings['emulate_reg']) && !empty($this->settings['display_emul'])) { $settings['name'] = array('passthrough', JText::_('Name'), 'name', '<p><strong>' . $request->metaUser->cmsUser->name . '</strong></p>'); $settings['username'] = array('passthrough', JText::_('User name'), 'username', '<p><strong>' . $request->metaUser->cmsUser->username . '</strong></p>'); $settings['email'] = array('passthrough', JText::_('Email'), 'email', '<p><strong>' . $request->metaUser->cmsUser->email . '</strong></p>'); } if (!empty($this->settings['settings'])) { for ($i = 0; $i < $this->settings['settings']; $i++) { $p = $i . '_'; if (!isset($this->settings[$p . 'short'])) { continue; } if (!empty($request->params[$this->settings[$p . 'short']])) { $content = $request->params[$this->settings[$p . 'short']]; } elseif (!empty($_POST['mi_' . $request->parent->id . '_' . $this->settings[$p . 'short']])) { $content = aecGetParam('mi_' . $request->parent->id . '_' . $this->settings[$p . 'short'], true, array('string', 'badchars')); } else { $content = AECToolbox::rewriteEngineRQ($this->settings[$p . 'default'], $request); } if (!empty($this->settings[$p . 'fixed']) && !$checkout && !$alwayspermit) { $settings[$this->settings[$p . 'name']] = array('passthrough', $this->settings[$p . 'name'], $this->settings[$p . 'short'], '<p><strong>' . $content . '</strong></p>'); continue; } if (!empty($this->settings[$p . 'short'])) { if ($this->settings[$p . 'type'] == 'list') { $extra = explode("\n", $this->settings[$p . 'list']); if (!count($extra)) { continue; } $fields = array(); foreach ($extra as $ex) { $fields[] = explode("|", $ex); } if ($this->settings[$p . 'ltype']) { $settings[$this->settings[$p . 'short'] . '_desc'] = array('p', $this->settings[$p . 'name']); $settings[$this->settings[$p . 'short']] = array('hidden', null, 'mi_' . $this->id . '_' . $this->settings[$p . 'short']); foreach ($fields as $id => $field) { if (!empty($field[1])) { $settings[$this->settings[$p . 'short'] . $id] = array('radio', 'mi_' . $this->id . '_' . $this->settings[$p . 'short'], trim($field[0]), true, trim($field[1])); } } continue; } else { $options = array(); foreach ($fields as $field) { if (!empty($field[1])) { $options[] = JHTML::_('select.option', trim($field[0]), trim($field[1])); } } $lists[$this->settings[$p . 'short']] = JHTML::_('select.genericlist', $options, $this->settings[$p . 'short'], 'size="1"', 'value', 'text', 0); } } if (!empty($this->settings[$p . 'mandatory'])) { $settings['validation']['rules'][$this->settings[$p . 'short']] = array('required' => true); } if ($this->settings[$p . 'type'] == 'list_language') { $lists[$this->settings[$p . 'short']] = JHTML::_('select.genericlist', $language_code_list, $this->settings[$p . 'short'], 'size="10"', 'value', 'text', $content); $this->settings[$p . 'type'] = 'list'; } if (!empty($this->settings[$p . 'formatting'])) { $settings['formatting'][] = array('id' => 'mi_' . $this->id . '_' . $this->settings[$p . 'short'], 'pattern' => $this->settings[$p . 'formatting']); } if ($this->settings[$p . 'type'] == 'checkbox') { $settings[$this->settings[$p . 'short']] = array($this->settings[$p . 'type'], $this->settings[$p . 'name'], $this->settings[$p . 'desc'], $content, $this->settings[$p . 'default']); } elseif ($this->settings[$p . 'type'] == 'list') { $settings[$this->settings[$p . 'short']] = array($this->settings[$p . 'type'], $this->settings[$p . 'name'], $this->settings[$p . 'name'], 'mi_' . $this->id . '_' . $this->settings[$p . 'short']); } else { $settings[$this->settings[$p . 'short']] = array($this->settings[$p . 'type'], $this->settings[$p . 'name'], $this->settings[$p . 'name'], $content); } if (!empty($this->settings[$p . 'validationtype'])) { $settings['validation']['rules'][$this->settings[$p . 'short']] = array(); foreach ($this->settings[$p . 'validationtype'] as $vtype) { $settings['validation']['rules'][$this->settings[$p . 'short']][$vtype] = true; } } } } } if ($useredit) { $unset = array('validation', 'username'); foreach ($unset as $k) { if (isset($settings[$k])) { unset($settings[$k]); } } $pref = 'mi_' . $this->id . '_'; foreach ($settings as $k => $v) { $settings[$pref . $k] = $v; unset($settings[$k]); } } if (!empty($lists)) { $settings['lists'] = $lists; } return $settings; }
/** * @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; } }