First commit

This commit is contained in:
Theodotos Andreou 2018-01-14 13:10:16 +00:00
commit c6e2478c40
13918 changed files with 2303184 additions and 0 deletions

10
modules/help/help-rtl.css Normal file
View file

@ -0,0 +1,10 @@
.help-items {
float: right;
padding-right: 0;
padding-left: 3%;
}
.help-items-last {
padding-right: 0;
padding-left: 0;
}

View file

@ -0,0 +1,86 @@
<?php
/**
* @file
* Admin page callbacks for the help module.
*/
/**
* Menu callback; prints a page listing a glossary of Drupal terminology.
*/
function help_main() {
// Add CSS
drupal_add_css(drupal_get_path('module', 'help') . '/help.css');
$output = '<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>' . help_links_as_list();
return $output;
}
/**
* Menu callback; prints a page listing general help for a module.
*
* @param $name
* A module name to display a help page for.
*/
function help_page($name) {
$output = '';
if (module_hook($name, 'help')) {
$info = system_get_info('module');
drupal_set_title($info[$name]['name']);
$temp = module_invoke($name, 'help', "admin/help#$name", drupal_help_arg());
if (empty($temp)) {
$output .= t("No help is available for module %module.", array('%module' => $info[$name]['name']));
}
else {
$output .= $temp;
}
// Only print list of administration pages if the module in question has
// any such pages associated to it.
$admin_tasks = system_get_module_admin_tasks($name, $info[$name]);
if (!empty($admin_tasks)) {
$links = array();
foreach ($admin_tasks as $task) {
$links[] = l($task['title'], $task['link_path'], $task['localized_options']);
}
$output .= theme('item_list', array('items' => $links, 'title' => t('@module administration pages', array('@module' => $info[$name]['name']))));
}
}
return $output;
}
/**
* Provides a formatted list of available help topics.
*
* @return
* A string containing the formatted list.
*/
function help_links_as_list() {
$empty_arg = drupal_help_arg();
$module_info = system_rebuild_module_data();
$modules = array();
foreach (module_implements('help', TRUE) as $module) {
if (module_invoke($module, 'help', "admin/help#$module", $empty_arg)) {
$modules[$module] = $module_info[$module]->info['name'];
}
}
asort($modules);
// Output pretty four-column list.
$count = count($modules);
$break = ceil($count / 4);
$output = '<div class="clearfix"><div class="help-items"><ul>';
$i = 0;
foreach ($modules as $module => $name) {
$output .= '<li>' . l($name, 'admin/help/' . $module) . '</li>';
if (($i + 1) % $break == 0 && ($i + 1) != $count) {
$output .= '</ul></div><div class="help-items' . ($i + 1 == $break * 3 ? ' help-items-last' : '') . '"><ul>';
}
$i++;
}
$output .= '</ul></div></div>';
return $output;
}

9
modules/help/help.css Normal file
View file

@ -0,0 +1,9 @@
.help-items {
float: left; /* LTR */
width: 22%;
padding-right: 3%; /* LTR */
}
.help-items-last {
padding-right: 0; /* LTR */
}

12
modules/help/help.info Normal file
View file

@ -0,0 +1,12 @@
name = Help
description = Manages the display of online help.
package = Core
version = VERSION
core = 7.x
files[] = help.test
; Information added by Drupal.org packaging script on 2017-06-21
version = "7.56"
project = "drupal"
datestamp = "1498069849"

63
modules/help/help.module Normal file
View file

