core.smarty_include_php.php
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:2k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. <?php
  2. /**
  3.  * Smarty plugin
  4.  * @package Smarty
  5.  * @subpackage plugins
  6.  */
  7. /**
  8.  * called for included php files within templates
  9.  *
  10.  * @param string $smarty_file
  11.  * @param string $smarty_assign variable to assign the included template's
  12.  *               output into
  13.  * @param boolean $smarty_once uses include_once if this is true
  14.  * @param array $smarty_include_vars associative array of vars from
  15.  *              {include file="blah" var=$var}
  16.  */
  17. //  $file, $assign, $once, $_smarty_include_vars
  18. function smarty_core_smarty_include_php($params, &$smarty)
  19. {
  20.     $_params = array('resource_name' => $params['smarty_file']);
  21.     require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
  22.     smarty_core_get_php_resource($_params, $smarty);
  23.     $_smarty_resource_type = $_params['resource_type'];
  24.     $_smarty_php_resource = $_params['php_resource'];
  25.     if (!empty($params['smarty_assign'])) {
  26.         ob_start();
  27.         if ($_smarty_resource_type == 'file') {
  28.             $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
  29.         } else {
  30.             $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
  31.         }
  32.         $smarty->assign($params['smarty_assign'], ob_get_contents());
  33.         ob_end_clean();
  34.     } else {
  35.         if ($_smarty_resource_type == 'file') {
  36.             $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
  37.         } else {
  38.             $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
  39.         }
  40.     }
  41. }
  42. /* vim: set expandtab: */
  43. ?>