first import

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2012-10-05 13:50:00 +02:00
commit 95098773d5
1051 changed files with 309382 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;
}

63
modules/help/help.api.php Normal file
View File

@@ -0,0 +1,63 @@
<?php
/**
* @file
* Hooks provided by the Help module.
*/
/**
* @addtogroup hooks
* @{
*/
/**
* Provide online user help.
*
* By implementing hook_help(), a module can make documentation available to
* the user for the module as a whole, or for specific paths. Help for
* developers should usually be provided via function header comments in the
* code, or in special API example files.
*
* For a detailed usage example, see page_example.module.
*
* @param $path
* The router menu path, as defined in hook_menu(), for the help that is
* being requested; e.g., 'admin/people' or 'user/register'. If the router
* path includes a wildcard, then this will appear in $path as %, even if it
* is a named %autoloader wildcard in the hook_menu() implementation; for
* example, node pages would have $path equal to 'node/%' or 'node/%/view'.
* To provide a help page for a whole module with a listing on admin/help,
* your hook implementation should match a path with a special descriptor
* after a "#" sign:
* 'admin/help#modulename'
* The main module help text, displayed on the admin/help/modulename
* page and linked to from the admin/help page.
* @param $arg
* An array that corresponds to the return value of the arg() function, for
* modules that want to provide help that is specific to certain values
* of wildcards in $path. For example, you could provide help for the path
* 'user/1' by looking for the path 'user/%' and $arg[1] == '1'. This given
* array should always be used rather than directly invoking arg(), because
* your hook implementation may be called for other purposes besides building
* the current page's help. Note that depending on which module is invoking
* hook_help, $arg may contain only empty strings. Regardless, $arg[0] to
* $arg[11] will always be set.
*
* @return
* A localized string containing the help text.
*/
function hook_help($path, $arg) {
switch ($path) {
// Main module help for the block module
case 'admin/help#block':
return '<p>' . t('Blocks are boxes of content rendered into an area, or region, of a web page. The default theme Bartik, for example, implements the regions "Sidebar first", "Sidebar second", "Featured", "Content", "Header", "Footer", etc., and a block may appear in any one of these areas. The <a href="@blocks">blocks administration page</a> provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions.', array('@blocks' => url('admin/structure/block'))) . '</p>';
// Help for another path in the block module
case 'admin/structure/block':
return '<p>' . t('This page provides a drag-and-drop interface for assigning a block to a region, and for controlling the order of blocks within regions. Since not all themes implement the same regions, or display regions in the same way, blocks are positioned on a per-theme basis. Remember that your changes will not be saved until you click the <em>Save blocks</em> button at the bottom of the page.') . '</p>';
}
}
/**
* @} End of "addtogroup hooks".
*/

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 2012-08-01
version = "7.15"
project = "drupal"
datestamp = "1343839327"

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', t('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>', t('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, t('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', t('[' . $module . '] Title was displayed'));
$this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', t('[' . $module . '] Heading was displayed'));
}
}
}
/**
* 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', t('Making sure the test module menu_test does not display a help link in admin/help'));
}
}