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\ActiveRecord;
 15 use ICanBoogie\Event;
 16 use ICanBoogie\Operation;
 17 
 18 use Brickrouge\Element;
 19 use Brickrouge\Form;
 20 use Brickrouge\Widget;
 21 
 22 use Icybee\Modules\Cache\Collection as CacheCollection;
 23 use Icybee\Modules\Images\Image as ImageActiveRecord;
 24 
 25 class Hooks
 26 {
 27     /**
 28      * Callback for the {@link Icybee\ConfigBlock::alter_children} event, adding
 29      * {@link PopThumbnailVersion} elements to the config block if image versions are defined for
 30      * the module.
 31      *
 32      * @param Event $ev
 33      */
 34     static public function on_configblock_alter_children(Event $event, \Icybee\ConfigBlock $block)
 35     {
 36         global $core;
 37 
 38         $module_id = (string) $event->module->id;
 39 
 40         $c = $core->configs->synthesize('thumbnailer', 'merge');
 41 
 42         if (!$c)
 43         {
 44             return;
 45         }
 46 
 47         $configs = array();
 48 
 49         foreach ($c as $version_name => $config)
 50         {
 51             if (empty($config['module']) || $config['module'] != $module_id)
 52             {
 53                 continue;
 54             }
 55 
 56             $configs[$version_name] = $config;
 57         }
 58 
 59         if (!$configs)
 60         {
 61             return;
 62         }
 63 
 64         $core->document->css->add(DIR . 'public/admin.css');
 65 
 66         $children = array();
 67 
 68         foreach ($configs as $version_name => $config)
 69         {
 70             list($defaults) = $config;
 71 
 72             $config += array
 73             (
 74                 'description' => null
 75             );
 76 
 77             $children['global[thumbnailer.versions][' . $version_name . ']'] = new Widget\PopThumbnailVersion
 78             (
 79                 array
 80                 (
 81                     Form::LABEL => new Element('span', array(Element::INNER_HTML => $config['title'] . '<br /><small>' . $version_name . '</small>')),
 82                     Element::DEFAULT_VALUE => $defaults,
 83                     Element::GROUP => 'thumbnailer',
 84                     Element::DESCRIPTION => $config['description'],
 85 
 86                     'value' => $core->registry["thumbnailer.verison.$version_name"]
 87                 )
 88             );
 89         }
 90 
 91         $event->attributes[Element::GROUPS]['thumbnailer'] = array
 92         (
 93             'title' => 'Miniatures',
 94             'description' => "Ce groupe permet de configurer les différentes
 95             versions de miniatures qu'il est possible d'utiliser pour
 96             les entrées de ce module."
 97         );
 98 
 99         $event->children = array_merge($event->children, $children);
100     }
101 
102     /**
103      * Clears the versions cache.
104      *
105      * @param \Icybee\ConfigOperation\BeforePropertiesEvent $event
106      */
107     static public function before_configoperation_properties(\Icybee\ConfigOperation\BeforePropertiesEvent $event)
108     {
109         global $core;
110 
111         if (empty($event->request->params['global']['thumbnailer.versions']))
112         {
113             return;
114         }
115 
116         unset($core->vars['cached_thumbnailer_versions']);
117     }
118 
119     /**
120      * Adds our cache manager to the cache collection.
121      *
122      * @param CacheCollection\CollectEvent $event
123      * @param CacheCollection $collection
124      */
125     static public function on_cache_collection_collect(CacheCollection\CollectEvent $event, CacheCollection $collection)
126     {
127         global $core;
128 
129         $event->collection['thumbnails'] = new CacheManager();
130     }
131 }
Autodoc API documentation generated by ApiGen 2.8.0