From 434a91f04126b6370e753a81cba697bb79cc5ae3 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 2 May 2005 15:07:37 +0000 Subject: [PATCH] allow to use etemplate apps as sitemgr modules: - extend etemplate's sitemgr_module class and set the $etemplate_method class-var to a method/menuaction of the app - the app need to return etemplate::exec() (otherwise the content is empty)!!! - the app need to avoid redirects or links, as this would leave sitemgr!!! --- etemplate/inc/class.sitemgr_module.inc.php | 59 ++++++++++++++++++++++ etemplate/inc/class.uietemplate.inc.php | 23 ++++++--- 2 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 etemplate/inc/class.sitemgr_module.inc.php diff --git a/etemplate/inc/class.sitemgr_module.inc.php b/etemplate/inc/class.sitemgr_module.inc.php new file mode 100644 index 0000000000..8926d169f5 --- /dev/null +++ b/etemplate/inc/class.sitemgr_module.inc.php @@ -0,0 +1,59 @@ +etemplate_method); + $GLOBALS['egw']->translation->add_app($app); + + $css = ''; + if (file_exists(EGW_SERVER_ROOT.'/'.$app.'/templates/default/app.css')) + { + $css = ""; + } + $ret = false; + if($_POST['etemplate_exec_id']) + { + $ret = ExecMethod('etemplate.etemplate.process_exec'); + } + return $css.($ret ? $ret : ExecMethod($this->etemplate_method)); + } +} diff --git a/etemplate/inc/class.uietemplate.inc.php b/etemplate/inc/class.uietemplate.inc.php index defd6ea9c8..29b997ef60 100644 --- a/etemplate/inc/class.uietemplate.inc.php +++ b/etemplate/inc/class.uietemplate.inc.php @@ -60,6 +60,8 @@ $this->boetemplate($name,$load_via); $this->xslt = is_object($GLOBALS['phpgw']->xslttpl); + + $this->sitemgr = is_object($GLOBALS['Common_BO']); } /** @@ -134,9 +136,14 @@ $this->html->input_hidden('submit_button','',False). $this->show($this->complete_array_merge($content,$changes),$sel_options,$readonlys,'exec'),array( 'etemplate_exec_id' => $id - ),'/etemplate/process_exec.php?menuaction='.$method,'','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']); + ),$this->sitemgr ? '' : '/etemplate/process_exec.php?menuaction='.$method, + '','eTemplate',$GLOBALS['phpgw_info']['etemplate']['form_options']); //_debug_array($GLOBALS['phpgw_info']['etemplate']['to_process']); - if (!$this->xslt) + if ($this->sitemgr) + { + + } + elseif (!$this->xslt) { $hooked = $GLOBALS['phpgw']->template->get_var('phpgw_body'); if (!@$GLOBALS['phpgw_info']['etemplate']['hooked'] && (int) $output_mode != 1) // not just returning the html @@ -156,7 +163,7 @@ $GLOBALS['phpgw']->xslttpl->set_var('phpgw',array('java_script' => $GLOBALS['phpgw_info']['flags']['java_script'].$this->include_java_script(2))); } - if ((int) $output_mode != 1) // NOT returning html + if (!$this->sitemgr && (int) $output_mode != 1) // NOT returning html { if (!$this->xslt) { @@ -204,9 +211,10 @@ 'output_mode' => $output_mode, 'session_used' => 0, 'ignore_validation' => $ignore_validation, + 'method' => $method, ),$id); - if ((int) $output_mode == 1) // return html + if ($this->sitemgr || (int) $output_mode == 1) // return html { return $html; } @@ -247,6 +255,8 @@ * it would set some constants to etemplate instead of the calling app. * process_exec then calls process_show for the eTemplate (to adjust the content of the _POST) and * ExecMethod's the given callback from the app with the content of the form as first argument. + * + * @return mixed false if no sessiondata and $this->sitemgr, else the returnvalue of exec of the method-calls */ function process_exec() { @@ -256,6 +266,7 @@ if (!$_POST['etemplate_exec_id'] || !is_array($session_data) || count($session_data) < 10) { + if ($this->sitemgr) return false; //echo "uitemplate::process_exec() id='$_POST[etemplate_exec_id]' invalid session-data !!!"; _debug_array($_SESSION); // this prevents an empty screen, if the sessiondata gets lost somehow $this->location(array('menuaction' => $_GET['menuaction'])); @@ -308,13 +319,13 @@ $GLOBALS['phpgw_info']['flags']['app_header'] = $session_data['app_header']; } //echo "

process_exec($this->name): loop is set, content=

\n"; _debug_array($content); - $this->exec($_GET['menuaction'],$session_data['content'],$session_data['sel_options'], + return $this->exec($session_data['method'],$session_data['content'],$session_data['sel_options'], $session_data['readonlys'],$session_data['preserv'],$session_data['output_mode'], $session_data['ignore_validation'],$content); } else { - ExecMethod($_GET['menuaction'],$this->complete_array_merge($session_data['preserv'],$content)); + return ExecMethod($session_data['method'],$this->complete_array_merge($session_data['preserv'],$content)); } }