Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Smarty plugin
Chris PeBenito 696b41
 * @package Smarty
Chris PeBenito 696b41
 * @subpackage plugins
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * called for included php files within templates
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * @param string $smarty_file
Chris PeBenito 696b41
 * @param string $smarty_assign variable to assign the included template's
Chris PeBenito 696b41
 *               output into
Chris PeBenito 696b41
 * @param boolean $smarty_once uses include_once if this is true
Chris PeBenito 696b41
 * @param array $smarty_include_vars associative array of vars from
Chris PeBenito 696b41
 *              {include file="blah" var=$var}
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
//  $file, $assign, $once, $_smarty_include_vars
Chris PeBenito 696b41
Chris PeBenito 696b41
function smarty_core_smarty_include_php($params, &$smarty)
Chris PeBenito 696b41
{
Chris PeBenito 696b41
    $_params = array('resource_name' => $params['smarty_file']);
Chris PeBenito 696b41
    require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
Chris PeBenito 696b41
    smarty_core_get_php_resource($_params, $smarty);
Chris PeBenito 696b41
    $_smarty_resource_type = $_params['resource_type'];
Chris PeBenito 696b41
    $_smarty_php_resource = $_params['php_resource'];
Chris PeBenito 696b41
Chris PeBenito 696b41
    if (!empty($params['smarty_assign'])) {
Chris PeBenito 696b41
        ob_start();
Chris PeBenito 696b41
        if ($_smarty_resource_type == 'file') {
Chris PeBenito 696b41
            $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
Chris PeBenito 696b41
        } else {
Chris PeBenito 696b41
            $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
Chris PeBenito 696b41
        }
Chris PeBenito 696b41
        $smarty->assign($params['smarty_assign'], ob_get_contents());
Chris PeBenito 696b41
        ob_end_clean();
Chris PeBenito 696b41
    } else {
Chris PeBenito 696b41
        if ($_smarty_resource_type == 'file') {
Chris PeBenito 696b41
            $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
Chris PeBenito 696b41
        } else {
Chris PeBenito 696b41
            $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
Chris PeBenito 696b41
        }
Chris PeBenito 696b41
    }
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
Chris PeBenito 696b41
/* vim: set expandtab: */
Chris PeBenito 696b41
Chris PeBenito 696b41
?>