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

  • ChangeOperation
  • Collection
  • FeedEditor
  • FeedEditorElement
  • ImageEditor
  • ImageEditorElement
  • Module
  • MultiEditorElement
  • NodeEditor
  • NodeEditorElement
  • PatronEditor
  • PatronEditorElement
  • PHPEditor
  • PHPEditorElement
  • RawEditor
  • RawEditorElement
  • RTEEditor
  • RTEEditorElement
  • SelectorElement
  • TabbableEditor
  • TabbableEditorElement
  • TabbableEditorRenderer
  • TabbableNewPaneOperation
  • TextEditor
  • TextEditorElement
  • TextmarkEditor
  • TextmarkEditorElement
  • WidgetsEditor
  • WidgetsEditorElement

Interfaces

  • Editor
  • EditorElement

Exceptions

  • EditorAlreadyInstantiated
  • EditorNotDefined
 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\Editor;
13 
14 use Brickrouge\Alert;
15 
16 use Brickrouge\Document;
17 use Brickrouge\Element;
18 
19 class WidgetsEditorElement extends Element implements EditorElement
20 {
21     static protected function add_assets(Document $document)
22     {
23         parent::add_assets($document);
24 
25         $document->css->add('assets/editor.css');
26         $document->js->add('assets/editor.js');
27     }
28 
29     public function __construct(array $attributes=array())
30     {
31         parent::__construct
32         (
33             'ul', $attributes + array
34             (
35                 'class' => 'widgets-selector combo'
36             )
37         );
38 
39         if ($this[Element::DESCRIPTION] === null)
40         {
41             $this[Element::DESCRIPTION] = "Sélectionner les widgets à afficher. Vous pouvez les ordonner par glissé-déposé.";
42         }
43     }
44 
45     public function render_inner_html()
46     {
47         global $core;
48 
49         $config = $core->configs->synthesize('widgets', 'merge');
50 
51         if (!$config)
52         {
53             return new Alert('There is no widget defined.', array(Alert::CONTEXT => Alert::CONTEXT_INFO));
54         }
55 
56         $rc = parent::render_inner_html();
57 
58         $value = $this['value'];
59         $name = $this['name'];
60 
61         $value = is_array($value) ? array_flip($value) : array();
62 
63         // TODO-20100204: check deprecated widgets ids
64 
65         $list = array_merge($value, $config);
66 
67         //\ICanBoogie\log('value: \1, list: \2 \3', array($value, $list, array_merge($value, $list)));
68 
69         foreach ($list as $id => $widget)
70         {
71             $rc .= '<li>';
72 
73             $rc .= new Element
74             (
75                 Element::TYPE_CHECKBOX, array
76                 (
77                     Element::LABEL => $widget['title'],
78 
79                     'name' => $name . '[' . $id . ']',
80                     'checked' => isset($value[$id])
81                 )
82             );
83 
84             $rc .= '</li>';
85         }
86 
87         return $rc;
88     }
89 }
Autodoc API documentation generated by ApiGen 2.8.0