/** * Constructor * <b>Example:</b> * $this->add(new StateAttribute("state_abbrev", self::AF_OBLIGATORY | self::AF_SEARCHABLE)); * state_abbrev is the database attribute that holds state abbrevation data as AK,CA,NY * It will display the full state name. * * @param string $name Name of the attribute * @param int $flags Flags for the attribute * @param string $switch Choose usa for USA states * @param bool $defaulttocurrent Set the default selected state to the * current state based on the atk language */ public function __construct($name, $flags = 0, $switch = 'usa', $defaulttocurrent = true) { $flags = $flags | self::AF_NO_TRANSLATION; $this->fillStateArray(); $valueArray = $this->getStateValueArray($switch); $optionsArray = $this->getStateOptionArray($switch); $this->m_defaulttocurrent = $defaulttocurrent; parent::__construct($name, $flags, $optionsArray, $valueArray); }
/** * Constructor. * * @param string $name Name of the attribute * @param int $flags Flags for this attribute * @param array $optionArray Array with options * @param $valueArray $value Array with values. If you don't use this parameter, * values are assumed to be the same as the options. */ public function __construct($name, $flags = 0, $optionArray, $valueArray = null) { parent::__construct($name, $flags, $optionArray, $valueArray); $size = 0; $valueArray = $this->getValues(); for ($i = 0, $_i = count($valueArray); $i < $_i; ++$i) { $size += Tools::atk_strlen($valueArray[$i]) + 1; // 1 extra for the '|' symbol } if ($size > 0) { $this->setAttribSize($size); } }
/** * Constructor. * * <b>Example:</b> * $this->add(new atkCountryAttribute("zipcode","world","","",self::AF_OBLIGATORY)); * * @param string $name Name of the attribute * @param int $flags Flags for the attribute * @param string $switch Can be "benelux", "europe", "world", "world_shortlist", "user" * If user, it will use the option and value Array. * @param array $optionArray Array with options * @param array $valueArray Array with values. If you don't use this parameter, * values are assumed to be the same as the options. * @param bool $defaultToCurrent Set the default selected country to the * current country based on the atk language */ public function __construct($name, $flags = 0, $switch = 'world', $optionArray = [], $valueArray = null, $defaultToCurrent = true) { $flags = $flags | self::AF_NO_TRANSLATION; if (empty($valueArray)) { $valueArray = $optionArray; } // When switch is not user get country options if ($switch != 'user') { if ($switch == 'world') { $this->fillWorldCountriesArray(); } else { $this->fillCountriesArray(); } $optionArray = $this->getCountryOptionArray($switch); $valueArray = $this->getCountryValueArray($switch); } $this->m_defaulttocurrent = $defaultToCurrent; parent::__construct($name, $flags, $optionArray, $valueArray); }