r102291 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102290‎ | r102291 | r102292 >
Date:15:39, 7 November 2011
Author:danwe
Status:deferred
Tags:
Comment:
All functions/variables returning page names in any way now are using 'wfEscapeWikiText()' like other variables like 'PAGENAME' for example. 'filter' parameter can be used for 'NUMBEROFSUBPAGES'
Modified paths:
  • /trunk/extensions/SubpageFun/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/SubpageFun/SFun_SubpageInfo.php (modified) (history)
  • /trunk/extensions/SubpageFun/SubpageFun.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SubpageFun/SFun_SubpageInfo.php
@@ -192,11 +192,11 @@
193193 * name (without prefix) will be returned.
194194 */
195195 static function getSubpageTitle( Title $page ) {
196 - $parent = SubpageInfo::getParentPage( $page );
 196+ $parent = SubpageInfo::getParentPage( $page );
197197 //return the whole subpage name not like SUBPAGENAME only the last part after the last "/":
198198 if( ! empty( $parent ) ) {
199199 return substr( $page->getText(), strlen( $parent->getText() . '/' ) );
200 - }
 200+ }
201201 return $page->getText(); //return PAGENAME
202202 }
203203 }
Index: trunk/extensions/SubpageFun/SubpageFun.php
@@ -8,7 +8,7 @@
99 * Support: http://www.mediawiki.org/wiki/Extension_talk:Subpage_Fun
1010 * Source code: http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SubpageFun
1111 *
12 - * @version: 0.5
 12+ * @version: 0.5.1
1313 * @license: ISC license
1414 * @author: Daniel Werner < danweetz@web.de >
1515 *
@@ -48,7 +48,7 @@
4949
5050 class ExtSubpageFun {
5151
52 - const VERSION = '0.5';
 52+ const VERSION = '0.5.1';
5353
5454 const MAG_SUBPAGETITLE = 'subpagetitle';
5555 const MAG_SUBPAGES = 'subpages';
@@ -142,10 +142,11 @@
143143 // return '';
144144 $out = array();
145145 foreach( $pages as $page ) {
 146+ $text = wfEscapeWikiText( $page->getPrefixedText() );
146147 if( $link ) {
147 - $out[] = '[[:' . $page->getPrefixedText() . ']]';
 148+ $out[] = "[[:{$text}]]";
148149 } else {
149 - $out[] = $page->getPrefixedText();
 150+ $out[] = $text;
150151 }
151152 }
152153 return implode( $sep, $out );
@@ -236,7 +237,7 @@
237238 if( $t === null ) {
238239 return ''; // invalid title given
239240 }
240 - return SubpageInfo::getSubpageTitle( $t );
 241+ return wfEscapeWikiText( SubpageInfo::getSubpageTitle( $t ) );
241242 }
242243
243244 static function subpages( &$parser ) {
@@ -325,16 +326,22 @@
326327 //get all possible arguments:
327328 $args = ExtSubpageFun::getFunctionArgsArray( func_get_args() );
328329
329 - $title = isset($args[1]) ? $args[1] : null;
330 - $depth = isset( $args['depth'] ) ? self::valDepth( $args['depth'] ) : null;
 330+ $title = isset($args[1]) ? $args[1] : null;
 331+ $depth = isset( $args['depth'] ) ? self::valDepth( $args['depth'] ) : null;
 332+ $filter = isset( $args['filter'] ) ? $args['filter'] : null;
331333
332 - //function logic:
 334+ // function logic:
333335 $t = self::newTitleObject( $parser, $title );
334336 if( $t === null ) {
335337 return ''; // invalid title given
336338 }
337339
 340+ // get subpages:
338341 $subpages = SubpageInfo::getSubpages( $t, $depth );
 342+
 343+ // filter by filter criterion:
 344+ $subpages = self::filterSiteList( $subpages, $filter );
 345+
339346 return count( $subpages );
340347 }
341348
@@ -347,10 +354,13 @@
348355 //get all parents because the toplevel is the highest existing parent:
349356 $parentpages = SubpageInfo::getAncestorPages( $t );
350357
351 - if( ! empty( $parentpages ) )
352 - return $parentpages[0]->getPrefixedText();
353 - else //no parent! The page itself is the top level:
354 - return $t->getPrefixedText();
 358+ if( ! empty( $parentpages ) ) {
 359+ return wfEscapeWikiText( $parentpages[0]->getPrefixedText() );
 360+ }
 361+ else {
 362+ ////no parent! The page itself is the top level:
 363+ return wfEscapeWikiText( $t->getPrefixedText() );
 364+ }
355365 }
356366
357367
Index: trunk/extensions/SubpageFun/RELEASE-NOTES
@@ -1,6 +1,11 @@
22 'Supage Fun' Changelog:
33 =======================
44
 5+* November 8, 2011 - Version 0.5.1:
 6+ - All functions/variables returning page names in any way are using 'wfEscapeWikiText()' now like other variables like 'PAGENAME'
 7+ for example.
 8+ - 'filter' parameter can be used for 'NUMBEROFSUBPAGES'.
 9+
510 * November 7, 2011 -- Version 0.5:
611 - All magic words are case-sensitive now and must be written in UPPERCASE.
712 - Input of invalid page names (with forbidden characters) will output '' instead of raising a php error. This behavior is adopted

Status & tagging log