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

  • AdjustThumbnailOptions
  • AdjustThumbnailVersion
  • CacheManager
  • GetOperation
  • Hooks
  • Module
  • PopThumbnailVersion
  • Thumbnail
  • Version
  • Versions

Exceptions

  • VersionNotDefined

Constants

  • CACHE_VERSIONS
  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 ICanBoogie\Modules\Thumbnailer;
 13 
 14 use ICanBoogie\Image;
 15 
 16 use Brickrouge\Element;
 17 use Brickrouge\Form;
 18 use Brickrouge\Group;
 19 use Brickrouge\Text;
 20 
 21 class AdjustThumbnailOptions extends Group
 22 {
 23     static protected function add_assets(\Brickrouge\Document $document)
 24     {
 25         parent::add_assets($document);
 26 
 27         $document->css->add(DIR . 'public/module.css');
 28         $document->js->add(DIR . 'public/module.js');
 29     }
 30 
 31     protected $elements = array();
 32 
 33     public function __construct(array $attributes=array())
 34     {
 35         $versions = array(null => '<personnalisé>');
 36 
 37         parent::__construct
 38         (
 39             $attributes + array
 40             (
 41                 self::CHILDREN => array
 42                 (
 43                     /*
 44                     'v' => $this->elements['v'] = new Element
 45                     (
 46                         'select', array
 47                         (
 48                             Element::OPTIONS => $versions
 49                         )
 50                     ),
 51                     */
 52 
 53                     new Element
 54                     (
 55                         'div', array
 56                         (
 57                             Element::CHILDREN => array
 58                             (
 59                                 '<span class="add-on">Size</span>',
 60 
 61                                 'width' => $this->elements['width'] = new Text
 62                                 (
 63                                     array
 64                                     (
 65                                         'class' => 'measure',
 66                                         'size' => 5
 67                                     )
 68                                 ),
 69 
 70                                 '<span class="add-on">&times</span>',
 71 
 72                                 'height' => $this->elements['height'] = new Text
 73                                 (
 74                                     array
 75                                     (
 76                                         'class' => 'measure',
 77                                         'size' => 5
 78                                     )
 79                                 ),
 80 
 81                                 '<span class="add-on">px</span>',
 82                             ),
 83 
 84                             'class' => 'input-prepend input-append'
 85                         )
 86                     ),
 87 
 88                     'method' => $this->elements['method'] = new Element
 89                     (
 90                         'select', array
 91                         (
 92                             Form::LABEL => 'Méthode',
 93 
 94                             Element::OPTIONS => array
 95                             (
 96                                 Image::RESIZE_FILL => 'Remplir',
 97                                 Image::RESIZE_FIT => 'Ajuster',
 98                                 Image::RESIZE_SURFACE => 'Surface',
 99                                 Image::RESIZE_FIXED_HEIGHT => 'Hauteur fixe, largeur ajustée',
100                                 Image::RESIZE_FIXED_HEIGHT_CROPPED => 'Hauteur fixe, largeur respectée',
101                                 Image::RESIZE_FIXED_WIDTH => 'Largeur fixe, hauteur ajustée',
102                                 Image::RESIZE_FIXED_WIDTH_CROPPED => 'Largeur fixe, hauteur respectée',
103                                 Image::RESIZE_CONSTRAINED => 'Contraindre'
104                             )
105                         )
106                     ),
107 
108                     new Element
109                     (
110                         'div', array
111                         (
112                             Group::LABEL => 'Format',
113 
114                             Element::CHILDREN => array
115                             (
116                                 'format' => $this->elements['format'] = new Element
117                                 (
118                                     'select', array
119                                     (
120                                         self::OPTIONS => array
121                                         (
122                                             null => 'Auto.',
123                                             'jpeg' => 'JPEG',
124                                             'png' => 'PNG',
125                                             'gif' => 'GIF'
126                                         ),
127 
128                                         'style' => 'width: auto;'
129                                     )
130                                 ),
131 
132                                 '&nbsp;',
133 
134                                 'quality' => $this->elements['quality'] = new Text
135                                 (
136                                     array
137                                     (
138                                         Text::ADDON => 'Qualité',
139                                         Text::ADDON_POSITION => 'before',
140                                         self::DEFAULT_VALUE => 90,
141 
142                                         'class' => 'measure',
143                                         'size' => 3
144                                     )
145                                 )
146                             ),
147 
148                             'class' => 'format-combo'
149                         )
150                     ),
151 
152                     'background' => $this->elements['background'] = new Text
153                     (
154                         array
155                         (
156                             Group::LABEL => 'Remplissage'
157                         )
158                     ),
159 
160                     'lightbox' => $this->elements['lightbox'] = new Element
161                     (
162                         Element::TYPE_CHECKBOX, array
163                         (
164                             Element::LABEL => "Afficher l'original en lightbox"
165                         )
166                     )
167                 ),
168 
169                 'class' => 'widget-adjust-thumbnail-options',
170                 'data-widget-constructor' => 'AdjustThumbnailOptions'
171             )
172         );
173 
174         $this->tag_name = 'div';
175     }
176 
177     public function offsetSet($attribute, $value)
178     {
179         if ($attribute === 'value' || $attribute === self::DEFAULT_VALUE)
180         {
181             $this->dispatch_value($value, $attribute);
182         }
183         else if ($attribute === 'name')
184         {
185             foreach ($this->elements as $identifier => $element)
186             {
187                 $element[$attribute] = $value . '[' . $identifier . ']';
188             }
189         }
190 
191         parent::offsetSet($attribute, $value);
192     }
193 
194     private function dispatch_value($value, $attribute)
195     {
196         $version = new Version($value);
197         $options = $version->to_array();
198 
199         if (!empty($value['lightbox']))
200         {
201             $options['lightbox'] = true;
202         }
203 
204         if ($options['background'] == 'transparent')
205         {
206             $options['background'] = '';
207         }
208 
209         foreach ($options as $name => $v)
210         {
211             if (empty($this->elements[$name]))
212             {
213                 continue;
214             }
215 
216             $element = $this->elements[$name];
217 
218             if ($element['type'] == 'checkbox' && $attribute == 'value')
219             {
220                 $element['checked'] = $v;
221             }
222             else
223             {
224                 $element[$attribute] = $v;
225             }
226         }
227     }
228 }
Autodoc API documentation generated by ApiGen 2.8.0