The examples in this article describe the SMARTYBC classes in PHP encapsulation. Share to everyone for your reference, specific as follows:
<?php/** * Project:Smarty:the php compiling template engine * File:SmartyBC.class.php * SVN: $Id: $ * This library is free software; Can redistribute it and/or * modify it under the terms of the GNU lesser General public * License as published by th e free Software Foundation;
either * Version 2.1 of the License, or (at your option) any later version. * This library was distributed in the hope that it would be useful, * but without any WARRANTY; Without even the implied warranty of * merchantability or FITNESS for A particular purpose.
The GNU * Lesser General public License for more details. * For your should have received a copy of the GNU Lesser General public * License along and this library; If not, write to the free Software * Foundation, Inc., Temple Place, Suite, Boston, MA 02111-1307 USA * for Quest Ions, help, comments, discussion, etc., please join the * Smarty mailing list. Send a blank e-mail to * Smarty-discussion-subscribe@googlegroups.com * * @link http://www.smarty.net/* @copyright 2008 New Digital Group, Inc. * @author Monte ohrt <monte at ohrt Dot com> * @author Uwe Tews * @author Rodney Rehm * @package Smarty */ * * * @ignore * * * require_once (dirname (__file__).
'/smarty.class.php '); /** * Smarty Backward compatability wrapper class * * @package Smarty/class Smartybc extends Smarty {/** * Sm
Arty 2 BC * * @var String */public $_version = self::smarty_version; /** * Initialize New SMARTYBC Object * * @param array $options options to set during initialization, e.g. Array ( ' Forcecompile ' => false) */Public function __construct (array $options = Array ()) {parent::__construct ($op
tions);
Register {PHP} tag $this->registerplugin (' block ', ' php ', ' Smarty_php_tag '); /** * wrapper for Assign_by_ref * * @param string $tpl _var the template variable name * @param mixed & $value the referenced value to assign * *
Public Function Assign_by_ref ($tpl _var, & $value) {$this->assignbyref ($tpl _var, $value); }/** * Wrapper for Append_by_ref * * @param string $tpl _var the template variable name * @param mixed $value the referenced value to append * @param a Boolean $merge flag if array elements shall be merged/public F
Unction Append_by_ref ($tpl _var, & $value, $merge = False) {$this->appendbyref ($tpl _var, $value, $merge);
}/** * Clear the given assigned template variable. * * @param string $tpl _var The template variable to clear */Public function clear_assign ($tpl _var) {$this-
>clearassign ($tpl _var); }/** * Registers custom function to is used in templates * * @param string $function The name of the Templat E function * @param string $function _impl the name of the PHP function to register * @param BOOL $cacheable * @p Aram Mixed $cache _attrs */Public function register_function ($functioN, $function _impl, $cacheable = True, $cache _attrs = null) {$this->registerplugin (' function ', $function, $functi
On_impl, $cacheable, $cache _attrs); }/** * Unregisters custom Function * * @param string $function name of template function */public FUNCTI
On Unregister_function ($function) {$this->unregisterplugin (' function ', $function); }/** * Registers object to is used in templates * * @param string $object name of template Object * @para M object $object _impl the referenced PHP object to register * @param array $allowed List of allowed methods (empty = All) * @param boolean $smarty _args smarty argument format, else traditional * @param array $block _methods List of Methods that are block format * * @throws smartyexception * @internal param array $block _functs list of methods T HAT are block format */Public Function Register_object ($object, $object _impl, $allowed = Array (), $smarty _args = Tru E, $block _metHods = Array ()) {Settype ($allowed, ' array ');
Settype ($smarty _args, ' Boolean ');
$this->registerobject ($object, $object _impl, $allowed, $smarty _args, $block _methods); /** * Unregisters Object * * @param string $object name of template object/Public function unregister
_object ($object) {$this->unregisterobject ($object); }/** * Registers block function to is used in templates * * @param string $block name of template block * @param string $block _impl PHP function to register * @param BOOL $cacheable * @param mixed $cache _attrs */PU Blic function Register_block ($block, $block _impl, $cacheable = True, $cache _attrs = null) {$this->registerplugin
(' Block ', $block, $block _impl, $cacheable, $cache _attrs); /** * Unregisters block function * * @param string $block name of template function */Public function U
Nregister_block ($block) {$this->unregisterplugin (' block ', $block);
} /** * Registers Compiler function * * @param string $function name of template function * @param string $f Unction_impl name of PHP function to register * @param bool $cacheable/Public Function register_compiler_funct Ion ($function, $function _impl, $cacheable = True) {$this->registerplugin (' compiler ', $function, $function _impl,
$cacheable); /** * unregisters compiler function * * @param string $function name of template function */public func
tion Unregister_compiler_function ($function) {$this->unregisterplugin (' compiler ', $function); }/** * Registers modifier to is used in templates * @param string $modifier name of template modifier * @param string $modifier _impl name of PHP function to register */Public Function register_modifier ($modifier, $modif
Ier_impl) {$this->registerplugin (' modifier ', $modifier, $modifier _impl); }/** * unregisters modifier * * @param string $modIfier name of template modifier/Public function Unregister_modifier ($modifier) {$this->unregisterplugin (
' modifier ', $modifier); /** * Registers a resource to fetch a template * @param string $type name of resource * @param array $ Functions array of functions to handle resource/Public function Register_resource ($type, $functions) {$this
->registerresource ($type, $functions); }/** * Unregisters a resource * * @param string $type name of resource */Public function Unregister_reso
Urce ($type) {$this->unregisterresource ($type); }/** * Registers a prefilter function to apply * to a template before compiling * * @param callable $functi
On */Public Function Register_prefilter ($function) {$this->registerfilter (' pre ', $function); }/** * Unregisters a prefilter function * * @param callable $function/Public function Unregister_prefi Lter ($function) {$thiS->unregisterfilter (' pre ', $function); }/** * Registers a postfilter function to apply * to a compiled template after compilation * * @param Calla
BLE $function */Public Function Register_postfilter ($function) {$this->registerfilter (' Post ', $function); }/** * Unregisters a postfilter function * * @param callable $function/Public function Unregister_po
Stfilter ($function) {$this->unregisterfilter (' Post ', $function);
/** * Registers an output filter function to apply * to a template output * * @param callable $function
* * Public Function Register_outputfilter ($function) {$this->registerfilter (' Output ', $function); /** * Unregisters an outputfilter function * * @param callable $function/Public function Unregister_o
Utputfilter ($function) {$this->unregisterfilter (' Output ', $function); /** * Load a filter of specified type and name * * @param striNG $type Filter Type * @param string $name Filter Name */Public Function Load_filter ($type, $name) {$this-
>loadfilter ($type, $name); }/** * Clear cached content for the given template and cache ID * * @param string $TPL _file name of template File * @param string $cache _id name of cache_id * @param string $compile _id name of compile_id * @param string $ Exp_time Expiration Time * * @return Boolean/Public Function Clear_cache ($TPL _file = null, $cache _id = null
, $compile _id = null, $exp _time = null) {return $this->clearcache ($tpl _file, $cache _id, $compile _id, $exp _time); /** * Clear the entire contents of cache (all templates) * * @param string $exp _time expire Time * * @return Boolean/Public Function Clear_all_cache ($exp _time = null) {return $this->clearcache (null, NULL,
NULL, $exp _time); /** * Test to the IF valid cache exists for this template * * @param string $TPL_file Name of template file * @param string $cache _id * @param string $compile _id * * @return Boolean * * Public Function is_cached ($tpl _file, $cache _id = null, $compile _id = null) {return $this->iscached ($tpl _file, $c
ache_id, $compile _id);
}/** * Clear all the assigned template variables.
* * Public Function clear_all_assign () {$this->clearallassign (); /** * Clears compiled version of specified template resource, * or all compiled template files if one are not spe
Cified.
* This function is for advanced use only, not normally needed. * * @param string $tpl _file * @param string $compile _id * @param string $exp _time * * @return Boolean Resul TS of {@link smarty_core_rm_auto ()} */Public function clear_compiled_tpl ($TPL _file = null, $compile _id = null, $exp _
Time = null) {return $this->clearcompiledtemplate ($tpl _file, $compile _id, $exp _time); }/** * Checks whether requested template exists. * * @param string $tpl _file * * @return Boolean/Public Function template_exists ($tpl _file) {return
$this->templateexists ($tpl _file);
/** * Returns An array containing template variables * * @param string $name * * @return Array/
Public Function get_template_vars ($name = null) {return $this->gettemplatevars ($name); /** * Returns An array containing config variables * * @param string $name * * @return Array/PU
Blic function get_config_vars ($name = null) {return $this->getconfigvars ($name);
/** * Load Configuration values * * @param string $file * @param string $section * @param string $scope */Public Function config_load ($file, $section = null, $scope = ' global ') {$this->configload ($file, $secti
On, $scope); /** * Return a reference to a registered object * * @param string $name * * @return Object/Publ IC function get_Registered_object ($name) {return $this->getregisteredobject ($name);
/** * Clear Configuration values * * @param string $var/Public Function clear_config ($var = null) {
$this->clearconfig ($var); /** * Trigger Smarty Error * * @param string $error _msg * @param integer $error _type/Public functi
On Trigger_error ($error _msg, $error _type = e_user_warning) {trigger_error ("Smarty Error: $error _msg", $error _type); }/** * Smarty {php}{/php} block function * @param array $params parameter list * @param string $content cont Ents of the block * @param object $template Template Object * @param boolean & $repeat Repeat flag * * @return Stri
NG content re-formatted/function Smarty_php_tag ($params, $content, $template, & $repeat) {eval ($content);
Return ";
}
More interested in smarty related content readers can view the site topics: "Smarty Template Primer Tutorial", "PHP Template Technology Summary", "PHP based on PDO Operation Database Skills summary", "PHP Operations and Operator Usage Summary", "PHP Network Programming Skills Summary", " Introduction to PHP Basic Grammar, "Introduction to PHP object-oriented programming", "PHP string (String) Usage Summary", "Php+mysql Database Operations Tutorial" and "PHP common database Operation Skills Summary"
I hope this article will help you with the PHP program design based on Smarty template.