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\Document;
 15 use Brickrouge\Element;
 16 
 17 /**
 18  * An element that can change its editor.
 19  *
 20  * @property Element $editor The editor element.
 21  */
 22 class MultiEditorElement extends Element
 23 {
 24     const EDITOR_TAGS = '#meditor-tags';
 25     const SELECTOR_NAME = '#meditor-selector-name';
 26     const NOT_SWAPPABLE = '#meditor-not-wappable';
 27 
 28     static protected function add_assets(Document $document)
 29     {
 30         parent::add_assets($document);
 31 
 32         $document->css->add('assets/elements.css');
 33         $document->js->add('assets/elements.js');
 34     }
 35 
 36     protected $editor_id;
 37 
 38     public function __construct($editor, array $attributes)
 39     {
 40         $this->editor_id = $editor ? $editor : 'rte';
 41 
 42         parent::__construct
 43         (
 44             'div', $attributes + array
 45             (
 46                 self::SELECTOR_NAME => 'editor',
 47 
 48                 'class' => 'editor-wrapper'
 49             )
 50         );
 51     }
 52 
 53     protected function get_editor()
 54     {
 55         global $core;
 56 
 57         $editor_id = $this->editor_id;
 58         $editor = $core->editors[$editor_id];
 59         $element = $editor->from
 60         (
 61             ($this[self::EDITOR_TAGS] ?: array()) + array
 62             (
 63                 Element::REQUIRED => $this[self::REQUIRED],
 64                 Element::DEFAULT_VALUE => $this[self::DEFAULT_VALUE],
 65 
 66                 'name' => $this['name'],
 67 //              'value' => $editor->unserialize($this['value'])
 68                 'value' => $this['value']
 69             )
 70         );
 71 
 72         if ($element->type == 'textarea')
 73         {
 74             $rows = $this['rows'];
 75 
 76             if ($rows !== null)
 77             {
 78                 $element['rows'] = $rows;
 79             }
 80         }
 81 
 82         return $element;
 83     }
 84 
 85     /**
 86      * Adds the `contents-name` and `selector-name` properties.
 87      *
 88      * @see Brickrouge.Element::alter_dataset()
 89      */
 90     protected function alter_dataset(array $dataset)
 91     {
 92         $dataset = parent::alter_dataset($dataset);
 93 
 94         $dataset['contents-name'] = $this['name'];
 95         $dataset['selector-name'] = $this[self::SELECTOR_NAME];
 96 
 97         return $dataset;
 98     }
 99 
100     /**
101      * The inner HTML of the element includes the editor element and the selector element.
102      *
103      * If the editor is not swappable an hidden element is used instead of the selector element.
104      *
105      * @see Brickrouge.Element::render_inner_html()
106      */
107     protected function render_inner_html()
108     {
109         $html = (string) $this->editor;
110         $editor_id = $this->editor_id;
111 
112         if ($this[self::NOT_SWAPPABLE])
113         {
114             $html .= new Element
115             (
116                 'hidden', array
117                 (
118                     'name' => $this[self::SELECTOR_NAME],
119                     'value' => $editor_id
120                 )
121             );
122         }
123         else
124         {
125             $options = (string) new SelectorElement
126             (
127                 array
128                 (
129                     Element::LABEL => 'Editor',
130                     Element::LABEL_POSITION => 'before',
131 
132                     'name' => $this[self::SELECTOR_NAME],
133                     'class' => 'editor-selector',
134                     'value' => $editor_id
135                 )
136             );
137 
138             if ($options)
139             {
140                 $html .= '<div class="editor-options clearfix"><div style="float: right">' . $options . '</div></div>';
141             }
142         }
143 
144         return $html;
145     }
146 }
Autodoc API documentation generated by ApiGen 2.8.0