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\A;
 15 
 16 /**
 17  * "Tabbable" editor content renderer.
 18  */
 19 class TabbableEditorRenderer
 20 {
 21     protected $editor;
 22 
 23     public function __construct(TabbableEditor $editor)
 24     {
 25         $this->editor = $editor;
 26     }
 27 
 28     public function __invoke($content)
 29     {
 30         $panes = $content;
 31 
 32         $nav = $this->render_nav($panes);
 33         $content = $this->render_content($panes);
 34 
 35         return <<<EOT
 36 <div class="tabbable">
 37 
 38     $nav
 39     $content
 40 
 41 </div>
 42 EOT;
 43     }
 44 
 45     protected function render_nav(array $panes)
 46     {
 47         $html = '';
 48 
 49         foreach ($panes as $i => $pane)
 50         {
 51             $html .= '<li';
 52 
 53             if (!$i)
 54             {
 55                 $html .= ' class="active"';
 56             }
 57 
 58             $html .= '>';
 59 
 60             $html .= $this->render_tabbable_tab($pane, $panes);
 61 
 62             $html .= '</li>';
 63         }
 64 
 65         return '<ul class="nav nav-tabs">' . $html . '</ul>';
 66     }
 67 
 68     protected function render_tabbable_tab(array $pane, array $panes)
 69     {
 70         return new A($pane['title'], '#', array('data-toggle' => 'tab'));
 71     }
 72 
 73     protected function render_content(array $panes)
 74     {
 75         $html = '';
 76 
 77         foreach ($panes as $i => $pane)
 78         {
 79             $editor_id = $pane['editor_id'];
 80 
 81             $html .= '<div class="tab-pane editor-' . \ICanBoogie\normalize($editor_id);
 82 
 83             if (!$i)
 84             {
 85                 $html .= ' active';
 86             }
 87 
 88             $html .= '">';
 89 
 90             $html .= $this->render_pane($pane);
 91 
 92             $html .= '</div>';
 93         }
 94 
 95         return '<div class="tab-content combo">' . $html . '</div>';
 96     }
 97 
 98     protected function render_pane(array $pane)
 99     {
100         global $core;
101 
102         $editor_id = $pane['editor_id'];
103         $serialized_content = $pane['serialized_content'];
104         $editor = $core->editors[$editor_id];
105 
106         return $editor->render($editor->unserialize($serialized_content));
107     }
108 }
Autodoc API documentation generated by ApiGen 2.8.0