/redirect/code/trunk/administrator/components/com_redirect/libraries/jxtended/form/fields/calendar.php
PHP | 82 lines | 39 code | 11 blank | 32 comment | 5 complexity | ade6f7f3cbf4a3017deb3d58261f653a MD5 | raw file
- <?php
- /**
- * @version $Id: calendar.php 390 2010-11-05 11:35:33Z eddieajau $
- * @package JXtended.Libraries
- * @subpackage Form
- * @copyright Copyright 2005 - 2010 New Life in IT Pty Ltd. All rights reserved.
- * @license GNU General Public License
- * @link http://www.theartofjoomla.com
- */
- defined('JPATH_BASE') or die;
- jimport('joomla.html.html');
- require_once dirname(__FILE__).'/text.php';
- /**
- * Form Field class for JXtended Libraries.
- *
- * @package JXtended.Libraries
- * @subpackage Form
- * @since 1.1
- */
- class JFormFieldCalendar extends JFormFieldText
- {
- /**
- * The field type.
- *
- * @var string
- */
- public $type = 'Calendar';
- /**
- * Method to get the field input.
- *
- * @return string The field input.
- */
- protected function _getInput()
- {
- $format = $this->_element->attributes('format');
- $filter = $this->_element->attributes('filter');
- $time = $this->_element->attributes('time');
- if ($this->value == 'now') {
- $this->value = strftime($format);
- }
- // Get some system objects.
- $config = JFactory::getConfig();
- $user = JFactory::getUser();
- switch (strtoupper($filter))
- {
- case 'SERVER_UTC':
- // Convert a date to UTC based on the server timezone.
- if (intval($this->value))
- {
- // Get a date object based on the correct timezone.
- $date = JFactory::getDate($this->value, 'UTC');
- $date->setOffset($config->getValue('config.offset'));
- // Transform the date string.
- $this->value = $date->toMySQL(true);
- }
- break;
- case 'USER_UTC':
- // Convert a date to UTC based on the user timezone.
- if (intval($this->value))
- {
- // Get a date object based on the correct timezone.
- $date = JFactory::getDate($this->value, 'UTC');
- $date->setOffset($user->getParam('timezone', $config->getValue('config.offset')));
- // Transform the date string.
- $this->value = $date->toMySQL(true);
- }
- break;
- }
- return JHtml::_('calendar', $this->value, $this->inputName, $this->inputId, $format);
- }
- }