Source for file Internal.class.php

Documentation is available at Internal.class.php

  1. <?php
  2. /**
  3.  * Gumbo Library Framework
  4.  *
  5.  * LICENSE
  6.  * This library is being released under the terms of the New BSD License.  A
  7.  * copy of the license is packaged with the software (LICENSE.txt).  If no
  8.  * copy is found, a copy of the license template can be found at:
  9.  * http://www.opensource.org/licenses/bsd-license.php
  10.  * 
  11.  * @category Gumbo
  12.  * @package Template
  13.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  14.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  15.  * @author Michael Luster <mluster79@yahoo.com>
  16.  * @link http://sourceforge.net/projects/phpgumbo
  17.  * @version 0.0.1
  18.  */
  19.  
  20. /**
  21.  * Internal Template Engine Class
  22.  * 
  23.  * The Internal Template Engine will include a template file into the
  24.  * parse method.  The engine will include the file as if the contents
  25.  * were written inside the method.  The Template file should contain
  26.  * HTML and PHP code intermixed.  The use of <?php .. ?> tags is recommended.
  27.  * The Template file should output the results to the browser.  The contents
  28.  * will be caught inside a buffer and the contents saved into the object.
  29.  * 
  30.  * Template File:
  31.  * <pre>
  32.  * ...
  33.  * <?php echo $this->template_variable; ?>
  34.  * ...
  35.  * </pre>
  36.  *
  37.  * @category Gumbo
  38.  * @package Template
  39.  * @copyright Copyright (c) 2007, iBayou, Michael Luster
  40.  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  41.  * @author Michael Luster <mluster79@yahoo.com>
  42.  * @link http://sourceforge.net/projects/phpgumbo
  43.  * @desc Internal Template Engine Class
  44.  * @version 0.0.1
  45.  */
  46.  
  47. gumbo_load ("Template_Engine");
  48.  
  49.     
  50.     /**
  51.      * Constructor
  52.      * @param string $file template file name
  53.      */
  54.     public function __construct ($file=null{
  55.         if (!is_null ($file)) $this->setFile ($file)}
  56.     }
  57.     
  58.     
  59.     
  60.     /** ACTION METHODS **/
  61.     /**
  62.      * Parses the template file into an HTML string
  63.      * @precondition setFormatted (false)
  64.      * @precondition setOutput (null)
  65.      * @postcondition isFormatted ()
  66.      */
  67.     protected function parse ({
  68.         // verify precondition
  69.         $this->setFormatted (false);
  70.         $this->setOutput (null);
  71.         
  72.         // start the buffer
  73.         // NOTE: Gumbo_Buffer not used to avoid dependency
  74.         ob_start ();
  75.             include ($this->getFullPath ());
  76.             $contents ob_get_contents ();
  77.         ob_end_clean ();
  78.         
  79.         $this->setOutput ($contents);
  80.         $this->setFormatted (true);
  81.     }
  82.     
  83. }
  84.  
  85. ?>