From 6eea17da4e8755173d2c780e76fd28f7a2dd0f2a Mon Sep 17 00:00:00 2001 From: Eileen Date: Mon, 23 Dec 2013 16:20:21 +1300 Subject: [PATCH] CRM-14021 respect for .extra.hlp files & for alterations in help page via pagerun hook ---------------------------------------- * CRM-14021: CiviCRM should render .extra.hlp files http://issues.civicrm.org/jira/browse/CRM-14021 --- CRM/Core/Page/Inline/Help.php | 11 ++++++++++- CRM/Core/Smarty/plugins/function.help.php | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CRM/Core/Page/Inline/Help.php b/CRM/Core/Page/Inline/Help.php index 5a4c5b2ede..c09e5550c8 100644 --- a/CRM/Core/Page/Inline/Help.php +++ b/CRM/Core/Page/Inline/Help.php @@ -41,6 +41,7 @@ class CRM_Core_Page_Inline_Help { $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'); @@ -48,7 +49,15 @@ class CRM_Core_Page_Inline_Help { $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); } } } diff --git a/CRM/Core/Smarty/plugins/function.help.php b/CRM/Core/Smarty/plugins/function.help.php index b3e79bb530..f369d6d011 100644 --- a/CRM/Core/Smarty/plugins/function.help.php +++ b/CRM/Core/Smarty/plugins/function.help.php @@ -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']); @@ -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 -- 2.25.1