function jqp_help in jQuery Plugin Handler (JQP) 6.2
Implementation of hook_help().
File
- ./
jqp.module, line 11 - Used to register and load javascript libraries and plugins from a cetral point
Code
function jqp_help($path, $arg) {
switch ($path) {
case 'admin/help#jqp':
$output[] = '<p>' . t('Javascript libraries can either be built up from an single javascript file, a javascript plugin or a set of javascript files, sometimes with stylesheets included. These libraries can be used to extend the look and feel of modules.') . '</p>';
$output[] = '<p>' . t('Libraries can be registered in several ways:') . '</p>';
$output[] = '<ul>';
$output[] = ' <li>';
$output[] = '<h4>' . t('.info files') . '</h4>';
$output[] = '<p>' . t('This is the preferred way of registering a library into javascript libraries\' cache. During installation, jQp module will check for the presence of a js_libraries folder in one of the following directories:') . '</p>';
$output[] = '<ul>';
$output[] = ' <li>js_libraries</li>';
$output[] = ' <li>sites/all/js_libraries</li>';
$output[] = ' <li>$profile/install_profile/js_libraries</li>';
$output[] = ' <li>$conf_path/js_libraries</li>';
$output[] = ' <li>$file_directory_path/js_libraries</li>';
$output[] = '</ul>';
$output[] = '<p>' . t('If this directory exists, this should be the place to place all libraries as separate folders, containing all required files for the library. If a library folder contains a .info file, this will be used to register the library. Here\'s an example of how a .info file should be written:', $replacements) . '</p>';
$output[] = '<pre>';
$output[] = '; $Id$';
$output[] = 'name = Library Name';
$output[] = 'description = Description of the library';
$output[] = 'project_url = http://www.library_project_page.org';
$output[] = 'stylesheets[][] = style.css';
$output[] = 'scripts[][] = jquery.test.min.js';
$output[] = 'scripts[1.4.4][] = jquery.test[1.4.4].min.js';
$output[] = 'scripts[1.4.4][] = drupal.js';
$output[] = '</pre>';
$output[] = '<p>' . t('This .info file will register two versions of this library (default and 1.4.4). style.css is added as a first element of the stylesheets array, and will therefore will have 0 as key. All elements of both the stylesheets and scripts array with a 0 key will be treated as the default version. Files with other keys, such as 1.4.4, will be handled as separate versions. If a specific version of a library is loaded, and there\'s no file type which overrides the default one, the default one is included automatically. Note that versions can include several files!') . '</p>';
$output[] = '</li>';
$output[] = '<li>';
$output[] = '<h4>' . t('hook_jqp()') . '</h4>';
$output[] = '<p>' . t('Modules can also register their own libraries using the provided hook function.') . '</p>';
$output[] = '<p><strong>' . t('Definition') . ':</strong></p>';
$output[] = '<p><code>hook_jqp(&$js_libraries)</code></p>';
$output[] = '<p><strong>' . t('Description') . ':</strong></p>';
$output[] = '<p>' . t('Provide other modules a hook to add custom libraries or alter already registered libraries.') . '</p>';
$output[] = '<p><strong>' . t('Parameters') . ':</strong></p>';
$output[] = '<p><code>$js_libraries</code>: ' . t('An associative array in which the library register is built up.') . '</p>';
$output[] = '<p><strong>' . t('Code') . ':</strong></p>';
$output[] = '<pre class="php">';
$output[] = '/**';
$output[] = ' * Implemantation of hook_jqp().';
$output[] = ' */';
$output[] = 'function hook_jqp(&$js_libraries) {';
$output[] = ' $js_libraries[\'plugin1\'] = array(';
$output[] = ' \'name\' => \'Plugin 1\',';
$output[] = ' \'description\' => \'This plugin is registered by a module.\',';
$output[] = ' \'project_url\' => \'http://www.library_project_page.org\',';
$output[] = ' \'scripts\' => array(';
$output[] = ' array(\'jquery.hoi.min.js\'), // This will have key 0, so it is the default version';
$output[] = ' \'1.4.3-BETA-3\' => array(\'jquery.hoi[2].min.js\'),';
$output[] = ' ),';
$output[] = ' \'stylesheets\' => array(';
$output[] = ' array(\'plugin1.css\'),';
$output[] = ' \'1.4.3-BETA-3\' => array(';
$output[] = ' \'plugin1[1.4.3-BETA-3].css\'';
$output[] = ' ),';
$output[] = ' ),';
$output[] = ' );';
$output[] = '}';
$output[] = '</pre>';
$output[] = '</li>';
$output[] = '<li>';
$output[] = '<h4>' . t('Loading a javascript library') . '</h4>';
$output[] = '<p>' . t('Loading a javascript library or plugin can be done using drupal_add_js_library().') . '</p>';
$output[] = '<p><strong>' . t('Definition') . ':</strong></p>';
$output[] = '<p><code>drupal_add_js_library($name, $version = 0, $options = array())</code></p>';
$output[] = '<p><strong>' . t('Description') . ':</strong></p>';
$output[] = '<p>' . t('Load a shared library from the javascript library directory.') . '</p>';
$output[] = '<p><strong>' . t('Parameters') . ':</strong></p>';
$output[] = '<p><code>$name</code>: ' . t('(required)') . " " . t('the name of the library or plugin to load.') . '</p>';
$output[] = '<p><code>$version</code>: ' . t('(optional)') . " " . t('the version of the library to load. If omitted the default version is loaded.') . '</p>';
$output[] = '<p><code>$options</code>: ' . t('(optional)') . " " . t('Array containing additional options to pass to drupal_add_js or drupal_add_css.') . '</p>';
$output[] = '<pre class="php">';
$output[] = ' array(';
$output[] = ' \'css\' => array($type = \'module\', $media = \'all\', $preprocess = TRUE),';
$output[] = ' \'js\' => array($type = \'module\', $scope = \'header\', $defer = FALSE, $cache = TRUE, $preprocess = TRUE),';
$output[] = ' );';
$output[] = '</pre>';
$output[] = '<p><strong>' . t('Example') . ':</strong></p>';
$output[] = '<p><code>drupal_add_js_library(\'beautytips\', \'0.9\', array(\'css\' => array(\'theme\', \'all\', FALSE)));</code></p>';
$output[] = '</li>';
$output[] = '<li>';
$output[] = '<h4>' . t('Administration pages') . '</h4>';
$output[] = '<p>' . t('After registering a library, the paths of the attached files can be changed at the !admin_pages. It is also possible to attach an detach files per version.', array(
'!admin_pages' => l('administration pages', 'admin/build/jqp'),
)) . '</p>';
$output[] = '</li>';
$output[] = '</ul>';
return join("\n", $output);
case 'admin/build/jqp':
$output[] = '<p>' . t('Javascript libraries can either be built up from an single javascript file, a javascript plugin or a set of javascript files, sometimes with stylesheets included. These libraries can be used to extend the look and feel of modules.') . '</p>';
$output[] = '<p>' . t('After registering a library, the paths of the attached files can be changed here. It is also possible to attach and detach files per version by clicking on the configure link.') . '</p>';
$output[] = '<p>' . t('You can completely rebuild the cache by clicking !rebuild link.', array(
'!rebuild' => l(t('this'), 'admin/build/jqp/rebuild_confirm'),
)) . '</p>';
return join("\n", $output);
}
}