Esempio n. 1
0
    /**
     * Loads the timezone choices
     *
     * The choices are generated from the ICU function
     * \DateTimeZone::listIdentifiers(). They are cached during a single request,
     * so multiple timezone fields on the same page don't lead to unnecessary
     * overhead.
     *
     * @return array  The timezone choices
     */
    protected function load()
    {
        parent::load();

        if (count(self::$timezones) == 0) {
            foreach (\DateTimeZone::listIdentifiers() as $timezone) {
                $parts = explode('/', $timezone);

                if (count($parts) > 2) {
                    $region = $parts[0];
                    $name = $parts[1].' - '.$parts[2];
                } else if (count($parts) > 1) {
                    $region = $parts[0];
                    $name = $parts[1];
                } else {
                    $region = 'Other';
                    $name = $parts[0];
                }

                if (!isset(self::$timezones[$region])) {
                    self::$timezones[$region] = array();
                }

                self::$timezones[$region][$timezone] = str_replace('_', ' ', $name);
            }
        }

        $this->choices = self::$timezones;
    }
Esempio n. 2
0
 /**
  * Initializes the list of choices.
  *
  * Each choices is padded according to the format given in the constructor
  *
  * @throws UnexpectedTypeException if the function does not return an array
  */
 protected function load()
 {
     parent::load();
     foreach ($this->choices as $key => $choice) {
         $this->choices[$key] = str_pad($choice, $this->padLength, $this->padString, $this->padType);
     }
 }
Esempio n. 3
0
    protected function load()
    {
        parent::load();

        $choices = $this->choices;
        $this->choices = array();

        foreach ($choices as $value) {
            $this->choices[$value] = str_pad($value, $this->padLength, $this->padString, $this->padType);
        }
    }