Completely revert changes from rev 28826.

Now using a seperate array to hold additional topmenu entries from hooks to prevent occasional duplication of info items.  Apps should now be able to call ['egw']->framework->add_topmenu_item('name', 'url', 'title') to add an additional entry to the topmenu.
This commit is contained in:
Nathan Gray 2009-12-17 18:07:59 +00:00
parent 95540c3fa7
commit b94bf0c8a0

View File

@ -60,6 +60,12 @@ class idots_framework extends egw_framework
*/
var $topmenu_icon_arr = array();
/**
* Contains array of information for additional topmenu items added
* by hooks
*/
private static $hook_items = array();
/**
* Constructor
*
@ -598,12 +604,8 @@ class idots_framework extends egw_framework
*/
function topmenu(array &$vars,array &$apps)
{
//if(!is_array($this->tplsav2->menuitems)) {
$this->tplsav2->menuitems = array();
//}
//if(!is_array($this->tplsav2->menuinfoitems)) {
$this->tplsav2->menuinfoitems = array();
//}
if($GLOBALS['egw_info']['user']['apps']['home'] && isset($apps['home']))
{
@ -621,6 +623,11 @@ class idots_framework extends egw_framework
}
//$this->_add_topmenu_item($apps['about'],lang('About %1',$GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title']));
// Add extra items added by hooks
foreach(self::$hook_items as $extra_item) {
$this->_add_topmenu_item($extra_item);
}
$this->_add_topmenu_item($apps['logout']);
$this->tplsav2->assign('info_icons',$this->topmenu_icon_arr);
@ -636,6 +643,27 @@ class idots_framework extends egw_framework
return $this->tplsav2->fetch('topmenu.tpl.php');
}
/**
* Called by hooks to add an entry in the topmenu location.
* Extra entries will be added just before Logout.
*
* @param string $id unique element id
* @param string $url Address for the entry to link to
* @param string $title Text displayed for the entry
* @param string $target Optional, so the entry can open in a new page or popup
* @access public
* @return void
*/
public static function add_topmenu_item($id,$url,$title,$target = '')
{
$entry['name'] = $id;
$entry['url'] = $url;
$entry['title'] = $title;
$entry['target'] = $target;
self::$hook_items[$id] = $entry;
}
/**
* called by hooks to add an icon in the topmenu info location
*