| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* sfWidgetFormI18nChoiceTimezone represents a timezone choice widget.
|
|
|
13 |
*
|
|
|
14 |
* @package symfony
|
|
|
15 |
* @subpackage widget
|
|
|
16 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
17 |
* @version SVN: $Id: sfWidgetFormI18nChoiceTimezone.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
|
|
|
18 |
*/
|
|
|
19 |
class sfWidgetFormI18nChoiceTimezone extends sfWidgetFormChoice
|
|
|
20 |
{
|
|
|
21 |
/**
|
|
|
22 |
* Constructor.
|
|
|
23 |
*
|
|
|
24 |
* Available options:
|
|
|
25 |
*
|
|
|
26 |
* * culture: The culture to use for internationalized strings
|
|
|
27 |
* * add_empty: Whether to add a first empty value or not (false by default)
|
|
|
28 |
* If the option is not a Boolean, the value will be used as the text value
|
|
|
29 |
*
|
|
|
30 |
* @param array $options An array of options
|
|
|
31 |
* @param array $attributes An array of default HTML attributes
|
|
|
32 |
*
|
|
|
33 |
* @see sfWidgetFormChoice
|
|
|
34 |
*/
|
|
|
35 |
protected function configure($options = array(), $attributes = array())
|
|
|
36 |
{
|
|
|
37 |
parent::configure($options, $attributes);
|
|
|
38 |
|
|
|
39 |
$this->addOption('culture');
|
|
|
40 |
$this->addOption('add_empty', false);
|
|
|
41 |
|
|
|
42 |
$culture = isset($options['culture']) ? $options['culture'] : 'en';
|
|
|
43 |
$timezones = array_keys(sfCultureInfo::getInstance($culture)->getTimeZones());
|
|
|
44 |
$timezones = array_combine($timezones, $timezones);
|
|
|
45 |
|
|
|
46 |
$addEmpty = isset($options['add_empty']) ? $options['add_empty'] : false;
|
|
|
47 |
if (false !== $addEmpty)
|
|
|
48 |
{
|
|
|
49 |
$timezones = array_merge(array('' => true === $addEmpty ? '' : $addEmpty), $timezones);
|
|
|
50 |
}
|
|
|
51 |
|
|
|
52 |
$this->setOption('choices', $timezones);
|
|
|
53 |
}
|
|
|
54 |
}
|