- make topmenu default pref setting now

- fix bugs and wrong implementation of topmenu
- introduce new hook: topmenu_info for adding content to the topmenu see messenges as example
This commit is contained in:
Pim Snel 2007-01-09 22:44:30 +00:00
parent 4e26206909
commit bfe1e5b04a
4 changed files with 734 additions and 633 deletions

View File

@ -1,5 +1,5 @@
<?php
/**
/**
* eGW idots template
*
* @link http://www.egroupware.org
@ -12,20 +12,20 @@
* @version $Id$
*/
require_once(EGW_API_INC.'/class.egw_framework.inc.php');
require_once(EGW_API_INC.'/class.Template.inc.php');
require_once(EGW_API_INC.'/class.dragdrop.inc.php');
require_once(EGW_API_INC.'/class.tplsavant2.inc.php');
require_once(EGW_API_INC.'/class.egw_framework.inc.php');
require_once(EGW_API_INC.'/class.Template.inc.php');
require_once(EGW_API_INC.'/class.dragdrop.inc.php');
require_once(EGW_API_INC.'/class.tplsavant2.inc.php');
/**
/**
* eGW idots template
*
* The idots_framework class draws the default idots template. It's a phplib template based template-set.
*
* Other phplib template based template-sets should extend (not copy!) this class and reimplement methods they which to change.
*/
class idots_framework extends egw_framework
{
class idots_framework extends egw_framework
{
/**
* HTML of the sidebox menu, get's collected here by calls to $this->sidebox
*
@ -45,6 +45,14 @@ class idots_framework extends egw_framework
*/
var $navbar_done;
/**
* Contains array with linked icons in the topmenu
*
* @var mixed
* @access public
*/
var $topmenu_icon_arr = array();
/**
* Constructor
*
@ -53,7 +61,6 @@ class idots_framework extends egw_framework
*/
function idots_framework($template='idots')
{
$GLOBALS['egw_info']['flags']['include_xajax'] = True;
$this->egw_framework($template); // call the constructor of the extended class
@ -97,6 +104,12 @@ class idots_framework extends egw_framework
*/
function navbar()
{
if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox')
{
$GLOBALS['egw']->hooks->process('topmenu_info');
echo $this->topmenu();
}
$this->navbar_done = true;
// the navbar
@ -129,7 +142,8 @@ class idots_framework extends egw_framework
$content = $this->tpl->fp('out','navbar_header');
// general (app-unspecific) sidebox menu
if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_sideboxmenu']!='no')
if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] == 'sidebox')
//if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_sideboxmenu']!='no')
{
$menu_title = lang('General Menu');
@ -234,10 +248,14 @@ class idots_framework extends egw_framework
// hook after navbar
// ToDo: change it to return the content!
if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] == 'sidebox')
{
ob_start();
$GLOBALS['egw']->hooks->process('after_navbar');
$content .= ob_get_contents();
ob_end_clean();
}
return $content;
}
@ -440,7 +458,7 @@ class idots_framework extends egw_framework
{
$var = parent::_get_navbar($apps);
if($GLOBALS['egw_info']['user']['preferences']['common']['show_top_menu'] == 'yes')
if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox')
{
$var['quick_add'] = '';
$var['user_info']='';
@ -606,12 +624,45 @@ class idots_framework extends egw_framework
$this->_add_topmenu_item('about',lang('About %1',$GLOBALS['egw_info']['apps'][$GLOBALS['egw_info']['flags']['currentapp']]['title']));
$this->_add_topmenu_item('logout');
$this->tplsav2->assign('info_icons',$this->topmenu_icon_arr);
$this->_add_topmenu_info_item($this->_user_time_info());
$this->_add_topmenu_info_item($this->_get_quick_add());
$this->tplsav2->display('topmenu.tpl.php');
}
/**
* called by hooks to add an icon in the topmenu info location
*
* @param string $id unique element id
* @param string $icon_src src of the icon image. Make sure this nog height then 18pixels
* @param string $iconlink where the icon links to
* @param booleon $blink set true to make the icon blink
* @param mixed $tooltip string containing the tooltip html, or null of no tooltip
* @access public
* @return void
*/
function topmenu_info_icon($id,$icon_src,$iconlink,$blink=false,$tooltip=null)
{
$icon_arr['id'] = $id;
$icon_arr['blink'] = $blink;
$icon_arr['link'] = $iconlink;
$icon_arr['image'] = $icon_src;
if(!is_null($tooltip))
{
if (!is_object($GLOBALS['egw']->html))
{
require_once(EGW_API_INC.'/class.html.inc.php');
$GLOBALS['egw']->html = new html;
}
$icon_arr['tooltip'] = $GLOBALS['egw']->html->tooltip($tooltip);
}
$this->topmenu_icon_arr[]=$icon_arr;
}
/**
* Returns the html from the closing div of the main application area to the closing html-tag
*
@ -660,17 +711,17 @@ class idots_framework extends egw_framework
}
return $content;
}
}
}
/**
* Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
*
* @param string $appname
* @param string $menu_title
* @param array $file
*/
function sidebox($appname,$menu_title,$file)
{
/**
* Parses one sidebox menu and add's the html to $this->sidebox_content for later use by $this->navbar
*
* @param string $appname
* @param string $menu_title
* @param array $file
*/
function sidebox($appname,$menu_title,$file)
{
if(!$appname || ($appname==$GLOBALS['egw_info']['flags']['currentapp'] && $file))
{
$this->tpl->set_var('lang_title',$menu_title);
@ -682,18 +733,18 @@ class idots_framework extends egw_framework
}
$this->sidebox_content .= $this->tpl->parse('out','extra_blocks_footer');
}
}
}
/**
* Return a sidebox menu item
*
* @internal PHP5 protected
* @param string $item_link
* @param string $item_text
* @return string
*/
function _sidebox_menu_item($item_link='',$item_text='')
{
/**
* Return a sidebox menu item
*
* @internal PHP5 protected
* @param string $item_link
* @param string $item_text
* @return string
*/
function _sidebox_menu_item($item_link='',$item_text='')
{
if($item_text === '_NewLine_' || $item_link === '_NewLine_')
{
return $this->tpl->parse('out','extra_block_spacer');
@ -732,5 +783,5 @@ class idots_framework extends egw_framework
$block .= $var['icon_or_star'] === False ? '_raw' : '_no_link';
}
return $this->tpl->parse('out',$block);
}
}
}

