https://www.mediawiki.org/wiki/Special:Code/MediaWiki/102291

Revision: 102291
Author:   danwe
Date:     2011-11-07 15:39:39 +0000 (Mon, 07 Nov 2011)
Log Message:
-----------
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
    trunk/extensions/SubpageFun/SFun_SubpageInfo.php
    trunk/extensions/SubpageFun/SubpageFun.php

Modified: trunk/extensions/SubpageFun/RELEASE-NOTES
===================================================================
--- trunk/extensions/SubpageFun/RELEASE-NOTES   2011-11-07 15:37:01 UTC (rev 
102290)
+++ trunk/extensions/SubpageFun/RELEASE-NOTES   2011-11-07 15:39:39 UTC (rev 
102291)
@@ -1,6 +1,11 @@
  'Supage Fun' Changelog:
  =======================
 
+* November 8, 2011 - Version 0.5.1:
+  - All functions/variables returning page names in any way are using 
'wfEscapeWikiText()' now like other variables like 'PAGENAME'
+    for example.
+  - 'filter' parameter can be used for 'NUMBEROFSUBPAGES'.
+
 * November 7, 2011 -- Version 0.5:
   - All magic words are case-sensitive now and must be written in UPPERCASE.
   - Input of invalid page names (with forbidden characters) will output '' 
instead of raising a php error. This behavior is adopted

Modified: trunk/extensions/SubpageFun/SFun_SubpageInfo.php
===================================================================
--- trunk/extensions/SubpageFun/SFun_SubpageInfo.php    2011-11-07 15:37:01 UTC 
(rev 102290)
+++ trunk/extensions/SubpageFun/SFun_SubpageInfo.php    2011-11-07 15:39:39 UTC 
(rev 102291)
@@ -192,11 +192,11 @@
         *                name (without prefix) will be returned.
         */      
        static function getSubpageTitle( Title $page ) {
-               $parent = SubpageInfo::getParentPage( $page );          
+               $parent = SubpageInfo::getParentPage( $page );
                //return the whole subpage name not like SUBPAGENAME only the 
last part after the last "/":
                if( ! empty( $parent ) ) {
                        return substr( $page->getText(), strlen( 
$parent->getText() . '/' ) );
-               }               
+               }
                return $page->getText(); //return PAGENAME
        }
 }

Modified: trunk/extensions/SubpageFun/SubpageFun.php
===================================================================
--- trunk/extensions/SubpageFun/SubpageFun.php  2011-11-07 15:37:01 UTC (rev 
102290)
+++ trunk/extensions/SubpageFun/SubpageFun.php  2011-11-07 15:39:39 UTC (rev 
102291)
@@ -8,7 +8,7 @@
  * Support:       http://www.mediawiki.org/wiki/Extension_talk:Subpage_Fun
  * Source code:   
http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SubpageFun
  * 
- * @version: 0.5
+ * @version: 0.5.1
  * @license: ISC license
  * @author:  Daniel Werner < danwe...@web.de >
  *
@@ -48,7 +48,7 @@
 
 class ExtSubpageFun {
 
-       const VERSION = '0.5';
+       const VERSION = '0.5.1';
 
        const MAG_SUBPAGETITLE     = 'subpagetitle';
        const MAG_SUBPAGES         = 'subpages';
@@ -142,10 +142,11 @@
                //      return '';
                $out = array();
                foreach( $pages as $page ) {
+                       $text = wfEscapeWikiText( $page->getPrefixedText() );
                        if( $link ) {
-                               $out[] = '[[:' . $page->getPrefixedText() . 
']]';
+                               $out[] = "[[:{$text}]]";
                        } else {
-                               $out[] = $page->getPrefixedText();
+                               $out[] = $text;
                        }
                }
                return implode( $sep, $out );
@@ -236,7 +237,7 @@
                if( $t === null ) {
                        return ''; // invalid title given
                }
-               return SubpageInfo::getSubpageTitle( $t );
+               return wfEscapeWikiText( SubpageInfo::getSubpageTitle( $t ) );
        }
        
        static function subpages( &$parser ) {
@@ -325,16 +326,22 @@
                //get all possible arguments:
                $args = ExtSubpageFun::getFunctionArgsArray( func_get_args() );
 
-               $title = isset($args[1]) ? $args[1] : null;
-               $depth = isset( $args['depth'] ) ? self::valDepth( 
$args['depth'] ) : null;
+               $title  = isset($args[1])          ? $args[1]                   
      : null;
+               $depth  = isset( $args['depth'] )  ? self::valDepth( 
$args['depth'] ) : null;
+               $filter = isset( $args['filter'] ) ? $args['filter']            
      : null;
                
-               //function logic:
+               // function logic:
                $t = self::newTitleObject( $parser, $title );
                if( $t === null ) {
                        return ''; // invalid title given
                }
                
+               // get subpages:
                $subpages = SubpageInfo::getSubpages( $t, $depth );
+               
+               // filter by filter criterion:
+               $subpages = self::filterSiteList( $subpages, $filter );
+                               
                return count( $subpages );
        }       
        
@@ -347,10 +354,13 @@
                //get all parents because the toplevel is the highest existing 
parent:
                $parentpages = SubpageInfo::getAncestorPages( $t );
                
-               if( ! empty( $parentpages ) )
-                       return $parentpages[0]->getPrefixedText();
-               else //no parent! The page itself is the top level:
-                       return $t->getPrefixedText();
+               if( ! empty( $parentpages ) ) {
+                       return wfEscapeWikiText( 
$parentpages[0]->getPrefixedText() );
+               }
+               else {
+                       ////no parent! The page itself is the top level:
+                       return wfEscapeWikiText( $t->getPrefixedText() );
+               }
        }
        
        


_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to