Return a selection of states or provinces for canada.

@param array $options

@return LibBaseTemplateTag
541018
public function state($options = array())
    {
        $options = new AnConfig($options);

        $options->append(array(
            'country_selector' => 'countery-selector',
            'country' => 'US',
            'selected' => null,
            'use_state_code' => true,
            'prompt' => true,
        ));

        $country = strtolower($options->country);

        $country_selector = null;

        if ($options->country_selector) {
            $country_selector = $options->country_selector;
        }

        $use_state_code = $options->use_state_code;

        unset($options->use_state_code);
        unset($options->country);
        unset($options->country_selector);

        $states = array();
        $provinces = array();

        foreach (self::$US_STATES as $key => $name) {
            $states[$use_state_code ? $key : $name] = AnTranslator::_($name);
        }

        foreach (self::$CANADA_PROVINCES as $key => $name) {
            $provinces[$use_state_code ? $key : $name] = AnTranslator::_($name);
        }

        $selected = $options->selected;

        unset($options->selected);

        $options = AnConfig::unbox($options);

        $states = $this->_html->select($options['name'], array('options' => $states, 'selected' => $selected), array_merge($options, array('country' => 'us')));
        $provinces = $this->_html->select($options['name'], array('options' => $provinces, 'selected' => $selected), array_merge($options, array('country' => 'canada')));
        $custom = $this->_html->textfield($options['name'], $selected, array_merge($options, array('country' => 'custom')));

        if (empty($country_selector)) {
            return $country == 'us' ? $states : $provinces;
        }

        return $states.$provinces.$custom;
    }
