本文整理汇总了PHP中CRM_Core_Smarty::template_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Smarty::template_exists方法的具体用法?PHP CRM_Core_Smarty::template_exists怎么用?PHP CRM_Core_Smarty::template_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Smarty
的用法示例。
在下文中一共展示了CRM_Core_Smarty::template_exists方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: smarty_function_help
/**
* Adds inline help
*
* @param array $params
* The function params.
* @param CRM_Core_Smarty $smarty
* Reference to the smarty object.
*
* @return string
* the help html to be inserted
*/
function smarty_function_help($params, &$smarty)
{
if (!isset($params['id']) || !isset($smarty->_tpl_vars['config'])) {
return NULL;
}
if (empty($params['file']) && isset($smarty->_tpl_vars['tplFile'])) {
$params['file'] = $smarty->_tpl_vars['tplFile'];
} elseif (empty($params['file'])) {
return NULL;
}
$params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
if (empty($params['title'])) {
$vars = $smarty->get_template_vars();
$smarty->assign('id', $params['id'] . '-title');
$name = trim($smarty->fetch($params['file'] . '.hlp'));
$additionalTPLFile = $params['file'] . '.extra.hlp';
if ($smarty->template_exists($additionalTPLFile)) {
$name .= trim($smarty->fetch($additionalTPLFile));
}
// Ensure we didn't change any existing vars CRM-11900
foreach ($vars as $key => $value) {
if ($smarty->get_template_vars($key) !== $value) {
$smarty->assign($key, $value);
}
}
} else {
$name = trim(strip_tags($params['title']));
}
$class = "helpicon";
if (!empty($params['class'])) {
$class .= " {$params['class']}";
}
// Escape for html
$title = htmlspecialchars(ts('%1 Help', array(1 => $name)));
// Escape for html and js
$name = htmlspecialchars(json_encode($name), ENT_QUOTES);
// Format params to survive being passed through json & the url
unset($params['text'], $params['title']);
foreach ($params as &$param) {
$param = is_bool($param) || is_numeric($param) ? (int) $param : (string) $param;
}
return '<a class="' . $class . '" title="' . $title . '" href="#" onclick=\'CRM.help(' . $name . ', ' . json_encode($params) . '); return false;\'> </a>';
}