Skip to content

Commit

Permalink
CRM-14021 respect for .extra.hlp files & for alterations in help page…
Browse files Browse the repository at this point in the history
… via pagerun hook

----------------------------------------
* CRM-14021: CiviCRM should render .extra.hlp files
  http://issues.civicrm.org/jira/browse/CRM-14021
  • Loading branch information
eileenmcnaughton committed Dec 23, 2013
1 parent 7874afe commit 6eea17d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
11 changes: 10 additions & 1 deletion CRM/Core/Page/Inline/Help.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,23 @@ function run() {
$args = $_REQUEST;
if (!empty($args['file']) && strpos($args['file'], '..') === FALSE) {
$file = $args['file'] . '.hlp';
$additionalTPLFile = $args['file'] . '.extra.hlp';
$smarty = CRM_Core_Smarty::singleton();
$smarty->assign('id', $args['id']);
CRM_Utils_Array::remove($args, 'file', 'class_name', 'type', 'q', 'id');
foreach ($args as &$arg) {
$arg = strip_tags($arg);
}
$smarty->assign('params', $args);
exit($smarty->fetch($file));

$extraoutput = '';
if ($smarty->template_exists($additionalTPLFile)) {
//@todo hook has been put here as a conservative approach
// but probably should always run. It doesn't run otherwise because of the exit
CRM_Utils_Hook::pageRun($this);
$extraoutput .= trim($smarty->fetch($additionalTPLFile));
}
exit($smarty->fetch($file) . $extraoutput);
}
}
}
7 changes: 6 additions & 1 deletion CRM/Core/Smarty/plugins/function.help.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function smarty_function_help($params, &$smarty) {
$params['file'] = $smarty->_tpl_vars['tplFile'];
}
elseif (empty($params['file'])) {
return $help;
return NULL;
}

$params['file'] = str_replace(array('.tpl', '.hlp'), '', $params['file']);
Expand All @@ -61,11 +61,16 @@ function smarty_function_help($params, &$smarty) {
$oldID = $smarty->get_template_vars('id');
$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));
}
$smarty->assign('id', $oldID);
}
else {
$name = trim(strip_tags($params['title']));
}

// Escape for html
$title = htmlspecialchars(ts('%1 Help', array(1 => $name)));
// Escape for html and js
Expand Down

0 comments on commit 6eea17d

Please sign in to comment.