View File

@ -11,6 +11,10 @@
/* $Id$ */
$top_menu = array(
'topmenu' => lang('Show as Topmenu'),
'sidebox' => lang('Show in sidebox')
);
$yes_no = array(
'yes' => lang('yes'),
'no' => lang('no')
@ -27,21 +31,12 @@
'xmlrpc' => False,
'admin' => False
),
'show_top_menu' => array(
'show_general_menu' => array(
'type' => 'select',
'label' => 'Show egroupware top menu?',
'name' => 'show_top_menu',
'values' => $yes_no,
'help' => 'When you say yes a top menu is rendered.',
'xmlrpc' => False,
'admin' => False
),
'show_general_sideboxmenu' => array(
'type' => 'select',
'label' => 'Show general sidebox menu?',
'name' => 'show_general_sideboxmenu',
'values' => $yes_no,
'help' => 'When you say yes the first sidebox is contains general egroupware items.',
'label' => 'How to show the general eGroupWare menu ?',
'name' => 'show_general_menu',
'values' => $top_menu,
'help' => 'Where and how will the egroupware links like preferences, about and logout be displayed.',
'xmlrpc' => False,
'admin' => False
),

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 B

After

Width:  |  Height:  |  Size: 147 B

View File

@ -1,3 +1,43 @@
<script language="JavaScript" type="text/javascript">
function opacity(id, opacStart, opacEnd, millisec) {
//speed for each frame
var speed = Math.round(millisec / 100);
var timer = 0;
//determine the direction for the blending, if start and end are the same nothing happens
if(opacStart > opacEnd) {
for(i = opacStart; i >= opacEnd; i--) {
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
}
else if(opacStart < opacEnd) {
for(i = opacStart; i <= opacEnd; i++)
{
setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
timer++;
}
}
}
//change the opacity for different browsers
function changeOpac(opacity, id) {
var object = document.getElementById(id).style;
object.opacity = (opacity / 100);
object.MozOpacity = (opacity / 100);
object.KhtmlOpacity = (opacity / 100);
object.filter = "alpha(opacity=" + opacity + ")";
}
function shiftOpacity(id, millisec) {
//if an element is invisible, make it visible, else make it ivisible
if(document.getElementById(id).style.opacity == 0) {
opacity(id, 0, 100, millisec);
} else {
opacity(id, 100, 0, millisec);
}
}
</script>
<div id="topmenu">
<div id="topmenu_items">
<?php foreach($this->menuitems as $mitems):?>
@ -6,9 +46,24 @@
</div>
<div id="topmenu_info">
<?php foreach($this->info_icons as $iicon):?>
<div style="padding:0px 10px 0px 0px;position:relative;float:left;"><a href="<?=$iicon['link']?>"><img id="<?=$iicon['id']?>" src="<?=$iicon['image']?>" <?=$iicon['tooltip']?>/></a></div>
<?php endforeach?>
<?php foreach($this->menuinfoitems as $mitems):?>
<div style="padding:0px 10px 0px 10px;position:relative;float:left;"><?=$mitems?></div>
<div style="padding:0px 10px 0px 0px;position:relative;float:left;"><?=$mitems?></div>
<?php endforeach?>
</div>
<div style="clear:both;"></div>
</div>
<script language="JavaScript" type="text/javascript">
<?php foreach($this->info_icons as $iicon):?>
<?php if($iicon['blink']):?>
setInterval("shiftOpacity('<?=$iicon['id']?>', 500)",1500);
<?php endif?>
<?php endforeach?>
//shiftOpacity('blinkimg', 500);
</script>