define (array(main => diary.html)); // $t->setkey (var1, some text); // $t->subst (inner, inner) // $t->setkey (var1, some more text); // $t->subst (inner, .inner) // $t->setkey (var2, var2 text); // $t->subst (content, main); // $t->print (content); // // description // // this is a class.fasttemplate.php3 replacement that provides most of the // same interface but has the ability to do nested dynamic templates. the // default is to do dynamic template expansion and no special action is // required for this to happen. // // class.fasttemplate.php3 methods not implemented // // clear_parse // same as clear. in fact, it was the same as clear in fasttemplate. // clear_all // if you really think you need this, try // unset $t; // $t = new template ($path); // which gives the same effect. // clear_tpl // use unload instead. this has the side effect of unloading all parent // and sibling templates which may be more drastic than you expect and // is different from class.fasttemplate.php3. this difference is // necessary since the only way we can force the reload of an embedded // template is to force the reload of the parent and sibling templates. // // class.fasttemplate.php3 methods by another name // // the existence of these functions is a historical artifact. i // originally had in mind to write a functional equivalent from scratch. // then i came my senses and just grabbed class.fasttemplate.php3 and // started hacking it. so, you can use the names on the right, but the // ones on the left are equivalent and are the names used in the original // class.fasttemplate.php3. // // parse --> subst // get_assiged --> getkey // assign --> setkey // clear_href --> unsetkey // clear_assign --> unsetkey // fastprint --> xprint // class rfasttemplate { // file name to be used for debugging output. needs to be set prior to // calling anything other than option setting commands (debug, debugall, // strict, dynamic) because once the file has been opened, this is ignored. var $debugfile = /tmp/class.rfasttemplate.php.dbg; // file descriptor for debugging output. var $debugfd = -1; // array for individual member functions. you can turn on debugging for a // particular member function by calling $this->debug(function_name) var $debug = array (); // turn this on to turn on debugging in all member functions via // $this->debugall(). turn if off via $this->debugall(false); var $debugall = false; // names of actual templates. each element will be an array with template // information including is originating file, file load status, parent // template, variable list, and actual template contents. var $template = array(); // holds paths-to-templates (see: set_root and findtemplate) var $root = array(); // holds the handle to the last template parsed by parse() var $last = ; // strict template checking. unresolved variables in templates will generate a // warning. var $strict = true; // if true, this suppresses the warning generated by $strict=true. var $quiet = false; // holds handles assigned by a call to parse(). var $handle = array(); // holds all assigned variable names and values. var $var = array(); // set to true is this is a win32 server. this was part of the // class.fasttemplate.php3 implementation and the only real place it kicks // in is in setting the terminating character on the value of $root, the // path where all the templates live. var $win32 = false; // automatically scan template for dynamic templates and assign new values // to template based on whatever names the html comments use. this can be // changed up until the time the first parse() is called. well, you can // change it anytime, but it will have no effect on already loaded // templates. also, if you have dynamic templates, the first call to parse // will load all of your templates, so changing it after that point will // have no effect on any defined templates. var $dynamic = true; // grrr. dont try to break these extra long regular expressions into // multiple lines for readability. php 4.03pl1 chokes on them if you do. // im guessing the reason is something obscure with the parenthesis // matching, the same sort of thing tcl might have, but im not sure. // regular expression which matches the beginning of a dynamic/inferior // template. the critical bit is that we need two parts: (1) the entire // match, and (2) the name of the dynamic template. the first part is // required because will do a strstr() to split the buffer into two // pieces: everything before the dynamic template declaration and // everything after. the second is needed because after finding a begin // we will search for an end and they both have to have the same name of // we consider the template malformed and throw and error. // both of these are written with pcre (perl-compatible regular // expressions) because we need the non-greedy operators to insure that // we dont read past the end of the html comment marker in the case that // the begin/end block have trailing comments after the tag name. var $regex_dynbeg = /()/; // regular expression which matches the end of a dynamic/inferior // template; see the comment about on the begin match. var $regex_dynend = /()/; // regular expression which matches a variable in the template. var $regex_var = /{[a-za-z][-_a-za-z0-9]*}/; // // description // constructor. // function rfasttemplate ($pathtotemplates = ) { // $pathtotemplates can also be an array of template roots, handled in set_root global $php_errormsg; if (!empty($pathtotemplates)) { $this->set_root ($pathtotemplates); } $this->debug = array (subst => false, parse_internal => false, parse_internal_1 => false, parsed => false, clear => false, clear_dynamic => false, load => false); return $this; } // // description // set the name to be u
http://www.bkjia.com/phpjc/532115.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/532115.htmltecharticle// 2001 alister bulman re-port multi template-roots + more // php3 port: copyright ?1999 cdi , all rights reserved. // perl version: copyright ?1998 jason moore , all rights reserv...