Class. rFastTemplate. php 1

Source: Internet
Author: User
Tags html comment
SyntaxHighlighter. all (); news & nbsp; | & nbsp; Security & nbsp; | & nbsp; Forum & nbsp; | & nbsp; download & nb

// 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 Reserved. /// RCS Revision // @ (#) $ Id: class. rFastTemplate. php, v 1.22 2001/10/18 21:36:53 roland Exp $ // $ Source:/home/cvs/projects/php/tools/class. rFastTemplate. php, v $ // Copyright Notice /// This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2, or (at your option) // any later version. //// class. rFastTemplate. php is distributed in the hope that it will be // useful, but without any warranty; without even the implied warranty of // MERCHANTABILITY or fitness for a particle PURPOSE. see the GNU // General Public License for more details. //// Comments /// I wowould like to thank CDI For pointing out the // copyright notice attached to his PHP3 port which I had blindly missed // in my first release of this code. /// This work is derived from class. fastTemplate. php3 version 1.1.0 as // available from http://www.thewebmasters.net /. that work makes // reference to the "GNU General Artistic License ". in corresponsible // with the author, the intent was to use the GNU General Public License; // this work does the same. //// Authors //// Roland Robert TS // Alister Bulman (multi template-roots) // Michal Rybarik (Define_raw () // CDI , PHP3 port // Jason Moore , Original Perl version /// Synopsis // require ("PATH-TO-TEMPLATE-CODE/class. template. php "); // $ t = new Template (" PATH-TO-TEMPLATE-DIRECTORY "); // $ t-> 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 have CT 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 // participant 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 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.