You are here

function advanced_help_get_topics in Advanced Help 5

Same name and namespace in other branches
  1. 6 advanced_help.module \advanced_help_get_topics()
  2. 7 advanced_help.module \advanced_help_get_topics()

Search the system for all available help topics.

6 calls to advanced_help_get_topics()
advanced_help_get_topic in ./advanced_help.module
Get the information for a single help topic.
advanced_help_index_page in ./advanced_help.module
Page callback to view the advanced help topic index.
advanced_help_search in ./advanced_help.module
Implementation of hook_search()
advanced_help_uasort in ./advanced_help.module
advanced_help_update_index in ./advanced_help.module
Implementation of hook_update_index().

... See full list

File

./advanced_help.module, line 561
advanced_help.module

Code

function advanced_help_get_topics() {
  static $topics = NULL;
  if (!isset($topics)) {
    $topics = array();
    $help_path = drupal_get_path('module', 'advanced_help') . '/modules';
    foreach (module_list() as $module) {
      $module_path = drupal_get_path('module', $module);
      $info = array();
      if (file_exists("{$module_path}/help/{$module}.help.ini")) {
        $path = "{$module_path}/help";
        $info = parse_ini_file("./{$module_path}/help/{$module}.help.ini", TRUE);
      }
      else {
        if (file_exists("{$help_path}/{$module}/{$module}.help.ini")) {
          $path = "{$help_path}/{$module}";
          $info = parse_ini_file("./{$help_path}/{$module}/{$module}.help.ini", TRUE);
        }
      }
      if (!empty($info)) {

        // Get translated titles:
        global $language;
        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();
        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;
          $topics[$module][$name] = array(
            'name' => $name,
            'title' => !empty($translation[$name]['title']) ? $translation[$name]['title'] : $topic['title'],
            'weight' => isset($topic['weight']) ? $topic['weight'] : 0,
            '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),
          );
        }
      }
    }
  }
  return $topics;
}