Content-Length: 29160 | pFad | https://www.mediawiki.org/wiki/Special:Code/MediaWiki/46662

r46662 MediaWiki - Code Review archive

r46662 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46661‎ | r46662 | r46663 >
Date:22:25, 31 January 2009
Author:mrzman
Status:deferred (Comments)
Tags:
Comment:
(bug 8249) Followup to r46630, add parser function versions of the various PAGENAME magic words
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -53,6 +53,18 @@
5454 $parser->setFunctionHook( 'talkspacee', array( __CLASS__, 'talkspacee' ), SFH_NO_HASH );
5555 $parser->setFunctionHook( 'subjectspace', array( __CLASS__, 'subjectspace' ), SFH_NO_HASH );
5656 $parser->setFunctionHook( 'subjectspacee', array( __CLASS__, 'subjectspacee' ), SFH_NO_HASH );
 57+ $parser->setFunctionHook( 'pagename', array( __CLASS__, 'pagename' ), SFH_NO_HASH );
 58+ $parser->setFunctionHook( 'pagenamee', array( __CLASS__, 'pagenamee' ), SFH_NO_HASH );
 59+ $parser->setFunctionHook( 'fullpagename', array( __CLASS__, 'fullpagename' ), SFH_NO_HASH );
 60+ $parser->setFunctionHook( 'fullpagenamee', array( __CLASS__, 'fullpagenamee' ), SFH_NO_HASH );
 61+ $parser->setFunctionHook( 'basepagename', array( __CLASS__, 'basepagename' ), SFH_NO_HASH );
 62+ $parser->setFunctionHook( 'basepagenamee', array( __CLASS__, 'basepagenamee' ), SFH_NO_HASH );
 63+ $parser->setFunctionHook( 'subpagename', array( __CLASS__, 'subpagename' ), SFH_NO_HASH );
 64+ $parser->setFunctionHook( 'subpagenamee', array( __CLASS__, 'subpagenamee' ), SFH_NO_HASH );
 65+ $parser->setFunctionHook( 'talkpagename', array( __CLASS__, 'talkpagename' ), SFH_NO_HASH );
 66+ $parser->setFunctionHook( 'talkpagenamee', array( __CLASS__, 'talkpagenamee' ), SFH_NO_HASH );
 67+ $parser->setFunctionHook( 'subjectpagename', array( __CLASS__, 'subjectpagename' ), SFH_NO_HASH );
 68+ $parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__, 'subjectpagenamee' ), SFH_NO_HASH );
5769 $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS );
5870
5971 if ( $wgAllowDisplayTitle ) {
@@ -295,6 +307,82 @@
296308 return '';
297309 return wfUrlencode( $t->getSubjectNsText() );
298310 }
 311+ /*
 312+ * Functions to get and normalize pagenames, corresponding to the magic words
 313+ * of the same names
 314+ */
 315+ static function pagename( $parser, $title = null ) {
 316+ $t = Title::newFromText( $title );
 317+ if ( is_null($t) )
 318+ return '';
 319+ return wfEscapeWikiText( $t->getText() );
 320+ }
 321+ static function pagenamee( $parser, $title = null ) {
 322+ $t = Title::newFromText( $title );
 323+ if ( is_null($t) )
 324+ return '';
 325+ return $t->getPartialURL();
 326+ }
 327+ static function fullpagename( $parser, $title = null ) {
 328+ $t = Title::newFromText( $title );
 329+ if ( is_null($t) || !$t->canTalk() )
 330+ return '';
 331+ return wfEscapeWikiText( $t->getPrefixedText() );
 332+ }
 333+ static function fullpagenamee( $parser, $title = null ) {
 334+ $t = Title::newFromText( $title );
 335+ if ( is_null($t) || !$t->canTalk() )
 336+ return '';
 337+ return $t->getPrefixedURL();
 338+ }
 339+ static function subpagename( $parser, $title = null ) {
 340+ $t = Title::newFromText( $title );
 341+ if ( is_null($t) )
 342+ return '';
 343+ return $t->getSubpageText();
 344+ }
 345+ static function subpagenamee( $parser, $title = null ) {
 346+ $t = Title::newFromText( $title );
 347+ if ( is_null($t) )
 348+ return '';
 349+ return $t->getSubpageUrlForm();
 350+ }
 351+ static function basepagename( $parser, $title = null ) {
 352+ $t = Title::newFromText( $title );
 353+ if ( is_null($t) )
 354+ return '';
 355+ return $t->getBaseText();
 356+ }
 357+ static function basepagenamee( $parser, $title = null ) {
 358+ $t = Title::newFromText( $title );
 359+ if ( is_null($t) )
 360+ return '';
 361+ return wfUrlEncode( str_replace( ' ', '_', $t->getBaseText() ) );
 362+ }
 363+ static function talkpagename( $parser, $title = null ) {
 364+ $t = Title::newFromText( $title );
 365+ if ( is_null($t) || !$t->canTalk() )
 366+ return '';
 367+ return wfEscapeWikiText( $t->getTalkPage()->getPrefixedText() );
 368+ }
 369+ static function talkpagenamee( $parser, $title = null ) {
 370+ $t = Title::newFromText( $title );
 371+ if ( is_null($t) || !$t->canTalk() )
 372+ return '';
 373+ return $t->getTalkPage()->getPrefixedUrl();
 374+ }
 375+ static function subjectpagename( $parser, $title = null ) {
 376+ $t = Title::newFromText( $title );
 377+ if ( is_null($t) )
 378+ return '';
 379+ return wfEscapeWikiText( $t->getSubjectPage()->getPrefixedText() );
 380+ }
 381+ static function subjectpagenamee( $parser, $title = null ) {
 382+ $t = Title::newFromText( $title );
 383+ if ( is_null($t) )
 384+ return '';
 385+ return $t->getSubjectPage()->getPrefixedUrl();
 386+ }
299387
300388 /**
301389 * Return the number of pages in the given category, or 0 if it's nonexis-
Index: trunk/phase3/RELEASE-NOTES
@@ -73,8 +73,9 @@
7474 "mw-confirmemail-pending"
7575 * Local redirects to foreign images are now displayed on the ImagePage when
7676 viewing on the local wiki.
77 -* The {{NAMESPACE}}, {{TALKSPACE}}, and {{SUBJECTSPACE}} magic words can now be
78 - used as parser functions to return the desired namespace for a given title.
 77+* (bug 8249) The magic words for namespaces and pagenames can now be used as
 78+ parser functions to return the desired namespace or normalized title/title part
 79+ for a given title.
7980 * Styled #mw-data-after-content in cologneblue.css to match the rest of the font (bug 17110)
8081 * (bug 7556) Time zone names in signatures lack i18n
8182

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r46630Allow the {{NAMESPACE}}, {{TALKSPACE}}, and {{SUBJECTSPACE}} magic words (and...mrzman01:35, 31 January 2009

Comments

#Comment by Werdna (talk | contribs)   00:09, 12 February 2009

As with r46662, don't these parser functions need to be localised and added to MagicWords.php?

See r46822 for an example of this...

#Comment by Mr.Z-man (talk | contribs)   00:13, 12 February 2009

They're already there as the corresponding magic words already exist

#Comment by Werdna (talk | contribs)   00:15, 12 February 2009

Oh, whoops.

Status & tagging log









ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://www.mediawiki.org/wiki/Special:Code/MediaWiki/46662

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy