function smarty_core_smarty_include_php($params, &$smarty) { $_params = array('resource_name' => $params['smarty_file']); require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; if (!empty($params['smarty_assign'])) { ob_start(); if ($_smarty_resource_type == 'file') { $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); } else { $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); } $smarty->assign($params['smarty_assign'], ob_get_contents()); ob_end_clean(); } else { if ($_smarty_resource_type == 'file') { $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); } else { $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); } } }
function smarty_core_smarty_include_php($params, &$smarty) { $_params = array('resource_name' => $params['smarty_file']); MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_php_resource.php'); smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; if (!empty($params['smarty_assign'])) { ob_start(); if ($_smarty_resource_type == 'file') { $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); } else { $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); } $smarty->assign($params['smarty_assign'], ob_get_contents()); ob_end_clean(); } else { if ($_smarty_resource_type == 'file') { $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); } else { $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); } } }
function smarty_function_show_breadcrumps($params, &$smarty) { $iObject = $params['iObject']; if ($iObject instanceof News) { $smarty->assign('iNews', $iObject); $file = "breadcrumps.news.tpl"; } if ($iObject instanceof Event) { $smarty->assign('iEvent', $iObject); $file = "breadcrumps.event.tpl"; } if ($iObject instanceof Album) { $smarty->assign('iAlbum', $iObject); $file = "breadcrumps.album.tpl"; } if ($iObject instanceof Category) { $smarty->assign('iCategory', $iObject); $file = "breadcrumps.category.tpl"; } $_params = array('resource_name' => fvSite::$fvConfig->get("path.smarty.blocks") . $file); require_once SMARTY_CORE_DIR . 'core.get_php_resource.php'; smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; unset($params['file']); $smarty->display($_smarty_php_resource); }
function smarty_function_show_media($params, &$smarty) { $iMedia = $params['media']; switch (intval($iMedia->type_id)) { case 1: $file = "image.tpl"; $smarty->assign('iMedia', $iMedia); $smarty->assign('thumb', $params['thumb'] ? $params['thumb'] : false); break; case 2: $file = "video.tpl"; $smarty->assign('width', $params['width'] ? $params['width'] : false); $smarty->assign('height', $params['height'] ? $params['height'] : false); $smarty->assign('iMedia', $iMedia); break; default: $file = "video.tpl"; $smarty->assign('iMedia', $iMedia); $smarty->assign('width', $params['width'] ? $params['width'] : false); $smarty->assign('height', $params['height'] ? $params['height'] : false); break; } $_params = array('resource_name' => fvSite::$fvConfig->get("path.smarty.blocks") . $file); require_once SMARTY_CORE_DIR . 'core.get_php_resource.php'; smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; unset($params['file']); $smarty->display($_smarty_php_resource); }
/** * Replace cached inserts with the actual results * * @param string $results * @return string */ function smarty_core_process_cached_inserts($params, &$smarty) { preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis', $params['results'], $match); list($cached_inserts, $insert_args) = $match; for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { if ($smarty->debugging) { $_params = array(); require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); $debug_start_time = smarty_core_get_microtime($_params, $smarty); } $args = unserialize($insert_args[$i]); $name = $args['name']; if (isset($args['script'])) { $_params = array('resource_name' => $smarty->_dequote($args['script'])); require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $smarty)) { return false; } $resource_type = $_params['resource_type']; $php_resource = $_params['php_resource']; if ($resource_type == 'file') { $smarty->_include($php_resource, true); } else { $smarty->_eval($php_resource); } } $function_name = $smarty->_plugins['insert'][$name][0]; if (empty($args['assign'])) { $replace = $function_name($args, $smarty); } else { $smarty->assign($args['assign'], $function_name($args, $smarty)); $replace = ''; } $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); if ($smarty->debugging) { $_params = array(); require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); $smarty->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$name, 'depth' => $smarty->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); } } return $params['results']; }
/** * Handle insert tags * * @param array $args * @return string */ function smarty_core_run_insert_handler($params, &$smarty) { MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_microtime.php'); if ($smarty->debugging) { $_params = array(); $_debug_start_time = smarty_core_get_microtime($_params, $smarty); } if ($smarty->caching) { $_arg_string = serialize($params['args']); $_name = $params['args']['name']; if (!isset($smarty->_cache_info['insert_tags'][$_name])) { $smarty->_cache_info['insert_tags'][$_name] = array('insert', $_name, $smarty->_plugins['insert'][$_name][1], $smarty->_plugins['insert'][$_name][2], !empty($params['args']['script']) ? true : false); } return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; } else { if (isset($params['args']['script'])) { $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_php_resource.php'); if(!smarty_core_get_php_resource($_params, $smarty)) { return false; } if ($_params['resource_type'] == 'file') { $smarty->_include($_params['php_resource'], true); } else { $smarty->_eval($_params['php_resource']); } unset($params['args']['script']); } $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; $_content = $_funcname($params['args'], $smarty); if ($smarty->debugging) { $_params = array(); MyOOS_CoreApi::requireOnce('lib/smarty/libs/internals/core.get_microtime.php'); $smarty->_smarty_debug_info[] = array('type' => 'insert', 'filename' => 'insert_'.$params['args']['name'], 'depth' => $smarty->_inclusion_depth, 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); } if (!empty($params['args']["assign"])) { $smarty->assign($params['args']["assign"], $_content); } else { return $_content; } } }
function smarty_function_show_block($params, &$smarty) { $_params = array('resource_name' => fvSite::$fvConfig->get("path.smarty.blocks") . $params['file']); require_once SMARTY_CORE_DIR . 'core.get_php_resource.php'; smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; unset($params['file']); if (count($params)) { foreach ($params as $key => $val) { $smarty->assign($key, $val); } } $smarty->display($_smarty_php_resource); }
function smarty_function_texteditor($params, &$smarty, $display = true) { $_params = array('resource_name' => fvSite::$fvConfig->get("path.smarty.blocks") . "imperavi.editor.tpl"); require_once SMARTY_CORE_DIR . 'core.get_php_resource.php'; smarty_core_get_php_resource($_params, $smarty); $_smarty_resource_type = $_params['resource_type']; $_smarty_php_resource = $_params['php_resource']; $smarty->assign('id', $params["id"]); $smarty->assign('name', $params["name"]); $smarty->assign('text', $params["text"]); $smarty->assign('width', $params["width"]); $smarty->assign('height', $params["height"]); //$smarty->display( $_smarty_php_resource ); return $smarty->fetch($_smarty_php_resource, null, null, $display); }