@ -0,0 +1,63 @@
<?php
/**
* @file
* Manages displaying online help.
*/
/**
* Implements hook_menu().
*/
function help_menu() {
$items['admin/help'] = array(
'title' => 'Help',
'description' => 'Reference for usage, configuration, and modules.',
'page callback' => 'help_main',
'access arguments' => array('access administration pages'),
'weight' => 9,
'file' => 'help.admin.inc',
);
foreach (module_implements('help', TRUE) as $module) {
$items['admin/help/' . $module] = array(
'title' => $module,
'page callback' => 'help_page',
'page arguments' => array(2),
'access arguments' => array('access administration pages'),
'type' => MENU_VISIBLE_IN_BREADCRUMB,
'file' => 'help.admin.inc',
);
}
return $items;
}
/**
* Implements hook_help().
*/
function help_help($path, $arg) {
switch ($path) {
case 'admin/help':
$output = '<p>' . t('Follow these steps to set up and start using your website:') . '</p>';
$output .= '<ol>';
$output .= '<li>' . t('<strong>Configure your website</strong> Once logged in, visit the <a href="@admin">administration section</a>, where you can <a href="@config">customize and configure</a> all aspects of your website.', array('@admin' => url('admin'), '@config' => url('admin/config'))) . '</li>';
$output .= '<li>' . t('<strong>Enable additional functionality</strong> Next, visit the <a href="@modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="@download_modules">Drupal modules download section</a>.', array('@modules' => url('admin/modules'), '@download_modules' => 'http://drupal.org/project/modules')) . '</li>';
$output .= '<li>' . t('<strong>Customize your website design</strong> To change the "look and feel" of your website, visit the <a href="@themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="@download_themes">Drupal themes download section</a>.', array('@themes' => url('admin/appearance'), '@download_themes' => 'http://drupal.org/project/themes')) . '</li>';
$output .= '<li>' . t('<strong>Start posting content</strong> Finally, you can <a href="@content">add new content</a> for your website.', array('@content' => url('node/add'))) . '</li>';
$output .= '</ol>';
$output .= '<p>' . t('For more information, refer to the specific topics listed in the next section or to the <a href="@handbook">online Drupal handbooks</a>. You may also post at the <a href="@forum">Drupal forum</a> or view the wide range of <a href="@support">other support options</a> available.', array('@help' => url('admin/help'), '@handbook' => 'http://drupal.org/documentation', '@forum' => 'http://drupal.org/forum', '@support' => 'http://drupal.org/support')) . '</p>';
return $output;
case 'admin/help#help':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Help module provides <a href="@help-page">Help reference pages</a> and context-sensitive advice to guide you through the use and configuration of modules. It is a starting point for the online <a href="@handbook">Drupal handbooks</a>. The handbooks contain more extensive and up-to-date information, are annotated with user-contributed comments, and serve as the definitive reference point for all Drupal documentation. For more information, see the online handbook entry for the <a href="@help">Help module</a>.', array('@help' => 'http://drupal.org/documentation/modules/help/', '@handbook' => 'http://drupal.org/documentation', '@help-page' => url('admin/help'))) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Providing a help reference') . '</dt>';
$output .= '<dd>' . t('The Help module displays explanations for using each module listed on the main <a href="@help">Help reference page</a>.', array('@help' => url('admin/help'))) . '</dd>';
$output .= '<dt>' . t('Providing context-sensitive help') . '</dt>';
$output .= '<dd>' . t('The Help module displays context-sensitive advice and explanations on various pages.') . '</dd>';
$output .= '</dl>';
return $output;
}
}

137
modules/help/help.test Normal file
View file

@ -0,0 +1,137 @@
<?php
/**
* @file
* Tests for help.module.
*/
/**
* Tests help display and user access for all modules implementing help.
*/
class HelpTestCase extends DrupalWebTestCase {
/**
* The admin user that will be created.
*/
protected $big_user;
/**
* The anonymous user that will be created.
*/
protected $any_user;
public static function getInfo() {
return array(
'name' => 'Help functionality',
'description' => 'Verify help display and user access to help based on permissions.',
'group' => 'Help',
);
}
function setUp() {
parent::setUp('blog', 'poll');
$this->getModuleList();
// Create users.
$this->big_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer permissions'));
$this->any_user = $this->drupalCreateUser(array());
}
/**
* Logs in users, creates dblog events, and tests dblog functionality.
*/
function testHelp() {
// Login the admin user.
$this->drupalLogin($this->big_user);
$this->verifyHelp();
// Login the regular user.
$this->drupalLogin($this->any_user);
$this->verifyHelp(403);
// Check for css on admin/help.
$this->drupalLogin($this->big_user);
$this->drupalGet('admin/help');
$this->assertRaw(drupal_get_path('module', 'help') . '/help.css', 'The help.css file is present in the HTML.');
// Verify that introductory help text exists, goes for 100% module coverage.
$this->assertRaw(t('For more information, refer to the specific topics listed in the next section or to the <a href="@drupal">online Drupal handbooks</a>.', array('@drupal' => 'http://drupal.org/documentation')), 'Help intro text correctly appears.');
// Verify that help topics text appears.
$this->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', 'Help topics text correctly appears.');
// Make sure links are properly added for modules implementing hook_help().
foreach ($this->modules as $module => $name) {
$this->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
}
}
/**
* Verifies the logged in user has access to the various help nodes.
*
* @param integer $response
* An HTTP response code.
*/
protected function verifyHelp($response = 200) {
foreach ($this->modules 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)));
}
}
}
/**
* Gets the list of enabled modules that implement hook_help().
*
* @return array
* A list of enabled modules.
*/
protected function getModuleList() {
$this->modules = array();
$result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
foreach ($result as $module) {
if (file_exists($module->filename) && function_exists($module->name . '_help')) {
$fullname = unserialize($module->info);
$this->modules[$module->name] = $fullname['name'];
}
}
}
}
/**
* Tests a module without help to verify it is not listed in the help page.
*/
class NoHelpTestCase extends DrupalWebTestCase {
/**
* The user who will be created.
*/
protected $big_user;
public static function getInfo() {
return array(
'name' => 'No help',
'description' => 'Verify no help is displayed for modules not providing any help.',
'group' => 'Help',
);
}
function setUp() {
// Use one of the test modules that do not implement hook_help().
parent::setUp('menu_test');
$this->big_user = $this->drupalCreateUser(array('access administration pages'));
}
/**
* Ensures modules not implementing help do not appear on admin/help.
*/
function testMainPageNoHelp() {
$this->drupalLogin($this->big_user);
$this->drupalGet('admin/help');
$this->assertNoText('Hook menu tests', 'Making sure the test module menu_test does not display a help link in admin/help');
}
}