//ini_set('error_reporting',E_ALL); ################################################## # # init template engine # // you need the template class from http://sf.net/projects/simpltpl if (!@(include 'HTML/Template/Xipe.php')) { print 'sorry, you need the template class PEAR::HTML_Template_Xipe<br>' . 'or if i have time i put the examples <a href="http://os.visionp.de/">here online</a>'; die; } require_once 'HTML/Template/Xipe/Filter/TagLib.php'; $options = array('templateDir' => dirname(__FILE__)); $tpl = new HTML_Template_Xipe($options); require_once 'HTML/Template/Xipe/Filter/Modifier.php'; $modifiers = new HTML_Template_Xipe_Filter_Modifier($tpl->options); $tpl->registerPrefilter(array(&$modifiers, 'imgSrc'), array(dirname(__FILE__), 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']))); // session stuff to save the opened folders etc. session_start(); if (!session_is_registered('session')) { $session = new stdClass(); // standard PHP-class constructor session_register('session'); $session->data = array(); $session->use = 'Filesystem'; } else { $session =& $_SESSION['session']; } // set the source to use if (@$_REQUEST['use_DB']) { $session->use = 'DB'; }
// include the files needed // require_once 'HTML/Template/Xipe.php'; require_once 'HTML/Template/Xipe/Filter/Basic.php'; // // make template class instance // $options = array('templateDir' => dirname(__FILE__), 'compileDir' => 'tmp', 'verbose' => true, 'locale' => '', 'logLevel' => 1, 'filterLevel' => 0); $tpl = new HTML_Template_Xipe($options); // // make filter class instance // and apply filters as needed // $tplFilter = new HTML_Template_Xipe_Filter_Basic($tpl->getOptions()); // pre filter $tpl->registerPrefilter(array(&$tplFilter, 'removeHtmlComments')); $tpl->registerPrefilter(array(&$tplFilter, 'removeCStyleComments')); $tpl->registerPrefilter(array(&$tplFilter, 'addIfBeforeForeach')); // this filter makes the foreach-blocks conditional, so they are only shown if they contain data, see api-doc // post filter $tpl->registerPostfilter(array(&$tplFilter, 'trimLines')); $tpl->registerPostfilter(array(&$tplFilter, 'optimizeHtmlCode')); // // fill variables used in the template // no assign-method necessary // $advantages = array('clean HTML-code', 'ALL the power of PHP inside a template', 'a compiled template', 'easy to use (template) engine'); $dontLike = array('php-tags in your html', 'the braces: "{" and "}", since they could be replaced by proper indention', 'to learn a new template language'); $viewSourceCodeUrl = 'http://www.kriesing.de/showsource.php?domain=wolfram.kriesing.de&file=/libs/php/SimpleTemplate/examples/simple/index.php'; $viewTemplateCodeUrl = 'http://www.kriesing.de/showsource.php?domain=wolfram.kriesing.de&file=/libs/php/SimpleTemplate/examples/simple/index.tpl'; $viewClassCodeUrl = 'http://www.kriesing.de/showsource.php?domain=wolfram.kriesing.de&file=/libs/php/SimpleTemplate/Engine.php';