All pastes #823848 Raw Edit

Unnamed

public php v1 · immutable
·published 2007-12-19 16:57 UTC
rendered paste body
<?php/** * mccms_template * * @package Mccms Template Engine * @author NeDlOh312 * @copyright 2007 * @version 0.01a * @access public */class mccms_template{    /**     *This is the directory that the current skins are in.     *     */    private $root_dir;    /**     *This will hold all the template data in an array     *Root level will be $tpl_array[ROOT][name][replace]     * @todo add blocks :S     */    private $tpl_array = array();    /**     *     */    private $tpl_files = array();    /**     *     */    private $uncompiled_code = array();    /**     *     */    private $output_code = array();    /**     *     */    private $ext = '';    /**     *	This is the template extension for each tempalte.      */    public function __construct($root_dir = "./", $ext = ',tpl')    {        if (is_dir($root_dir) && $root_dir !== '')        {            $this->root_dir = $root_dir;        } else        {            $this->triger_error('File Location : "' . $root_dir .                '" is not a valid destination ');        }        $this->ext = $ext;    }    public function open_file($fname, $quick_name)    {        if (@fopen($this->root_dir . $fname . $this->ext))        {            $this->tpl_files[$quickname][$fname][$this->root_dir . $fname . $this->ext];        } else        {            $this->triger_error('There was a problem opening ' . $fname);        }    }    public function assign_array($array)    {        reset($array);        foreach ($array as $name => $replace)        {            if (!in_array($name, $this->tpl_array))            {                $this->assign_single_var($name, $replace);            } else            {                if ($this->trigger_on_dupe)                {                    $this->triger_error('There was a Duplicate name for ' . $name);                }            }        }    }    public function assign_single_var($name, $replace)    {        if ($this->tpl_array[$this->cur_block][$name][$replace])        {            return (true);        } else        {            $this->triger_error('Error assigning ' . $name);        }    }    private function triger_error($text, $error = E_USER_ERROR)    {        if (isset($text) && isset($error))        {            trigger_error($text, $error);        } else        {            return (false);        }    }    public function __destruct()    {        if (sizeof($this->tpl_array) || sizeof($this->tpl_files))        {            $this->tpl_array = array();            $this->tpl_files = array();        }    }}$tpl = new mccms_template();?>