r14212 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r14211‎ | r14212 | r14213 >
Date:03:51, 14 May 2006
Author:robchurch
Status:old
Tags:
Comment:
(bug 5845) Introduce BASEPAGENAME and BASEPAGENAMEE magic words
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -2098,6 +2098,10 @@
20992099 return $this->mTitle->getSubpageText();
21002100 case MAG_SUBPAGENAMEE:
21012101 return $this->mTitle->getSubpageUrlForm();
 2102+ case MAG_BASEPAGENAME:
 2103+ return $this->mTitle->getBaseText();
 2104+ case MAG_BASEPAGENAMEE:
 2105+ return wfUrlEncode( str_replace( ' ', '_', $this->mTitle->getBaseText() ) );
21022106 case MAG_TALKPAGENAME:
21032107 if( $this->mTitle->canTalk() ) {
21042108 $talkPage = $this->mTitle->getTalkPage();
Index: trunk/phase3/includes/MagicWord.php
@@ -86,6 +86,8 @@
8787 'MAG_NEWSECTIONLINK',
8888 'MAG_NUMBEROFPAGES',
8989 'MAG_CURRENTVERSION',
 90+ 'MAG_BASEPAGENAME',
 91+ 'MAG_BASEPAGENAMEE',
9092 );
9193 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
9294 wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
@@ -134,6 +136,8 @@
135137 MAG_NEWSECTIONLINK,
136138 MAG_NUMBEROFPAGES,
137139 MAG_CURRENTVERSION,
 140+ MAG_BASEPAGENAME,
 141+ MAG_BASEPAGENAMEE,
138142 );
139143 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
140144 wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
Index: trunk/phase3/includes/Title.php
@@ -692,6 +692,21 @@
693693 }
694694
695695 /**
 696+ * Get the base name, i.e. the leftmost parts before the /
 697+ * @return string Base name
 698+ */
 699+ function getBaseText() {
 700+ global $wgNamespacesWithSubpages;
 701+ if( isset( $wgNamespacesWithSubpages[ $this->mNamespace] ) && $wgNamespacesWithSubpages[ $this->mNamespace ] ) {
 702+ $parts = explode( '/', $this->getText() );
 703+ unset( $parts[ count( $parts ) - 1 ] );
 704+ return implode( '/', $parts );
 705+ } else {
 706+ return $this->getText();
 707+ }
 708+ }
 709+
 710+ /**
696711 * Get the lowest-level subpage name, i.e. the rightmost part after /
697712 * @return string Subpage name
698713 */
Index: trunk/phase3/RELEASE-NOTES
@@ -261,6 +261,7 @@
262262 * (bug 5935) Improvement to German localisation (de)
263263 * (bug 5937) Register links from gallery captions with the parent parser output
264264 object so that link tables receive those updates too
 265+* (bug 5845) Introduce BASEPAGENAME and BASEPAGENAMEE magic words
265266
266267 == Compatibility ==
267268
Index: trunk/phase3/languages/Language.php
@@ -242,6 +242,8 @@
243243 MAG_FULLPAGENAMEE => array( 1, 'FULLPAGENAMEE' ),
244244 MAG_SUBPAGENAME => array( 1, 'SUBPAGENAME' ),
245245 MAG_SUBPAGENAMEE => array( 1, 'SUBPAGENAMEE' ),
 246+ MAG_BASEPAGENAME => array( 1, 'BASEPAGENAME' ),
 247+ MAG_BASEPAGENAMEE => array( 1, 'BASEPAGENAMEE' ),
246248 MAG_TALKPAGENAME => array( 1, 'TALKPAGENAME' ),
247249 MAG_TALKPAGENAMEE => array( 1, 'TALKPAGENAMEE' ),
248250 MAG_SUBJECTPAGENAME => array( 1, 'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ),

Status & tagging log