Extension:Admin Links/Hooks/AdminLinks

From Linux Web Expert

AdminLinks
Available from version ???

Define function:
public static function onAdminLinks( array( &$admin_links_tree ) ) { ... }
Attach hook:
$wgHooks['AdminLinks'][] = 'MyExtensionHooks::onAdminLinks';
Called from:File(s): AdminLinks / includes/AdminLinks.php
Function(s): execute

For more information about attaching hooks, see Manual:Hooks .
For examples of other extensions using this hook, see Category:AdminLinks extensions.

In order for an extension to add links and sections to the Admin Links page, it must define a new function, and register it with the "AdminLinks" hook. The registration should look like:

$wgHooks['AdminLinks'][] = 'my-function';

And the header of the function should look like:

function my-function(&$admin_links_tree)

The "tree" passed in to the function is of type ALTree. Each ALTree holds a group of sections, of type ALSection. A section is comprised of a group of rows, of type ALRow. A row, finally, holds a group of links or other text, each of type ALItem. The relevant methods for each are:

ALTree:

  • getSection($section_header) - retrieves the section of the tree that has this header
  • addSection($section, $next_section_header = null) - adds a section to this tree, before the section with the specified header, if one is specified

ALSection:

  • getRow($row_name) - retrieves the row from this section that has this header
  • addRow($row, $next_row_name = null) - adds a row to this section, before the row with the specified name, if one is specified

ALRow:

  • addItem($item, $next_item_label = null) - adds an item to this row, before the item with the specified label, if one is specified

ALItem:

  • newFromPage($page_name_or_title, $description = null, $params = null) - creates a new ALItem object that links to a wiki page, with the ability to specify a description and parameters; the first argument can be either a page name or a Title object
  • newFromSpecialPage($page_name) - creates a new ALItem object that links to a special page
  • newFromEditLink($page_name, $description) - creates a new ALItem object that links to the 'edit' action of a wiki page, with the specified text description
  • newFromExternalLink($url, $label) - creates a new ALItem object that links to a URL, with a specified text label