From d036809f36b5156e51990526a3e7c9795eae286d Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Sun, 7 Feb 2010 02:36:32 +0000 Subject: [PATCH] Bug 7264 - Magic word to give Page Title as if pipe-trick performed on it {{pipetrick:}} --- RELEASE-NOTES | 1 + includes/parser/CoreParserFunctions.php | 12 ++++++++++++ languages/messages/MessagesEn.php | 1 + 3 files changed, 14 insertions(+) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index f0d3a73bec..68916aa841 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -834,6 +834,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 4099) Pipe trick doesn't work when emptiness is only provided by empty template parameter * (bug 845) [[#foo|]], [[/bar|]] should be equivalent to [[#foo|foo]], [[/bar|bar]] (new use of "pipe trick") * (bug 21660) Support full-width commas for pipe trick +* (bug 7264) Magic word to give Page Title as if pipe-trick performed on it {{pipetrick:}} === Languages updated in 1.16 === diff --git a/includes/parser/CoreParserFunctions.php b/includes/parser/CoreParserFunctions.php index d1fe95f9f2..bca239f8d9 100644 --- a/includes/parser/CoreParserFunctions.php +++ b/includes/parser/CoreParserFunctions.php @@ -67,6 +67,7 @@ class CoreParserFunctions { $parser->setFunctionHook( 'talkpagenamee', array( __CLASS__, 'talkpagenamee' ), SFH_NO_HASH ); $parser->setFunctionHook( 'subjectpagename', array( __CLASS__, 'subjectpagename' ), SFH_NO_HASH ); $parser->setFunctionHook( 'subjectpagenamee', array( __CLASS__, 'subjectpagenamee' ), SFH_NO_HASH ); + $parser->setFunctionHook( 'pipetrick', array( __CLASS__, 'pipetrick' ), SFH_NO_HASH ); $parser->setFunctionHook( 'tag', array( __CLASS__, 'tagObj' ), SFH_OBJECT_ARGS ); $parser->setFunctionHook( 'formatdate', array( __CLASS__, 'formatDate' ) ); @@ -439,6 +440,17 @@ class CoreParserFunctions { return $t->getSubjectPage()->getPrefixedUrl(); } + /** + * Performs the pipe trick. Can be used in three ways: + * {{pipetrick:title}} == {{pipetrick:title|}} != {{pipetrick:|title}} + */ + static function pipetrick( $parser, $link = '', $text = '' ) { + if ($link) + return $parser->getPipeTrickText( $link ); + else + return $parser->getPipeTrickLink( $text ); + } + /** * Return the number of pages in the given category, or 0 if it's nonexis- * tent. This is an expensive parser function and can't be called too many diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 6f1dd22af1..97661aa427 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -317,6 +317,7 @@ $magicWords = array( 'plural' => array( 0, 'PLURAL:' ), 'fullurl' => array( 0, 'FULLURL:' ), 'fullurle' => array( 0, 'FULLURLE:' ), + 'pipetrick' => array( 0, 'PIPETRICK:' ), 'lcfirst' => array( 0, 'LCFIRST:' ), 'ucfirst' => array( 0, 'UCFIRST:' ), 'lc' => array( 0, 'LC:' ), -- 2.20.1