r62077 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r62076‎ | r62077 | r62078 >
Date:02:36, 7 February 2010
Author:conrad
Status:reverted (Comments)
Tags:
Comment:
Bug 7264 - Magic word to give Page Title as if pipe-trick performed on it {{pipetrick:}}
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/parser/CoreParserFunctions.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/CoreParserFunctions.php
@@ -67,6 +67,7 @@
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' ), SFH_NO_HASH );
7172 $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS );
7273 $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) );
7374
@@ -440,6 +441,17 @@
441442 }
442443
443444 /**
 445+ * Performs the pipe trick. Can be used in three ways:
 446+ * {{pipetrick:title}} == {{pipetrick:title|}} != {{pipetrick:|title}}
 447+ */
 448+ static function pipetrick( $parser, $link = '', $text = '' ) {
 449+ if ($link)
 450+ return $parser->getPipeTrickText( $link );
 451+ else
 452+ return $parser->getPipeTrickLink( $text );
 453+ }
 454+
 455+ /**
444456 * Return the number of pages in the given category, or 0 if it's nonexis-
445457 * tent. This is an expensive parser function and can't be called too many
446458 * times per page.
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -317,6 +317,7 @@
318318 'plural' => array( 0, 'PLURAL:' ),
319319 'fullurl' => array( 0, 'FULLURL:' ),
320320 'fullurle' => array( 0, 'FULLURLE:' ),
 321+ 'pipetrick' => array( 0, 'PIPETRICK:' ),
321322 'lcfirst' => array( 0, 'LCFIRST:' ),
322323 'ucfirst' => array( 0, 'UCFIRST:' ),
323324 'lc' => array( 0, 'LC:' ),
Index: trunk/phase3/RELEASE-NOTES
@@ -834,6 +834,7 @@
835835 * (bug 4099) Pipe trick doesn't work when emptiness is only provided by empty template parameter
836836 * (bug 845) [[#foo|]], [[/bar|]] should be equivalent to [[#foo|foo]], [[/bar|bar]] (new use of "pipe trick")
837837 * (bug 21660) Support full-width commas for pipe trick
 838+* (bug 7264) Magic word to give Page Title as if pipe-trick performed on it {{pipetrick:}}
838839
839840 === Languages updated in 1.16 ===
840841

Follow-up revisions

RevisionCommit summaryAuthorDate
r62081Fixes for r62077...conrad13:17, 7 February 2010
r62111partial revert for r62081. Make {{PIPETRICK}} like {{PAGENAME}}, add {{PIPETR...conrad02:07, 8 February 2010
r62689Moving Conrad's recent parser work out to a branch. Reverted r62434, r62416, ...tstarling05:19, 19 February 2010

Comments

#Comment by Siebrand (talk | contribs)   08:07, 7 February 2010

I have no idea what "pipe-trick" is - obviously this is a concept know to you and others. Could you add more documentation and consider changing the magic word to a more understandable one?

#Comment by Liangent (talk | contribs)   10:05, 7 February 2010

The name "pipe trick" is used here: Special:Search/pipe trick.

#Comment by IAlex (talk | contribs)   12:10, 7 February 2010

And please don't use the SFH_NO_HASH flag for new parser function (means that {{#pipetrick:}} must be used instead of {{pipetrick:}}).

#Comment by Conrad.Irwin (talk | contribs)   13:41, 7 February 2010

I made some changes to the Wikipedia documentation to reflect the semantic differences introduced by Special:Code/MediaWiki/62076

#Comment by Platonides (talk | contribs)   14:42, 7 February 2010

Is trick an appropiate word to place in the wikitext function name?

Why not just call it {{#piped: {{PAGENAME}} }} ?

#Comment by Conrad.Irwin (talk | contribs)   15:15, 7 February 2010

Some other possible choices of name (based on bug 7264, and bug 21994:

  1. pipetrick: name of feature used throughout documentation (w:Help:Pipe trick), code (see parserTests.txt), and bug reports (see RELEASE-NOTES)
  2. piped: name of a different, but similar feature (w:Wikipedia:Piped links)
  3. trim: name of a totally different function in some programming languages
  4. pstlink: misleading, as the pipe trick now happens not only at pre-save-transform time.
  5. disambig: only one very specific use of this feature
  6. contextlink: archaic name for this feature (only remains in parser tests, as far as I know)

The remaining features of bug 7264 want some thought on proper syntax; but I think this name is the best choice for this function.

#Comment by Conrad.Irwin (talk | contribs)   15:18, 7 February 2010

Some other possible choices of name (based on bug 7264, and bug 21994):

  1. pipetrick: name of feature used throughout documentation (w:Help:Pipe trick), code (see parserTests.txt), and bug reports (see RELEASE-NOTES)
  2. piped: name of a different, but similar feature (w:Wikipedia:Piped links)
  3. trim: name of a totally different function in some programming languages
  4. pstlink: misleading, as the pipe trick now happens not only at pre-save-transform time.
  5. disambig: only one very specific use of this feature
  6. contextlink: archaic name for this feature (only remains in parser tests, as far as I know)

The remaining features of bug 7264 want some thought on proper syntax; but I think this name is the best choice for this function.

#Comment by Conrad.Irwin (talk | contribs)   02:08, 8 February 2010

IAlex, I have re-added the SFH_NO_HASH to provide consistency with other page title functions. see my comment at bug 7264 for more detail.

#Comment by Conrad.Irwin (talk | contribs)   20:00, 12 February 2010

I have added it to Help:Magic words for documentation.

Status & tagging log