added new css support, common/shared template file support, and printer templates support

This commit is contained in:
seek3r 2002-05-23 21:28:59 +00:00
parent 66b702e1f7
commit 563107b8c8
2 changed files with 89 additions and 17 deletions

View File

@ -42,14 +42,25 @@
/* last error message is retained here */
var $last_error = '';
var $print = False;
/***************************************************************************/
/* public: Constructor.
* root: template directory.
* unknowns: how to handle unknown variables.
*/
function Template($root = '.', $unknowns = 'remove')
function Template($root = '.', $unknowns = 'remove', $print = False)
{
if ($print)
{
$this->print = True;
}
/* This covers loading up the common tpl file and CSS data */
$this->set_root(PHPGW_TEMPLATE_DIR);
$this->set_file('common', 'common.tpl');
$this->set_var('phpgw_css',$GLOBALS['phpgw_info']['theme']['css']);
/* Now move on to loading up the requested template set */
$this->set_root($root);
$this->set_unknowns($unknowns);
}
@ -373,16 +384,35 @@
$new_filename = $filename;
}
if ($this->print && $time!=2 && $time!=4)
{
$new_filename = $new_filename.'_print';
}
if (!file_exists($new_filename))
{
if($time==2)
switch($time)
{
$this->halt("filename: file $new_filename does not exist.");
}
else
{
$new_root = str_replace($GLOBALS['phpgw_info']['server']['template_set'],'default',$root);
$new_filename = $this->filename(str_replace($root.'/','',$new_filename),$new_root,2);
case 2:
$new_root = str_replace($GLOBALS['phpgw_info']['server']['template_set'],'default',$root);
$new_filename = $this->filename($filename,$new_root,3);
break;
case 3:
$new_filename = $this->filename($filename,$root,4);
break;
case 4:
$this->halt("filename: file $new_filename does not exist.");
break;
default:
if (!$this->print)
{
$new_root = str_replace($GLOBALS['phpgw_info']['server']['template_set'],'default',$root);
$new_filename = $this->filename(str_replace($root.'/','',$new_filename),$new_root,4);
}
else
{
$new_filename = $this->filename($filename,$root,2);
}
}
}
return $new_filename;

View File

@ -350,16 +350,9 @@
unset($enable_class);
reset($GLOBALS['phpgw_info']['flags']);
/*************************************************************************\
* These lines load up the templates class *
\*************************************************************************/
if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class'])
{
$GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
}
/*************************************************************************\
* These lines load up the themes *
* These lines load up the themes and CSS data *
\*************************************************************************/
if (! $GLOBALS['phpgw_info']['user']['preferences']['common']['theme'])
{
@ -404,8 +397,57 @@
exit;
}
if (!isset($GLOBALS['phpgw_info']['theme']['css']))
{
$GLOBALS['phpgw_info']['theme']['css'] = '';
}
if (isset($GLOBALS['phpgw_info']['theme']['hovlink'])
&& ($GLOBALS['phpgw_info']['theme']['hovlink'] != ''))
{
$csshover = "\t".'A:hover{ text-decoration:none; color: ' .$GLOBALS['phpgw_info']['theme']['hovlink'] .'; }'."\n";
}
else
{
$csshover = '';
}
$GLOBALS['phpgw_info']['theme']['css'] = "\t".'a { text-decoration:none; }'."\n"
."\t".'A:link{ text-decoration:none; color: '.$GLOBALS['phpgw_info']['theme']['link'].'; }'."\n"
."\t".'A:visted{ text-decoration:none; color: '.$GLOBALS['phpgw_info']['theme']['vlink'].'; }'."\n"
."\t".'A:active{ text-decoration:none; color: '.$GLOBALS['phpgw_info']['theme']['alink'].'; }'."\n"
.$csshover
.$GLOBALS['phpgw_info']['theme']['css'];
unset($csshover);
if(@file_exists(PHPGW_APP_TPL . '/app.css'))
{
$app_css_file = fopen (PHPGW_APP_TPL . '/app.css', "r");
$contents = fread ($app_css_file, filesize ($app_css_file));
fclose ($app_css_file);
$GLOBALS['phpgw_info']['theme']['css'] .= "\n".$contents;
}
unset($theme_to_load);
/*************************************************************************\
* These lines load up the templates class *
\*************************************************************************/
if(!@$GLOBALS['phpgw_info']['flags']['disable_Template_class'])
{
$GLOBALS['phpgw']->template = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
}
/*************************************************************************\
* These lines remove the css data from memory since the template set will *
* already have loaded it into its own memory space *
\*************************************************************************/
if(!@$GLOBALS['phpgw_info']['flags']['keep_phpgw_css'])
{
// unset($GLOBALS['phpgw_info']['theme']['css']);
}
/*************************************************************************\
* If they are using frames, we need to set some variables *
\*************************************************************************/