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

  • A
  • Actions
  • Alert
  • AlterCSSClassNamesEvent
  • AssetsCollector
  • Button
  • CSSCollector
  • Dataset
  • Date
  • DateRange
  • DateTime
  • Decorator
  • Document
  • DropdownMenu
  • Element
  • File
  • Form
  • Group
  • Helpers
  • HTMLString
  • Iterator
  • JSCollector
  • ListView
  • ListViewColumn
  • Modal
  • Pager
  • Popover
  • PopoverWidget
  • Ranger
  • RecursiveIterator
  • Salutation
  • Searchbox
  • Section
  • SplitButton
  • Text
  • Widget

Interfaces

  • CSSClassNames
  • DecoratorInterface
  • HTMLStringInterface
  • Validator

Traits

  • CSSClassNamesProperty

Exceptions

  • ElementIsEmpty

Functions

  • _array_flatten_callback
  • array_flatten
  • array_insert
  • check_session
  • dump
  • escape
  • escape_all
  • format
  • format_size
  • get_accessible_file
  • get_document
  • normalize
  • render_css_class
  • render_exception
  • retrieve_form
  • retrieve_form_errors
  • shorten
  • stable_sort
  • store_form
  • store_form_errors
  • strip
  • t
 1 <?php
 2 
 3 /*
 4  * This file is part of the Brickrouge 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 Brickrouge;
13 
14 /**
15  * An actions element that can be used with forms or popovers.
16  */
17 class Actions extends Element
18 {
19     /**
20      * Actions.
21      *
22      * @var string|array
23      */
24     protected $actions;
25 
26     /**
27      * @param boolean|array|string|Element $actions Actions can be defined as a boolean, an array
28      * a string or an instance of the {@link Element} class. @see {@link render_inner_html()}
29      *
30      * @param array $attributes
31      */
32     public function __construct($actions, array $attributes=array())
33     {
34         $this->actions = $actions;
35 
36         parent::__construct('div', $attributes + array('class' => 'actions'));
37     }
38 
39     /**
40      * Renders the actions.
41      *
42      * If actions are defined as the string "boolean" they are replaced by an array with the
43      * buttons `button[data-action="cancel"]` and
44      * `button[data-action="ok"][type=submit].btn-primary`.
45      *
46      * If actions are defined as a boolean, they are replaced by a
47      * `button[type=submit][data-action="ok"].btn-primary` element with the label "Send".
48      *
49      * If actions are defined as an array, the array is concatenated with the glue
50      * `<span class="separator">&nbsp;</span>`.
51      *
52      * Otherwise actions are used as is.
53      *
54      * @see Element::render_inner_html()
55      */
56     protected function render_inner_html()
57     {
58         $html = parent::render_inner_html();
59         $actions = $this->actions;
60 
61         if ($actions == 'boolean')
62         {
63             $actions = array
64             (
65                 new Button('Cancel', array('data-action' => 'cancel')),
66                 new Button('Ok', array('data-action' => 'ok', 'type' => 'submit', 'class' => 'btn-primary')),
67             );
68         }
69 
70         if (is_array($actions))
71         {
72             foreach ($actions as $name => $action)
73             {
74                 if (!is_string($name) || !($action instanceof Element) || $action['name'] !== null)
75                 {
76                     continue;
77                 }
78 
79                 $action['name'] = $name;
80             }
81 
82             $actions = implode('<span class="separator">&nbsp;</span>', $actions);
83         }
84         else if ($actions === true)
85         {
86             $actions = new Button('Ok', array('dataset' => array('action' => 'ok'), 'type' => 'submit', 'class' => 'btn-primary'));
87         }
88 
89         return $html . $actions;
90     }
91 }
Autodoc API documentation generated by ApiGen 2.8.0