r62111 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62110‎ | r62111 | r62112 >
Date:02:07, 8 February 2010
Author:conrad
Status:reverted (Comments)
Tags:
Comment:
partial revert for r62081. Make {{PIPETRICK}} like {{PAGENAME}}, add {{PIPETRICKE}}. fix r62077 better.
Modified paths:
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/parserTests.txt (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/parserTests.txt
@@ -2022,21 +2022,41 @@
20232023 !! end
20242024
20252025 !! test
2026 -Magic Word: {{#PIPETRICK:}}
 2026+Magic Word: {{PIPETRICK}}
20272027 !! options
20282028 title=[[Some (page)]]
20292029 !! input
2030 -{{#pipetrick:Hello (one)}}
2031 -{{#pipetrick:World, hi|}}
2032 -{{#pipetrick:|Other}}
 2030+{{PIPETRICK}}
 2031+{{PIPETRICK:Hello (one)}}
 2032+{{PIPETRICK:World, hi|}}
 2033+{{PIPETRICK:|Other}}
20332034 !! result
2034 -<p>Hello
 2035+<p>Some
 2036+Hello
20352037 World
20362038 Other (page)
20372039 </p>
20382040 !! end
20392041
20402042 !! test
 2043+Magic Word: {{PIPETRICKE}}
 2044+!! options
 2045+title=[[Some other (page)]]
 2046+!! input
 2047+{{PIPETRICKE}}
 2048+{{PIPETRICKE:User:Ævar Arnfjörð Bjarmason}}
 2049+{{PIPETRICKE:#Something to do|}}
 2050+{{PIPETRICKE:|The?last}}
 2051+!! result
 2052+<p>Some_other
 2053+%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
 2054+Something_to_do
 2055+The%3Flast_(page)
 2056+</p>
 2057+!! end
 2058+
 2059+
 2060+!! test
20412061 Magic Word: {{REVISIONID}}
20422062 !! input
20432063 {{REVISIONID}}
Index: trunk/phase3/includes/parser/Parser.php
@@ -2493,6 +2493,14 @@
24942494 $subjPage = $this->mTitle->getSubjectPage();
24952495 $value = $subjPage->getPrefixedUrl();
24962496 break;
 2497+ case 'pipetrick':
 2498+ $text = $this->mTitle->getText();
 2499+ $value = $this->getPipeTrickText( $text );
 2500+ break;
 2501+ case 'pipetricke':
 2502+ $text = $this->mTitle->getText();
 2503+ $value = wfUrlEncode( str_replace( ' ', '_', $this->getPipeTrickText( $text ) ) );
 2504+ break;
24972505 case 'revisionid':
24982506 // Let the edit saving system know we should parse the page
24992507 // *after* a revision ID has been assigned.
Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -67,7 +67,8 @@
6868 $parser->setFunctionHook( 'talkpagenamee', array( __CLASS__, 'talkpagenamee' ), SFH_NO_HASH );
6969 $parser->setFunctionHook( 'subjectpagename', array( __CLASS__, 'subjectpagename' ), SFH_NO_HASH );
7070 $parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__, 'subjectpagenamee' ), SFH_NO_HASH );
71 - $parser->setFunctionHook( 'pipetrick', array( __CLASS__, 'pipetrick' ) );
 71+ $parser->setFunctionHook( 'pipetrick', array( __CLASS__, 'pipetrick' ), SFH_NO_HASH );
 72+ $parser->setFunctionHook( 'pipetricke', array( __CLASS__, 'pipetricke' ), SFH_NO_HASH );
7273 $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS );
7374 $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
7475
@@ -455,6 +456,13 @@
456457 }
457458
458459 /**
 460+ * Performs the pipetrick and then url encodes the result
 461+ */
 462+ static function pipetricke( $parser, $link = '', $text = '' ) {
 463+ return wfUrlEncode( str_replace( ' ', '_', CoreParserFunctions::pipetrick( &$parser, $link, $text ) ) );
 464+ }
 465+
 466+ /**
459467 * Return the number of pages in the given category, or 0 if it's nonexis-
460468 * tent. This is an expensive parser function and can't be called too many
461469 * times per page.
Index: trunk/phase3/includes/MagicWord.php
@@ -84,6 +84,8 @@
8585 'revisionuser',
8686 'subpagename',
8787 'subpagenamee',
 88+ 'pipetrick',
 89+ 'pipetricke',
8890 'talkspace',
8991 'talkspacee',
9092 'subjectspace',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -263,6 +263,8 @@
264264 'talkpagenamee' => array( 1, 'TALKPAGENAMEE' ),
265265 'subjectpagename' => array( 1, 'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ),
266266 'subjectpagenamee' => array( 1, 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ),
 267+ 'pipetrick' => array( 1, 'PIPETRICK' ),
 268+ 'pipetricke' => array( 1, 'PIPETRICKE' ),
267269 'msg' => array( 0, 'MSG:' ),
268270 'subst' => array( 0, 'SUBST:' ),
269271 'safesubst' => array( 0, 'SAFESUBST:' ),
@@ -317,7 +319,6 @@
318320 'plural' => array( 0, 'PLURAL:' ),
319321 'fullurl' => array( 0, 'FULLURL:' ),
320322 'fullurle' => array( 0, 'FULLURLE:' ),
321 - 'pipetrick' => array( 0, 'PIPETRICK:' ),
322323 'lcfirst' => array( 0, 'LCFIRST:' ),
323324 'ucfirst' => array( 0, 'UCFIRST:' ),
324325 'lc' => array( 0, 'LC:' ),

Follow-up revisions

RevisionCommit summaryAuthorDate
r62123Cleanup r62111, don't pass by referencedemon11:30, 8 February 2010
r62689Moving Conrad's recent parser work out to a branch. Reverted r62434, r62416, ...tstarling05:19, 19 February 2010

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r62077Bug 7264 - Magic word to give Page Title as if pipe-trick performed on it {{...conrad02:36, 7 February 2010
r62081Fixes for r62077...conrad13:17, 7 February 2010

Comments

#Comment by Simetrical (talk | contribs)   18:20, 8 February 2010

You should still have a #. {{PAGENAME}} doesn't have it because it was grandfathered in, but all new magic words/parser functions/etc. should start with # so that they can't conflict with templates.

Status & tagging log