Index: trunk/phase3/includes/parser/CoreParserFunctions.php |
— | — | @@ -53,6 +53,18 @@ |
54 | 54 | $parser->setFunctionHook( 'talkspacee', array( __CLASS__, 'talkspacee' ), SFH_NO_HASH ); |
55 | 55 | $parser->setFunctionHook( 'subjectspace', array( __CLASS__, 'subjectspace' ), SFH_NO_HASH ); |
56 | 56 | $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 ); |
57 | 69 | $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS ); |
58 | 70 | |
59 | 71 | if ( $wgAllowDisplayTitle ) { |
— | — | @@ -295,6 +307,82 @@ |
296 | 308 | return ''; |
297 | 309 | return wfUrlencode( $t->getSubjectNsText() ); |
298 | 310 | } |
| 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 | + } |
299 | 387 | |
300 | 388 | /** |
301 | 389 | * Return the number of pages in the given category, or 0 if it's nonexis- |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -73,8 +73,9 @@ |
74 | 74 | "mw-confirmemail-pending" |
75 | 75 | * Local redirects to foreign images are now displayed on the ImagePage when |
76 | 76 | 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. |
79 | 80 | * Styled #mw-data-after-content in cologneblue.css to match the rest of the font (bug 17110) |
80 | 81 | * (bug 7556) Time zone names in signatures lack i18n |
81 | 82 | |