Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

webapp/smartyapp.php

Go to the documentation of this file.
00001 <?php
00002 
00007 
00008 define('SMARTYAPP_VERSION', 0.1);
00009 
00010 require_once(SMARTY_DIR.'Smarty.class.php'); // we need the Smarty class definition
00011 require_once('webapp.php');     //  we need the WebApp definition
00012 
00020 class SmartyApp extends WebApp
00021 {
00023     var $smarty;
00025     var $template;
00026 
00030     function SmartyApp() 
00031         {
00032             $this->WebApp();
00033             $this->smarty =& new Smarty();
00034         }
00035 
00044     function assign() 
00045         {
00046             $smarty =& $this->getSmarty();
00047             $control_box =& $this->getControlBox();
00048 
00049             foreach ($control_box->getAllIds() as $id) 
00050                 {
00051                     if ($control_box->childDisplay($id))
00052                         $smarty->assign($id, $control_box->childToString($id));
00053                 }
00054         }
00055     
00056     // ACCESSOR METHODS
00057 
00061     function &getSmarty() 
00062         {
00063             return $this->smarty;
00064         }
00065 
00071     function setSmarty(&$smarty) 
00072         {
00073             $this->smarty =& $smarty;
00074         }
00075 
00079     function getTemplate() 
00080         {
00081             return $this->template;
00082         }
00083 
00088     function setTemplate($template) 
00089         {            
00090             $this->template = $template;
00091         }
00092 
00093     /***************************************************
00094      * Version INTERFACE
00095      ***************************************************/
00096 
00097     function version() 
00098         {
00099             return SMARTYAPP_VERSION;
00100         }
00101     
00102     /***************************************************
00103      * Printable INTERFACE
00104      ***************************************************/
00105 
00111     function toString() 
00112         {
00113             $smarty =& $this->getSmarty();
00114 
00115             if (!$template = $this->getTemplate())
00116                 trigger_error('No smarty template has been set', E_USER_ERROR);
00117             
00118             $this->assign();
00119 
00120             $string = $smarty->fetch($template, null, null, false);
00121             
00122             //ob_start();
00123             //$smarty->display($template);
00124             //$string = ob_get_contents();
00125             //ob_end_clean();
00126             
00127             return $string;
00128         }
00129 
00130     /***************************************************
00131      * Serialisation INTERFACE
00132      ***************************************************/
00133 
00134     function __sleep() 
00135         {
00136             $sleep_vars = parent::__sleep();
00137             
00138             array_push($sleep_vars, 'smarty', 'template');
00139             return $sleep_vars;
00140         }
00141 }
00142 
00143 
00144 ?>

Generated on Mon Feb 14 10:55:54 2005 for MapApp by doxygen 1.3.5