summaryrefslogtreecommitdiff
path: root/src/SemanticScuttle/Service/Template.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-05-25 19:43:36 +0200
committerChristian Weiske <cweiske@cweiske.de>2011-05-25 19:43:36 +0200
commit5ba53394fcda4ae9cfa9af52b37fb67517deeb5a (patch)
tree4416be7903a2b339382e9f933284f50797edc239 /src/SemanticScuttle/Service/Template.php
parent63b0a4b8cb38a8a7c41410900b9dfcc84e6a33a9 (diff)
downloadsemanticscuttle-5ba53394fcda4ae9cfa9af52b37fb67517deeb5a.tar.gz
semanticscuttle-5ba53394fcda4ae9cfa9af52b37fb67517deeb5a.tar.bz2
implement request #1989987: theme support. merge themes branch with --squash
Diffstat (limited to 'src/SemanticScuttle/Service/Template.php')
-rw-r--r--src/SemanticScuttle/Service/Template.php29
1 files changed, 27 insertions, 2 deletions
diff --git a/src/SemanticScuttle/Service/Template.php b/src/SemanticScuttle/Service/Template.php
index efa8d28..b5d4cfa 100644
--- a/src/SemanticScuttle/Service/Template.php
+++ b/src/SemanticScuttle/Service/Template.php
@@ -14,6 +14,7 @@
*/
require_once 'SemanticScuttle/Model/Template.php';
+require_once 'SemanticScuttle/Model/Theme.php';
/**
* SemanticScuttle template service.
@@ -38,6 +39,14 @@ class SemanticScuttle_Service_Template extends SemanticScuttle_Service
*/
protected $basedir;
+ /**
+ * The template theme to use.
+ * Set in constructor based on $GLOBALS['theme']
+ *
+ * @var SemanticScuttle_Model_Theme
+ */
+ protected $theme;
+
/**
@@ -64,6 +73,8 @@ class SemanticScuttle_Service_Template extends SemanticScuttle_Service
protected function __construct()
{
$this->basedir = $GLOBALS['TEMPLATES_DIR'];
+ $this->theme = new SemanticScuttle_Model_Theme($GLOBALS['theme']);
+ //FIXME: verify the theme exists
}
@@ -74,19 +85,33 @@ class SemanticScuttle_Service_Template extends SemanticScuttle_Service
* @param string $template Template filename relative
* to template dir
* @param array $vars Array of template variables.
+ * The current theme object will be added
+ * automatically with name "theme".
*
* @return SemanticScuttle_Model_Template Template object
*/
- function loadTemplate($template, $vars = null)
+ public function loadTemplate($template, $vars = null)
{
if (substr($template, -4) != '.php') {
$template .= '.php';
}
+
+ $oldIncPath = get_include_path();
+ set_include_path(
+ $this->basedir . $this->theme->getName()
+ . PATH_SEPARATOR . $this->basedir . 'default'
+ //needed since services are instantiated in templates
+ . PATH_SEPARATOR . $oldIncPath
+ );
+
+ $vars['theme'] = $this->theme;
$tpl = new SemanticScuttle_Model_Template(
- $this->basedir .'/'. $template, $vars, $this
+ $template, $vars, $this
);
$tpl->parse();
+ set_include_path($oldIncPath);
+
return $tpl;
}
}