annotate modules/admin_menu/admin_menu.api.php @ 6:a75ead649730

added biblio, admin_menu and reference modules
author danieleb <danielebarchiesi@me.com>
date Fri, 20 Sep 2013 11:18:21 +0100
parents
children
rev   line source
danielebarchiesi@6 1 <?php
danielebarchiesi@6 2
danielebarchiesi@6 3 /**
danielebarchiesi@6 4 * @file
danielebarchiesi@6 5 * API documentation for Administration menu.
danielebarchiesi@6 6 */
danielebarchiesi@6 7
danielebarchiesi@6 8 /**
danielebarchiesi@6 9 * Provide expansion arguments for dynamic menu items.
danielebarchiesi@6 10 *
danielebarchiesi@6 11 * The map items must be keyed by the dynamic path to expand, i.e. a menu path
danielebarchiesi@6 12 * containing one or more '%' placeholders. Each map item may have the following
danielebarchiesi@6 13 * properties:
danielebarchiesi@6 14 * - parent: The parent menu path to link the expanded items to.
danielebarchiesi@6 15 * - arguments: An array of argument sets that will be used in the expansion.
danielebarchiesi@6 16 * Each set consists of an array of one or more placeholders, which again is
danielebarchiesi@6 17 * an array of possible expansion values. Upon expansion, each argument is
danielebarchiesi@6 18 * combined with every other argument from the set (technically, the cartesian
danielebarchiesi@6 19 * product of all arguments). The expansion values may be empty; that is, you
danielebarchiesi@6 20 * do not need to insert logic to skip map items for which no values exist,
danielebarchiesi@6 21 * since Administration menu will take care of that.
danielebarchiesi@6 22 *
danielebarchiesi@6 23 * @see admin_menu.map.inc
danielebarchiesi@6 24 */
danielebarchiesi@6 25 function hook_admin_menu_map() {
danielebarchiesi@6 26 // Expand content types below Structure > Content types.
danielebarchiesi@6 27 // The key denotes the dynamic path to expand to multiple menu items.
danielebarchiesi@6 28 $map['admin/structure/types/manage/%node_type'] = array(
danielebarchiesi@6 29 // Link generated items directly to the "Content types" item.
danielebarchiesi@6 30 'parent' => 'admin/structure/types',
danielebarchiesi@6 31 // Create expansion arguments for the '%node_type' placeholder.
danielebarchiesi@6 32 'arguments' => array(
danielebarchiesi@6 33 array(
danielebarchiesi@6 34 '%node_type' => array_keys(node_type_get_types()),
danielebarchiesi@6 35 ),
danielebarchiesi@6 36 ),
danielebarchiesi@6 37 );
danielebarchiesi@6 38 return $map;
danielebarchiesi@6 39 }
danielebarchiesi@6 40
danielebarchiesi@6 41 /**
danielebarchiesi@6 42 * Add to the administration menu content before it is rendered.
danielebarchiesi@6 43 *
danielebarchiesi@6 44 * Only use this hook to add new data to the menu structure. Use
danielebarchiesi@6 45 * hook_admin_menu_output_alter() to *alter* existing data.
danielebarchiesi@6 46 *
danielebarchiesi@6 47 * @param array $content
danielebarchiesi@6 48 * A structured array suitable for drupal_render(), potentially containing:
danielebarchiesi@6 49 * - menu: The administrative menu of links below the path 'admin/*'.
danielebarchiesi@6 50 * - icon: The icon menu.
danielebarchiesi@6 51 * - account: The user account name and log out link.
danielebarchiesi@6 52 * - users: The user counter.
danielebarchiesi@6 53 * Additionally, these special properties:
danielebarchiesi@6 54 * - #components: The actual components contained in $content are configurable
danielebarchiesi@6 55 * and depend on the 'admin_menu_components' configuration value. #components
danielebarchiesi@6 56 * holds a copy of that for convenience.
danielebarchiesi@6 57 * - #complete: A Boolean indicating whether the complete menu should be built,
danielebarchiesi@6 58 * ignoring the current configuration in #components.
danielebarchiesi@6 59 * Passed by reference.
danielebarchiesi@6 60 *
danielebarchiesi@6 61 * @see hook_admin_menu_output_alter()
danielebarchiesi@6 62 * @see admin_menu_links_menu()
danielebarchiesi@6 63 * @see admin_menu_links_icon()
danielebarchiesi@6 64 * @see admin_menu_links_user()
danielebarchiesi@6 65 * @see theme_admin_menu_links()
danielebarchiesi@6 66 */
danielebarchiesi@6 67 function hook_admin_menu_output_build(&$content) {
danielebarchiesi@6 68 // In case your implementation provides a configurable component, check
danielebarchiesi@6 69 // whether the component should be displayed:
danielebarchiesi@6 70 if (empty($content['#components']['shortcut.links']) && !$content['#complete']) {
danielebarchiesi@6 71 return;
danielebarchiesi@6 72 }
danielebarchiesi@6 73
danielebarchiesi@6 74 // Add new top-level item to the menu.
danielebarchiesi@6 75 if (isset($content['menu'])) {
danielebarchiesi@6 76 $content['menu']['myitem'] = array(
danielebarchiesi@6 77 '#title' => t('My item'),
danielebarchiesi@6 78 // #attributes are used for list items (LI).
danielebarchiesi@6 79 '#attributes' => array('class' => array('mymodule-myitem')),
danielebarchiesi@6 80 '#href' => 'mymodule/path',
danielebarchiesi@6 81 // #options are passed to l().
danielebarchiesi@6 82 '#options' => array(
danielebarchiesi@6 83 'query' => drupal_get_destination(),
danielebarchiesi@6 84 // Apply a class on the link (anchor).
danielebarchiesi@6 85 'attributes' => array('class' => array('myitem-link-anchor')),
danielebarchiesi@6 86 ),
danielebarchiesi@6 87 // #weight controls the order of links in the resulting item list.
danielebarchiesi@6 88 '#weight' => 50,
danielebarchiesi@6 89 );
danielebarchiesi@6 90 }
danielebarchiesi@6 91 // Add link to the icon menu to manually run cron.
danielebarchiesi@6 92 if (isset($content['icon'])) {
danielebarchiesi@6 93 $content['icon']['myitem']['cron'] = array(
danielebarchiesi@6 94 '#title' => t('Run cron'),
danielebarchiesi@6 95 '#access' => user_access('administer site configuration'),
danielebarchiesi@6 96 '#href' => 'admin/reports/status/run-cron',
danielebarchiesi@6 97 );
danielebarchiesi@6 98 }
danielebarchiesi@6 99 }
danielebarchiesi@6 100
danielebarchiesi@6 101 /**
danielebarchiesi@6 102 * Change the administration menu content before it is rendered.
danielebarchiesi@6 103 *
danielebarchiesi@6 104 * Only use this hook to alter existing data in the menu structure. Use
danielebarchiesi@6 105 * hook_admin_menu_output_build() to *add* new data.
danielebarchiesi@6 106 *
danielebarchiesi@6 107 * @param array $content
danielebarchiesi@6 108 * A structured array suitable for drupal_render(). Passed by reference.
danielebarchiesi@6 109 *
danielebarchiesi@6 110 * @see hook_admin_menu_output_build()
danielebarchiesi@6 111 */
danielebarchiesi@6 112 function hook_admin_menu_output_alter(&$content) {
danielebarchiesi@6 113 }
danielebarchiesi@6 114
danielebarchiesi@6 115 /**
danielebarchiesi@6 116 * Return content to be replace via JS in the cached menu output.
danielebarchiesi@6 117 *
danielebarchiesi@6 118 * @param bool $complete
danielebarchiesi@6 119 * A Boolean indicating whether all available components of the menu will be
danielebarchiesi@6 120 * output and the cache will be skipped.
danielebarchiesi@6 121 *
danielebarchiesi@6 122 * @return array
danielebarchiesi@6 123 * An associative array whose keys are jQuery selectors and whose values are
danielebarchiesi@6 124 * strings containing the replacement content.
danielebarchiesi@6 125 */
danielebarchiesi@6 126 function hook_admin_menu_replacements($complete) {
danielebarchiesi@6 127 $items = array();
danielebarchiesi@6 128 // If the complete menu is output, then it is uncached and will contain the
danielebarchiesi@6 129 // current counts already.
danielebarchiesi@6 130 if (!$complete) {
danielebarchiesi@6 131 // Check whether the users count component is enabled.
danielebarchiesi@6 132 $components = variable_get('admin_menu_components', array());
danielebarchiesi@6 133 if (!empty($components['admin_menu.users']) && ($user_count = admin_menu_get_user_count())) {
danielebarchiesi@6 134 // Replace the counters in the cached menu output with current counts.
danielebarchiesi@6 135 $items['.admin-menu-users a'] = $user_count;
danielebarchiesi@6 136 }
danielebarchiesi@6 137 }
danielebarchiesi@6 138 return $items;
danielebarchiesi@6 139 }
danielebarchiesi@6 140
danielebarchiesi@6 141 /**
danielebarchiesi@6 142 * Inform about additional module-specific caches that can be cleared.
danielebarchiesi@6 143 *
danielebarchiesi@6 144 * Administration menu uses this hook to gather information about available
danielebarchiesi@6 145 * caches that can be flushed individually. Each returned item forms a separate
danielebarchiesi@6 146 * menu link below the "Flush all caches" link in the icon menu.
danielebarchiesi@6 147 *
danielebarchiesi@6 148 * @return array
danielebarchiesi@6 149 * An associative array whose keys denote internal identifiers for a
danielebarchiesi@6 150 * particular caches (which can be freely defined, but should be in a module's
danielebarchiesi@6 151 * namespace) and whose values are associative arrays containing:
danielebarchiesi@6 152 * - title: The name of the cache, without "cache" suffix. This label is
danielebarchiesi@6 153 * output as link text, but also for the "!title cache cleared."
danielebarchiesi@6 154 * confirmation message after flushing the cache; make sure it works and
danielebarchiesi@6 155 * makes sense to users in both locations.
danielebarchiesi@6 156 * - callback: The name of a function to invoke to flush the individual cache.
danielebarchiesi@6 157 */
danielebarchiesi@6 158 function hook_admin_menu_cache_info() {
danielebarchiesi@6 159 $caches['update'] = array(
danielebarchiesi@6 160 'title' => t('Update data'),
danielebarchiesi@6 161 'callback' => '_update_cache_clear',
danielebarchiesi@6 162 );
danielebarchiesi@6 163 return $caches;
danielebarchiesi@6 164 }