Source for file fielddate.php

Documentation is available at fielddate.php

  1. <?php
  2. /**
  3.  * @package    FrameworkOnFramework
  4.  * @subpackage form
  5.  * @copyright  Copyright (C) 2010 - 2012 Akeeba Ltd. All rights reserved.
  6.  * @license    GNU General Public License version 2 or later; see LICENSE.txt
  7.  */
  8. // Protect from unauthorized access
  9. defined('_JEXEC'or die;
  10.  
  11. /**
  12.  * Generic field header, with text input (search) filter
  13.  *
  14.  * @package  FrameworkOnFramework
  15.  * @since    2.0
  16.  */
  17. {
  18.     /**
  19.      * Get the filter field
  20.      *
  21.      * @return  string  The HTML
  22.      */
  23.     protected function getFilter()
  24.     {
  25.         // Initialize some field attributes.
  26.         $format         $this->element['format'? (string) $this->element['format''%Y-%m-%d';
  27.         $attributes  array();
  28.  
  29.         if ($this->element['size'])
  30.         {
  31.             $attributes['size'= (int) $this->element['size'];
  32.         }
  33.  
  34.         if ($this->element['maxlength'])
  35.         {
  36.             $attributes['maxlength'= (int) $this->element['maxlength'];
  37.         }
  38.  
  39.         if ($this->element['filterclass'])
  40.         {
  41.             $attributes['class'= (string) $this->element['filterclass'];
  42.         }
  43.  
  44.         if ((string) $this->element['readonly'== 'true')
  45.         {
  46.             $attributes['readonly''readonly';
  47.         }
  48.  
  49.         if ((string) $this->element['disabled'== 'true')
  50.         {
  51.             $attributes['disabled''disabled';
  52.         }
  53.  
  54.         if ($this->element['onchange'])
  55.         {
  56.             $attributes['onchange'= (string) $this->element['onchange'];
  57.         }
  58.         else
  59.         {
  60.             $onchange 'document.adminForm.submit()';
  61.         }
  62.  
  63.         if ((string) $this->element['placeholder'])
  64.         {
  65.             $attributes['placeholder'JText::_((string) $this->element['placeholder']);
  66.         }
  67.  
  68.         $name $this->element['searchfieldname'$this->element['searchfieldname'$this->name;
  69.  
  70.         if ($this->element['searchfieldname'])
  71.         {
  72.             $model       $this->form->getModel();
  73.             $searchvalue $model->getState((string) $this->element['searchfieldname']);
  74.         }
  75.         else
  76.         {
  77.             $searchvalue $this->value;
  78.         }
  79.  
  80.         // Get some system objects.
  81.         $config JFactory::getConfig();
  82.         $user JFactory::getUser();
  83.  
  84.         // If a known filter is given use it.
  85.         switch (strtoupper((string) $this->element['filter']))
  86.         {
  87.             case 'SERVER_UTC':
  88.                 // Convert a date to UTC based on the server timezone.
  89.                 if ((int) $this->value)
  90.                 {
  91.                     // Get a date object based on the correct timezone.
  92.                     $date JFactory::getDate($searchvalue'UTC');
  93.                     $date->setTimezone(new DateTimeZone($config->get('offset')));
  94.  
  95.                     // Transform the date string.
  96.                     $searchvalue $date->format('Y-m-d H:i:s'truefalse);
  97.                 }
  98.                 break;
  99.  
  100.             case 'USER_UTC':
  101.                 // Convert a date to UTC based on the user timezone.
  102.                 if ((int) $searchvalue)
  103.                 {
  104.                     // Get a date object based on the correct timezone.
  105.                     $date JFactory::getDate($this->value'UTC');
  106.                     $date->setTimezone(new DateTimeZone($user->getParam('timezone'$config->get('offset'))));
  107.  
  108.                     // Transform the date string.
  109.                     $searchvalue $date->format('Y-m-d H:i:s'truefalse);
  110.                 }
  111.                 break;
  112.         }
  113.  
  114.         return JHtml::_('calendar'$searchvalue$name$name$format$attributes);
  115.     }
  116.  
  117.     /**
  118.      * Get the buttons HTML code
  119.      *
  120.      * @return  string  The HTML
  121.      */
  122.     protected function getButtons()
  123.     {
  124.         return '';
  125.     }
  126. }

Documentation generated on Tue, 19 Nov 2013 15:02:59 +0100 by phpDocumentor 1.4.3