Extension:Subpage Fun

What can this extension do?
This extension provides your wiki with seven new parser functions/variables to get information about subpages you can't get with MediaWikis existing magic Words. Also, this extension has a slightly different concept about what is considered a subpage than MediaWikis existing functions.

You can read almost everything you need to know about MediaWiki subpages here. This extension goes one step further and says a subpage is not simply the part behind a slash (/). A page is only then a subpage when a parent page exists. This means a page AC/DC won't be a subpage as long as the page AC doesn't exist. Assuming the page AC/DC/Discography exists, the page AC/DC/Discography/1975/1976 would have the  1975/1976. The MediaWiki  variable would only output 1976 in this case which is nonsense since this page doesn't even exist.

For developers this extension provides the php class  which can be helpful to gather information about subpages within other extensions.

Usage
Subpage Fun defines,  ,  ,  ,   and. You can use them either like that as variables for the current page or you can use them with a parameter like  to use them for any page you want.


 * SUBPAGETITLE: The real name of a subpage, not only the part behind the last slash (/) like MediaWiki's SUBPAGENAME outputs it.
 * SUBPAGES: Outputs all Subpages as a comma separated list. This means all descendant pages, not only direct child pages. The output has no specific order.
 * PARENTPAGES: Outputs all ancestor pages as a comma separated list. The output begins with the top level page and ends with the direct parent page.
 * SIBLINGPAGES: Outputs all sibling pages of the same subpage level and tree as a comma separated list. The output has no specific order.
 * SUBPAGELEVEL: The subpage level of a page. A normal page which is no subpage at all would return 0.
 * NUMBEROFSUBPAGES:	How many subpages does a page have. Also works with subpages to see how many subpages they have. Counts all descendant pages, not only direct child pages.
 * TOPLEVELPAGE: The top level page which is the page with subpage level 0 within the same subpage tree.

Advanced list formatting
,,   have a list output. You can use this output for further use with Extension:ArrayExtension for example.

There are several more parameters for each of those functions beside 1 which allows to define the page to get the information from. If parameter linked has any value at all the pages in the list become links. Parameter sep allows to define a different list separator than the default separator. Parameter depth works with,   and. It allows to define the relative depth to the most distant page. If the depth is set to a value smaller than 0 or not set, the functions will output everything, for  a negative value will return that many elements starting from the top-level page.

 Examples: 


 * will output the currents page direct parent page as link.
 * will give the same result as  with the only difference that if   is the top-level page already, an empty string is returned.
 * will output all direct subpages below somepage seperated by a simple space.

Developers support
Developers can use some static php functions from the SubpageInfo class which delivers information about subpages which the MediaWiki Title class doesn't provide.

Download instructions
You can take the code from /Source code. Create a new directory SubpageFun in your MediaWiki's extension directory and put the code in a new file SubpageFun.php there.

Installation
To install this extension, add the following to LocalSettings.php:

Change Log
the latest Subpage Fun extension has been tested on MediaWiki version 1.15

 History: 


 * Sep. 16, 2011 -- Version 0.4:
 * Cleaned-up code, gotten rid of global functions. All useful functions for other extension developers are in  class, parser function/variables stuff has its own   class now.
 * Function  now allows the use of parameter depth.
 * Function  now allows negative depth values to return that many pages starting from the top-level parent.
 * If parameter depth is,   will return  ,   and   an empty string.
 * Named function Arguments won't accidentally be threated as parameter 1 anymore if no value is given (e.g.  is possible without confusions now)


 * Mar. 24, 2011 -- Version 0.3.2.1: Fit for PHP 5.3: Split function replaced by preg_split.


 * Mar. 24, 2011 -- Version 0.3.2:
 * won't output any namespace anymore.
 * Bug solved in which page titles with some special characters were causing problems.


 * Dec. 30, 2009 -- Version 0.3.1: Minor change in extension meta infos for proper appearance in special:version. Extension status is now stable.


 * Dec. 10, 2009 -- Version 0.3.0:
 * Changed "2" and "3" parameters for advanced list formations against named parameters linked and sep.
 * Added named parameter depth for  and


 * Dec. 9, 2009 -- Version 0.2.0: Variable/function  added.


 * Dec. 9, 2009 -- Version 0.1.0: First release of Subpage Fun. Comes with the six variables/functions,  ,  ,   and.