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

  • AlterColumnsEvent
  • AlterQueryEvent
  • AlterRenderedCellsEvent
  • BooleanCellRenderer
  • BooleanColumn
  • CellRenderer
  • Column
  • DateColumn
  • DateTimeColumn
  • EditColumn
  • EditDecorator
  • FilterDecorator
  • HeaderRenderer
  • KeyColumn
  • Options
  • RegisterColumnsEvent
  • SizeColumn
  • Translator
 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\ManageBlock;
13 
14 use ICanBoogie\ActiveRecord\Query;
15 
16 use Brickrouge\Element;
17 
18 /**
19  * Representation of a _boolean_ column.
20  */
21 class BooleanColumn extends Column
22 {
23     public function __construct(\Icybee\ManageBlock $manager, $id, array $options=array())
24     {
25         parent::__construct
26         (
27             $manager, $id, $options + array
28             (
29                 'title' => null,
30                 'class' => 'cell-boolean',
31                 'discreet' => false,
32                 'filters' => array
33                 (
34                     'options' => array
35                     (
36                         '=1' => 'Yes',
37                         '=0' => 'No'
38                     )
39                 ),
40 
41                 'orderable' => false,
42                 'cell_renderer' => __NAMESPACE__ . '\BooleanCellRenderer'
43             )
44         );
45     }
46 
47     public function add_assets(\Brickrouge\Document $document)
48     {
49         parent::add_assets($document);
50 
51         $document->js->add('boolean.column.js');
52     }
53 
54     public function alter_query_with_filter(Query $query, $filter_value)
55     {
56         return $query->and(array($this->id => $filter_value));
57     }
58 }
59 
60 /**
61  * Renderer for the _boolean_ column cells.
62  */
63 class BooleanCellRenderer extends CellRenderer
64 {
65     /**
66      * Returns an decorated checkbox element.
67      *
68      * @return \Brickrouge\Element
69      */
70     public function __invoke($record, $property)
71     {
72         return new Element
73         (
74             'label', array
75             (
76                 Element::CHILDREN => array
77                 (
78                     new Element
79                     (
80                         Element::TYPE_CHECKBOX, array
81                         (
82                             'value' => $record->{ $this->column->manager->primary_key },
83                             'checked' => ($record->$property != 0),
84                             'data-property' => $property,
85                             'data-property-type' => 'boolean'
86                         )
87                     )
88                 ),
89 
90                 'class' => 'checkbox-wrapper circle'
91             )
92         );
93     }
94 }
Autodoc API documentation generated by ApiGen 2.8.0