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

  • BaseOperation
  • CacheManager
  • CatalogsCacheManager
  • ClearOperation
  • Collection
  • ConfigOperation
  • ConfigsCacheManager
  • DisableOperation
  • EditorOperation
  • EnableOperation
  • Hooks
  • ManageBlock
  • Module
  • ModulesCacheManager
  • StatOperation

Interfaces

  • CacheManagerInterface

Exceptions

  • CacheNotDefined
  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 Icybee\Modules\Cache;
 13 
 14 use ICanBoogie\I18n;
 15 
 16 class ManageBlock extends \Brickrouge\ListView
 17 {
 18     static public function add_assets(\Brickrouge\Document $document)
 19     {
 20         parent::add_assets($document);
 21 
 22         $document->css->add(\Icybee\ASSETS . 'css/manage.css');
 23         $document->css->add(DIR . 'public/admin.css');
 24         $document->js->add(DIR . 'public/admin.js');
 25     }
 26 
 27     protected $module;
 28 
 29     /**
 30      * Cache collection.
 31      *
 32      * @var Collection
 33      */
 34     protected $collection;
 35 
 36     public function __construct(Module $module, array $attributes=array())
 37     {
 38         $this->module = $module;
 39         $this->collection = Collection::get();
 40 
 41         parent::__construct
 42         (
 43             $attributes + array
 44             (
 45                 self::COLUMNS => array
 46                 (
 47                     'is_active' => __CLASS__ . '\IsActiveColumn',
 48                     'title' => __CLASS__ . '\TitleColumn',
 49                     'configuration' => __CLASS__ . '\ConfigurationColumn',
 50                     'usage' => __CLASS__ . '\UsageColumn',
 51                     'clear' => __CLASS__ . '\ClearColumn'
 52                 ),
 53 
 54                 self::ENTRIES => $this->collection
 55             )
 56         );
 57     }
 58 
 59     protected function get_entries()
 60     {
 61         $indexed_entries = array();
 62         $i = 0;
 63 
 64         foreach (parent::get_entries() as $entry)
 65         {
 66             $indexed_entries[$i++] = $entry;
 67         }
 68 
 69         return $indexed_entries;
 70     }
 71 
 72     protected function render_rows(array $rows)
 73     {
 74         $rendered_rows = parent::render_rows($rows);
 75         $entries = $this->entries;
 76         $grouped = array();
 77 
 78         foreach ($rendered_rows as $i => $row)
 79         {
 80             $cache = $entries[$i];
 81             $group_title = I18n\t(ucfirst($cache->group), array(), array('scope' => 'cache.group'));
 82             $grouped[$group_title][$i] = $row;
 83         }
 84 
 85         $rendered_rows = array();
 86 
 87         foreach ($grouped as $group_title => $rows)
 88         {
 89             $rendered_rows[] = <<<EOT
 90 <tr class="listview-divider">
 91     <td>&nbsp;</td>
 92     <td>$group_title</td>
 93     <td colspan="3">&nbsp;</td>
 94 </tr>
 95 EOT;
 96             foreach ($rows as $i => $row)
 97             {
 98                 $cache = $entries[$i];
 99 
100                 list($n, $stat) = $cache->stat();
101 
102                 if (!$n)
103                 {
104                     $row->add_class('empty');
105                 }
106 
107                 $row['data-entry-key'] = $cache->id;
108 
109                 $rendered_rows[] = $row;
110             }
111         }
112 
113         return $rendered_rows;
114     }
115 }
116 
117 namespace Icybee\Modules\Cache\ManageBlock;
118 
119 use ICanBoogie\I18n;
120 
121 use Brickrouge\Button;
122 use Brickrouge\Element;
123 use Brickrouge\ListView;
124 use Brickrouge\ListViewColumn;
125 
126 class IsActiveColumn extends ListViewColumn
127 {
128     public function __construct(ListView $listview, $id, array $options=array())
129     {
130         parent::__construct
131         (
132             $listview, $id, $options + array
133             (
134                 'title' => null
135             )
136         );
137     }
138 
139     public function render_cell($entry)
140     {
141         $checked = $entry->state;
142 
143         return new Element
144         (
145             'label', array
146             (
147                 Element::CHILDREN => array
148                 (
149                     new Element
150                     (
151                         Element::TYPE_CHECKBOX, array
152                         (
153                             'checked' => $checked,
154                             'disabled' => $entry->state === null,
155                             'name' => $entry->id
156                         )
157                     )
158                 ),
159 
160                 'title' => "Enable/disable the cache",
161                 'class' => 'checkbox-wrapper circle' . ($checked ? ' checked': '')
162             )
163         );
164     }
165 }
166 
167 class TitleColumn extends ListViewColumn
168 {
169     public function __construct(ListView $listview, $id, array $options=array())
170     {
171         parent::__construct
172         (
173             $listview, $id, $options + array
174             (
175                 'title' => 'Cache type'
176             )
177         );
178     }
179 
180     public function render_cell($cache)
181     {
182         $title = I18n\t($cache->title, array(), array('scope' => 'cache.title'));
183         $description = I18n\t($cache->description, array(), array('scope' => 'cache.description'));
184 
185         return <<<EOT
186 $title<div class="element-description">$description</div>
187 EOT;
188     }
189 }
190 
191 class ConfigurationColumn extends ListViewColumn
192 {
193     public function __construct(ListView $listview, $id, array $options=array())
194     {
195         parent::__construct
196         (
197             $listview, $id, $options + array
198             (
199                 'title' => 'Configuration'
200             )
201         );
202     }
203 
204     public function render_cell($cache)
205     {
206         $config_preview = $cache->config_preview;
207 
208         if (!$config_preview)
209         {
210             return;
211         }
212 
213         return '<span title="Configure the cache" class="spinner" tabindex="0">' . $config_preview . '</span>';
214     }
215 }
216 
217 class UsageColumn extends ListViewColumn
218 {
219     public function __construct(ListView $listview, $id, array $options=array())
220     {
221         parent::__construct
222         (
223             $listview, $id, $options + array
224             (
225                 'title' => 'Usage'
226             )
227         );
228     }
229 
230     public function render_cell($cache)
231     {
232         list($n, $stat) = $cache->stat();
233 
234         return $stat;
235     }
236 }
237 
238 class ClearColumn extends ListViewColumn
239 {
240     public function __construct(ListView $listview, $id, array $options=array())
241     {
242         parent::__construct
243         (
244             $listview, $id, $options + array
245             (
246                 'title' => null
247             )
248         );
249     }
250 
251     public function render_cell($cache)
252     {
253         return new Button('Clear', array('class' => 'btn-warning', 'name' => 'clear'));
254     }
255 }
Autodoc API documentation generated by ApiGen 2.8.0