From 6d387b8aa2ba5269f3fff71d5a2f823c5716cc28 Mon Sep 17 00:00:00 2001
From: Pim Snel <mipmip@alumni.egroupware.org>
Date: Wed, 6 Jul 2005 23:12:42 +0000
Subject: [PATCH] - fixed the application manual call from text menu - sidebox
 is working again and can be opened and closed from the textmenu (its open by
 default) - sidebox saves its state to the preferences - some html and css
 cleanups - IE support still broken

---
 phpgwapi/templates/idots2/css/idots2.css      |  3 ++
 phpgwapi/templates/idots2/css/idots2_page.css | 32 +++++++++--
 phpgwapi/templates/idots2/head.inc.php        |  3 +-
 .../templates/idots2/js/x-desktop/events.js   | 27 ++++++++++
 phpgwapi/templates/idots2/navbar.inc.php      | 49 ++++++++++++-----
 phpgwapi/templates/idots2/navbar.tpl          | 38 +++++++++----
 phpgwapi/templates/idots2/write_settings.php  | 53 +++++++++++++++++++
 .../idots2/write_shortcut_setting.php         |  1 +
 phpgwapi/templates/idots2/write_size.php      |  3 --
 9 files changed, 175 insertions(+), 34 deletions(-)
 create mode 100644 phpgwapi/templates/idots2/write_settings.php

diff --git a/phpgwapi/templates/idots2/css/idots2.css b/phpgwapi/templates/idots2/css/idots2.css
index 8168244f21..a6b173bad2 100755
--- a/phpgwapi/templates/idots2/css/idots2.css
+++ b/phpgwapi/templates/idots2/css/idots2.css
@@ -155,6 +155,9 @@ a.appTitles,.appTitles
 	z-index:40;
 }
 
+
+
+
 #divAppboxHeader
 {
 	/*width:100%;*/
diff --git a/phpgwapi/templates/idots2/css/idots2_page.css b/phpgwapi/templates/idots2/css/idots2_page.css
index 3c633012c1..d7afdeb98a 100755
--- a/phpgwapi/templates/idots2/css/idots2_page.css
+++ b/phpgwapi/templates/idots2/css/idots2_page.css
@@ -198,17 +198,39 @@ td
    border-top:outset 1px #9c9c9c;	
    border-bottom:outset 1px #9c9c9c;	
    border-right:outset 1px #9c9c9c;	
-/*   padding-top:50px;
-   padding-bottom:60px;
-  */
    left:0px;
    width:170px;
-/**   height:100%;*/
-   background-color:#cccccc;
+   background-color:white;
    display:none;
    overflow:visible;
    position:fixed;
    z-index:899;	
+   padding:0;
+}
+
+.sidebox
+{
+
+}
+
+.sidebox li
+{
+   display:block;
+   margin:2px;
+}
+
+.sidebox ul
+{
+	_list-style:none;
+	list-style-position:inside;
+	padding-left:10px;
+}
+
+.sidebox_title
+{
+	background-color:#dedede;
+	padding:5px;
+	font-weight:bold;
 }
 
 .divLoginbox 
diff --git a/phpgwapi/templates/idots2/head.inc.php b/phpgwapi/templates/idots2/head.inc.php
index d6e36223f8..a37b83bf22 100755
--- a/phpgwapi/templates/idots2/head.inc.php
+++ b/phpgwapi/templates/idots2/head.inc.php
@@ -83,7 +83,8 @@
 		$app = "";
 	
 	}
