Location: PHPKode > projects > MyAppFW PHP Application Framework > myappfw-0.1-beta/include/incl_class/class.template.php
<?php

    if(!defined("CAN_CONTINUE")) { echo "No Direct Access Allowed..."; exit(); }

    class Template {

        var $file_ext = ".tpl";
        var $template_dir;
        var $buffer;

	function selectTemplate($template) {
	    $this->template_dir = 'templates/'.$template.'/';
	}

        function bufferTemplate($file) {

            if(file_exists($this->template_dir.$file.$this->file_ext)) {
                $this->buffer = file_get_contents($this->template_dir.$file.$this->file_ext);
                return $this->buffer;
            }

            else {
                echo $this->template_dir.$file.$this->file_ext.' does not exist';
            }

        }

        function parseVariables($input, $array) {

            $search = preg_match_all('/{.*?}/', $input, $matches);

            for ($i = 0; $i < $search; $i++) {
                $matches[0][$i] = str_replace(array('{', '}'), null, $matches[0][$i]);
            }

            foreach($matches[0] as $value) {
                $input = str_replace('{'.$value.'}', $array[$value], $input);
            }

            return $input;

        }



    }

?>
Return current item: MyAppFW PHP Application Framework