Changeset 15901
- Timestamp:
- 01/19/12 23:13:21 (4 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
inc/classes/BxDolMenu.php (modified) (2 diffs)
-
install/sql/v70.sql (modified) (1 diff)
-
templates/base/scripts/BxBaseMenu.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/inc/classes/BxDolMenu.php
r15854 r15901 20 20 * Menus. 21 21 * 22 * It allows to display menu using different templates. 22 * Menu uses some set of items and the template to display it, 23 * so it is possible to have several menus which uses the same set of items but different templates. 24 * 25 * Menu is any set of some links or actions, for example menu can be links in site's footer or actions in profile view. 26 * 27 * 28 * @section menu_create Creating the Menu object: 29 * 30 * 1. Add record to 'sys_objects_menu' table: 31 * 32 * - object: name of the menu object, in the format: vendor prefix, underscore, module prefix, underscore, internal identifier or nothing; for example: bx_groups_actions - actions menu in group view. 33 * - title: name of the menu, displayed in the studio menu builder. 34 * - set_name: name of items' set. 35 * - module: the module this menu belongs to. 36 * - template_id: the template to use for menu displaying, this is id from 'sys_menu_templates' table. 37 * - deleteable: it determines if menu can be deleted from the studio menu builder. 38 * - active: it is possible to disable particular menu, then it will not be displayed. 39 * - override_class_name: user defined class name which is derived from BxTemplMenu. 40 * - override_class_file: the location of the user defined class, leave it empty if class is located in system folders. 41 * 42 * Menu templates are stored in 'sys_menu_templates' table: 43 * - id: template id. 44 * - template: template file. 45 * - title: template title to display in the studio menu builder. 46 * All menu templates iterate through 'bx_repeat:menu_items' and use the following template variables for each menu item: __link__, __target__, __onclick__, __title__, __class_add__. 47 * 48 * 49 * 2. Add menu an empty menu set to 'sys_menu_sets' table (if you want to use new set of items for created menu): 50 * - set_name: the set name. 51 * - module: the module this set belongs to. 52 * - title: name of the set, displayed in studio menu builder. 53 * - deletable: it determines if the set can be deleted from menu builder. 54 * 55 * 56 * 3. Add menu items to the set by adding records to 'sys_menu_items' table: 57 * - set_name: the set name this item belogs to. 58 * - module: the module this item belongs to. 59 * - name: name of the item (not displayed to the end user), unique in the particular set. 60 * - title: menu item title to display to the end user, please note that some templates can still display menu as icons without text titles. 61 * - link: menu item URL. 62 * - onclick: menu item onclick event. 63 * - target: menu item target. 64 * - icon: menu item icon, please note that some templates can still display menu as text without icons. 65 * - visibile_for_levels: bit field with set of member level ids. To use member level id in bit field - the level id minus 1 as power of 2 is used, for example: 66 * - user level id = 1 -> 2^(1-1) = 1 67 * - user level id = 2 -> 2^(2-1) = 2 68 * - user level id = 3 -> 2^(3-1) = 4 69 * - user level id = 4 -> 2^(4-1) = 8 70 * - active: it is possible to disable particular menu item, then it will not be displayed. 71 * - order: menu item order in the particular set. 72 * 73 * 74 * 4. Display Menu. 75 * Use the following sample code to display menu: 76 * @code 77 * bx_import('BxTemplMenu'); 78 * $oMenu = BxTemplMenu::getObjectInstance('sample_menu'); // 'sample_menu' is 'object' field from 'sys_objects_menu' table. 79 * if ($oMenu) 80 * echo $oMenu->getCode; // display menu 81 * @endcode 82 * 83 * But in most cases you don't need to use above code to display menu, 84 * menu objects are integrated into pages - there is special 'menu' page block type for it. 85 * 23 86 */ 24 25 87 class BxDolMenu extends BxDol { 26 88 … … 97 159 return true; 98 160 } 99 161 162 /** 163 * Check if menu items is selected. 164 * @param $a menu item array 165 * @return boolean 166 */ 100 167 protected function _isSelected ($a) { 101 168 return $a['module'] == self::$SEL_MODULE && $a['name'] == self::$SEL_NAME ? true : false; 102 169 } 103 170 171 /** 172 * Check if menu items is visible. 173 * @param $a menu item array 174 * @return boolean 175 */ 104 176 protected function _isVisible ($a) { 105 if (!$a['hidden_for_levels']) 106 return true; 107 bx_import('BxTemplAcl'); 108 $oACL = BxTemplAcl::getInstance(); 109 $iProfileId = 1; // TODO: get current profile id 110 $aACL = $oACL->getMemberMembershipInfo($iProfileId); 111 return !($a['hidden_for_levels'] & pow(2, $aACL['id'] - 1)); 177 bx_import('BxDolAcl'); 178 return BxDolAcl::getInstance()->isMemberLevelInSet($a['visibile_for_levels']); 112 179 } 113 180 181 /** 182 * Replace provided markers in menu item array, curently markers are replaced in title, link and onclick fields. 183 * @param $a menu item array 184 * @return array where markes are replaced with real values 185 */ 114 186 protected function _replaceMarkers ($a) { 115 187 if (empty($this->_aMarkers)) -
trunk/install/sql/v70.sql
r15897 r15901 4564 4564 `onclick` varchar(255) NOT NULL, 4565 4565 `target` varchar(255) NOT NULL, 4566 `icon` varchar(255) NOT NULL, 4567 ` hidden_for_levels` int(10) unsigned NOT NULL DEFAULT '0',4566 `icon` varchar(255) NOT NULL, 4567 `visibile_for_levels` int(11) NOT NULL DEFAULT '2147483647', 4568 4568 `active` tinyint(4) NOT NULL DEFAULT '1', 4569 4569 `order` int(11) NOT NULL, -
trunk/templates/base/scripts/BxBaseMenu.php
r15865 r15901 13 13 /** 14 14 * Menu representation. 15 * @see BxDol menu15 * @see BxDolMenu 16 16 */ 17 17 class BxBaseMenu extends BxDolMenu { … … 28 28 } 29 29 30 30 /** 31 * Get menu code. 32 * @return string 33 */ 31 34 public function getCode () { 32 35 … … 41 44 } 42 45 46 /** 47 * Get menu items array, which are ready to pass to template. 48 * @return array 49 */ 43 50 protected function _getMenuItems () { 44 51 $aRet = array(); … … 66 73 return $aRet; 67 74 } 68 75 76 /** 77 * Add css/js files which are needed for menu display and functionality. 78 */ 69 79 protected function _addJsCss() { 70 80 $this->_oTemplate->addCss('menu.css');
Note: See TracChangeset
for help on using the changeset viewer.