]> projects.mako.cc - scuttle/blobdiff - services/templateservice.php
Merge branch 'master' of https://github.com/underhilllabs/scuttle
[scuttle] / services / templateservice.php
index 191ab8df67a0592204ad77dad903392c0d7966ff..1a1719c880dc048a537cdd55d3162a48d79ddcb3 100644 (file)
@@ -1,46 +1,48 @@
 <?php
 class TemplateService {
-    var $basedir;
-  
-    function &getInstance() {
-        static $instance;
-        if (!isset($instance))
-            $instance =& new TemplateService();
-        return $instance;
-    }
-  
-    function TemplateService() {
-        $this->basedir = $GLOBALS['TEMPLATES_DIR'];    
+  var $basedir;
+
+  function &getInstance() {
+    static $instance;
+    if (!isset($instance)) {
+      $instance = new TemplateService();
     }
-  
-    function loadTemplate($template, $vars = NULL) {
-        if (substr($template, -4) != '.php')
-            $template .= '.php';
-        $tpl =& new Template($this->basedir .'/'. $template, $vars, $this);
-        $tpl->parse();
-        return $tpl;
+    return $instance;
+  }
+
+  function TemplateService() {
+    $this->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);
+  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

Benjamin Mako Hill || Want to submit a patch?