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\I18n;
15 
16 use Brickrouge\Element;
17 
18 /**
19  * Decorates a component with a _filter_ element.
20  *
21  * @TODO-20130627: create a _real_ decorator, with a component.
22  */
23 class FilterDecorator
24 {
25     private $record;
26     private $property;
27     private $filtering;
28     private $label;
29     private $value;
30 
31     /**
32      * Constructor.
33      *
34      * @param \ICanBoogie\ActiveRecord $record
35      * @param string $property The property to filter.
36      * @param null|string $label Defines the label for the filter link. If null the value of the
37      * property is used instead. If the value of the property is used it is escapted using the
38      * {@link \ICanBoogie\escape()} function, otherwise the label is use as is.
39      *
40      * @return string
41      */
42     public function __construct($record, $property, $filtering, $label=null, $value=null)
43     {
44         $this->record = $record;
45         $this->property = $property;
46         $this->filtering = $filtering;
47         $this->label = $label;
48         $this->value = $value;
49     }
50 
51     public function render()
52     {
53         $property = $this->property;
54         $value = $this->value;
55         $label = $this->label;
56 
57         if ($value === null)
58         {
59             $value = $this->record->$property;
60         }
61 
62         if ($label === null)
63         {
64             $label = \ICanBoogie\escape($value);
65         }
66 
67         if ($this->filtering)
68         {
69             return $label;
70         }
71 
72         $title = \ICanBoogie\escape(I18n\t('Display only: :identifier', array(':identifier' => strip_tags($label))));
73         $url = \ICanBoogie\escape($property . '=') . urlencode($value);
74 
75         return <<<EOT
76 <a class="filter" href="?$url" title="$title">$label</a>
77 EOT;
78     }
79 
80     public function __toString()
81     {
82         try
83         {
84             return $this->render();
85         }
86         catch (\Exception $e)
87         {
88             return \Brickrouge\render_exception($e);
89         }
90     }
91 }
Autodoc API documentation generated by ApiGen 2.8.0