PageRenderTime 54ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/redirect/code/trunk/administrator/components/com_redirect/libraries/jxtended/form/fields/calendar.php

https://bitbucket.org/eddieajau/the-art-of-joomla-archive
PHP | 82 lines | 39 code | 11 blank | 32 comment | 5 complexity | ade6f7f3cbf4a3017deb3d58261f653a MD5 | raw file
  1. <?php
  2. /**
  3. * @version $Id: calendar.php 390 2010-11-05 11:35:33Z eddieajau $
  4. * @package JXtended.Libraries
  5. * @subpackage Form
  6. * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
  7. * @license GNU General Public License
  8. * @link http://www.theartofjoomla.com
  9. */
  10. defined('JPATH_BASE') or die;
  11. jimport('joomla.html.html');
  12. require_once dirname(__FILE__).'/text.php';
  13. /**
  14. * Form Field class for JXtended Libraries.
  15. *
  16. * @package JXtended.Libraries
  17. * @subpackage Form
  18. * @since 1.1
  19. */
  20. class JFormFieldCalendar extends JFormFieldText
  21. {
  22. /**
  23. * The field type.
  24. *
  25. * @var string
  26. */
  27. public $type = 'Calendar';
  28. /**
  29. * Method to get the field input.
  30. *
  31. * @return string The field input.
  32. */
  33. protected function _getInput()
  34. {
  35. $format = $this->_element->attributes('format');
  36. $filter = $this->_element->attributes('filter');
  37. $time = $this->_element->attributes('time');
  38. if ($this->value == 'now') {
  39. $this->value = strftime($format);
  40. }
  41. // Get some system objects.
  42. $config = JFactory::getConfig();
  43. $user = JFactory::getUser();
  44. switch (strtoupper($filter))
  45. {
  46. case 'SERVER_UTC':
  47. // Convert a date to UTC based on the server timezone.
  48. if (intval($this->value))
  49. {
  50. // Get a date object based on the correct timezone.
  51. $date = JFactory::getDate($this->value, 'UTC');
  52. $date->setOffset($config->getValue('config.offset'));
  53. // Transform the date string.
  54. $this->value = $date->toMySQL(true);
  55. }
  56. break;
  57. case 'USER_UTC':
  58. // Convert a date to UTC based on the user timezone.
  59. if (intval($this->value))
  60. {
  61. // Get a date object based on the correct timezone.
  62. $date = JFactory::getDate($this->value, 'UTC');
  63. $date->setOffset($user->getParam('timezone', $config->getValue('config.offset')));
  64. // Transform the date string.
  65. $this->value = $date->toMySQL(true);
  66. }
  67. break;
  68. }
  69. return JHtml::_('calendar', $this->value, $this->inputName, $this->inputId, $format);
  70. }
  71. }