Changeset 5945
- Timestamp:
- 01/18/12 18:38:52 (4 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
-
core/viewhelper/smarty/function.modulenavigation.php (modified) (2 diffs)
-
modules/systeminfo/systeminfo.menu.php (modified) (1 diff)
-
themes/core/view/smarty/modulenavigation-generic.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/viewhelper/smarty/function.modulenavigation.php
r5059 r5945 27 27 function smarty_function_modulenavigation($params, $smarty) 28 28 { 29 $modulename = Clansuite_HttpRequest::getRoute()->getModuleName(); 30 $modulenavigation_file = ROOT_MOD. $modulename . DS . $modulename . '.menu.php'; 29 $module = Clansuite_HttpRequest::getRoute()->getModuleName(); 31 30 32 if( is_file($modulenavigation_file) ) 31 $file = ROOT_MOD. $module . DS . $module . '.menu.php'; 32 33 if( is_file($file) ) 33 34 { 34 35 # this includes the file, which contains a php array name $modulenavigation 35 include $ modulenavigation_file;36 include $file; 36 37 37 # convert URLs by callback 38 $modulenavigation = array_map("convertURLs", $modulenavigation); 38 # push the $modulenavigation array to a callback function 39 # for further processing of the menu items 40 $modulenavigation = array_map("applyCallbacks", $modulenavigation); 41 42 var_dump($modulenavigation); 39 43 40 44 $smarty->assign('modulenavigation', $modulenavigation); 45 41 46 # The file is located in clansuite/themes/core/view/smarty/modulenavigation-generic.tpl 42 47 return $smarty->fetch('modulenavigation-generic.tpl'); 43 48 } 44 else 49 else # the module menu navigation file is missing 45 50 { 46 $smarty->assign('modulename', $module name);51 $smarty->assign('modulename', $module); 47 52 $errormessage = $smarty->fetch('modulenavigation_not_found.tpl'); 48 53 trigger_error($errormessage); … … 51 56 52 57 /** 53 * array_map callback function to replace the values of the 'url' key 54 * because these might be shorthands like "/index/show" etc. 58 * array_map callback function 55 59 * 56 * @param array $array 60 * 1) convert short urls 61 * 2) execute callback conditions of menu items 62 * 63 * @param array $modulenavigation 57 64 */ 58 function convertURLs($array)65 function applyCallbacks(array $modulenavigation) 59 66 { 60 $array['url'] = Clansuite_Router::buildURL($array['url']); 61 return $array; 67 /** 68 * 1) Convert Short Urls 69 * 70 * This replaces the values of the 'url' key (array['url']), 71 * because these might be shorthands, like "/index/show". 72 */ 73 $modulenavigation['url'] = Clansuite_Router::buildURL($modulenavigation['url']); 74 75 /** 76 * 2) Conditions of menu items 77 * 78 * If the condition of the menu item is not met, 79 * then condition is set to false, otherwise true. 80 */ 81 if(isset($modulenavigation['condition']) === true) 82 { 83 /** 84 * the if statement evaluates the content of the key condition 85 * and compares it to false, then reassigns the boolean value as 86 * the condition value. 87 * 88 * for now you might define 'condition' => extension_loaded('apc') 89 * 90 * @todo check usage of closures 91 */ 92 if($modulenavigation['condition'] === false) 93 { 94 $modulenavigation['condition'] = false; 95 } 96 else 97 { 98 $modulenavigation['condition'] = true; 99 } 100 } 101 102 return $modulenavigation; 62 103 } 63 104 ?> -
trunk/modules/systeminfo/systeminfo.menu.php
r4768 r5945 53 53 'url' => '/systeminfo/admin/show_apc', 54 54 'icon' => '', 55 'title' => '' 55 'title' => '', 56 'condition' => extension_loaded('apc') 56 57 ), 57 58 ); -
trunk/themes/core/view/smarty/modulenavigation-generic.tpl
r5155 r5945 78 78 <ul> 79 79 {foreach $modulenavigation as $item} 80 81 {* if the condition is not met, then do not display the menu item *} 82 {if isset($item.condition) === true and $item.condition === false} 83 {continue} 84 {/if} 85 80 86 <li> 81 87 <a href="{$item.url}" title="{$item.title}"> <span>{$item.name}</span> </a>
Note: See TracChangeset
for help on using the changeset viewer.
