aboutsummaryrefslogtreecommitdiffstats
path: root/include/template.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/template.class.php')
-rw-r--r--include/template.class.php26
1 files changed, 20 insertions, 6 deletions
diff --git a/include/template.class.php b/include/template.class.php
index 7bcab1150..90d7d58b8 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -22,9 +22,6 @@
// +-----------------------------------------------------------------------+
-require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php');
-
-
class Template {
var $smarty;
@@ -42,6 +39,7 @@ class Template {
// used by html_head smarty block to add content before </head>
var $html_head_elements = array();
+ private $html_style = '';
const COMBINED_SCRIPTS_TAG = '<!-- COMBINED_SCRIPTS -->';
var $scriptLoader;
@@ -112,6 +110,7 @@ class Template {
$this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') );
$this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') );
$this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
+ $this->smarty->register_block('html_style', array(&$this, 'block_html_style') );
$this->smarty->register_function('combine_script', array(&$this, 'func_combine_script') );
$this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') );
$this->smarty->register_function('combine_css', array(&$this, 'func_combine_css') );
@@ -466,15 +465,21 @@ class Template {
$this->css_by_priority = array();
}
- if ( count($this->html_head_elements) )
+ if ( count($this->html_head_elements) || strlen($this->html_style) )
{
$search = "\n</head>";
$pos = strpos( $this->output, $search );
if ($pos !== false)
{
- $this->output = substr_replace( $this->output, "\n".implode( "\n", $this->html_head_elements ), $pos, 0 );
+ $rep = "\n".implode( "\n", $this->html_head_elements );
+ if (strlen($this->html_style))
+ {
+ $rep='<style type="text/css">'.$this->html_style.'</style>';
+ }
+ $this->output = substr_replace( $this->output, $rep, $pos, 0 );
} //else maybe error or warning ?
$this->html_head_elements = array();
+ $this->html_style = '';
}
echo $this->output;
@@ -532,6 +537,15 @@ class Template {
}
}
+ function block_html_style($params, $content, &$smarty, &$repeat)
+ {
+ $content = trim($content);
+ if ( !empty($content) )
+ { // second call
+ $this->html_style .= $content;
+ }
+ }
+
/**
* combine_script smarty function allows inclusion of a javascript file in the current page.
* The engine will combine several js files into a single one in order to reduce the number of
@@ -842,7 +856,7 @@ class PwgTemplateAdapter
$args = func_get_args();
return call_user_func_array('sprintf', $args );
}
-
+
function derivative_url($type, $img)
{
return DerivativeImage::url($type, $img);