侯体宗的博客
  • 首页
  • 人生(杂谈)
  • 技术
  • 关于我
  • 更多分类
    • 文件下载
    • 文字修仙
    • 中国象棋ai
    • 群聊
    • 九宫格抽奖
    • 拼图
    • 消消乐
    • 相册

php封装的smartyBC类完整实例

php  /  管理员 发布于 7年前   193

本文实例讲述了php封装的smartyBC类。分享给大家供大家参考,具体如下:

 * @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{  /**   * Smarty 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($options);    // 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 boolean $merge  flag if array elements shall be merged   */  public function 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 be used in templates   *   * @param string $function   the name of the template function   * @param string $function_impl the name of the PHP function to register   * @param bool  $cacheable   * @param mixed $cache_attrs   */  public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)  {    $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);  }  /**   * Unregisters custom function   *   * @param string $function name of template function   */  public function unregister_function($function)  {    $this->unregisterPlugin('function', $function);  }  /**   * Registers object to be used in templates   *   * @param string $object   name of template object   * @param 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 that are block format   */  public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $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 be 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   */  public 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 unregister_block($block)  {    $this->unregisterPlugin('block', $block);  }  /**   * Registers compiler function   *   * @param string $function   name of template function   * @param string $function_impl name of PHP function to register   * @param bool  $cacheable   */  public function register_compiler_function($function, $function_impl, $cacheable = true)  {    $this->registerPlugin('compiler', $function, $function_impl, $cacheable);  }  /**   * Unregisters compiler function   *   * @param string $function name of template function   */  public function unregister_compiler_function($function)  {    $this->unregisterPlugin('compiler', $function);  }  /**   * Registers modifier to be 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, $modifier_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_resource($type)  {    $this->unregisterResource($type);  }  /**   * Registers a prefilter function to apply   * to a template before compiling   *   * @param callable $function   */  public function register_prefilter($function)  {    $this->registerFilter('pre', $function);  }  /**   * Unregisters a prefilter function   *   * @param callable $function   */  public function unregister_prefilter($function)  {    $this->unregisterFilter('pre', $function);  }  /**   * Registers a postfilter function to apply   * to a compiled template after compilation   *   * @param callable $function   */  public function register_postfilter($function)  {    $this->registerFilter('post', $function);  }  /**   * Unregisters a postfilter function   *   * @param callable $function   */  public function unregister_postfilter($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_outputfilter($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 see 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, $cache_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 is not specified.   * This function is for advanced use only, not normally needed.   *   * @param string $tpl_file   * @param string $compile_id   * @param string $exp_time   *   * @return boolean results 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   */  public 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, $section, $scope);  }  /**   * return a reference to a registered object   *   * @param string $name   *   * @return object   */  public 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 function 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 contents of the block * @param object $template template object * @param boolean &$repeat repeat flag * * @return string content re-formatted */function smarty_php_tag($params, $content, $template, &$repeat){  eval($content);  return '';}

更多关于Smarty相关内容感兴趣的读者可查看本站专题:《smarty模板入门基础教程》、《PHP模板技术总结》、《PHP基于pdo操作数据库技巧总结》、《PHP运算与运算符用法总结》、《PHP网络编程技巧总结》、《PHP基本语法入门教程》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于smarty模板的PHP程序设计有所帮助。

