本文整理汇总了PHP中Smarty_Internal_Template::_isTplObj方法的典型用法代码示例。如果您正苦于以下问题:PHP Smarty_Internal_Template::_isTplObj方法的具体用法?PHP Smarty_Internal_Template::_isTplObj怎么用?PHP Smarty_Internal_Template::_isTplObj使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Smarty_Internal_Template
的用法示例。
在下文中一共展示了Smarty_Internal_Template::_isTplObj方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTags
/**
* Return array of tag/attributes of all tags used by an template
*
* @api Smarty::getTags()
* @link http://www.smarty.net/docs/en/api.get.tags.tpl
*
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
* @param null|string|Smarty_Internal_Template $template
*
* @return array of tag/attributes
* @throws \SmartyException
*/
public function getTags(Smarty_Internal_TemplateBase $obj, $template = null)
{
/* @var Smarty $smarty */
$smarty = $obj->_getSmartyObj();
if ($obj->_isTplObj() && !isset($template)) {
$tpl = clone $obj;
} elseif (isset($template) && $template->_isTplObj()) {
$tpl = clone $template;
} elseif (isset($template) && is_string($template)) {
/* @var Smarty_Internal_Template $tpl */
$tpl = new $smarty->template_class($template, $smarty);
// checks if template exists
if (!$tpl->source->exists) {
throw new SmartyException("Unable to load template {$tpl->source->type} '{$tpl->source->name}'");
}
}
if (isset($tpl)) {
$tpl->smarty = clone $tpl->smarty;
$tpl->smarty->_cache['get_used_tags'] = true;
$tpl->_cache['used_tags'] = array();
$tpl->smarty->merge_compiled_includes = false;
$tpl->smarty->disableSecurity();
$tpl->caching = false;
$tpl->loadCompiler();
$tpl->compiler->compileTemplate($tpl);
return $tpl->_cache['used_tags'];
}
throw new SmartyException("Missing template specification");
}
示例2: get_debug_vars
/**
* Recursively gets variables from all template/data scopes
*
* @param Smarty_Internal_Template|Smarty_Data $obj object to debug
*
* @return StdClass
*/
public function get_debug_vars($obj)
{
$config_vars = array();
foreach ($obj->config_vars as $key => $var) {
$config_vars[$key]['value'] = $var;
if ($obj->_isTplObj()) {
$config_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
} elseif ($obj->_isDataObj()) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$config_vars[$key]['scope'] = 'Smarty object';
}
}
$tpl_vars = array();
foreach ($obj->tpl_vars as $key => $var) {
foreach ($var as $varkey => $varvalue) {
if ($varkey == 'value') {
$tpl_vars[$key][$varkey] = $varvalue;
} else {
if ($varkey == 'nocache') {
if ($varvalue == true) {
$tpl_vars[$key][$varkey] = $varvalue;
}
} else {
if ($varkey != 'scope' || $varvalue !== 0) {
$tpl_vars[$key]['attributes'][$varkey] = $varvalue;
}
}
}
}
if ($obj->_isTplObj()) {
$tpl_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
} elseif ($obj->_isDataObj()) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$tpl_vars[$key]['scope'] = 'Smarty object';
}
}
if (isset($obj->parent)) {
$parent = $this->get_debug_vars($obj->parent);
foreach ($parent->tpl_vars as $name => $pvar) {
if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
$tpl_vars[$name]['scope'] = $pvar['scope'];
}
}
$tpl_vars = array_merge($parent->tpl_vars, $tpl_vars);
foreach ($parent->config_vars as $name => $pvar) {
if (isset($config_vars[$name]) && $config_vars[$name]['value'] === $pvar['value']) {
$config_vars[$name]['scope'] = $pvar['scope'];
}
}
$config_vars = array_merge($parent->config_vars, $config_vars);
} else {
foreach (Smarty::$global_tpl_vars as $key => $var) {
if (!array_key_exists($key, $tpl_vars)) {
foreach ($var as $varkey => $varvalue) {
if ($varkey == 'value') {
$tpl_vars[$key][$varkey] = $varvalue;
} else {
if ($varkey == 'nocache') {
if ($varvalue == true) {
$tpl_vars[$key][$varkey] = $varvalue;
}
} else {
if ($varkey != 'scope' || $varvalue !== 0) {
$tpl_vars[$key]['attributes'][$varkey] = $varvalue;
}
}
}
}
$tpl_vars[$key]['scope'] = 'Global';
}
}
}
return (object) array('tpl_vars' => $tpl_vars, 'config_vars' => $config_vars);
}
示例3: getUniqueTemplateName
/**
* modify template_resource according to resource handlers specifications
*
* @param \Smarty_Internal_Template|\Smarty $obj Smarty instance
* @param string $template_resource template_resource to extract resource handler and name of
*
* @return string unique resource name
*/
public static function getUniqueTemplateName($obj, $template_resource)
{
$smarty = $obj->_getSmartyObj();
list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type);
// TODO: optimize for Smarty's internal resource types
$resource = Smarty_Resource::load($smarty, $type);
// go relative to a given template?
$_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/');
if ($obj->_isTplObj() && $_file_is_dotted && ($obj->source->type == 'file' || $obj->parent->source->type == 'extends')) {
$name = $smarty->_realpath(dirname($obj->parent->source->filepath) . $smarty->ds . $name);
}
return $resource->buildUniqueResourceName($smarty, $name);
}