sfWidgetFormI18nDateTime.class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfWidgetFormI18nDateTime represents a date and time widget.
  11. *
  12. * @package symfony
  13. * @subpackage widget
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfWidgetFormI18nDateTime.class.php 9173 2008-05-22 06:50:20Z dwhittle $
  16. */
  17. class sfWidgetFormI18nDateTime extends sfWidgetFormDateTime
  18. {
  19. /**
  20. * Constructor.
  21. *
  22. * Available options:
  23. *
  24. * * culture: The culture to use for internationalized strings (required)
  25. *
  26. * @param array $options An array of options
  27. * @param array $attributes An array of default HTML attributes
  28. *
  29. * @see sfWidgetFormDateTime
  30. */
  31. protected function configure($options = array(), $attributes = array())
  32. {
  33. parent::configure($options, $attributes);
  34. $this->addRequiredOption('culture');
  35. $culture = isset($options['culture']) ? $options['culture'] : 'en';
  36. // format
  37. $this->setOption('format', str_replace(array('{0}', '{1}'), array('%time%', '%date%'), sfDateTimeFormatInfo::getInstance($culture)->getDateTimeOrderPattern()));
  38. }
  39. /**
  40. * @see sfWidgetFormDateTime
  41. */
  42. protected function getDateWidget($attributes = array())
  43. {
  44. return new sfWidgetFormI18nDate(array_merge(array('culture' => $this->getOption('culture')), $this->getOptionsFor('date')), $this->getAttributesFor('date', $attributes));
  45. }
  46. /**
  47. * @see sfWidgetFormDateTime
  48. */
  49. protected function getTimeWidget($attributes = array())
  50. {
  51. return new sfWidgetFormI18nTime(array_merge(array('culture' => $this->getOption('culture')), $this->getOptionsFor('time')), $this->getAttributesFor('time', $attributes));
  52. }
  53. }