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

  • BlockController
  • DashboardBlock
  • Hooks
  • Module
  • OrderOperation
  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\Dashboard;
 13 
 14 use ICanBoogie\I18n;
 15 
 16 use Brickrouge\Element;
 17 
 18 class DashboardBlock extends Element
 19 {
 20     static protected function add_assets(\Brickrouge\Document $document)
 21     {
 22         parent::add_assets($document);
 23 
 24         $document->css->add(DIR . 'public/dashboard.css');
 25         $document->js->add(DIR . 'public/dashboard.js');
 26     }
 27 
 28     /**
 29      * The Dashboard module.
 30      *
 31      * @var Module
 32      */
 33     protected $module;
 34 
 35     public function __construct(Module $module)
 36     {
 37         $this->module = $module;
 38 
 39         parent::__construct('div', array('id' => 'dashboard'));
 40     }
 41 
 42     public function render_inner_html()
 43     {
 44         global $core;
 45 
 46         $panels = $core->configs->synthesize('dashboard', 'merge');
 47 
 48         foreach ($panels as $i => $panel)
 49         {
 50             $panels[$i] += array
 51             (
 52                 'column' => 0,
 53                 'weight' => 0
 54             );
 55         }
 56 
 57         $user_config = $core->user->metas['dashboard.order'];
 58 
 59         if ($user_config)
 60         {
 61             $user_config = json_decode($user_config);
 62 
 63             foreach ($user_config as $column_index => $user_panels)
 64             {
 65                 foreach ($user_panels as $panel_weight => $panel_id)
 66                 {
 67                     $panels[$panel_id]['column'] = $column_index;
 68                     $panels[$panel_id]['weight'] = $panel_weight;
 69                 }
 70             }
 71         }
 72 
 73         uasort($panels, function($a, $b) { return $a['weight'] - $b['weight']; });
 74 
 75         $html = $this->render_panels($panels);
 76 
 77         return <<<EOT
 78 <div id="dashboard-panels">
 79     $html
 80 </div>
 81 EOT;
 82     }
 83 
 84     protected function render_panels(array $panels)
 85     {
 86         $colunms = array
 87         (
 88             array(),
 89             array()
 90         );
 91 
 92         // config sign: ⚙
 93 
 94         foreach ($panels as $id => $descriptor)
 95         {
 96             try
 97             {
 98                 if (empty($descriptor['callback']))
 99                 {
100                     continue;
101                 }
102 
103                 $contents = call_user_func($descriptor['callback']);
104             }
105             catch (\Exception $e)
106             {
107                 $contents = \Brickrouge\render_exception($e);
108             }
109 
110             if (!$contents)
111             {
112                 continue;
113             }
114 
115             $title = I18n\t($id, array(), array('scope' => 'dashboard.title', 'default' => $descriptor['title']));
116 
117             $panel = <<<EOT
118 <div class="panel" id="$id">
119     <div class="panel-title">$title</div>
120     <div class="panel-contents">$contents</div>
121 </div>
122 EOT;
123 
124             $colunms[$descriptor['column']][] = $panel;
125         }
126 
127         $html = '';
128 
129         foreach ($colunms as $i => $panels)
130         {
131             $panels = implode(PHP_EOL, $panels);
132 
133             $html .= <<<EOT
134 <div class="column">
135     $panels
136     <div class="panel-holder">&nbsp;</div>
137 </div>
138 EOT;
139         }
140 
141         return $html;
142     }
143 }
Autodoc API documentation generated by ApiGen 2.8.0