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

  • Get
  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\Operation\Widget;
 13 
 14 use ICanBoogie\Exception;
 15 use ICanBoogie\Operation;
 16 
 17 use Brickrouge\Button;
 18 use Brickrouge\Popover;
 19 use Brickrouge\Widget;
 20 
 21 class Get extends Operation
 22 {
 23     private $widget_class;
 24 
 25     protected function get_controls()
 26     {
 27         return array
 28         (
 29             self::CONTROL_AUTHENTICATION => true
 30         )
 31 
 32         + parent::get_controls();
 33     }
 34 
 35     protected function validate(\ICanboogie\Errors $errors)
 36     {
 37         $this->widget_class = $class = 'Brickrouge\Widget\\' . \ICanBoogie\camelize(strtr($this->request['class'], '-', '_'));
 38 
 39         if (!class_exists($class, true))
 40         {
 41             throw new Exception('Unknown widget class: %class', array('%class' => $class));
 42         }
 43 
 44         return true;
 45     }
 46 
 47     protected function process()
 48     {
 49         global $core, $document;
 50 
 51         if (!$core->user_id)
 52         {
 53             throw new Exception('Unauthorized', array(), 401);
 54         }
 55 
 56         $user = $core->user;
 57 
 58         if ($user->language)
 59         {
 60             $core->locale = $user->language;
 61         }
 62 
 63         $request = $this->request;
 64         $document = $core->document;
 65 
 66         $rc = null;
 67         $mode = $request['mode'];
 68         $selected = $request['selected'];
 69 
 70         if ($request['value'])
 71         {
 72             $selected = $request['value'];
 73         }
 74 
 75         $class = $this->widget_class;
 76 
 77         $el = new $class
 78         (
 79             array
 80             (
 81                 'value' => $selected,
 82                 Widget\AdjustNode::T_CONSTRUCTOR => $request['constructor']
 83             )
 84         );
 85 
 86         if (!$mode)
 87         {
 88             $rc = (string) $el;
 89         }
 90         else if ($mode == 'popup')
 91         {
 92             $rc = (string) new Popover
 93             (
 94                 array
 95                 (
 96                     Popover::ACTIONS => array
 97                     (
 98                         new Button('Cancel', array('data-action' => 'cancel')),
 99                         new Button('Remove', array('data-action' => 'remove', 'class' => 'btn-danger')),
100                         new Button('Use', array('data-action' => 'use', 'class' => 'btn-primary'))
101                     ),
102 
103                     Popover::FIT_CONTENT => true,
104 
105                     Popover::INNER_HTML => $el,
106 
107                     'class' => 'popover popover--' . \ICanBoogie\normalize($this->request['class']) . ' contrast'
108                 )
109             );
110         }
111         else if ($mode == 'results')
112         {
113             $rc = $el->get_results($_GET);
114         }
115         else if ($mode)
116         {
117             throw new Exception('Uknown widget mode: %mode', array('%mode' => $mode));
118         }
119 
120         $this->response['assets'] = $document->assets;
121         $this->response['mode'] = $mode;
122 
123         return $rc;
124     }
125 }
Autodoc API documentation generated by ApiGen 2.8.0