WidgetItemMenu Class Reference
[View]
A widget printing a menu based upon actions retrieved from given item. More...
Public Member Functions |
|
| __construct ($item, $context= 'view', $params=false, $args=array()) | |
| render ($policy=self::NONE) | |
| Renders what should be rendered. |
|
Static Public Member Functions |
|
| static | output ($item, $context= 'view', $params=false, $args=array(), $policy=self::NONE) |
Public Attributes |
|
| $args | |
| $aro | |
| $context | |
| $item | |
| $params | |
| const | SEPARATE_COMMANDS = 256 |
| const | SORTED = 128 |
Protected Member Functions |
|
| retrieve_actions ($item) | |
| Obtain actions from item , if suitable.
|
|
| separate ($arr_in, &$out_actions, &$out_commands) | |
| Divide actions into actions and commands.
|
|
| sort (&$arr_actions) | |
| Sort by Description. |
|
| sort_compare_callback ($a, $b) | |
| Sort callback to sort by description.
|
|
Detailed Description
A widget printing a menu based upon actions retrieved from given item.
Definition at line 8 of file menu.widget.php.
Constructor & Destructor Documentation
| WidgetItemMenu::__construct | ( | $ | item, | |
| $ | context = 'view', |
|||
| $ | params = false, |
|||
| $ | args = array() |
|||
| ) |
Definition at line 23 of file menu.widget.php.
00023 { 00024 $this->item = $item; 00025 $this->context = $context; 00026 $this->params = $params; 00027 $this->aro = AccessControl::get_current_aro(); 00028 $this->args = $args; 00029 }
Member Function Documentation
| static WidgetItemMenu::output | ( | $ | item, | |
| $ | context = 'view', |
|||
| $ | params = false, |
|||
| $ | args = array(), |
|||
| $ | policy =
self::NONE |
|||
| ) | [static] |
Definition at line 18 of file menu.widget.php.
00018 { 00019 $w = new WidgetItemMenu($item, $context, $params, $args); 00020 return $w->render($policy); 00021 }
| WidgetItemMenu::render | ( | $ | policy =
self::NONE |
) |
Renders what should be rendered.
- Parameters:
-
int $policy Defines how to render, meaning depends on implementation
- Returns:
- string The rendered content
Implements IRenderer.
Definition at line 31 of file menu.widget.php.
00031 { 00032 $ret = ''; 00033 $sources = $this->retrieve_actions($this->item); 00034 $commands = array(); 00035 $actions = array(); 00036 $has_commands = false; 00037 00038 if (Common::flag_is_set($policy, self::SEPARATE_COMMANDS)) { 00039 $this->separate($sources, $actions, $commands); 00040 $has_commands = (count($commands) > 0); 00041 } 00042 else { 00043 $actions = $sources; 00044 foreach($sources as $s) { 00045 if ($s instanceof ICommand) { 00046 $has_commands = true; 00047 break; 00048 } 00049 } 00050 } 00051 00052 if (Common::flag_is_set($policy, self::SORTED)) { 00053 $this->sort($actions); 00054 $this->sort($commands); 00055 } 00056 00057 if ($has_commands || count($actions)) { 00058 $view = ViewFactory::create_view(IViewFactory::MESSAGE, 'core::widgets/menu'); 00059 $view->assign('actions', $actions); 00060 00061 if ($has_commands) { 00062 Load::tools('formhandler'); 00063 $formhandler = new FormHandler('process_commands', 'process_commands', FormHandler::TOKEN_POLICY_REUSE); 00064 $formhandler->prepare_view($view); 00065 } 00066 00067 $view->assign('commands', $commands); 00068 $view->assign('policy', $policy); 00069 $view->assign('css_class', Arr::get_item($this->args, 'css_class', 'list_menu')); 00070 $ret = $view->render(); 00071 } 00072 00073 return $ret; 00074 }
| WidgetItemMenu::retrieve_actions | ( | $ | item | ) | [protected] |
Obtain actions from item , if suitable.
- Parameters:
-
IActionSource|array $item
- Returns:
- array
Definition at line 82 of file menu.widget.php.
00082 { 00083 $actions = array(); 00084 if ($item instanceof IActionSource) { 00085 $actions = $this->item->get_actions($this->aro, $this->context, $this->params); 00086 } 00087 else if (is_array($item)) { 00088 $actions = $this->item; 00089 } 00090 return $actions; 00091 }
| WidgetItemMenu::separate | ( | $ | arr_in, | |
| &$ | out_actions, | |||
| &$ | out_commands | |||
| ) | [protected] |
Divide actions into actions and commands.
Definition at line 96 of file menu.widget.php.
| WidgetItemMenu::sort | ( | &$ | arr_actions | ) | [protected] |
Sort by Description.
Definition at line 127 of file menu.widget.php.
| WidgetItemMenu::sort_compare_callback | ( | $ | a, | |
| $ | b | |||
| ) | [protected] |
Member Data Documentation
| WidgetItemMenu::$args |
Definition at line 16 of file menu.widget.php.
| WidgetItemMenu::$aro |
Definition at line 15 of file menu.widget.php.
| WidgetItemMenu::$context |
Definition at line 13 of file menu.widget.php.
| WidgetItemMenu::$item |
Definition at line 12 of file menu.widget.php.
| WidgetItemMenu::$params |
Definition at line 14 of file menu.widget.php.
| const WidgetItemMenu::SEPARATE_COMMANDS = 256 |
Definition at line 10 of file menu.widget.php.
| const WidgetItemMenu::SORTED = 128 |
Definition at line 9 of file menu.widget.php.
The documentation for this class was generated from the following file:
- gyro/core/view/widgets/menu.widget.php
