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

  • Actionbar
  • ActionbarContextual
  • ActionbarNav
  • ActionbarNew
  • ActionbarSearch
  • ActionbarTitle
  • ActionbarToolbar
  • AdminMenu
  • Form
  • Group
  • Navigation
  • SiteMenu
  • UserMenu
  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\Element;
 13 
 14 use ICanBoogie\Module;
 15 use ICanBoogie\Operation;
 16 use ICanBoogie\Route;
 17 
 18 use Brickrouge\A;
 19 use Brickrouge\Element;
 20 use Brickrouge\DropdownMenu;
 21 
 22 use Icybee\Modules\Users\Roles\Role;
 23 
 24 /**
 25  * The _user menu_ element is made of two parts: a link to the user profile and a dropdown menu.
 26  * The dropdown menu provides a link to the user profile and a link to logout the user.
 27  */
 28 class UserMenu extends Element
 29 {
 30     public function __construct(array $attributes=array())
 31     {
 32         parent::__construct('div', $attributes);
 33     }
 34 
 35     protected function render_inner_html()
 36     {
 37         global $core;
 38 
 39         $user = $core->user;
 40         $site = $core->site;
 41 
 42         $roles = '';
 43 
 44         if ($user->is_admin)
 45         {
 46             $roles = 'Admin';
 47         }
 48         else if ($user->has_permission(Module::PERMISSION_ADMINISTER, 'users.roles'))
 49         {
 50             foreach ($user->roles as $role)
 51             {
 52                 $roles .= ', <a href="' . $site->path . '/admin/users.roles/' . $role->rid . '/edit">' . $role->name . '</a>';
 53             }
 54 
 55             $roles = substr($roles, 2);
 56         }
 57         else
 58         {
 59             $n = count($user->roles);
 60 
 61             foreach ($user->roles as $role)
 62             {
 63                 if ($n > 1 && $role->rid == Role::USER_RID)
 64                 {
 65                     continue;
 66                 }
 67 
 68                 $roles .= ', ' . $role->name;
 69             }
 70 
 71             $roles = substr($roles, 2);
 72         }
 73 
 74         $username = new A($user->name, \ICanBoogie\Routing\contextualize('/admin/profile'));
 75 
 76         $options = array
 77         (
 78             \ICanBoogie\Routing\contextualize('/admin/profile') => 'Profile',
 79             false,
 80             Operation::encode('users/logout') => 'Logout'
 81         );
 82 
 83         array_walk
 84         (
 85             $options, function(&$v, $k)
 86             {
 87                 if (!is_string($v))
 88                 {
 89                     return;
 90                 }
 91 
 92                 $v = new A($v, $k);
 93             }
 94         );
 95 
 96         $menu = new DropdownMenu
 97         (
 98             array
 99             (
100                 DropdownMenu::OPTIONS => $options,
101 
102                 'value' => $core->request->path
103             )
104         );
105 
106         return <<<EOT
107 $username
108 <span class="btn-group">
109     <span class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user icon-white"></i> <span class="caret"></span></span>
110     $menu
111 </span>
112 EOT;
113     }
114 }
Autodoc API documentation generated by ApiGen 2.8.0