Esempio n. 1
0
 /**
  * Prints a listing of admin tasks, organized by module.
  *
  * @return array
  *   A render array containing the listing.
  */
 public function index()
 {
     $module_info = system_get_info('module');
     foreach ($module_info as $module => $info) {
         $module_info[$module] = new \stdClass();
         $module_info[$module]->info = $info;
     }
     uasort($module_info, 'system_sort_modules_by_info_name');
     $menu_items = array();
     foreach ($module_info as $module => $info) {
         // Only display a section if there are any available tasks.
         if ($admin_tasks = system_get_module_admin_tasks($module, $info->info)) {
             // Sort links by title.
             uasort($admin_tasks, array('\\Drupal\\Component\\Utility\\SortArray', 'sortByTitleElement'));
             // Move 'Configure permissions' links to the bottom of each section.
             $permission_key = "user.admin_permissions.{$module}";
             if (isset($admin_tasks[$permission_key])) {
                 $permission_task = $admin_tasks[$permission_key];
                 unset($admin_tasks[$permission_key]);
                 $admin_tasks[$permission_key] = $permission_task;
             }
             $menu_items[$info->info['name']] = array($info->info['description'], $admin_tasks);
         }
     }
     $output = array('#theme' => 'system_admin_index', '#menu_items' => $menu_items);
     return $output;
 }
Esempio n. 2
0
 /**
  * Verifies the logged in user has access to the various help nodes.
  *
  * @param integer $response
  *   An HTTP response code.
  */
 protected function verifyHelp($response = 200)
 {
     $this->drupalGet('admin/index');
     $this->assertResponse($response);
     if ($response == 200) {
         $this->assertText('This page shows you all available administration tasks for each module.');
     } else {
         $this->assertNoText('This page shows you all available administration tasks for each module.');
     }
     foreach ($this->getModuleList() as $module => $name) {
         // View module help node.
         $this->drupalGet('admin/help/' . $module);
         $this->assertResponse($response);
         if ($response == 200) {
             $this->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array('%module' => $module)));
             $this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', format_string('%module heading was displayed', array('%module' => $module)));
             $admin_tasks = system_get_module_admin_tasks($module, system_get_info('module', $module));
             if (!empty($admin_tasks)) {
                 $this->assertText(t('@module administration pages', array('@module' => $name)));
             }
             foreach ($admin_tasks as $task) {
                 $this->assertLink($task['title']);
                 // Ensure there are no double escaped '&' or '<' characters.
                 $this->assertNoEscaped('&amp;', 'The help text does not have double escaped &amp;.');
                 $this->assertNoEscaped('&lt;', 'The help text does not have double escaped &lt;.');
                 // Ensure there are no escaped '<' characters.
                 $this->assertNoEscaped('<', 'The help text does not have single escaped &lt;.');
             }
             // Ensure there are no double escaped '&' or '<' characters.
             $this->assertNoEscaped('&amp;');
             $this->assertNoEscaped('&lt;');
             // Ensure there are no escaped '<' characters.
             $this->assertNoEscaped('<');
         }
     }
 }
Esempio n. 3
0
 /**
  * Prints a page listing general help for a module.
  *
  * @param string $name
  *   A module name to display a help page for.
  *
  * @return array
  *   A render array as expected by drupal_render().
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function helpPage($name)
 {
     $build = array();
     if ($this->moduleHandler()->implementsHook($name, 'help')) {
         $module_name = $this->moduleHandler()->getName($name);
         $build['#title'] = SafeMarkup::checkPlain($module_name);
         $temp = $this->moduleHandler()->invoke($name, 'help', array("help.page.{$name}", $this->routeMatch));
         if (empty($temp)) {
             $build['top']['#markup'] = $this->t('No help is available for module %module.', array('%module' => $module_name));
         } else {
             $build['top']['#markup'] = $temp;
         }
         // Only print list of administration pages if the module in question has
         // any such pages associated with it.
         $admin_tasks = system_get_module_admin_tasks($name, system_get_info('module', $name));
         if (!empty($admin_tasks)) {
             $links = array();
             foreach ($admin_tasks as $task) {
                 $link['url'] = $task['url'];
                 $link['title'] = $task['title'];
                 $links[] = $link;
             }
             $build['links'] = array('#theme' => 'links__help', '#heading' => array('level' => 'h3', 'text' => $this->t('@module administration pages', array('@module' => $module_name))), '#links' => $links);
         }
         return $build;
     } else {
         throw new NotFoundHttpException();
     }
 }
 /**
  * Prints a page listing general help for a module.
  *
  * @param string $name
  *   A module name to display a help page for.
  *
  * @return array
  *   A render array as expected by drupal_render().
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function helpPage($name)
 {
     $build = array();
     if ($this->moduleHandler()->implementsHook($name, 'help')) {
         $module_name = $this->moduleHandler()->getName($name);
         $build['#title'] = $module_name;
         $info = system_get_info('module', $name);
         if ($info['package'] === 'Core (Experimental)') {
             drupal_set_message($this->t('This module is experimental. <a href=":url">Experimental modules</a> are provided for testing purposes only. Use at your own risk.', [':url' => 'https://www.drupal.org/core/experimental']), 'warning');
         }
         $temp = $this->moduleHandler()->invoke($name, 'help', array("help.page.{$name}", $this->routeMatch));
         if (empty($temp)) {
             $build['top'] = ['#markup' => $this->t('No help is available for module %module.', array('%module' => $module_name))];
         } else {
             if (!is_array($temp)) {
                 $temp = ['#markup' => $temp];
             }
             $build['top'] = $temp;
         }
         // Only print list of administration pages if the module in question has
         // any such pages associated with it.
         $admin_tasks = system_get_module_admin_tasks($name, system_get_info('module', $name));
         if (!empty($admin_tasks)) {
             $links = array();
             foreach ($admin_tasks as $task) {
                 $link['url'] = $task['url'];
                 $link['title'] = $task['title'];
                 $links[] = $link;
             }
             $build['links'] = array('#theme' => 'links__help', '#heading' => array('level' => 'h3', 'text' => $this->t('@module administration pages', array('@module' => $module_name))), '#links' => $links);
         }
         return $build;
     } else {
         throw new NotFoundHttpException();
     }
 }