http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88407

Revision: 88407
Author:   jeroendedauw
Date:     2011-05-19 15:06:29 +0000 (Thu, 19 May 2011)
Log Message:
-----------
work on special:watchlistconditions

Modified Paths:
--------------
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
    trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
    trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
    trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php       
2011-05-19 14:19:04 UTC (rev 88406)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php       
2011-05-19 15:06:29 UTC (rev 88407)
@@ -31,6 +31,10 @@
        'swl-group-properties' => 'Properties covered by this group:',
        'swl-group-remove-property' => 'Remove property',
        'swl-group-page-selection' => 'Pages in',
+       'swl-group-save' => 'Save',
+       'swl-group-category' => 'category',
+       'swl-group-namespace' => 'namespace',
+       'swl-group-concept' => 'concept',
 
        // Special:SemanticWatchlist
        'swl-watchlist-position' => "Showing '''$1''' of the last changes 
starting with '''#$2'''.",

Modified: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
===================================================================
--- trunk/extensions/SemanticWatchlist/SemanticWatchlist.php    2011-05-19 
14:19:04 UTC (rev 88406)
+++ trunk/extensions/SemanticWatchlist/SemanticWatchlist.php    2011-05-19 
15:06:29 UTC (rev 88407)
@@ -112,7 +112,10 @@
                'swl-group-properties',
                'swl-group-remove-property',
                'swl-group-page-selection',
-               'save', 
+               'swl-group-save',
+               'swl-group-category',
+               'swl-group-namespace',
+               'swl-group-concept',
        )
 );
 

Modified: 
trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php  
2011-05-19 14:19:04 UTC (rev 88406)
+++ trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php  
2011-05-19 15:06:29 UTC (rev 88407)
@@ -70,7 +70,7 @@
                        $groupsHtml[] = $this->getGroupHtml( $group );
                }
                
-               $wgOut->addHTML( implode( '<br />', $groupsHtml ) );
+               $wgOut->addHTML( implode( '', $groupsHtml ) );
                
                $wgOut->addModules( 'ext.swl.watchlistconditions' );
        }
@@ -85,6 +85,12 @@
         * @return string
         */
        protected function getGroupHtml( SWLGroup $group ) {
+               $namespaces = $group->getNamespaces();
+               
+               foreach ( $namespaces as &$ns ) {
+                       $ns = MWNamespace::getCanonicalName( $ns );
+               }
+               
                return Html::rawElement(
                        'fieldset',
                        array(
@@ -92,7 +98,7 @@
                                'class' => 'swl_group',
                                'groupname' => $group->getName(),
                                'categories' => implode( '|', 
$group->getCategories() ),
-                               'namespaces' => implode( '|', 
$group->getNamespaces() ),
+                               'namespaces' => implode( '|', $namespaces ),
                                'properties' => implode( '|', 
$group->getProperties() ),
                                'concepts' => implode( '|', 
$group->getConcepts() ),
                        ),

Modified: 
trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
===================================================================
--- trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js    
2011-05-19 14:19:04 UTC (rev 88406)
+++ trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js    
2011-05-19 15:06:29 UTC (rev 88407)
@@ -17,7 +17,7 @@
                
                var propTd = $( '<td />' ).attr( {
                        //'bgcolor': 'gray',
-                       'rowspan': 2
+                       'rowspan': 3
                } );
                
                propTd.html( mediaWiki.msg( 'swl-group-properties' ) );
@@ -36,12 +36,47 @@
                var nameTd = $( '<td />' ).html( $( '<p />' ).text( 
mediaWiki.msg( 'swl-group-name' ) + ' ' ).append( nameInput ) );
                table.append( $( '<tr />' ).html( nameTd ) );
                
+               var conditionValue, conditionType;
+               
+               switch ( true ) {
+                       case group.categories.length > 0:
+                               conditionValue = group.categories[0];
+                               conditionType = 'category';
+                               break;
+                       case group.namespaces.length > 0:
+                               conditionValue = group.namespaces[0];
+                               conditionType = 'namespace';
+                               break;
+                       case group.concepts.length > 0:
+                               conditionValue = group.concepts[0];
+                               conditionType = 'concept';
+                               break;
+               }
+               
+               var conditionTypeInput = $( '<select />' );
+               var conditionTypes = [ 'category', 'namespace', 'concept' ];
+               
+               for ( i in conditionTypes ) {
+                       var optionElement = $( '<option />' ).text( 
mediaWiki.msg( 'swl-group-' + conditionTypes[i] ) ).attr( 'value', 
conditionTypes[i] );
+                       
+                       if ( conditionType == conditionTypes[i] ) {
+                               optionElement.attr( 'selected', 'selected' );
+                       }
+                       
+                       conditionTypeInput.append( optionElement );
+               }
+               
                var conditionNameInput = $( '<input />' ).attr( {
                        'type': 'text',
-                       'value': group.name,
+                       'value': conditionValue,
                        'size': 30
                } );
-               var conditionTd = $( '<td />' ).html( $( '<p />' ).text( 
mediaWiki.msg( 'swl-group-page-selection' ) + ' ' ).append( conditionNameInput 
) );
+               var conditionTd = $( '<td />' ).html( 
+                       $( '<p />' ).text( mediaWiki.msg( 
'swl-group-page-selection' ) + ' ' )
+                       .append( conditionTypeInput )
+                       .append( conditionNameInput )
+               );
+               
                table.append( $( '<tr />' ).html( conditionTd ) );
                
                this.append( table );
@@ -49,7 +84,7 @@
                this.append(
                        $( '<input />' ).attr( {
                                'type': 'button',
-                               'value': mediaWiki.msg( 'save' )
+                               'value': mediaWiki.msg( 'swl-group-save' )
                        } ).click( function() {
                                this.disabled = true;
                                self.doSave( function() { this.disabled = 
false; } );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to