Autodoc
  • Namespace
  • Class
  • Tree

Namespaces

  • BlueTihi
    • Context
  • Brickrouge
    • Element
      • Nodes
    • Renderer
    • Widget
  • ICanBoogie
    • ActiveRecord
    • AutoConfig
    • CLDR
    • Composer
    • Core
    • Event
    • Exception
    • HTTP
      • Dispatcher
      • Request
    • I18n
      • Translator
    • Mailer
    • Modules
      • Taxonomy
        • Support
      • Thumbnailer
        • Versions
    • Object
    • Operation
      • Dispatcher
    • Prototype
    • Routes
    • Routing
      • Dispatcher
    • Session
  • Icybee
    • ActiveRecord
      • Model
    • ConfigOperation
    • Document
    • EditBlock
    • Element
      • ActionbarContextual
      • ActionbarSearch
      • ActionbarToolbar
    • FormBlock
    • Installer
    • ManageBlock
    • Modules
      • Articles
      • Cache
        • Collection
        • ManageBlock
      • Comments
        • ManageBlock
      • Contents
        • ManageBlock
      • Dashboard
      • Editor
        • Collection
      • Files
        • File
        • ManageBlock
      • Forms
        • Form
        • ManageBlock
      • I18n
      • Images
        • ManageBlock
      • Members
      • Modules
        • ManageBlock
      • Nodes
        • ManageBlock
        • Module
      • Pages
        • BreadcrumbElement
        • LanguagesElement
        • ManageBlock
        • NavigationBranchElement
        • NavigationElement
        • Page
        • PageController
      • Registry
      • Search
      • Seo
      • Sites
        • ManageBlock
      • Taxonomy
        • Terms
          • ManageBlock
        • Vocabulary
          • ManageBlock
      • Users
        • ManageBlock
        • NonceLogin
        • Roles
      • Views
        • ActiveRecordProvider
        • Collection
        • View
    • Operation
      • ActiveRecord
      • Constructor
      • Module
      • Widget
    • Rendering
  • None
  • Patron
  • PHP

Classes

  • AdjustImage
  • AdjustNode
  • AdjustThumbnail
  • AdjustThumbnailVersion
  • PopThumbnailVersion
  • TimeZone
  1 <?php
  2 
  3 /*
  4  * This file is part of the Icybee package.
  5  *
  6  * (c) Olivier Laviale <olivier.laviale@gmail.com>
  7  *
  8  * For the full copyright and license information, please view the LICENSE
  9  * file that was distributed with this source code.
 10  */
 11 
 12 namespace Brickrouge\Widget;
 13 
 14 use Brickrouge\Element;
 15 
 16 class TimeZone extends \Brickrouge\Element
 17 {
 18     /*
 19     static protected function add_assets(\Brickrouge\Document $document)
 20     {
 21         parent::add_assets($document);
 22 
 23         $document->js->add('time-zone.js');
 24     }
 25     */
 26 
 27     public function __construct(array $attributes=array())
 28     {
 29         parent::__construct('div', $attributes);
 30     }
 31 
 32     public function render_inner_html()
 33     {
 34         global $core;
 35 
 36         $offsets = array();
 37         $list = timezone_identifiers_list();
 38         $groups = array();
 39 
 40         foreach ($list as $name)
 41         {
 42             if ($name == 'UTC')
 43             {
 44                 continue;
 45             }
 46 
 47             list($group) = explode('/', $name, 2);
 48 
 49             $groups[$group][] = $name;
 50         }
 51 
 52         $value = $this['value'];
 53 
 54         if ($value === null)
 55         {
 56             $value = $this[self::DEFAULT_VALUE];
 57         }
 58 
 59         $html = '';
 60         $html .= '<option value="">&nbsp;</option>';
 61 
 62         foreach ($groups as $group => $timezones)
 63         {
 64             $group_strlen = strlen($group) + 1;
 65             $html .= '<optgroup label="' . $group . '">';
 66 
 67             foreach ($timezones as $timezone)
 68             {
 69                 $html .= '<option value="' . $timezone . '"';
 70 
 71                 if ($timezone === $value)
 72                 {
 73                     $html .= ' selected="selected"';
 74                 }
 75 
 76                 $html .= '>' . substr($timezone, $group_strlen) . '</option>';
 77             }
 78 
 79             $html .= '</optgroup>';
 80         }
 81 
 82         return new Element
 83         (
 84             'select', array
 85             (
 86                 Element::INNER_HTML => $html,
 87 
 88                 'name' => $this['name']
 89             )
 90         );
 91         /*
 92 
 93 
 94 
 95 
 96 
 97 
 98 
 99 
100 
101 
102 
103 
104 
105 
106 
107         $utc_time = new \DateTime('now', new \DateTimezone('UTC'));
108 
109         foreach ($list as $zone)
110         {
111             $tz_value = new \DateTimeZone($zone);
112             $offset = $tz_value->getOffset($utc_time);
113 
114             $offsets[$offset][] = $zone;
115         }
116 
117         ksort($offsets);
118 
119         foreach ($offsets as $offset => $names)
120         {
121             sort($names);
122 
123             $offsets[$offset] = $names;
124         }
125 
126         $now = time();
127         $options = array();
128         $f = $core->locale->date_formatter;
129 
130         $tz = date_default_timezone_get();
131         date_default_timezone_set('GMT');
132 
133         foreach ($offsets as $offset => $zones)
134         {
135             $options[$offset] = $f->format_datetime($now + $offset);
136         }
137 
138         date_default_timezone_set($tz);
139 
140         $this->dataset['offsets'] = $offsets;
141 
142         $value = $this['value'];
143 
144         if ($value === null)
145         {
146             $value = $this[self::DEFAULT_VALUE];
147         }
148 
149         if ($value)
150         {
151             $offset = null;
152             $zone = null;
153 
154             if (is_numeric($value))
155             {
156                 $offset = $value;
157             }
158             else
159             {
160                 $tz_value = new \DateTimeZone($value);
161                 $offset = $tz_value->getOffset($utc_time);
162                 $zone = $value;
163                 $value = $offset;
164             }
165 
166             $this->dataset['zone'] = $zone;
167         }
168 
169         $rc = parent::render_inner_html();
170 
171         if (!$this[self::REQUIRED])
172         {
173             $options = array(null => '') + $options;
174         }
175 
176         $rc .= new Element
177         (
178             'select', array
179             (
180                 Element::OPTIONS => $options,
181 
182                 'name' => $this['name'],
183                 'value' => $value
184             )
185         );
186 
187         return $rc;
188         */
189     }
190 }
Autodoc API documentation generated by ApiGen 2.8.0