r13612 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13611‎ | r13612 | r13613 >
Date:15:38, 12 April 2006
Author:robchurch
Status:old
Tags:
Comment:
Add TALKSPACE, SUBJECTSPACE, TALKPAGENAME, SUBJECTPAGENAME (and encoded forms for all) magic words
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/MagicWord.php (modified) (history)
  • /trunk/phase3/includes/Namespace.php (modified) (history)
  • /trunk/phase3/includes/Parser.php (modified) (history)
  • /trunk/phase3/includes/Title.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Parser.php
@@ -2097,12 +2097,40 @@
20982098 return $this->mTitle->getSubpageText();
20992099 case MAG_SUBPAGENAMEE:
21002100 return $this->mTitle->getSubpageUrlForm();
 2101+ case MAG_TALKPAGENAME:
 2102+ if( $this->mTitle->canTalk() ) {
 2103+ $talkPage = $this->mTitle->getTalkPage();
 2104+ return $talkPage->getPrefixedText();
 2105+ } else {
 2106+ return '';
 2107+ }
 2108+ case MAG_TALKPAGENAMEE:
 2109+ if( $this->mTitle->canTalk() ) {
 2110+ $talkPage = $this->mTitle->getTalkPage();
 2111+ return $talkPage->getPrefixedUrl();
 2112+ } else {
 2113+ return '';
 2114+ }
 2115+ case MAG_SUBJECTPAGENAME:
 2116+ $subjPage = $this->mTitle->getSubjectPage();
 2117+ return $subjPage->getPrefixedText();
 2118+ case MAG_SUBJECTPAGENAMEE:
 2119+ $subjPage = $this->mTitle->getSubjectPage();
 2120+ return $subjPage->getPrefixedUrl();
21012121 case MAG_REVISIONID:
21022122 return $this->mRevisionId;
21032123 case MAG_NAMESPACE:
21042124 return $wgContLang->getNsText( $this->mTitle->getNamespace() );
21052125 case MAG_NAMESPACEE:
21062126 return wfUrlencode( $wgContLang->getNsText( $this->mTitle->getNamespace() ) );
 2127+ case MAG_TALKSPACE:
 2128+ return $this->mTitle->canTalk() ? $this->mTitle->getTalkNsText() : '';
 2129+ case MAG_TALKSPACEE:
 2130+ return $this->mTitle->canTalk() ? wfUrlencode( $this->mTitle->getTalkNsText() ) : '';
 2131+ case MAG_SUBJECTSPACE:
 2132+ return $this->mTitle->getSubjectNsText();
 2133+ case MAG_SUBJECTSPACEE:
 2134+ return( wfUrlencode( $this->mTitle->getSubjectNsText() ) );
21072135 case MAG_CURRENTDAYNAME:
21082136 return $varCache[$index] = $wgContLang->getWeekdayName( date( 'w', $ts ) + 1 );
21092137 case MAG_CURRENTYEAR:
Index: trunk/phase3/includes/MagicWord.php
@@ -73,6 +73,14 @@
7474 'MAG_SUBPAGENAME',
7575 'MAG_SUBPAGENAMEE',
7676 'MAG_DISPLAYTITLE',
 77+ 'MAG_TALKSPACE',
 78+ 'MAG_TALKSPACEE',
 79+ 'MAG_SUBJECTSPACE',
 80+ 'MAG_SUBJECTSPACEE',
 81+ 'MAG_TALKPAGENAME',
 82+ 'MAG_TALKPAGENAMEE',
 83+ 'MAG_SUBJECTPAGENAME',
 84+ 'MAG_SUBJECTPAGENAMEE',
7785 );
7886 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
7987 wfRunHooks( 'MagicWordMagicWords', array( &$magicWords ) );
@@ -108,6 +116,14 @@
109117 MAG_SUBPAGENAME,
110118 MAG_SUBPAGENAMEE,
111119 MAG_DISPLAYTITLE,
 120+ MAG_TALKSPACE,
 121+ MAG_TALKSPACEE,
 122+ MAG_SUBJECTSPACE,
 123+ MAG_SUBJECTSPACEE,
 124+ MAG_TALKPAGENAME,
 125+ MAG_TALKPAGENAMEE,
 126+ MAG_SUBJECTPAGENAME,
 127+ MAG_SUBJECTPAGENAMEE,
