本文整理汇总了PHP中Smarty_Internal_Template::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Template::__construct方法的具体用法?PHP Smarty_Internal_Template::__construct怎么用?PHP Smarty_Internal_Template::__construct使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::__construct方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Exception
function __construct($name, $smarty, $parent, $nocache)
{
parent::__construct('string:', $smarty, $parent);
if (!isset($this->smarty->template_functions[$name])) {
throw new Exception("Call to undefined template function \"{$name}\" in template \"{$parent->template_resource}\"");
}
$this->called_nocache = $nocache;
$this->mustCompile = false;
if ($nocache) {
$smarty->template_functions[$name]['called_nocache'] = true;
$this->properties['function'][$name]['called_nocache'] = true;
}
$this->properties['nocache_hash'] = $smarty->template_functions[$name]['nocache_hash'];
// load compiled function
if ($nocache) {
// if called in nocache mode convert nocache code to real code
$this->compiled_template = preg_replace(array("!(<\\?php echo ')?/\\*/?%%SmartyNocache:{$this->smarty->template_functions[$name]['nocache_hash']}%%\\*/(';\\?>)?!", "!\\\\'!"), array('', "'"), $smarty->template_functions[$name]['compiled']);
} else {
$this->compiled_template = $smarty->template_functions[$name]['compiled'];
}
// assign default paramter
if (isset($smarty->template_functions[$name]['parameter'])) {
$_smarty_tpl = $this;
foreach ($smarty->template_functions[$name]['parameter'] as $_key => $_value) {
$this->assign($_key, eval("return {$_value};"));
}
}
// set flag if {function} contains nocache code
if ($smarty->template_functions[$name]['has_nocache_code']) {
$this->has_nocache_code = true;
}
}
示例2: __construct
/**
* Create template data object
*
* Some of the global Smarty settings copied to template scope
* It load the required template resources and cacher plugins
*
* @param string $template_resource template resource string
* @param Smarty $smarty Smarty instance
* @param Smarty_Internal_Template $_parent back pointer to parent object with variables or null
* @param mixed $_cache_id cache id or null
* @param mixed $_compile_id compile id or null
* @param bool $_caching use caching?
* @param int $_cache_lifetime cache life-time in seconds
*/
public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
{
$bSkipDelegate = false;
if (preg_match('#^Inherit@(.+)#i', $template_resource, $aMatch)) {
/**
* Получаем шаблон по цепочке наследования
*/
$sTpl = trim($aMatch[1]);
$sParentTemplate = Engine::getInstance()->Plugin_GetParentInherit($sTpl);
if ($sTpl == $sParentTemplate) {
/**
* Сбрасываем цепочку наследования к начальному состоянию
*/
Engine::getInstance()->Plugin_ResetInheritPosition($sParentTemplate);
/**
* В параметре может быть путь до шаблона с ".tpl" в конце, а таже может быть путь до шаблона компонента вида "component.name.template"
*/
if (!preg_match("#^\\.tpl\$#i", $sTpl)) {
$aPath = explode('.', $sTpl);
if (count($aPath) == 3 and preg_match('#^([\\w\\_]+\\:)?component$#i', $aPath[0], $aMatch2)) {
$sPrefix = '';
if (isset($aMatch2[1])) {
$sPrefix = $aMatch2[1];
}
$sParentTemplate = Engine::getInstance()->Component_GetTemplatePath($sPrefix . $aPath[1], $aPath[2], false);
}
}
}
$template_resource = $sParentTemplate;
$bSkipDelegate = true;
}
/*
* Ловим использование extends на файлы компонентов
* Синтаксис: {extends 'Component@compname.template'}
*/
if (preg_match('#^Component@(.+)#i', $template_resource, $aMatch)) {
$aPath = explode('.', $aMatch[1], 2);
$template_resource = Engine::getInstance()->Component_GetTemplatePath($aPath[0], isset($aPath[1]) ? $aPath[1] : null, true);
$bSkipDelegate = true;
}
if (!$bSkipDelegate) {
$template_resource = Engine::getInstance()->Plugin_GetDelegate('template', $template_resource);
}
parent::__construct($template_resource, $smarty, $_parent, $_cache_id, $_compile_id, $_caching, $_cache_lifetime);
}
示例3: __construct
/**
* Create template data object
*
* Some of the global Smarty settings copied to template scope
* It load the required template resources and cacher plugins
*
* @param string $template_resource template resource string
* @param Smarty $smarty Smarty instance
* @param Smarty_Internal_Template $_parent back pointer to parent object with variables or null
* @param mixed $_cache_id cache id or null
* @param mixed $_compile_id compile id or null
* @param bool $_caching use caching?
* @param int $_cache_lifetime cache life-time in seconds
*/
public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
{
$bSkipDelegate = false;
if (preg_match('#^Inherit@(.+)#i', $template_resource, $aMatch)) {
/**
* Получаем шаблон по цепочке наследования
*/
$sTpl = trim($aMatch[1]);
$sParentTemplate = Engine::getInstance()->Plugin_GetParentInherit($sTpl);
if ($sTpl == $sParentTemplate) {
/**
* Сбрасываем цепочку наследования к начальному состоянию
*/
Engine::getInstance()->Plugin_ResetInheritPosition($sParentTemplate);
}
$template_resource = $sParentTemplate;
$bSkipDelegate = true;
}
if (!$bSkipDelegate) {
$template_resource = Engine::getInstance()->Plugin_GetDelegate('template', $template_resource);
}
parent::__construct($template_resource, $smarty, $_parent, $_cache_id, $_compile_id, $_caching, $_cache_lifetime);
}