From 29422fa55379aa61a61019b832c83dab6d450264 Mon Sep 17 00:00:00 2001 From: cweiske Date: Sat, 3 Oct 2009 14:00:33 +0000 Subject: move files to new locations git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@386 b3834d28-1941-0410-a4f8-b48e95affb8f --- src/SemanticScuttle/Service/templateservice.php | 46 +++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/SemanticScuttle/Service/templateservice.php (limited to 'src/SemanticScuttle/Service/templateservice.php') diff --git a/src/SemanticScuttle/Service/templateservice.php b/src/SemanticScuttle/Service/templateservice.php new file mode 100644 index 0000000..05e494c --- /dev/null +++ b/src/SemanticScuttle/Service/templateservice.php @@ -0,0 +1,46 @@ +basedir = $GLOBALS['TEMPLATES_DIR']; + } + + function loadTemplate($template, $vars = NULL) { + if (substr($template, -4) != '.php') + $template .= '.php'; + $tpl =& new Template($this->basedir .'/'. $template, $vars, $this); + $tpl->parse(); + return $tpl; + } +} + +class Template { + var $vars = array(); + var $file = ''; + var $templateservice; + + function Template($file, $vars = NULL, &$templateservice) { + $this->vars = $vars; + $this->file = $file; + $this->templateservice = $templateservice; + } + + function parse() { + if (isset($this->vars)) + extract($this->vars); + include($this->file); + } + + function includeTemplate($name) { + return $this->templateservice->loadTemplate($name, $this->vars); + } +} +?> \ No newline at end of file -- cgit v1.2.3-54-g00ecf