コード例 #1
0
ファイル: TimezoneChoiceList.php プロジェクト: nacef/symfony
    /**
     * 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;
    }
コード例 #2
0
ファイル: PaddedChoiceList.php プロジェクト: rfc1483/blog
 /**
  * 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);
     }
 }
コード例 #3
0
ファイル: PaddedChoiceList.php プロジェクト: nacef/symfony
    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);
        }
    }