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

Revision: 112862
Author:   aaron
Date:     2012-03-02 00:40:23 +0000 (Fri, 02 Mar 2012)
Log Message:
-----------
MFT r112849, r112851, r112856, r112859

Modified Paths:
--------------
    branches/wmf/1.19wmf1/extensions/CategoryTree/CategoryTreeFunctions.php
    branches/wmf/1.19wmf1/extensions/CategoryTree/modules/ext.categoryTree.js

Property Changed:
----------------
    branches/wmf/1.19wmf1/extensions/
    branches/wmf/1.19wmf1/extensions/CategoryTree/
    branches/wmf/1.19wmf1/extensions/CategoryTree/CategoryTreeFunctions.php


Property changes on: branches/wmf/1.19wmf1/extensions
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JSTesting/extensions:100352-107913
/branches/REL1_15/phase3/extensions:51646
/branches/REL1_17/phase3/extensions:81445,81448
/branches/new-installer/phase3/extensions:43664-66004
/branches/sqlite/extensions:58211-58321
/branches/wmf/1.18wmf1/extensions:97508
/trunk/extensions:111043,111199,111218,111484,111575,111604,111659-111661,111668,111670,111688,111690,111698,111713,111715,111780,111796,111814,111947,112074,112153,112160,112166,112260,112282,112360,112517,112571,112613,112628,112758,112770-112772,112775
/trunk/phase3/extensions:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251
   + /branches/JSTesting/extensions:100352-107913
/branches/REL1_15/phase3/extensions:51646
/branches/REL1_17/phase3/extensions:81445,81448
/branches/new-installer/phase3/extensions:43664-66004
/branches/sqlite/extensions:58211-58321
/branches/wmf/1.18wmf1/extensions:97508
/trunk/extensions:111043,111199,111218,111484,111575,111604,111659-111661,111668,111670,111688,111690,111698,111713,111715,111780,111796,111814,111947,112074,112153,112160,112166,112260,112282,112360,112517,112571,112613,112628,112758,112770-112772,112775,112849,112851,112856,112859
/trunk/phase3/extensions:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251


Property changes on: branches/wmf/1.19wmf1/extensions/CategoryTree
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/JSTesting/extensions/CategoryTree:100352-107913
/branches/REL1_15/phase3/extensions/CategoryTree:51646
/branches/REL1_17/phase3/extensions/CategoryTree:81445,81448
/branches/new-installer/phase3/extensions/CategoryTree:43664-66004
/branches/sqlite/extensions/CategoryTree:58211-58321
/branches/wmf/1.18wmf1/extensions/CategoryTree:97508
/trunk/extensions/CategoryTree:111043,111199,111218,111484,111575,111604,111659-111661,111668,111670,111688,111690,111698,111713,111715,111780,111796,111814,111947,112074,112153,112160,112166,112260,112282,112360,112517,112571,112613,112628,112751
/trunk/phase3/extensions/CategoryTree:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251
   + /branches/JSTesting/extensions/CategoryTree:100352-107913
/branches/REL1_15/phase3/extensions/CategoryTree:51646
/branches/REL1_17/phase3/extensions/CategoryTree:81445,81448
/branches/new-installer/phase3/extensions/CategoryTree:43664-66004
/branches/sqlite/extensions/CategoryTree:58211-58321
/branches/wmf/1.18wmf1/extensions/CategoryTree:97508
/trunk/extensions/CategoryTree:111043,111199,111218,111484,111575,111604,111659-111661,111668,111670,111688,111690,111698,111713,111715,111780,111796,111814,111947,112074,112153,112160,112166,112260,112282,112360,112517,112571,112613,112628,112751,112849,112851,112856,112859
/trunk/phase3/extensions/CategoryTree:111002,111029,111034,111062,111067,111076,111085,111128,111144,111251

