read eTemplates from filesystem if

$GLOBALS['phpgw_info']['server']['eTemplate-source'] == 'files'
This commit is contained in:
Ralf Becker 2002-09-17 13:27:37 +00:00
parent 4214452471
commit 34c963535a
2 changed files with 52 additions and 5 deletions

View File

@ -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)
{

View File

@ -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 "<p>Can't open '$file' !!!</p>\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='')