r88407 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88406‎ | r88407 | r88408 >
Date:15:06, 19 May 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on special:watchlistconditions
Modified paths:
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php (modified) (history)
  • /trunk/extensions/SemanticWatchlist/SemanticWatchlist.php (modified) (history)
  • /trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php (modified) (history)
  • /trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticWatchlist/specials/jquery.watchlistcondition.js
@@ -17,7 +17,7 @@
1818
1919 var propTd = $( '<td />' ).attr( {
2020 //'bgcolor': 'gray',
21 - 'rowspan': 2
 21+ 'rowspan': 3
2222 } );
2323
2424 propTd.html( mediaWiki.msg( 'swl-group-properties' ) );
@@ -36,12 +36,47 @@
3737 var nameTd = $( '<td />' ).html( $( '<p />' ).text( mediaWiki.msg( 'swl-group-name' ) + ' ' ).append( nameInput ) );
3838 table.append( $( '<tr />' ).html( nameTd ) );
3939
 40+ var conditionValue, conditionType;
 41+
 42+ switch ( true ) {
 43+ case group.categories.length > 0:
 44+ conditionValue = group.categories[0];
 45+ conditionType = 'category';
 46+ break;
 47+ case group.namespaces.length > 0:
 48+ conditionValue = group.namespaces[0];
 49+ conditionType = 'namespace';
 50+ break;
 51+ case group.concepts.length > 0:
 52+ conditionValue = group.concepts[0];
 53+ conditionType = 'concept';
 54+ break;
 55+ }
 56+
 57+ var conditionTypeInput = $( '<select />' );
 58+ var conditionTypes = [ 'category', 'namespace', 'concept' ];
 59+
 60+ for ( i in conditionTypes ) {
 61+ var optionElement = $( '<option />' ).text( mediaWiki.msg( 'swl-group-' + conditionTypes[i] ) ).attr( 'value', conditionTypes[i] );
 62+
 63+ if ( conditionType == conditionTypes[i] ) {
 64+ optionElement.attr( 'selected', 'selected' );
 65+ }
 66+
 67+ conditionTypeInput.append( optionElement );
 68+ }
 69+
4070 var conditionNameInput = $( '<input />' ).attr( {
4171 'type': 'text',
42 - 'value': group.name,
 72+ 'value': conditionValue,
4373 'size': 30
4474 } );
45 - var conditionTd = $( '<td />' ).html( $( '<p />' ).text( mediaWiki.msg( 'swl-group-page-selection' ) + ' ' ).append( conditionNameInput ) );
 75+ var conditionTd = $( '<td />' ).html(
 76+ $( '<p />' ).text( mediaWiki.msg( 'swl-group-page-selection' ) + ' ' )
 77+ .append( conditionTypeInput )
 78+ .append( conditionNameInput )
 79+ );
 80+
4681 table.append( $( '<tr />' ).html( conditionTd ) );
4782
4883 this.append( table );
@@ -49,7 +84,7 @@
5085 this.append(
5186 $( '<input />' ).attr( {
5287 'type': 'button',
53 - 'value': mediaWiki.msg( 'save' )
 88+ 'value': mediaWiki.msg( 'swl-group-save' )
5489 } ).click( function() {
5590 this.disabled = true;
5691 self.doSave( function() { this.disabled = false; } );
Index: trunk/extensions/SemanticWatchlist/specials/SpecialWatchlistConditions.php
@@ -70,7 +70,7 @@
7171 $groupsHtml[] = $this->getGroupHtml( $group );
7272 }
7373
74 - $wgOut->addHTML( implode( '<br />', $groupsHtml ) );
 74+ $wgOut->addHTML( implode( '', $groupsHtml ) );
7575
7676 $wgOut->addModules( 'ext.swl.watchlistconditions' );
7777 }
@@ -85,6 +85,12 @@
8686 * @return string
8787 */
8888 protected function getGroupHtml( SWLGroup $group ) {
 89+ $namespaces = $group->getNamespaces();
 90+
 91+ foreach ( $namespaces as &$ns ) {
 92+ $ns = MWNamespace::getCanonicalName( $ns );
 93+ }
 94+
8995 return Html::rawElement(
9096 'fieldset',
9197 array(
@@ -92,7 +98,7 @@
9399 'class' => 'swl_group',
94100 'groupname' => $group->getName(),
95101 'categories' => implode( '|', $group->getCategories() ),
96 - 'namespaces' => implode( '|', $group->getNamespaces() ),
 102+ 'namespaces' => implode( '|', $namespaces ),
97103 'properties' => implode( '|', $group->getProperties() ),
98104 'concepts' => implode( '|', $group->getConcepts() ),
99105 ),
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.i18n.php
@@ -31,6 +31,10 @@
3232 'swl-group-properties' => 'Properties covered by this group:',
3333 'swl-group-remove-property' => 'Remove property',
3434 'swl-group-page-selection' => 'Pages in',
 35+ 'swl-group-save' => 'Save',
 36+ 'swl-group-category' => 'category',
 37+ 'swl-group-namespace' => 'namespace',
 38+ 'swl-group-concept' => 'concept',
3539
3640 // Special:SemanticWatchlist
3741 'swl-watchlist-position' => "Showing '''$1''' of the last changes starting with '''#$2'''.",
Index: trunk/extensions/SemanticWatchlist/SemanticWatchlist.php
@@ -112,7 +112,10 @@
113113 'swl-group-properties',
114114 'swl-group-remove-property',
115115 'swl-group-page-selection',
116 - 'save',
 116+ 'swl-group-save',
 117+ 'swl-group-category',
 118+ 'swl-group-namespace',
 119+ 'swl-group-concept',
117120 )
118121 );
119122

Status & tagging log