/**
 * Zikula_View function to get a country name from a given country name.
 *
 * Available parameters:
 *   - assign:   If set, the results are assigned to the corresponding variable instead of printed out
 *   - code:     Country code to get the corresponding name for
 *
 * Example
 *   {get_country_name_for_country_code  code=ZZ}
 *
 * @param array       $params All attributes passed to this function from the template.
 * @param Zikula_View $view   Reference to the Zikula_View object.
 *
 * @return string The value of the last status message posted, or void if no status message exists.
 */
function smarty_function_get_country_name_for_country_code($params, Zikula_View $view)
{
    $code = strtolower(isset($params['code']) ? $params['code'] : 'ZZ');
    $assign = isset($params['assign']) ? $params['assign'] : null;
    $countries = ZLanguage::countryMap();
    if (isset($countries[$code])) {
        $result = $countries[$code];
    } else {
        $result = $countries['ZZ'];
    }
    if ($assign) {
        $view->assign($assign, $result);
    } else {
        return $result;
    }
}
Esempio n. 2
0
 /**
  * Return the HTML for the country selector.
  *
  * @param string  $name          The name of the generated selector (default='countries') (optional).
  * @param string  $selectedValue The value which is currently selected (default='') (optional).
  * @param string  $defaultValue  The default value to select (default='') (optional).
  * @param string  $defaultText   The text for the default value (default='') (optional).
  * @param integer $allValue      The value to assign for the "All" choice (optional) (default=0).
  * @param string  $allText       The text to display for the "All" choice (optional) (default='').
  * @param boolean $submit        Whether or not to auto-submit the selector.
  * @param boolean $disabled      Whether or not to disable selector (optional) (default=false).
  * @param integer $multipleSize  The size to use for a multiple selector, 1 produces a normal/single selector (optional (default=1).
  *
  * @return The generated HTML for the selector.
  */
 public static function getSelector_Countries($name = 'countries', $selectedValue = '', $defaultValue = 0, $defaultText = '', $allValue = 0, $allText = '', $submit = false, $disabled = false, $multipleSize = 1)
 {
     $countries = ZLanguage::countryMap();
     asort($countries);
     return self::getSelector_Generic($name, $countries, $selectedValue, $defaultValue, $defaultText, $allValue, $allText, $submit, $disabled, $multipleSize);
 }
Esempio n. 3
0
 /**
  * Checks if string field value is a valid country code.
  *
  * @param string  $fieldName     The name of the property to be checked
  * @return boolean result of this check
  */
 public function isValidCountry($fieldName)
 {
     $countryMap = ZLanguage::countryMap();
     return in_array($this->entity[$fieldName], array_keys($countryMap));
 }