-	$var = Array(
+	
+$var = Array(
 		'img_icon'      => PHPGW_IMAGES_DIR . '/favicon.ico',
 		'img_shortcut'  => PHPGW_IMAGES_DIR . '/favicon.ico',
 		'slider_effects'=> $slider_effects,
diff --git a/phpgwapi/templates/idots2/js/x-desktop/events.js b/phpgwapi/templates/idots2/js/x-desktop/events.js
index e77a1d76e8..839b039196 100755
--- a/phpgwapi/templates/idots2/js/x-desktop/events.js
+++ b/phpgwapi/templates/idots2/js/x-desktop/events.js
@@ -175,6 +175,33 @@ function saveSize(idotsName) {
 
 }
 
+function saveSideboxState(idotsName,sideboxstate) {
+title = xDT.prop(idotsName, 'wTitle');
+//w = xDT.prop(idotsName, 'wWidth');
+//h = xDT.prop(idotsName, 'wHeight');
+
+url = strXmlUrl + "/write_settings.php?action=save_sidebox_state&title=" + idotsName + "&sidebox_state="+sideboxstate;
+/*var found = false;
+for(i = 0; i < aTitle.length; i++)
+{
+	if(aTitle[i] != "" && aTitle[i] == title) {
+		aWidth[i] = w;
+		aHeight[i] = h;
+		found = true;
+	}
+}
+if(!found) 
+{
+	aTitle[aTitle.length] = title;
+	aWidth[aWidth.length] = w;
+	aHeight[aHeight.length] = h;	
+}
+*/
+loadXMLDoc(url);
+return true;
+
+}
+
 function findPosX(obj)
 {
         var curleft = 0;
diff --git a/phpgwapi/templates/idots2/navbar.inc.php b/phpgwapi/templates/idots2/navbar.inc.php
index f69ecba106..3c11b1d7ea 100755
--- a/phpgwapi/templates/idots2/navbar.inc.php
+++ b/phpgwapi/templates/idots2/navbar.inc.php
@@ -41,21 +41,25 @@
 	  $GLOBALS['idots2_tpl']->set_block('navbar','show_clock','show_clock');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','no_clock','no_clock');
 
+	  
 	  $GLOBALS['idots2_tpl']->set_block('navbar','sidebox_container','sidebox_container');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','sidebox_container_footer','sidebox_container_footer');
-	  
+	  $GLOBALS['idots2_tpl']->set_block('navbar','sidebox_set_open','sidebox_set_open');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','sidebox','sidebox');
+	  $GLOBALS['idots2_tpl']->set_block('navbar','sidebox_spacer','sidebox_spacer');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','sidebox_footer','sidebox_footer');
+
 	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_sidebox_block_row','extra_sidebox_block_row');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_sidebox_block_row_raw','extra_sidebox_block_row_raw');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_sidebox_block_row_no_link','extra_sidebox_block_row_no_link');
 
-	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_blocks_header','extra_block_header');
+	 
+	  $GLOBALS['idots2_tpl']->set_block('navbar','menu_header','menu_header');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_block_row','extra_block_row');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_block_row_raw','extra_block_row_raw');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_block_row_no_link','extra_block_row_no_link');
-	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_block_spacer','extra_block_spacer');
-	  $GLOBALS['idots2_tpl']->set_block('navbar','extra_blocks_footer','extra_blocks_footer');
+	  $GLOBALS['idots2_tpl']->set_block('navbar','txt_menu_spacer','txt_menu_spacer');
+	  $GLOBALS['idots2_tpl']->set_block('navbar','menu_footer','menu_footer');
 
 	  $GLOBALS['idots2_tpl']->set_block('navbar','begin_toolbar','begin_toolbar');
 	  $GLOBALS['idots2_tpl']->set_block('navbar','end_toolbar','end_toolbar');
@@ -319,6 +323,19 @@
 	  }
 	  else 
 	  {
+		 $GLOBALS['phpgw']->preferences->read_repository();
+
+/*		 foreach($GLOBALS['phpgw_info']['user']['apps'] as $name => $data)
+		 {
+			if($data['title'] == $title) {
+			   $state['name'] = $name;
+			   $GLOBALS['phpgw']->preferences->change('phpgwapi','sidebox_state'.$name,$state);
+			   $GLOBALS['phpgw']->preferences->save_repository(True);
+			   break;
+			}
+		 }
+		 */
+		 
 		 // build the menu
 		 $menu=array();
 		 $menu['Window'] = array(
@@ -348,7 +365,7 @@
 			array(
 			   'text'    => lang('%1 manual',$GLOBALS['phpgw_info']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']]['title']),
 			   'no_lang' => True,
-			   'link'    => 'javascript:parent.openX(\''.lang('%1 manual',$GLOBALS['phpgw_info']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']]['title']).'\',\''.$GLOBALS['phpgw_info']['navbar']['manual']['url'].'\')'
+			   'link'    => 'javascript:parent.openX(\''.lang('%1 manual',$GLOBALS['phpgw_info']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']]['title']).'\',\''.$GLOBALS['phpgw_info']['navbar']['manual']['url'].'?app_manual='.$GLOBALS['phpgw_info']['flags']['currentapp'].'\')'
 			),
 			array(
 			   'text'    => '<hr style="border:0;border-bottom:dashed 1px #444444;height:1px;color:#444444;">',
@@ -434,20 +451,24 @@
 			'Logout'=>$GLOBALS['egw_info']['navbar']['logout']['url']
 		 );
 		 $var['menu_link'] = '';
-		 //$var['sideboxcolstart'] = '<t'.'d id="tdSidebox" valign="top">';
 		 $var['remove_padding'] = '';
+		 $var['current_app'] = $GLOBALS['egw_info']['flags']['currentapp'];
 		 $GLOBALS['idots2_tpl']->set_var($var);
 		 
 		 $GLOBALS['idots2_tpl']->pparse('out','sidebox_container');
 
-		 //display_sidebox('',$menu_title,$file);
 		 $GLOBALS['egw']->hooks->single('sidebox_menu',$GLOBALS['egw_info']['flags']['currentapp']);
 
-		 //$var['sideboxcolend'] = '</'.'td>';
 		 $GLOBALS['idots2_tpl']->pparse('out','sidebox_container_footer');
 
-		 
+
 		 $GLOBALS['idots2_tpl']->pparse('out','navbar_footer');
+		 
+		 // get sidebox state and set it with js
+		 if($GLOBALS['phpgw_info']['user']['preferences']['phpgwapi']['sidebox_'.$GLOBALS['phpgw_info']['flags']['currentapp']]!='close')
+		 {
+			$GLOBALS['idots2_tpl']->pparse('out','sidebox_set_open');
+		 }
 
 		 // If the application has a header include, we now include it
 		 if(!@$GLOBALS['phpgw_info']['flags']['noappheader'] && @isset($_GET['menuaction']))
@@ -491,14 +512,14 @@
 	  {
 		 $var['lang_title']=$menu_title;//$appname.' '.lang('Menu');
 		 $GLOBALS['idots2_tpl']->set_var($var);
-		 $GLOBALS['idots2_tpl']->pfp('out','extra_blocks_header');
+		 $GLOBALS['idots2_tpl']->pfp('out','menu_header');
 
 		 foreach($file as $text => $url)
 		 {
-			sidebox_menu_item($url,$text);
+			textmenu_item($url,$text);
 		 }
 
-		 $GLOBALS['idots2_tpl']->pparse('out','extra_blocks_footer');
+		 $GLOBALS['idots2_tpl']->pparse('out','menu_footer');
 	  }
    }
 
@@ -506,7 +527,7 @@
    {
 	  if($item_text === '_NewLine_' || $item_link === '_NewLine_')
 	  {
-		 $GLOBALS['idots2_tpl']->pparse('out','extra_block_spacer');
+		 $GLOBALS['idots2_tpl']->pparse('out','txt_menu_spacer');
 	  }
 	  else
 	  {
@@ -563,7 +584,7 @@
    {
 	  if($item_text === '_NewLine_' || $item_link === '_NewLine_')
 	  {
-		 $GLOBALS['idots2_tpl']->pparse('out','extra_block_spacer');
+		 $GLOBALS['idots2_tpl']->pparse('out','sidebox_spacer');
 	  }
 	  else
 	  {
diff --git a/phpgwapi/templates/idots2/navbar.tpl b/phpgwapi/templates/idots2/navbar.tpl
index 2cf278f526..a52996cc98 100755
--- a/phpgwapi/templates/idots2/navbar.tpl
+++ b/phpgwapi/templates/idots2/navbar.tpl
@@ -155,17 +155,18 @@ function sidebox_close()
 {
 	document.getElementById('sidebox_container').style.display="none";
 	document.getElementById('divAppbox').style.marginLeft="0px;";
+	parent.saveSideboxState('{current_app}','close');
 }
 
 function sidebox_open()
 {
 	document.getElementById('sidebox_container').style.display="block";
-	document.getElementById('divAppbox').style.marginLeft="180px;";
+	document.getElementById('divAppbox').style.marginLeft="170px;";
+	parent.saveSideboxState('{current_app}','open');
 }
 </script>
 
 <div id="sidebox_container">
-<br/>
 <!-- END sidebox_container -->
 
 <!-- BEGIN sidebox_container_footer -->
@@ -174,16 +175,23 @@ function sidebox_open()
 <!-- END sidebox_container_footer -->
 
 
+<!-- BEGIN sidebox_set_open -->
+<script>
+sidebox_open();
+</script>
+<!-- END sidebox_set_open -->
+
 
 
 <!-- BEGIN sidebox -->
 
 <div class="sidebox">
-<ul>
+<div class="sidebox_title">{lang_title}</div>
+<table style="width:100%">
 <!-- END sidebox -->
 
 <!-- BEGIN sidebox_footer -->
-</ul>
+</table>
 </div>
 
 <!-- END sidebox_footer -->
@@ -191,11 +199,18 @@ function sidebox_open()
 
 <!-- BEGIN extra_sidebox_block_row -->
 
-<li><a class="rowSidebox" href="{item_link}"{target}>{lang_item}</a></li>
+<tr class="divSideboxEntry">
+<td width="20" align="center" valign="middle" class="textSidebox">{icon_or_star}</td><td class="textSidebox"><a class="textSidebox" href="{item_link}"{target}>{lang_item}</a></td>
+</tr>
 
 <!-- END extra_sidebox_block_row -->
 
 
+<!-- BEGIN sidebox_spacer -->
+
+<!-- END sidebox_spacer -->
+
+
 <!-- BEGIN extra_sidebox_block_row_raw -->
 
 <li><div><a href="#">{lang_item}</a></div></li>
@@ -220,19 +235,19 @@ function sidebox_open()
 <!-- END navbar_footer -->
 
 
-<!-- BEGIN extra_blocks_header -->
+<!-- BEGIN menu_header -->
 
 	<li onclick="itemClick(event);" onmouseover="itemHover(event);"> <a href="javascript:void(0);">{lang_title}</a>
 	<ul>
 
-<!-- END extra_blocks_header -->
+<!-- END menu_header -->
 
 
-<!-- BEGIN extra_blocks_footer -->
+<!-- BEGIN menu_footer -->
 
 	</ul></li>
 
-<!-- END extra_blocks_footer -->
+<!-- END menu_footer -->
 
 
 <!-- BEGIN extra_block_row -->
@@ -256,9 +271,10 @@ function sidebox_open()
 <!-- END extra_block_row_no_link -->
 
 
-<!-- BEGIN extra_block_spacer -->
+<!-- BEGIN txt_menu_spacer -->
 &nbsp;
-<!-- END extra_block_spacer -->
+<!-- END txt_menu_spacer -->
+
 
 
 <!-- BEGIN launch_app -->
diff --git a/phpgwapi/templates/idots2/write_settings.php b/phpgwapi/templates/idots2/write_settings.php
new file mode 100644
index 0000000000..c49bf95865
--- /dev/null
+++ b/phpgwapi/templates/idots2/write_settings.php
@@ -0,0 +1,53 @@
+<?php
+   /**************************************************************************\
+   * eGroupWare                                                               *
+   * http://www.egroupware.org                                                *
+   * This file is written by Rob van Kraanen <rvkraanen@gmail.com>            *
+   * This file is written by Pim Snel <pim@lingewoud.com>                     *
+   * Copyright 2005 Lingewoud BV - www.lingewoud.com                          *
+   * --------------------------------------------                             *
+   *  This program is free software; you can redistribute it and/or modify it *
+   *  under the terms of the GNU General Public License as published by the   *
+   *  Free Software Foundation; either version 2 of the License, or (at your  *
+   *  option) any later version.                                              *
+   \**************************************************************************/
+   
+   //todo move shortcutsetting and size also to this file
+
+   $phpgw_info = array();
+   $GLOBALS['phpgw_info']['flags'] = array(
+	  'noheader' => True,
+	  'nonavbar' => True,
+	  'disable_Template_class' => True,
+	  'currentapp' => 'notifywindow'
+   );
+   
+   include('../../../header.inc.php');
+   header("Content-type: text/xml");
+   header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
+   header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
+   header( "Cache-Control: no-cache, must-revalidate" ); 
+   header( "Pragma: no-cache" );
+   echo '<?xml version="1.0" encoding="UTF-8"
+   standalone="yes"?>';
+   echo "\r\n<response>\r\n";
+   if($_GET[action]=='save_sidebox_state')
+   {
+	  $title = $_GET["title"];
+	  $sidebox_state = $_GET["sidebox_state"];
+	  echo $title." ".$sidebox_state;
+	  $GLOBALS['phpgw']->preferences->read_repository();
+
+	  foreach($GLOBALS['phpgw_info']['user']['apps'] as $name => $data)
+	  {
+		 if($name == $title) 
+		 {
+			$GLOBALS['phpgw']->preferences->change('phpgwapi','sidebox_'.$name,$_GET["sidebox_state"]);
+			$GLOBALS['phpgw']->preferences->save_repository(True);
+			break;
+		 }
+	  }
+   }
+   echo "</response>"; 
+   
+?>
diff --git a/phpgwapi/templates/idots2/write_shortcut_setting.php b/phpgwapi/templates/idots2/write_shortcut_setting.php
index c8fa621507..d09bb06b75 100755
--- a/phpgwapi/templates/idots2/write_shortcut_setting.php
+++ b/phpgwapi/templates/idots2/write_shortcut_setting.php
@@ -3,6 +3,7 @@
 * eGroupWare                                                               *
 * http://www.egroupware.org                                                *
 * This file is written by Rob van Kraanen <rvkraanen@gmail.com>            *
+* Copyright 2005 Lingewoud BV - www.lingewoud.com                          *
 * --------------------------------------------                             *
 *  This program is free software; you can redistribute it and/or modify it *
 *  under the terms of the GNU General Public License as published by the   *
diff --git a/phpgwapi/templates/idots2/write_size.php b/phpgwapi/templates/idots2/write_size.php
index c45b4241ec..13482bad11 100755
--- a/phpgwapi/templates/idots2/write_size.php
+++ b/phpgwapi/templates/idots2/write_size.php
@@ -29,7 +29,6 @@
 	standalone="yes"?>';
 	echo "\r\n<response>\r\n";
 
-
 	$title = $_GET["title"];
 	$width = $_GET["w"];
 	$height= $_GET["h"];
@@ -44,8 +43,6 @@
 			$size['height'] = $height;
 			$GLOBALS['phpgw']->preferences->change('phpgwapi','size_'.$name,$size);
 			$GLOBALS['phpgw']->preferences->save_repository(True);
-			
-			
 		}
 	}
 	echo "</response>";