112128 );
113129 if ( ! defined( 'MEDIAWIKI_INSTALL' ) )
114130 wfRunHooks( 'MagicWordwgVariableIDs', array( &$wgVariableIDs ) );
Index: trunk/phase3/includes/Title.php
@@ -605,6 +605,23 @@
606606 }
607607
608608 /**
 609+ * Get the namespace text of the talk page
 610+ * @return string
 611+ */
 612+ function getTalkNsText() {
 613+ global $wgContLang;
 614+ return( $wgContLang->getNsText( Namespace::getTalk( $this->mNamespace ) ) );
 615+ }
 616+
 617+ /**
 618+ * Could this title have a corresponding talk page?
 619+ * @return bool
 620+ */
 621+ function canTalk() {
 622+ return( Namespace::canTalk( $this->mNamespace ) );
 623+ }
 624+
 625+ /**
609626 * Get the interwiki prefix (or null string)
610627 * @return string
611628 * @access public
Index: trunk/phase3/includes/Namespace.php
@@ -117,5 +117,13 @@
118118 return NULL;
119119 }
120120 }
 121+
 122+ /**
 123+ * Can this namespace ever have a talk namespace?
 124+ * @param $index Namespace index
 125+ */
 126+ function canTalk( $index ) {
 127+ return( $index >= NS_MAIN );
 128+ }
121129 }
122130 ?>
Index: trunk/phase3/RELEASE-NOTES
@@ -57,6 +57,8 @@
5858 All extensions using it have been corrected.
5959 * Propagate ISBN number for Booksources in LanguageNo.php
6060 * (bug 5548) Improvements to Indonesian localisation [patch: Ivan Lanin]
 61+* Add TALKSPACE, SUBJECTSPACE, TALKPAGENAME, SUBJECTPAGENAME (and encoded forms for all)
 62+ magic words
6163
6264 == Compatibility ==
6365
Index: trunk/phase3/languages/Language.php
@@ -227,10 +227,18 @@
228228 MAG_PAGENAMEE => array( 1, 'PAGENAMEE' ),
229229 MAG_NAMESPACE => array( 1, 'NAMESPACE' ),
230230 MAG_NAMESPACEE => array( 1, 'NAMESPACEE' ),
 231+ MAG_TALKSPACE => array( 1, 'TALKSPACE' ),
 232+ MAG_TALKSPACEE => array( 1, 'TALKSPACEE' ),
 233+ MAG_SUBJECTSPACE => array( 1, 'SUBJECTSPACE', 'ARTICLESPACE' ),
 234+ MAG_SUBJECTSPACEE => array( 1, 'SUBJECTSPACEE', 'ARTICLESPACEE' ),
231235 MAG_FULLPAGENAME => array( 1, 'FULLPAGENAME' ),
232236 MAG_FULLPAGENAMEE => array( 1, 'FULLPAGENAMEE' ),
233 - MAG_SUBPAGENAME => array( 0, 'SUBPAGENAME' ),
234 - MAG_SUBPAGENAMEE => array( 0, 'SUBPAGENAMEE' ),
 237+ MAG_SUBPAGENAME => array( 1, 'SUBPAGENAME' ),
 238+ MAG_SUBPAGENAMEE => array( 1, 'SUBPAGENAMEE' ),
 239+ MAG_TALKPAGENAME => array( 1, 'TALKPAGENAME' ),
 240+ MAG_TALKPAGENAMEE => array( 1, 'TALKPAGENAMEE' ),
 241+ MAG_SUBJECTPAGENAME => array( 1, 'SUBJECTPAGENAME', 'ARTICLEPAGENAME' ),
 242+ MAG_SUBJECTPAGENAMEE => array( 1, 'SUBJECTPAGENAMEE', 'ARTICLEPAGENAMEE' ),
235243 MAG_MSG => array( 0, 'MSG:' ),
236244 MAG_SUBST => array( 0, 'SUBST:' ),
237245 MAG_MSGNW => array( 0, 'MSGNW:' ),

Status & tagging log