Commit 64a38f5a authored by merlinofchaos's avatar merlinofchaos
Browse files

#305301 by yched: Allow .ini file to specify the module name as printed in...

#305301 by yched: Allow .ini file to specify the module name as printed in both the topic navigation and the breadcrumb.
parent e4222c92
......@@ -191,7 +191,16 @@ function advanced_help_index_page($module = '') {
$items = array();
foreach ($modules as $module => $module_name) {
if (!empty($topics[$module])) {
$items[] = advanced_help_l($module_name, "admin/advanced_help/$module");
if (isset($settings[$module]['index name'])) {
$name = $settings[$module]['index name'];
}
elseif (isset($settings[$module]['name'])) {
$name = $settings[$module]['name'];
}
else {
$name = t($module_name);
}
$items[] = advanced_help_l($name, "admin/advanced_help/$module");
}
}
......@@ -311,9 +320,16 @@ function advanced_help_search_form_submit($form, &$form_state) {
* Small helper function to get a module's proper name.
*/
function advanced_help_get_module_name($module) {
$info = db_fetch_object(db_query("SELECT * FROM {system} WHERE name = '%s'", $module));
$info = unserialize($info->info);
return t($info['name']);
$settings = advanced_help_get_settings();
if (isset($settings[$module]['name'])) {
$name = $settings[$module]['name'];
}
else {
$info = db_fetch_object(db_query("SELECT * FROM {system} WHERE name = '%s'", $module));
$info = unserialize($info->info);
$name = t($info['name']);
}
return $name;
}
/**
......@@ -578,7 +594,19 @@ function advanced_help_get_topic($module, $topic) {
* Search the system for all available help topics.
*/
function advanced_help_get_topics() {
list ($topics, $settings) = _advanced_help_parse_ini();
return $topics;
}
function advanced_help_get_settings() {
list ($topic, $settings) = _advanced_help_parse_ini();
return $settings;
}
function _advanced_help_parse_ini() {
static $topics = NULL;
static $settings = NULL;
if (!isset($topics)) {
$topics = array();
$help_path = drupal_get_path('module', 'advanced_help') . '/modules';
......@@ -599,9 +627,9 @@ function advanced_help_get_topics() {
if (file_exists("$module_path/translations/help/$language->language/$module.help.ini")) {
$translation = parse_ini_file("$module_path/translations/help/$language->language/$module.help.ini", TRUE);
}
$settings = array();
$settings[$module] = array();
if (!empty($info['advanced help settings'])) {
$settings = $info['advanced help settings'];
$settings[$module] = $info['advanced help settings'];
unset($info['advanced help settings']);
}
......@@ -615,15 +643,15 @@ function advanced_help_get_topics() {
'parent' => isset($topic['parent']) ? $topic['parent'] : 0,
'file' => $file . '.html', // require extension
'path' => $path, // not in .ini file
'line break' => isset($topic['line break']) ? $topic['line break'] : (isset($settings['line break']) ? $settings['line break'] : FALSE),
'navigation' => isset($topic['navigation']) ? $topic['navigation'] : (isset($settings['navigation']) ? $settings['navigation'] : TRUE),
'css' => isset($topic['css']) ? $topic['css'] : (isset($settings['css']) ? $settings['css'] : NULL),
'line break' => isset($topic['line break']) ? $topic['line break'] : (isset($settings[$module]['line break']) ? $settings[$module]['line break'] : FALSE),
'navigation' => isset($topic['navigation']) ? $topic['navigation'] : (isset($settings[$module]['navigation']) ? $settings[$module]['navigation'] : TRUE),
'css' => isset($topic['css']) ? $topic['css'] : (isset($settings[$module]['css']) ? $settings[$module]['css'] : NULL),
);
}
}
}
}
return $topics;
return array($topics, $settings);
}
/**
......
......@@ -11,6 +11,10 @@ Global settings may be put into a section named <strong>[advanced help settings]
<dd>If set to true, the navigation will be displayed at the end of the help topic: previous topic, next topic, and child topics.</dd>
<dt><strong>css</strong></dt>
<dd>Specify a css file that will be used for all help files (unless overridden), including the .css extension. This .css file must reside in the help directory along with the .html files, and will not be affected by translation.</dd>
<dt><strong>name</strong></dt>
<dd>May be set to override the module name as displayed in both the module index as well as the navigation and breadcrumb trail. In general this does not need to be set, but a few modules may want to use a more friendly name than appears in the .info file.</dd>
<dt><strong>index name</strong></dt>
<dd>This may be set to change the name of the module in the module index. It overrides the 'name' setting above, as well as the module name in its .info file.</dd>
</dl>
Each section after that will correspond to a single help file, and each one may have the following settings:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment