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 Brickrouge\Element;
 15 
 16 /**
 17  * Representation of a _primary key_ column.
 18  */
 19 class KeyColumn extends Column
 20 {
 21     private $ownership;
 22 
 23     public function __construct($manager, $id, array $options=array())
 24     {
 25         parent::__construct
 26         (
 27             $manager, $id, array
 28             (
 29                 'title' => null,
 30                 'class' => 'cell-key'
 31             )
 32         );
 33     }
 34 
 35     public function alter_records(array $records)
 36     {
 37         global $core;
 38 
 39         $key = $this->id;
 40         $module = $this->manager->module;
 41         $user = $core->user;
 42         $ownership = array();
 43 
 44         foreach ($records as $record)
 45         {
 46             $ownership[$record->$key] = $user->has_ownership($module, $record);
 47         }
 48 
 49         $this->ownership = $ownership;
 50 
 51         return parent::alter_records($records);
 52     }
 53 
 54     public function render_cell($record)
 55     {
 56         global $core;
 57 
 58         $key = $record->{ $this->id };
 59 
 60         return new Element
 61         (
 62             'label', array
 63             (
 64                 Element::CHILDREN => array
 65                 (
 66                     new Element
 67                     (
 68                         Element::TYPE_CHECKBOX, array
 69                         (
 70                             'value' => $key,
 71                             'disabled' => !$this->ownership[$key]
 72                         )
 73                     )
 74                 ),
 75 
 76                 'class' => 'checkbox-wrapper rectangle',
 77                 'title' => $this->t('Toggle selection for the record #:key', array(':key' => $key))
 78             )
 79         );
 80     }
 81 
 82     /**
 83      * Renders a _master_ checkbox.
 84      *
 85      * If the user as no ownership of any of the records a non-breakable space is returned instead.
 86      *
 87      * @return Element|string
 88      */
 89     public function render_header()
 90     {
 91         if (!count($this->ownership))
 92         {
 93             return '&nbsp;';
 94         }
 95 
 96         return new Element
 97         (
 98             'label', array
 99             (
100                 Element::CHILDREN => array
101                 (
102                     new Element
103                     (
104                         Element::TYPE_CHECKBOX
105                     )
106                 ),
107 
108                 'class' => 'checkbox-wrapper rectangle',
109                 'title' => $this->t('Toggle selection for the records ([alt] to toggle selection)')
110             )
111         );
112     }
113 
114     public function add_assets(\BrickRouge\Document $document)
115     {
116         $document->js->add('key.column.js');
117         $document->css->add('key.column.css');
118     }
119 }
Autodoc API documentation generated by ApiGen 2.8.0