567686
public function getList(array $options = array())
    {
        $result = null;
        $this->hook->attach('sku.list.before', $options, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $sql = 'SELECT ps.*, p.title, p.currency';

        if (!empty($options['count'])) {
            $sql = 'SELECT COUNT(ps.product_sku_id)';
        }

        $sql .= ' FROM product_sku ps LEFT JOIN product p ON(ps.product_id = p.product_id)';

        $conditions = array();

        if (isset($options['product_sku_id'])) {
            $sql .= ' WHERE ps.product_sku_id = ?';
            $conditions[] = $options['product_sku_id'];
        } else {
            $sql .= ' WHERE ps.product_sku_id IS NOT NULL';
        }

        if (isset($options['sku'])) {
            $sql .= ' AND ps.sku=?';
            $conditions[] = $options['sku'];
        }

        if (isset($options['store_id'])) {
            $sql .= ' AND p.store_id=?';
            $conditions[] = $options['store_id'];
        }

        if (isset($options['title_sku'])) {
            $sql .= ' AND (p.title LIKE ? OR ps.sku LIKE ?)';
            $conditions[] = "%{$options['title_sku']}%";
            $conditions[] = "%{$options['title_sku']}%";
        }

        if (isset($options['product_id'])) {
            $sql .= ' AND ps.product_id=?';
            $conditions[] = $options['product_id'];
        }

        if (isset($options['combination_id'])) {
            $sql .= ' AND ps.combination_id=?';
            $conditions[] = $options['combination_id'];
        }

        if (isset($options['status'])) {
            $sql .= ' AND ps.status=?';
            $conditions[] = (int) $options['status'];
        }

        $sql .= " ORDER BY ps.sku ASC";

        if (!empty($options['limit'])) {
            $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit']));
        }

        if (empty($options['count'])) {
            $list = $this->db->fetchAll($sql, $conditions, array('index' => 'product_sku_id'));
            $result = $this->prepareList($list);
        } else {
            $result = (int) $this->db->fetchColumn($sql, $conditions);
        }

        $this->hook->attach('sku.list.after', $options, $result, $this);
        return $result;
    }
619761
def get_countrytag(country):
    """"""
    norm_name = {
        'australia': 'Australia',
        'brazil': 'Brazil',
        'brasil': 'Brazil',
        'canada': 'Canada',
        'european union': 'European Union',
        'eu': 'European Union',
        'e.u.': 'European Union',
        'france': 'France',
        'mexico': 'Mexico',
        'méxico': 'Mexico',
        'méjico': 'Mexico',
        'spain': 'Spain',
        'espana': 'Spain',
        'españa': 'Spain',
        'uk': 'United Kingdom',
        'u.k.': 'United Kingdom',
        'united kingdom': 'United Kingdom',
        'united states of america': 'United States',
        'united states': 'United States',
        'us': 'United States',
        'usa': 'United States',
        'u.s.': 'United States',
        'u.s.a.': 'United States'
    }
    if country is not None and country.lower() in norm_name:
        return REGIONTAGS.get(norm_name.get(country.lower()))
    else:
        raise ValueError(
            'The available regions are {0}.'.format(
                ', '.join('\'{}\''.format(k) for k in REGIONTAGS)))
1330546
public function options()
    {
        $countries = $this->all();
        $options = Collection::make();
        foreach ($countries as $country) {
            $options->push(['name' => $country->name, 'id' => $country->id]);
        }
        return $options;
    }
1200695
public function getFilterOptions(array $options = array()) {
		$options['types'] = $this->comment->getType();
		$options['subtypes'] = array($this->comment->getSubtype(), 'hjcomment');
		$options['container_guids'] = $this->comment->container_guid;
		if (!isset($options['order_by'])) {
			$options['order_by'] = 'e.guid ASC';
		}
		return $options;
	}
1356180
public function addOptions(array $options) : Select
    {
        foreach ($options as $value => $content) {
            $this->addOption($content, $value);
        }

        return $this;
    }
419059
public static function getcountries()
	{
		$countries = array();

		if (!($gdb = self::getGeoDBO()))
		{
			return $countries;
		}

		$gdb->setQuery("SELECT code, name FROM countries ORDER BY name");
		$results = $gdb->loadObjectList();

		if ($results)
		{
			foreach ($results as $row)
			{
				if ($row->code != '-' && $row->name != '-')
				{
					array_push($countries, array(
						'code' => strtolower($row->code),
						'id'   => $row->code,
						'name' => $row->name
					));
				}
			}
		}

		return $countries;
	}
1078620
public function getContents(array $options=array()){
		$options['quality']=isset($options['quality'])?$options['quality']:80;
		ob_start();
		@imagejpeg($this->resource,null,$options['quality']);
		return ob_get_clean();
	}
442372
public static function selectOptions($optionsArray, $selected = NULL) {
    $ret = array();
    foreach ($optionsArray as $value => $label) {
      if ($label instanceof HTMLTag) {
        $tag = $label;
        
        if ($tag->getAttribute('value') === $selected)
          $tag->setAttribute('selected','selected');

      } else {
        /* Interface Form Item */
        if($label instanceof \Psc\Form\Item) {
          $item = $label;
          $label = $item->getFormLabel();
          $value = $item->getFormValue();
        }
        
        $tag = static::tag('option',self::esc((string) $label),array('value'=>$value));
        if ($value === $selected)
          $tag->setAttribute('selected','selected');
      }
      
      $ret[] = $tag;
    }
    return $ret;
  }
1106518
private function getSelectedStates(Args $args)
    {
        $states = array();

        if ($args->isOptionSet('enabled')) {
            $states[] = ModuleState::ENABLED;
        }

        if ($args->isOptionSet('not-found')) {
            $states[] = ModuleState::NOT_FOUND;
        }

        if ($args->isOptionSet('not-loadable')) {
            $states[] = ModuleState::NOT_LOADABLE;
        }

        return $states ?: ModuleState::all();
    }
780967
protected function _groupTemplate($options)
    {
        $groupTemplate = $options['options']['type'] . 'FormGroup';
        if (!$this->templater()->get($groupTemplate)) {
            $groupTemplate = 'formGroup';
        }

        return $this->formatTemplate($groupTemplate, [
            'input' => $options['input'],
            'label' => $options['label'],
            'error' => $options['error'],
            'templateVars' => $this->_processTemplateVars($options)
        ]);
    }
321377
public static function getContinentByCountry($country='')
	{
		if (!$country || !($gdb = self::getGeoDBO()))
		{
			return array();
		}

		$gdb->setQuery("SELECT DISTINCT continent FROM country_continent WHERE LOWER(country) ='" . strtolower($country) . "'");
		return $gdb->loadColumn();
	}
35294
public static function getCountries()
    {
        // Put frequently country at the top
        $countries = array();
        $frequently = array();

        foreach (Convert::$aCountries as $k => $country) {
            //echo strtolower($k) . '<br />';
            if (in_array(strtolower($k), ['be', 'fr', 'gb'])) {
                $frequently[strtolower($k)] = $country;
            } else {
                $countries[strtolower($k)] = $country;
            }
        }

        return array_merge($frequently, $countries);
    }
527839
public function tags ($options = [])
		{
			$options[ 'data-role' ] = 'tagsinput';

			$this->adjustLabelFor($options);
			if (!isset($options[ 'id' ]))
				$options[ 'id' ] = $this->getInputId();

			$model = $this->model;
			$attribute = $this->attribute;
			$data = $model->$attribute;
			$value = '';
			if (is_array($data))
			{
				if (count($data) > 0)
				{
					if (is_object($data[ 0 ]))
						$value = implode(',', ArrayHelper::objectsAttribute($data, 'title'));
					else
						$value = implode(',', $data);
				}
			}
			else
				$value = $data;

			$this->parts[ '{input}' ] = Html::textInput(Html::getInputName($model, $attribute), $value, $options);

			return $this;
		}
379495
public function getPager(array $options = array())
    {
        $options += array(
            'query' => $this->getFilterQuery(),
            'limit' => $this->config('list_limit', 20)
        );

        return array(
            'rendered' => $this->getWidgetPager($options),
            'limit' => $this->pager->getLimit()
        );
    }
554493
public function getUcpaas(array $options = [])
    {
        if (!$this->ucpaas) {
            $this->ucpaas = new \Ucpaas($options);
        }

        return $this->ucpaas;
    }
651350
protected function _yearSelect($options, $context)
    {
        $options += [
            'name' => '',
            'val' => null,
            'start' => date('Y', strtotime('-5 years')),
            'end' => date('Y', strtotime('+5 years')),
            'order' => 'desc',
            'templateVars' => [],
            'options' => []
        ];

        if (!empty($options['val'])) {
            $options['start'] = min($options['val'], $options['start']);
            $options['end'] = max($options['val'], $options['end']);
        }
        if (empty($options['options'])) {
            $options['options'] = $this->_generateNumbers($options['start'], $options['end']);
        }
        if ($options['order'] === 'desc') {
            $options['options'] = array_reverse($options['options'], true);
        }
        unset($options['start'], $options['end'], $options['order']);

        return $this->_select->render($options, $context);
    }