您可能感兴趣的文章:

  • php常用表单验证类用法实例
  • PHP代码实现表单数据验证类
  • php表单敏感字符过滤类
  • 一个漂亮的php验证码类(分享)
  • PHP验证码类代码( 最新修改,完全定制化! )
  • PHP 动态随机生成验证码类代码
  • PHP的一个完整SMTP类(解决邮件服务器需要验证时的问题)
  • PHP学习笔记 用户注册模块用户类以及验证码类
  • 生成随机字符串和验证码的类的PHP实例
  • PHP 基于文件头的文件类型验证类函数
  • php实现的Captcha验证码类实例
  • php封装的page分页类完整实例
  • php封装的单文件(图片)上传类完整实例
  • php基于单例模式封装mysql类完整实例
  • php封装的表单验证类完整实例


  • 上一条:
    php魔术方法功能与用法实例分析
    下一条:
    php封装的smarty类完整实例
  • 昵称:

    邮箱:

    0条评论 (评论内容有缓存机制,请悉知!)
    最新最热
    • 分类目录
    • 人生(杂谈)
    • 技术
    • linux
    • Java
    • php
    • 框架(架构)
    • 前端
    • ThinkPHP
    • 数据库
    • 微信(小程序)
    • Laravel
    • Redis
    • Docker
    • Go
    • swoole
    • Windows
    • Python
    • 苹果(mac/ios)
    • 相关文章
    • Laravel从Accel获得5700万美元A轮融资(0个评论)
    • PHP 8.4 Alpha 1现已发布!(0个评论)
    • 用Time Warden监控PHP中的代码处理时间(0个评论)
    • 在PHP中使用array_pop + yield实现读取超大型目录功能示例(0个评论)
    • Property Hooks RFC在PHP 8.4中越来越接近现实(0个评论)
    • 近期文章
    • 在windows10中升级go版本至1.24后LiteIDE的Ctrl+左击无法跳转问题解决方案(0个评论)
    • 智能合约Solidity学习CryptoZombie第四课:僵尸作战系统(0个评论)
    • 智能合约Solidity学习CryptoZombie第三课:组建僵尸军队(高级Solidity理论)(0个评论)
    • 智能合约Solidity学习CryptoZombie第二课:让你的僵尸猎食(0个评论)
    • 智能合约Solidity学习CryptoZombie第一课:生成一只你的僵尸(0个评论)
    • 在go中实现一个常用的先进先出的缓存淘汰算法示例代码(0个评论)
    • 在go+gin中使用"github.com/skip2/go-qrcode"实现url转二维码功能(0个评论)
    • 在go语言中使用api.geonames.org接口实现根据国际邮政编码获取地址信息功能(1个评论)
    • 在go语言中使用github.com/signintech/gopdf实现生成pdf分页文件功能(95个评论)
    • gmail发邮件报错:534 5.7.9 Application-specific password required...解决方案(0个评论)
    • 近期评论
    • 122 在

      学历:一种延缓就业设计,生活需求下的权衡之选中评论 工作几年后,报名考研了,到现在还没认真学习备考,迷茫中。作为一名北漂互联网打工人..
    • 123 在

      Clash for Windows作者删库跑路了,github已404中评论 按理说只要你在国内,所有的流量进出都在监控范围内,不管你怎么隐藏也没用,想搞你分..
    • 原梓番博客 在

      在Laravel框架中使用模型Model分表最简单的方法中评论 好久好久都没看友情链接申请了,今天刚看,已经添加。..
    • 博主 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 @1111老铁这个不行了,可以看看近期评论的其他文章..
    • 1111 在

      佛跳墙vpn软件不会用?上不了网?佛跳墙vpn常见问题以及解决办法中评论 网站不能打开,博主百忙中能否发个APP下载链接,佛跳墙或极光..
    • 2016-10
    • 2016-11
    • 2017-06
    • 2017-07
    • 2017-08
    • 2017-09
    • 2017-11
    • 2017-12
    • 2018-01
    • 2018-02
    • 2018-03
    • 2020-03
    • 2020-04
    • 2020-05
    • 2020-06
    • 2020-07
    • 2020-09
    • 2021-02
    • 2021-03
    • 2021-04
    • 2021-05
    • 2021-06
    • 2021-07
    • 2021-08
    • 2021-09
    • 2021-10
    • 2021-11
    • 2021-12
    • 2022-01
    • 2022-02
    • 2022-05
    • 2022-06
    • 2022-07
    • 2022-08
    • 2022-09
    • 2022-10
    • 2022-11
    • 2022-12
    • 2023-01
    • 2023-02
    • 2023-03
    • 2023-04
    • 2023-05
    • 2023-06
    • 2023-07
    • 2023-08
    • 2023-09
    • 2023-10
    • 2023-11
    • 2023-12
    • 2024-01
    • 2024-02
    • 2024-03
    • 2024-04
    • 2024-05
    • 2024-06
    • 2024-07
    • 2024-09
    Top

    Copyright·© 2019 侯体宗版权所有· 粤ICP备20027696号 PHP交流群

    侯体宗的博客