Location: PHPKode > projects > igloo opensource > xmods/simbio/GUI/template_parser/GUI_template_parser.inc.php
<?php

/*-------1---------2---------3---------4---------5---------6---------7---------8---*/
// +----------------------------------------------------------------------+
// | PHP version 4, 5                                                     |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 The YHA (Yono Hendro Arie) Group             |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at                              |
// | http://www.php.net/license/2_02.txt.                                 |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | hide@address.com so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Symbio Template Parser Class                                         |
// | Parse HTML Template                                                  |
// +----------------------------------------------------------------------+
// | Original Authors: Hendro Wicaksono <hide@address.com>       |
// | Modified By: Arie Nugraha <hide@address.com>                        |
// +----------------------------------------------------------------------+
//
// $Id$

class GUI_template_parser
{
    # properties
    var $file = ''; // variable to store template name info
    var $result = ''; // variable to store template result

    # class constructor
    /*
    @return void
    @param string $tplfile_path - the path to template file
        the template file must be an html file
    */
    function GUI_template_parser($tpl_file_path)
    {
        // check if the template file is HTML or not 
        if (substr($tpl_file_path, -5) != '.html') {
            $error = 'Template file must be HTML file';
            echo $error;
        } else {
            $this->file = $tpl_file_path;
        }
       
        // reading template file and store it into result properties
        $handle = fopen($this->file, 'r');
        while (!feof($handle)) {
            $this->result .= fgets($handle, 4096);
        }
        fclose($handle);
    }

    # method to replacing markers with real content
    /*
    @return void
    @param string $marker - the marker to replace in template file
    @param string $replacement - the real content to put in the marker
    */
    function assign($marker, $replacement)
    {
        $this->result = str_replace($marker, $replacement, $this->result);
    }

    # final method to print out the template
    function printOut()
    {
        echo $this->result;
    }


}

?>
Return current item: igloo opensource