Revision 6e9292aa
Added by Assos Assos over 9 years ago
drupal7/sites/all/modules/advanced_help/advanced_help.module | ||
---|---|---|
34 | 34 |
|
35 | 35 |
/** |
36 | 36 |
* Implements hook_menu(). |
37 |
* |
|
38 |
* Strings in hook_help() should not be run through t(). |
|
37 | 39 |
*/ |
38 | 40 |
function advanced_help_menu() { |
39 |
// View help topic index. |
|
40 |
// |
|
41 |
// This is structured little oddly so that POTX can handle the translation. |
|
42 |
if (module_exists('help')) { |
|
43 |
$items['admin/advanced_help'] = array( |
|
44 |
'title' => 'Advanced help', |
|
41 |
$help_exists = module_exists('help') ? TRUE : FALSE; |
|
42 |
if ($help_exists) { |
|
43 |
// Add tabs to core Help page to access Advanced Help. |
|
44 |
$items['admin/help/tab1'] = array( |
|
45 |
'title' => 'Help', |
|
46 |
'type' => MENU_DEFAULT_LOCAL_TASK, |
|
47 |
'weight' => 0, |
|
48 |
); |
|
49 |
|
|
50 |
$items['admin/help/ah'] = array( |
|
51 |
'title' => 'Advanced Help', |
|
45 | 52 |
'page callback' => 'advanced_help_index_page', |
46 | 53 |
'access arguments' => array('view advanced help index'), |
47 |
'weight' => 9, |
|
54 |
'type' => MENU_LOCAL_TASK, |
|
55 |
'weight' => 2, |
|
48 | 56 |
); |
49 | 57 |
} |
50 | 58 |
else { |
51 |
$items['admin/advanced_help'] = array( |
|
59 |
// Make Advanced Help the normal help. |
|
60 |
$items['admin/help/ah'] = array( |
|
52 | 61 |
'title' => 'Help', |
53 | 62 |
'page callback' => 'advanced_help_index_page', |
54 | 63 |
'access arguments' => array('view advanced help index'), |
64 |
'type' => MENU_NORMAL_ITEM, |
|
55 | 65 |
'weight' => 9, |
56 | 66 |
); |
57 | 67 |
} |
58 |
$items['advanced_help/search/%'] = array(
|
|
68 |
$items['help/ah/search/%'] = array(
|
|
59 | 69 |
'title' => 'Search help', |
60 | 70 |
'page callback' => 'advanced_help_search_view', |
61 | 71 |
'page arguments' => array('advanced_help'), |
... | ... | |
134 | 144 |
if (!isset($return)) { |
135 | 145 |
// Extract keys as remainder of path |
136 | 146 |
// Note: support old GET format of searches for existing links. |
137 |
$path = explode('/', $_GET['q'], 3);
|
|
147 |
$path = explode('/', $_GET['q'], 4);
|
|
138 | 148 |
$keys = empty($_REQUEST['keys']) ? '' : $_REQUEST['keys']; |
139 |
$return = count($path) == 3 ? $path[2] : $keys;
|
|
149 |
$return = count($path) == 4 ? $path[3] : $keys;
|
|
140 | 150 |
} |
141 | 151 |
return $return; |
142 | 152 |
} |
... | ... | |
149 | 159 |
return drupal_not_found(); |
150 | 160 |
} |
151 | 161 |
|
152 |
$breadcrumb[] = advanced_help_l(t('Help'), 'admin/advanced_help');
|
|
162 |
$breadcrumb[] = advanced_help_l(t('Advanced help'), 'admin/help/ah');
|
|
153 | 163 |
|
154 | 164 |
if (!isset($_POST['form_id'])) { |
155 | 165 |
$keys = advanced_help_search_get_keys(); |
... | ... | |
216 | 226 |
advanced_help_get_topic_hierarchy($topics); |
217 | 227 |
$items = advanced_help_get_tree($topics, $topics[$module]['']['children']); |
218 | 228 |
|
219 |
$breadcrumb[] = advanced_help_l(t('Help'), 'admin/advanced_help');
|
|
229 |
$breadcrumb[] = advanced_help_l(t('Advanced help'), 'admin/help/ah');
|
|
220 | 230 |
|
221 | 231 |
drupal_set_title(t('@module help index', array('@module' => advanced_help_get_module_name($module)))); |
222 | 232 |
$output['items-module'] = array( |
... | ... | |
247 | 257 |
else { |
248 | 258 |
$name = t($module_name); |
249 | 259 |
} |
250 |
$items[] = advanced_help_l($name, "admin/advanced_help/$module");
|
|
260 |
$items[] = advanced_help_l($name, "admin/help/ah/$module");
|
|
251 | 261 |
} |
252 | 262 |
} |
253 | 263 |
|
254 |
drupal_set_title(t('Module help index'));
|
|
264 |
drupal_set_title(t('Advanced help'));
|
|
255 | 265 |
$output['items-nomodule'] = array( |
256 | 266 |
'#theme' => 'item_list', |
257 | 267 |
'#items' => $items, |
... | ... | |
362 | 372 |
$form['modules'][$group][$module]['links']['help'] = array( |
363 | 373 |
'#type' => 'link', |
364 | 374 |
'#title' => t('Help'), |
365 |
'#href' => "admin/advanced_help/$module",
|
|
375 |
'#href' => "admin/help/ah/$module",
|
|
366 | 376 |
'#options' => array( |
367 | 377 |
'attributes' => array( |
368 | 378 |
'class' => array('module-link', 'module-link-help'), |
... | ... | |
383 | 393 |
*/ |
384 | 394 |
function advanced_help_search_form($form, &$form_state, $keys = '') { |
385 | 395 |
module_load_include('inc', 'search', 'search.pages'); |
386 |
$form = search_form($form, $form_state, 'admin/advanced_help', $keys, 'advanced_help', t('Search help'));
|
|
396 |
$form = search_form($form, $form_state, 'admin/help/ah', $keys, 'advanced_help', t('Search help'));
|
|
387 | 397 |
|
388 | 398 |
$form['basic']['inline']['submit']['#validate'] = array('search_form_validate'); |
389 | 399 |
$form['basic']['inline']['submit']['#submit'] = array('advanced_help_search_form_submit'); |
... | ... | |
404 | 414 |
$popup = !empty($_GET['popup']) && user_access('view advanced help popup'); |
405 | 415 |
|
406 | 416 |
if ($popup) { |
407 |
$form_state['redirect'] = array('advanced_help/search/' . $keys, array('query' => array('popup' => 'true')));
|
|
417 |
$form_state['redirect'] = array('help/ah/search/' . $keys, array('query' => array('popup' => 'true')));
|
|
408 | 418 |
} |
409 | 419 |
else { |
410 |
$form_state['redirect'] = 'advanced_help/search/' . $keys;
|
|
420 |
$form_state['redirect'] = 'help/ah/search/' . $keys;
|
|
411 | 421 |
} |
412 | 422 |
} |
413 | 423 |
|
... | ... | |
477 | 487 |
$breadcrumb[] = advanced_help_l($parent['title'], "help/$pmodule/$ptopic"); |
478 | 488 |
} |
479 | 489 |
|
480 |
$breadcrumb[] = advanced_help_l(advanced_help_get_module_name($pmodule), "admin/advanced_help/$pmodule");
|
|
481 |
$breadcrumb[] = advanced_help_l(t('Help'), "admin/advanced_help");
|
|
490 |
$breadcrumb[] = advanced_help_l(advanced_help_get_module_name($pmodule), "admin/help/ah/$pmodule");
|
|
491 |
$breadcrumb[] = advanced_help_l(t('Help'), "admin/help/ah");
|
|
482 | 492 |
|
483 | 493 |
$output = advanced_help_view_topic($module, $topic, $popup); |
484 | 494 |
if (empty($output)) { |
... | ... | |
646 | 656 |
} |
647 | 657 |
} |
648 | 658 |
else { |
649 |
$output = '<div class="advanced-help-topic"><pre class="readme">' . check_plain($output) . '</pre></div>'; |
|
659 |
$readme = ''; |
|
660 |
if ('md' == $ext) { |
|
661 |
$readme .= |
|
662 |
'<p>' . |
|
663 |
t('If you install the !module module, the text below will be filtered by the module, producing rich text.', |
|
664 |
array('!module' => l(t('Markdown filter'), |
|
665 |
'https://www.drupal.org/project/markdown', |
|
666 |
array('attributes' => array('title' => t('Link to project.')))))) . '</p>'; |
|
667 |
} |
|
668 |
$readme .= |
|
669 |
'<div class="advanced-help-topic"><pre class="readme">' . check_plain($output) . '</pre></div>'; |
|
670 |
$output = $readme; |
|
650 | 671 |
} |
651 | 672 |
return $output; |
652 | 673 |
} |
... | ... | |
705 | 726 |
$up = "help/$parent[0]/$parent[1]"; |
706 | 727 |
} |
707 | 728 |
else { |
708 |
$up = "admin/advanced_help/$module";
|
|
729 |
$up = "admin/help/ah/$module";
|
|
709 | 730 |
} |
710 | 731 |
|
711 | 732 |
$siblings = $topics[$parent_module][$parent_topic]['children']; |
... | ... | |
1109 | 1130 |
$variables['content'] = drupal_render($variables['content']); |
1110 | 1131 |
} |
1111 | 1132 |
// Closure should be filled last. |
1112 |
$variables['closure'] = theme('closure'); |
|
1133 |
// There has never been a theme hook for closure (going back to |
|
1134 |
// first release 2008-04-17). Unable to figure out its purpose. |
|
1135 |
// $variables['closure'] = theme('closure'); |
|
1113 | 1136 |
} |
1114 | 1137 |
|
1115 | 1138 |
/** |
Also available in: Unified diff
Weekly update of contrib modules