From 4fa662a56992148a38653a7b9f5096160b4b062a Mon Sep 17 00:00:00 2001 From: ceb Date: Sat, 30 Nov 2002 02:02:32 +0000 Subject: [PATCH] started updating help system --- phpgwapi/inc/class.common.inc.php | 83 ++++---- phpgwapi/inc/class.help.inc.php | 256 +++++++++++++++++++++++++ phpgwapi/inc/class.help_helper.inc.php | 113 +++++++++++ phpgwapi/inc/class.listbox.inc.php | 6 +- phpgwapi/inc/functions.inc.php | 3 +- 5 files changed, 412 insertions(+), 49 deletions(-) create mode 100644 phpgwapi/inc/class.help.inc.php create mode 100644 phpgwapi/inc/class.help_helper.inc.php diff --git a/phpgwapi/inc/class.common.inc.php b/phpgwapi/inc/class.common.inc.php index 2a4a935f3c..1dd304d794 100644 --- a/phpgwapi/inc/class.common.inc.php +++ b/phpgwapi/inc/class.common.inc.php @@ -661,7 +661,7 @@ { $appname = $GLOBALS['phpgw_info']['flags']['currentapp']; } - if ($appname == 'home' || $appname == 'logout' || $appname == 'login' || $appname == 'about') + if ($appname == 'home' || $appname == 'logout' || $appname == 'login' || $appname == 'about' || $appname == 'help') { $appname = 'phpgwapi'; } @@ -1069,7 +1069,14 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' 'app_tpl' => $app_tpl ); - $GLOBALS['phpgw']->xslttpl->add_file($this->get_tpl_dir('phpgwapi') . SEP . 'phpgw'); + if ($GLOBALS['phpgw_info']['flags']['headonly'] == True) + { + $GLOBALS['phpgw']->xslttpl->add_file($this->get_tpl_dir('phpgwapi','default') . SEP . 'phpgw_header'); + } + else + { + $GLOBALS['phpgw']->xslttpl->add_file($this->get_tpl_dir('phpgwapi') . SEP . 'phpgw'); + } $cur_app = $GLOBALS['phpgw_info']['flags']['currentapp']; @@ -1137,15 +1144,15 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $var['about_img_hover'] = $this->image('phpgwapi','question_mark2'); } - if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'manual') + if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'help') { - $var['manual_img'] = $this->image('manual','manual'); - $var['manual_img_hover'] = $this->image_on('manual','manual','_over'); + $var['help_img'] = $this->image('phpgwapi','help'); + $var['help_img_hover'] = $this->image_on('phpgwapi','help','_over'); } else { - $var['manual_img'] = $this->image_on('manual','manual','_over'); - $var['manual_img_hover'] = $this->image('manual','manual'); + $var['help_img'] = $this->image_on('phpgwapi','help','_over'); + $var['help_img_hover'] = $this->image('phpgwapi','help'); } $var['logo_img'] = $this->image('phpgwapi','logo2'); @@ -1159,7 +1166,7 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $var['prefs_img'] = $this->image('preferences','preferences-'.($app=='preferences' ? 'red' : 'grey')); $var['logout_img'] = $this->image('phpgwapi','logout'); $var['about_img'] = $this->image('phpgwapi','about-'.($app=='about' ? 'red' : 'grey')); - $var['manual_img'] = $this->image('manual','help'); + $var['help_img'] = $this->image('phpgwapi','help'); $var['greybar'] = $this->image('phpgwapi','greybar'); break; case 'justweb': @@ -1168,32 +1175,32 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $var['prefs_img'] = $this->image('preferences','tab_prefs'); $var['logout_img'] = $this->image('phpgwapi','tab_logout'); $var['about_img'] = $this->image('phpgwapi','tab_help'); - $var['manual_img'] = $this->image('manual','tab_manual'); + $var['help_img'] = $this->image('phpgwapi','tab_help'); break; case 'funkwerk': $var['about_img'] = '!'; - $var['manual_img'] = '?'; + $var['help_img'] = '?'; switch ($cur_app) { case 'home': $var['top_css_home'] = 'top_menu_selected'; - $var['top_css'] = $var['top_css_prefs'] = $var['top_css_about'] = $var['top_css_manual'] = 'top_menu'; + $var['top_css'] = $var['top_css_prefs'] = $var['top_css_about'] = $var['top_css_help'] = 'top_menu'; break; case 'preferences': $var['top_css_prefs'] = 'top_menu_selected'; - $var['top_css'] = $var['top_css_home'] = $var['top_css_about'] = $var['top_css_manual'] = 'top_menu'; + $var['top_css'] = $var['top_css_home'] = $var['top_css_about'] = $var['top_css_help'] = 'top_menu'; break; case 'about': $var['top_css_about'] = 'top_menu_selected'; - $var['top_css'] = $var['top_css_home'] = $var['top_css_prefs'] = $var['top_css_manual'] = 'top_menu'; + $var['top_css'] = $var['top_css_home'] = $var['top_css_prefs'] = $var['top_css_help'] = 'top_menu'; break; - case 'manual': - $var['top_css_manual'] = 'top_menu_selected'; + case 'help': + $var['top_css_help'] = 'top_menu_selected'; $var['top_css'] = $var['top_css_home'] = $var['top_css_prefs'] = $var['top_css_about'] = 'top_menu'; break; default: - $var['top_css'] = $var['top_css_home'] = $var['top_css_prefs'] = $var['top_css_about'] = $var['top_css_manual'] = 'top_menu'; + $var['top_css'] = $var['top_css_home'] = $var['top_css_prefs'] = $var['top_css_about'] = $var['top_css_help'] = 'top_menu'; break; } break; @@ -1202,7 +1209,7 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $var['prefs_img'] = $GLOBALS['phpgw_info']['navbar']['preferences']['icon']; $var['logout_img'] = $GLOBALS['phpgw_info']['navbar']['logout']['icon']; $var['about_img'] = $GLOBALS['phpgw_info']['navbar']['about']['icon']; - $var['manual_img'] = $GLOBALS['phpgw_info']['navbar']['manual']['icon']; + $var['help_img'] = $GLOBALS['phpgw_info']['navbar']['help']['icon']; break; } @@ -1210,19 +1217,19 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $var['prefs_link'] = $GLOBALS['phpgw_info']['navbar']['preferences']['url']; $var['logout_link'] = $GLOBALS['phpgw_info']['navbar']['logout']['url']; $var['about_link'] = $GLOBALS['phpgw_info']['navbar']['about']['url']; - $var['manual_link'] = $GLOBALS['phpgw_info']['navbar']['manual']['url']; + $var['help_link'] = $GLOBALS['phpgw_info']['navbar']['help']['url']; $var['home_title'] = $GLOBALS['phpgw_info']['navbar']['home']['title']; $var['prefs_title'] = $GLOBALS['phpgw_info']['navbar']['preferences']['title']; $var['logout_title'] = $GLOBALS['phpgw_info']['navbar']['logout']['title']; $var['about_title'] = $GLOBALS['phpgw_info']['navbar']['about']['title']; - $var['manual_title'] = $GLOBALS['phpgw_info']['navbar']['manual']['title']; + $var['help_title'] = $GLOBALS['phpgw_info']['navbar']['help']['title']; $var['home_statustext'] = $GLOBALS['phpgw_info']['navbar']['home']['title']; $var['prefs_statustext'] = $GLOBALS['phpgw_info']['navbar']['preferences']['title']; $var['logout_statustext'] = $GLOBALS['phpgw_info']['navbar']['logout']['title']; $var['about_statustext'] = $GLOBALS['phpgw_info']['navbar']['about']['title']; - $var['manual_statustext'] = $GLOBALS['phpgw_info']['navbar']['manual']['title']; + $var['help_statustext'] = $GLOBALS['phpgw_info']['navbar']['help']['title']; if (isset($GLOBALS['phpgw_ifo']['navbar']['admin']) && isset($GLOBALS['phpgw_info']['user']['preferences']['common']['show_currentusers'])) { @@ -1249,7 +1256,7 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $app_css = 'left'; } - if ($app != 'home' && $app != 'preferences' && $app != 'about' && $app != 'logout' && $app != 'manual') + if ($app != 'home' && $app != 'preferences' && $app != 'about' && $app != 'logout' && $app != 'help') { $var['applications'][] = array ( @@ -1306,26 +1313,16 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $this->msgbox('',False,'phpgw'); } - $var['app_tpl'] = ''; + $var['app_tpl'] = ''; + $var['current_app'] = $GLOBALS['phpgw_info']['flags']['currentapp']; - switch($GLOBALS['phpgw_info']['flags']['currentapp']) + $menuaction = get_var('menuaction',Array('GET')); + $xslt_app = get_var('xslt_app',Array('GET')); + + if ($menuaction && $GLOBALS['phpgw_info']['flags']['xslt_app']) { - case 'home': - $var['home'] = True; - break; - case 'about': - $var['about'] = True; - break; - default: - $menuaction = get_var('menuaction',Array('GET')); - $xslt_app = get_var('xslt_app',Array('GET')); - - if ($menuaction && $GLOBALS['phpgw_info']['flags']['xslt_app']) - { - $app_function = strrchr($menuaction,'.'); - $var['app_tpl'] = substr($app_function,1,strlen($app_function)); - } - break; + $app_function = strrchr($menuaction,'.'); + $var['app_tpl'] = substr($app_function,1,strlen($app_function)); } $var['lang_powered_by'] = lang('powered by'); @@ -1411,10 +1408,10 @@ if (!@is_file(PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $GLOBALS['phpgw_info' $GLOBALS['phpgw_info']['navbar']['preferences']['icon'] = $this->image('preferences',Array('navbar','nonav')); $GLOBALS['phpgw_info']['navbar']['preferences']['icon_hover'] = $this->image_on('preferences',Array('navbar','nonav'),'-over'); - $GLOBALS['phpgw_info']['navbar']['manual']['title'] = lang('manual'); - $GLOBALS['phpgw_info']['navbar']['manual']['url'] = $GLOBALS['phpgw']->link('/manual/index.php'); - $GLOBALS['phpgw_info']['navbar']['manual']['icon'] = $this->image('manual',Array('navbar','nonav')); - $GLOBALS['phpgw_info']['navbar']['manual']['icon_hover'] = $this->image_on('manual',Array('navbar','nonav'),'-over'); + $GLOBALS['phpgw_info']['navbar']['help']['title'] = lang('manual'); + $GLOBALS['phpgw_info']['navbar']['help']['url'] = $GLOBALS['phpgw']->link('/help.php'); + $GLOBALS['phpgw_info']['navbar']['help']['icon'] = $this->image('phpgwapi',Array('help','nonav')); + $GLOBALS['phpgw_info']['navbar']['help']['icon_hover'] = $this->image_on('phpgwapi',Array('help','nonav'),'-over'); if ($GLOBALS['phpgw_info']['flags']['currentapp'] == 'home') //|| $GLOBALS['phpgw_info']['flags']['currentapp'] == 'preferences') { diff --git a/phpgwapi/inc/class.help.inc.php b/phpgwapi/inc/class.help.inc.php new file mode 100644 index 0000000000..a05feaf219 --- /dev/null +++ b/phpgwapi/inc/class.help.inc.php @@ -0,0 +1,256 @@ +lang = $GLOBALS['phpgw_info']['user']['preferences']['common']['lang']; + $this->title = ''; + $this->app_name = ''; + $this->app_id = 0; + + $this->up = ''; + $this->down = ''; + $this->close = ''; + $this->question = ''; + $this->edit = ''; + + $this->extrabox = ''; + $this->xextrabox = ''; + $this->listbox = ''; + $this->data = array(); + + if (!$reset) + { + $this->output = array(); + } + $GLOBALS['phpgw']->xslttpl->add_file('help'); + } + + /* + Use these functions to get and set the values of this + object's variables. This is good OO practice, as it means + that datatype checking can be completed and errors raised accordingly. + */ + function setvar($var,$value='') + { + if ($value=='') + { + global $$var; + $value = $$var; + } + $this->$var = $value; + // echo $var." = ".$this->$var."
\n"; + } + + function getvar($var='') + { + if ($var=='' || !isset($this->$var)) + { + echo 'Programming Error: '.$this->getvar('classname').'->getvar('.$var.')!
'."\n"; + $GLOBALS['phpgw_info']['flags']['nodisplay'] = True; + exit; + } + //echo "Var = ".$var."
\n"; + //echo $var." = ".$this->$var."
\n"; + return $this->$var; + } + + function start_template($extra = '') + { + if ($extra && $this->app_name) + { + $GLOBALS['phpgw']->xslttpl->add_file($GLOBALS['phpgw']->common->get_tpl_dir($this->app_name,'default') . SEP . 'extrahelp'); + } + } + + function set_controls($control='',$control_param='') + { + //echo '
Control: ' . $control . ', control_param="' . $control_param . '"'; + + if($control != '' && is_array($control_param)) + { + $this->setvar($control,$GLOBALS['phpgw']->link($control_param['url'],'app='.$control_param['app'].'&control='.$control)); + } + } + + function set_internal($extra_data = '') + { + if($extra_data !='') + { + $this->extrabox = $extra_data; + } + } + + function set_xinternal($extra_data='') + { + if($extra_data !='') + { + $this->xextrabox = $extra_data; + } + } + + function draw_box() + { + if($this->up || $this->down || $this->close || $this->question || $this->edit) + { + $control_array = array + ( + 'up', + 'down', + 'question', + 'close', + 'edit' + ); + @reset($control_array); + while(list($key,$param) = each($control_array)) + { + if(isset($this->$param) && $this->$param) + { + $image_width = 15; + if($param == 'edit') + { + $image_width = 30; + } + + $control_link[] = array + ( + 'param_url' => $this->$param, + 'link_img' => $GLOBALS['phpgw']->common->image('phpgwapi',$param.'.button'), + 'img_width' => $image_width, + 'lang_param_statustext' => lang($param) + ); + } + } + + $this->output['help_data'][] = array + ( + 'title' => $this->title, + 'control_link' => $control_link, + 'listbox' => $this->listbox, + 'extrabox' => $this->extrabox, + 'xextrabox' => $this->xextrabox + ); + } + } + + function check_file($file) + { + $check_file = PHPGW_SERVER_ROOT . $file; + + if(@is_file($check_file)) + { + return $file; + } + else + { + return ''; + } + } + + function check_help_file($file) + { + $lang = strtoupper($this->lang); + + $help_file = $this->check_file('/' . $this->app_name . '/help/'. $lang . '/' . $file); + + if($help_file == '') + { + $help_file = $this->check_file('/' . $this->app_name . '/help/EN/' . $file); + } + + if ($help_file) + { + return $GLOBALS['phpgw']->link($help_file); + } + + return False; + } + + /*function display_manual_section($appname,$file) + { + $font = $GLOBALS['phpgw_info']['theme']['font']; + $navbar = $GLOBALS['phpgw_info']['user']['preferences']['common']['navbar_format']; + $lang = strtoupper($GLOBALS['phpgw_info']['user']['preferences']['common']['lang']); + $GLOBALS['treemenu'][] = '..'.($navbar != 'text'?''.ucwords($appname).'':'').($navbar != 'icons'?''.lang($appname).'':'').'|'.$GLOBALS['phpgw']->link('/'.$appname.'/help/index.php'); + + $help_file = check_help_file($appname,$lang,$appname.'.php'); + if($help_file != '') + { + $GLOBALS['treemenu'][] = '...'.lang('Overview').'|'.$GLOBALS['phpgw']->link($help_file); + } + while(list($title,$filename) = each($file)) + { + $help_file = check_help_file($appname,$lang,$filename); + if($help_file != '') + { + $GLOBALS['treemenu'][] = '...'.lang($title).'|'.$GLOBALS['phpgw']->link($help_file); + } + } + } + + function show_menu($expandlevels) + { + $menutree = CreateObject('phpgwapi.menutree','text'); + $menutree->set_lcs(300); + + $str = '
'; + $str .= ''; + $str .= 'Note: Some of this information is out of date
'; + + $GLOBALS['treemenu'] = Array(); + + $GLOBALS['phpgw']->hooks->process('manual',array('manual','preferences')); + + reset($GLOBALS['treemenu']); + + $str .= $menutree->showtree($GLOBALS['treemenu'],$expandlevels).'
'; + + return $str; + }*/ + } +?> diff --git a/phpgwapi/inc/class.help_helper.inc.php b/phpgwapi/inc/class.help_helper.inc.php new file mode 100644 index 0000000000..4b8504f4ff --- /dev/null +++ b/phpgwapi/inc/class.help_helper.inc.php @@ -0,0 +1,113 @@ +help(); + } + + function set_params($param) + { + $this->help(True); + @reset($param); + while(list($key,$value) = each($param)) + { + if($key != 'title') + { + //echo 'Setting '.$key.':'.$value."
\n"; + $this->setvar($key,$value); + } + } + $this->title = $param['title']; + + if($param['app_id']) + { + $app_id = $this->getvar('app_id'); + + $var = Array + ( + 'up' => Array('url' => '/set_box.php', 'app' => $app_id), + 'down' => Array('url' => '/set_box.php', 'app' => $app_id), + 'close' => Array('url' => '/set_box.php', 'app' => $app_id), + 'question' => Array('url' => '/set_box.php', 'app' => $app_id), + 'edit' => Array('url' => '/set_box.php', 'app' => $app_id) + ); + + while(list($key,$value) = each($var)) + { + $this->set_controls($key,$value); + } + } + } + + function draw($extra_data='') + { + if(is_array($this->data) && !empty($this->data)) + { + for ($x = 0; $x < count($this->data); $x++) + { + $var[] = array + ( + 'text' => $this->data[$x]['text'], + 'link' => $this->data[$x]['link'], + 'lang_link_statustext' => $this->data[$x]['lang_link_statustext'] + ); + } + $this->listbox = $var; + } + $this->set_internal($extra_data); + $this->draw_box(); + } + + function xdraw($extra_data='') + { + if ($extra_data) + { + $this->start_template(True); + } + + if(is_array($this->data) && !empty($this->data)) + { + for ($x = 0; $x < count($this->data); $x++) + { + $var[] = array + ( + 'text' => $this->data[$x]['text'], + 'link' => $this->data[$x]['link'], + 'lang_link_statustext' => $this->data[$x]['lang_link_statustext'] + ); + } + $this->listbox = $var; + } + $this->set_xinternal($extra_data); + $this->draw_box(); + } + } +?> diff --git a/phpgwapi/inc/class.listbox.inc.php b/phpgwapi/inc/class.listbox.inc.php index 1a21d48d4a..0b8c8cecd4 100755 --- a/phpgwapi/inc/class.listbox.inc.php +++ b/phpgwapi/inc/class.listbox.inc.php @@ -86,7 +86,6 @@ */ function draw($extra_data='') { - $this->start_template(); if(is_array($this->data) && !empty($this->data)) { for ($x = 0; $x < count($this->data); $x++) @@ -110,10 +109,7 @@ { $this->start_template(True); } - else - { - $this->start_template(); - } + if(is_array($this->data) && !empty($this->data)) { for ($x = 0; $x < count($this->data); $x++) diff --git a/phpgwapi/inc/functions.inc.php b/phpgwapi/inc/functions.inc.php index e849aaace5..7cb5f02417 100644 --- a/phpgwapi/inc/functions.inc.php +++ b/phpgwapi/inc/functions.inc.php @@ -370,7 +370,8 @@ $continue_app_data = True; if ($GLOBALS['phpgw_info']['flags']['currentapp'] != 'home' && $GLOBALS['phpgw_info']['flags']['currentapp'] != 'preferences' && - $GLOBALS['phpgw_info']['flags']['currentapp'] != 'about') + $GLOBALS['phpgw_info']['flags']['currentapp'] != 'about' && + $GLOBALS['phpgw_info']['flags']['currentapp'] != 'help') { // This will need to use ACL in the future if (! $GLOBALS['phpgw_info']['user']['apps'][$GLOBALS['phpgw_info']['flags']['currentapp']] ||