diff --git a/etemplate/inc/class.editor.inc.php b/etemplate/inc/class.editor.inc.php index 45412a0936..cf495c1698 100644 --- a/etemplate/inc/class.editor.inc.php +++ b/etemplate/inc/class.editor.inc.php @@ -404,7 +404,7 @@ { mkdir($dir .= "/$template"); } - $file = "$dir/$name"; + $file = $dir . '/' . substr($name,strlen($app)+1); if ($this->etemplate->lang) { $file .= '.' . $this->etemplate->lang; @@ -420,8 +420,11 @@ { return 0; } - $xul_io = CreateObject('etemplate.xul_io'); - $xul = $xul_io->export(&$this->etemplate); + if (!is_object($this->etemplate->xul_io)) + { + $this->etemplate->xul_io = CreateObject('etemplate.xul_io'); + } + $xul = $this->etemplate->xul_io->export(&$this->etemplate); fwrite($f,$xul); fclose($f); @@ -438,8 +441,11 @@ $xul = fread ($f, filesize ($file)); fclose($f); - $xul_io = CreateObject('etemplate.xul_io'); - $msg = $xul_io->import(&$this->etemplate,$xul); + if (!is_object($this->etemplate->xul_io)) + { + $this->etemplate->xul_io = CreateObject('etemplate.xul_io'); + } + $msg = $this->etemplate->xul_io->import(&$this->etemplate,$xul); if (!$msg) { diff --git a/etemplate/inc/class.soetemplate.inc.php b/etemplate/inc/class.soetemplate.inc.php index 4e3b655c9e..d7556da400 100644 --- a/etemplate/inc/class.soetemplate.inc.php +++ b/etemplate/inc/class.soetemplate.inc.php @@ -158,6 +158,10 @@ { $this->init($name,$template,$lang,$group,$version); + if ($GLOBALS['phpgw_info']['server']['eTemplate-source'] == 'files' && $this->readfile()) + { + return True; + } if ($this->name) { $this->test_import($this->name); // import updates in setup-dir @@ -207,6 +211,43 @@ return True; } + /*! + @function readfile + @abstract Reads an eTemplate from the filesystem, the keys are already set by init in read + @result True if a template is found, else False + */ + function readfile() + { + list($app,$name) = split("\.",$this->name,2); + $template = $this->template == '' ? 'default' : $this->template; + $file = PHPGW_SERVER_ROOT . "/$app/templates/$template/$name"; + if ($this->lang) + { + $file .= '.' . $this->lang; + } + $file .= '.xul'; + + if (!is_readable($file) || !($f = fopen($file,'r'))) + { + //echo "

Can't open '$file' !!!

\n"; + return False; + } + $xul = fread ($f, filesize ($file)); + fclose($f); + + if (!is_object($this->xul_io)) + { + $this->xul_io = CreateObject('etemplate.xul_io'); + } + if ($this->xul_io->import(&$this,$xul) != '') + { + return False; + } + $this->name = $app . '.' . $name; // if template was copied or app was renamed + + return True; + } + /*! @function search @syntax search($name,$template='default',$lang='default',$group=0,$version='')