Commit 33cf2950 authored by merlinofchaos's avatar merlinofchaos
Browse files

Allow line break filter; more complete help on .ini file.

parent b5fe4124
......@@ -3,7 +3,7 @@
<html xmlns="" xml:lang="<?php print $language->language ?>" lang="<?php print $language->language ?>" dir="<?php print $language->dir ?>">
<title><?php print $head_title; ?></title>
<title><?php print $title; ?></title>
<?php print $head; ?>
<?php print $styles; ?>
<?php print $scripts; ?>
......@@ -446,6 +446,14 @@ function advanced_help_view_topic($module, $topic, $popup = FALSE) {
// Make some exchanges. The strtr is because url() translates $ into %24
// but we need to change it back for the regex replacement.
// Run the line break filter if requested
if (!empty($info['line break'])) {
// Remove the header since it adds an extra <br /> to the filter.
$output = preg_replace('/^<!--[^\n]*-->\n/', '', $output);
$output = _filter_autop($output);
// Change 'topic:' to the URL for another help topic.
if ($popup) {
$output = preg_replace('/href="topic:([^"]+)"/', 'href="' . strtr(url('help/$1', array('query' => 'popup=true')), array('%24' => '$')) . '"', $output);
......@@ -505,6 +513,12 @@ function advanced_help_get_topics() {
if (file_exists("$module_path/translations/help/$language->language/$")) {
$translation = parse_ini_file("$module_path/translations/help/$language->language/$", TRUE);
$settings = array();
if (!empty($info['advanced help settings'])) {
$settings = $info['advanced help settings'];
unset($info['advanced help settings']);
foreach ($info as $name => $topic) {
// Each topic should have a name, a title, a file and of course the path.
$file = !empty($topic['file']) ? $topic['file'] : $name;
......@@ -515,6 +529,7 @@ 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),
; $Id$
title = Using advanced help
file = using-advanced-help
weight = -10
title = Translating advanced help
file = translation
\ No newline at end of file
title = Help .ini file format
line break = TRUE
\ No newline at end of file
<!-- $Id$ -->
The advanced help configuration file is in simple .ini file format, divided into sections for each help file, plus an optional section for global settings that might be inherited for each help file.
The first line of an advanced help ini file should be ;$Id$ which will be a comment providing the CVS identifier for the file. The ; indicates a comment character. Anything after the ; will be ignored.
Global settings may be put into a section named <strong>[advanced help settings]</strong> -- this means that this name is reserved and it cannot be a help file in any module. The following settings may be set in this section:
<dt><strong>line break</strong></dt>
<dd>If set to any value, the line break filter will be applied to all help files defined by this module, unless that help file specifically is set otherwise. By default, the line break filter is not applied; however, help files can be much easier to write with the line break filter on.</dd>
Each section after that will correspond to a single help file, and each one may have the following settings:
<dd>The title of the topic, presented to the user and used in links. If you have special characters in your title, be sure to enclose it in quotes.</dd>
<dd>The filename, without the .html extension, used for the topic. This is optional; if not specified, the topic name wil be the file name.</dd>
<dd>The weight, used for sorting topics on the administration page. Defaults to 0 of unspecified. Items with the same weight are sorted alphabetically.</dd>
<dd>The topic ID to use in a hierarchy; children will be listed beneath parents in the topic list, and will have the parent in their breadcrumb trail.</dd>
<dt><strong>line break</strong</dt>
<dd>If set to true, linebreaks will be converted into br and p tags automatically. If unspecified, will default to off. Set to 0 to disable the filter if this has been turned on in the global settings.</dd>
For example, here is a version of the <strong></strong> file:
title = "Using advanced help"
weight = -10
title = Translating advanced help
title = Help .ini file format
line break = TRUE
\ No newline at end of file
<!-- $Id$ -->
<p>To translate advanced help, first create a <b>translations/help/$language</b> directory
in the module directory. Then, copy the .ini file and all .html files from
the help directory.</p>
<!-- $Id$ -->
<p>The <em>Advanced help</em> system is a pluggable system that provides advanced help facilities for Drupal and its modules. Although the advanced help does not provide general help by itself, it provides a powerful and easy framework that modules may use to provide their own help.
......@@ -38,3 +39,5 @@ within the help directory, such as images you wish to embed within the help text
<p>If the search module is enabled, the contents of help system will be indexed on cron. If you enable new modules and wish to immediately index its help text, visit the "Administration -> Reports -> Status report" and click the "Run cron manually" link.</p>
<p>Example: <a href="path:nowhere.jpg">Don't click this!</a></p>
<p>See: <a href="topic:advanced_help/ini-file">ini file format</a></p>
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