Permalink
Browse files

add the new template plugin

  • Loading branch information...
1 parent e841646 commit c2572529a52468b78a8d041315b5b04186644b94 @bastianallgeier bastianallgeier committed Mar 22, 2010
Showing with 34 additions and 0 deletions.
  1. +34 −0 plugins/template.php
View
@@ -0,0 +1,34 @@
+<?php
+
+if(!c::get('tpl.root')) c::set('tpl.root', c::get('root') . '/templates');
+
+class tpl {
+
+ static public $vars = array();
+
+ function set($key, $value=false) {
+ if(is_array($key)) {
+ self::$vars = array_merge(self::$vars, $key);
+ } else {
+ self::$vars[$key] = $value;
+ }
+ }
+
+ function get($key=null, $default=null) {
+ if($key===null) return (array)self::$vars;
+ return a::get(self::$vars, $key, $default);
+ }
+
+ function load($template='default', $vars=array(), $return=false) {
+ $file = c::get('tpl.root') . '/' . $template . '.php';
+ if(!file_exists($file)) return false;
+ @extract(self::$vars);
+ @extract($vars);
+ content::start();
+ require($file);
+ return content::end($return);
+ }
+
+}
+
+?>

0 comments on commit c257252

Please sign in to comment.