Modified: 
branches/wmf/1.19wmf1/extensions/CategoryTree/CategoryTreeFunctions.php
===================================================================
--- branches/wmf/1.19wmf1/extensions/CategoryTree/CategoryTreeFunctions.php     
2012-03-02 00:37:01 UTC (rev 112861)
+++ branches/wmf/1.19wmf1/extensions/CategoryTree/CategoryTreeFunctions.php     
2012-03-02 00:40:23 UTC (rev 112862)
@@ -315,19 +315,19 @@
                }
 
                $attr['data-ct-mode'] = $this->mOptions['mode'];
-               $attr['data-ct-options'] = Xml::escapeTagsOnly( 
$this->getOptionsAsJsStructure() );
+               $attr['data-ct-options'] = $this->getOptionsAsJsStructure();
 
                $html = '';
-               $html .= Xml::openElement( 'div', $attr );
+               $html .= Html::openElement( 'div', $attr );
 
                if ( !$allowMissing && !$title->getArticleID() ) {
-                       $html .= Xml::openElement( 'span', array( 'class' => 
'CategoryTreeNotice' ) );
+                       $html .= Html::openElement( 'span', array( 'class' => 
'CategoryTreeNotice' ) );
                        if ( $parser ) {
                                $html .= $parser->recursiveTagParse( 
wfMsgNoTrans( 'categorytree-not-found', $category ) );
                        } else {
                                $html .= wfMsgExt( 'categorytree-not-found', 
'parseinline', htmlspecialchars( $category ) );
                        }
-                       $html .= Xml::closeElement( 'span' );
+                       $html .= Html::closeElement( 'span' );
                        }
                else {
                        if ( !$hideroot ) {


Property changes on: 
branches/wmf/1.19wmf1/extensions/CategoryTree/CategoryTreeFunctions.php
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/branches/wmf/1.16wmf4/extensions/CategoryTree/CategoryTreeFunctions.php:67183
/trunk/extensions/CategoryTree/CategoryTreeFunctions.php:112751
   + 
/branches/wmf/1.16wmf4/extensions/CategoryTree/CategoryTreeFunctions.php:67183
/trunk/extensions/CategoryTree/CategoryTreeFunctions.php:112751,112856,112859

Modified: 
branches/wmf/1.19wmf1/extensions/CategoryTree/modules/ext.categoryTree.js
===================================================================
--- branches/wmf/1.19wmf1/extensions/CategoryTree/modules/ext.categoryTree.js   
2012-03-02 00:37:01 UTC (rev 112861)
+++ branches/wmf/1.19wmf1/extensions/CategoryTree/modules/ext.categoryTree.js   
2012-03-02 00:40:23 UTC (rev 112862)
@@ -27,7 +27,7 @@
         */
        handleNode: function( e ) {
                var $link = $( this );
-               if ( $link.data( 'ctState' ) === 'collapsed' ) {
+               if ( $link.data( 'ct-state' ) === 'collapsed' ) {
                        categoryTree.expandNode( $link );
                } else {
                        categoryTree.collapseNode( $link );
@@ -48,9 +48,9 @@
                $link
                        .html( mw.msg( 'categorytree-collapse-bullet' ) )
                        .attr( 'title', mw.msg( 'categorytree-collapse' ) )
-                       .data( 'ctState', 'expanded' );
+                       .data( 'ct-state', 'expanded' );
 
-               if ( !$link.data( 'ctLoaded' ) ) {
+               if ( !$link.data( 'ct-loaded' ) ) {
                        categoryTree.loadChildren( $link, $children );
                }
        },
@@ -68,7 +68,7 @@
                $link
                        .html( mw.msg( 'categorytree-expand-bullet' ) )
                        .attr( 'title', mw.msg( 'categorytree-expand' ) )
-                       .data( 'ctState', 'collapsed' );
+                       .data( 'ct-state', 'collapsed' );
        },
 
        /**
@@ -78,26 +78,55 @@
         * @param {jQuery} $children
         */
        loadChildren: function( $link, $children ) {
-               $link.data( 'ctLoaded', true );
+               var $linkParentCTTag, ctTitle, ctMode, ctOptions;
+
+               /**
+                * Error callback
+                */
+               function error() {
+                       var $retryLink;
+
+                       $retryLink = $( '<a>' )
+                               .text( mw.msg( 'categorytree-retry' ) )
+                               .attr( 'href', '#' )
+                               .click( function ( e ) {
+                                       e.preventDefault();
+                                       categoryTree.loadChildren( $link, 
$children );
+                               } );
+
+                       $children
+                               .text( mw.msg( 'categorytree-error' ) + ' ' )
+                               .append( $retryLink );
+               }
+
+               $link.data( 'ct-loaded', true );
+
                $children.html(
                        $( '<i class="CategoryTreeNotice"></i>' )
                                .text( mw.msg( 'categorytree-loading' ) )
                );
 
-               var $parentTag = $link.parents( '.CategoryTreeTag' );
+               $linkParentCTTag = $link.parents( '.CategoryTreeTag' );
 
-               if ( $parentTag.length === 0 ) {
-                       // Probably a CategoryPage
-                       $parentTag = $( '<div />' )
-                               .hide()
-                               .data( 'ctOptions', mw.config.get( 
'wgCategoryTreePageCategoryOptions' ) );
+               // Element may not have a .CategoryTreeTag parent, fallback to 
defauls
+               // Probably a CategoryPage (@todo: based on what?)
+               ctTitle = $link.data( 'ct-title' );
+               ctMode = $linkParentCTTag.data( 'ct-mode' );
+               ctMode = typeof ctMode === 'number' ? ctMode : undefined;
+               ctOptions = $linkParentCTTag.data( 'ct-options' ) || 
mw.config.get( 'wgCategoryTreePageCategoryOptions' );
+
+               // Mode and options have defaults or fallbacks, title does not.
+               // Don't make a request if there is no title.
+               if ( typeof ctTitle !== 'string' ) {
+                       error();
+                       return;
                }
 
                $.get(
                        mw.util.wikiScript(), {
                                action: 'ajax',
                                rs: 'efCategoryTreeAjaxWrapper',
-                               rsargs: [$link.data( 'ctTitle' ), 
$parentTag.data( 'ctOptions' ), 'json'] // becomes 
&rsargs[]=arg1&rsargs[]=arg2...
+                               rsargs: [ctTitle, ctOptions, 'json'] // becomes 
&rsargs[]=arg1&rsargs[]=arg2...
                        }
                )
                        .success( function ( data ) {
@@ -105,16 +134,20 @@
                                data = data.replace(/##LOAD##/g, mw.msg( 
'categorytree-expand' ) );
 
                                if ( data === '' ) {
-                                       switch ( $parentTag.data( 'ctMode' ) ) {
+                                       switch ( ctMode ) {
+                                               // CT_MODE_CATEGORIES = 0
                                                case 0:
                                                        data = mw.msg( 
'categorytree-no-subcategories' );
                                                        break;
+                                               // CT_MODE_PAGES = 10
                                                case 10:
                                                        data = mw.msg( 
'categorytree-no-pages' );
                                                        break;
+                                               // CT_MODE_PARENTS = 100
                                                case 100:
                                                        data = mw.msg( 
'categorytree-no-parent-categories' );
                                                        break;
+                                               // CT_MODE_ALL = 20
                                                default:
                                                        data = mw.msg( 
'categorytree-nothing-found' );
                                        }
@@ -126,17 +159,10 @@
                                        .html( data )
                                        .find( '.CategoryTreeToggle' )
                                                .click( categoryTree.handleNode 
);
+
                                categoryTree.showToggles();
                        } )
-                       .error( function() {
-                               var $retryLink = $( '<a />' )
-                                       .text( mw.msg( 'categorytree-retry' ) )
-                                       .attr( 'href', '#' )
-                                       .click( function() { 
categoryTree.loadChildren( $link, $children ); } );
-                               $children
-                                       .text( mw.msg( 'categorytree-error' ) )
-                                       .append( $retryLink );
-                       } );
+                       .error( error );
        }
 };
 


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

Reply via email to