Example #1
0
 function create($filename)
 {
     $filename = $filename . '.tpl.php';
     $__template_filename__ = k_search_include_path($filename);
     if (!is_file($__template_filename__)) {
         throw new Exception("Failed opening '" . $filename . "' for inclusion. (include_path=" . ini_get('include_path') . ")");
     }
     return new k_Template($__template_filename__);
 }
Example #2
0
 /**
  * @param k_Context
  * @return string
  */
 function render($context)
 {
     $__previous_context = isset($GLOBALS['k_current_context']) ? $GLOBALS['k_current_context'] : null;
     $GLOBALS['k_current_context'] = $context;
     if (func_num_args() > 1) {
         extract(func_get_arg(1));
     }
     ob_start();
     try {
         if (!k_search_include_path($this->path)) {
             throw new Exception("Unable to find file '" . $this->path . "'");
         }
         include $this->path;
         $buffer = ob_get_clean();
         $GLOBALS['k_current_context'] = $__previous_context;
         return $buffer;
     } catch (Exception $ex) {
         ob_end_clean();
         $GLOBALS['k_current_context'] = $__previous_context;
         throw $ex;
     }
 }
Example #3
0
/**
 * A simple autoloader.
 */
function k_autoload($classname)
{
    $filename = str_replace('_', '/', strtolower($classname)) . '.php';
    if (k_search_include_path($filename)) {
        require_once $filename;
    }
}