r108850 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108849‎ | r108850 | r108851 >
Date:21:24, 13 January 2012
Author:rmoen
Status:reverted (Comments)
Tags:
Comment:
patch from MrBlueSky, resloves bug 25909. Add dropdown list for tags in recent changes and new pages
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.19 (modified) (history)
  • /trunk/phase3/includes/ChangeTags.php (modified) (history)
  • /trunk/phase3/includes/actions/HistoryAction.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialNewpages.php (modified) (history)
  • /trunk/phase3/includes/specials/SpecialRecentchanges.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesQqq.php (modified) (history)

Diff [purge]

Index: trunk/phase3/RELEASE-NOTES-1.19
@@ -119,6 +119,7 @@
120120 * mediawiki.js Message object constructor is now publicly available as mw.Message.
121121 * (bug 29309) allow CSS class per tooltip (tipsy)
122122 * (bug 33565) Add accesskey/tooltip to submit buttons on Special:EditWatchlist.
 123+* (bug 25909) Add a drop-down list for the tags in Recentchanges and Newpages
123124
124125 === Bug fixes in 1.19 ===
125126 * $wgUploadNavigationUrl should be used for file redlinks if.
Index: trunk/phase3/includes/ChangeTags.php
@@ -26,7 +26,7 @@
2727
2828 static function tagDescription( $tag ) {
2929 $msg = wfMessage( "tag-$tag" );
30 - return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag );
 30+ return $msg->exists() ? $msg->parse() : htmlspecialchars( $tag );
3131 }
3232
3333 ## Basic utility method to add tags to a particular change, given its rc_id, rev_id and/or log_id.
@@ -109,7 +109,10 @@
110110 global $wgRequest, $wgUseTagFilter;
111111
112112 if( $filter_tag === false ) {
113 - $filter_tag = $wgRequest->getVal( 'tagfilter' );
 113+ $filter_tag = $wgRequest->getVal( 'tagfilterdropdown', '' );
 114+ if ( $filter_tag === '' || $filter_tag === 'other' ) {
 115+ $filter_tag = $wgRequest->getVal( 'tagfilter' );
 116+ }
114117 }
115118
116119 // Figure out which conditions can be done.
@@ -178,6 +181,45 @@
179182 }
180183
181184 /**
 185+ * Build a text box and a dropdown list to select a change tag
 186+ *
 187+ * @param $msgkey String: message key for the message where a (newline delimited)
 188+ * list of tags can be specified. These tags will be put in the dropdown list.
 189+ * If the specified message is empty, only the text field will be returned.
 190+ * @param $selectedtxt String: tag to put in text box
 191+ * @param $selecteddropdown String: tag to select in dropdown
 192+ * @return Array of html fragments of which the first element is the label
 193+ * If $wgUseTagFilter is false or there are no defined tags, an empty array is returned
 194+ */
 195+ public static function buildTagFilterWithDropdown( $msgkey, $selectedtxt = '', $selecteddropdown = 'other' ) {
 196+
 197+ global $wgUseTagFilter;
 198+
 199+ $definedtags = self::listDefinedTags();
 200+
 201+ if ( !$wgUseTagFilter || !count( $definedtags ) ) {
 202+ // no tag filter if there are no tags defined or $wgUseTagFilter is false
 203+ return array();
 204+ }
 205+
 206+ // Extract tags from message: one tag per line
 207+ $tags = preg_split( "/\n/", wfMsgForContent( $msgkey ), -1, PREG_SPLIT_NO_EMPTY);
 208+
 209+ $data[] = Html::rawElement( 'label', array( 'for' => 'tagfilter' ), wfMsgExt( 'tag-filter', 'parseinline' ) );
 210+
 211+ if ( count( $tags ) ) {
 212+ // Add dropdown list only when message $msgkey contains at least one tag
 213+ $data[] = Xml::listDropDown( 'tagfilterdropdown', implode( "\n", $tags ),
 214+ wfMsgForContent( 'tag-filter-dropdown-other' ), $selecteddropdown );
 215+ }
 216+
 217+ $data[] = Xml::input( 'tagfilter', 20, $selectedtxt );
 218+
 219+ return $data;
 220+
 221+ }
 222+
 223+ /**
182224 *Basically lists defined tags which count even if they aren't applied to anything
183225 *
184226 * @return array
Index: trunk/phase3/includes/actions/HistoryAction.php
@@ -136,7 +136,13 @@
137137 $year = $request->getInt( 'year' );
138138 $month = $request->getInt( 'month' );
139139 $tagFilter = $request->getVal( 'tagfilter' );
140 - $tagSelector = ChangeTags::buildTagFilterSelector( $tagFilter );
 140+ $tagFilterDropdown = $request->getVal( 'tagfilterdropdown' );
 141+ $tagSelector = ChangeTags::buildTagFilterWithDropdown(
 142+ 'tag-filter-dropdown-list',
 143+ $tagFilter,
 144+ $tagFilterDropdown
 145+ );
 146+ $tagSelector = implode( ' ', $tagSelector );
141147
142148 /**
143149 * Option to show only revisions that have been (partially) hidden via RevisionDelete
@@ -161,14 +167,26 @@
162168 Html::hidden( 'title', $this->getTitle()->getPrefixedDBKey() ) . "\n" .
163169 Html::hidden( 'action', 'history' ) . "\n" .
164170 Xml::dateMenu( $year, $month ) . ' ' .
165 - ( $tagSelector ? ( implode( ' ', $tagSelector ) . ' ' ) : '' ) .
166 - $checkDeleted .
 171+ Html::rawElement(
 172+ 'span',
 173+ array( 'style' => 'white-space: nowrap' ),
 174+ ( $tagSelector ? ( $tagSelector . ' ' ) : '' )
 175+ ) .
 176+ Html::rawElement(
 177+ 'span',
 178+ array( 'style' => 'white-space: nowrap' ),
 179+ $checkDeleted
 180+ ) .
167181 Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "\n" .
168182 '</fieldset></form>'
169183 );
170184
171185 wfRunHooks( 'PageHistoryBeforeList', array( &$this->page ) );
172186
 187+ if ( $tagFilterDropdown !== '' && $tagFilterDropdown !== 'other' ) {
 188+ $tagFilter = $tagFilterDropdown;
 189+ }
 190+
173191 // Create and output the list.
174192 $pager = new HistoryPager( $this, $year, $month, $tagFilter, $conds );
175193 $out->addHTML(
Index: trunk/phase3/includes/specials/SpecialNewpages.php
@@ -59,6 +59,7 @@
6060 $opts->add( 'username', '' );
6161 $opts->add( 'feed', '' );
6262 $opts->add( 'tagfilter', '' );
 63+ $opts->add( 'tagfilterdropdown', '' );
6364
6465 $this->customFilters = array();
6566 wfRunHooks( 'SpecialNewPagesFilters', array( $this, &$this->customFilters ) );
@@ -211,6 +212,7 @@
212213 $namespace = $this->opts->consumeValue( 'namespace' );
213214 $username = $this->opts->consumeValue( 'username' );
214215 $tagFilterVal = $this->opts->consumeValue( 'tagfilter' );
 216+ $tagFilterDropdownVal = $this->opts->consumeValue( 'tagfilterdropdown' );
215217
216218 // Check username input validity
217219 $ut = Title::makeTitleSafe( NS_USER, $username );
@@ -223,9 +225,14 @@
224226 }
225227 $hidden = implode( "\n", $hidden );
226228
227 - $tagFilter = ChangeTags::buildTagFilterSelector( $tagFilterVal );
 229+ $tagFilter = ChangeTags::buildTagFilterWithDropdown(
 230+ 'tag-filter-newpages-dropdown-list',
 231+ $tagFilterVal,
 232+ $tagFilterDropdownVal
 233+ );
228234 if ( $tagFilter ) {
229 - list( $tagFilterLabel, $tagFilterSelector ) = $tagFilter;
 235+ $tagFilterLabel = array_shift( $tagFilter );
 236+ $tagFilterSelector = implode( '&#160;', $tagFilter );
230237 }
231238
232239 $form = Xml::openElement( 'form', array( 'action' => $wgScript ) ) .
@@ -533,8 +540,7 @@
534541 $fields,
535542 $info['conds'],
536543 $info['join_conds'],
537 - $info['options'],
538 - $this->opts['tagfilter']
 544+ $info['options']
539545 );
540546
541547 return $info;
Index: trunk/phase3/includes/specials/SpecialRecentchanges.php
@@ -60,6 +60,7 @@
6161 $opts->add( 'categories', '' );
6262 $opts->add( 'categories_any', false );
6363 $opts->add( 'tagfilter', '' );
 64+ $opts->add( 'tagfilterdropdown', '' );
6465 return $opts;
6566 }
6667
@@ -400,8 +401,7 @@
401402 // Tag stuff.
402403 // Doesn't work when transcluding. See bug 23293
403404 ChangeTags::modifyDisplayQuery(
404 - $tables, $fields, $conds, $join_conds, $query_options,
405 - $opts['tagfilter']
 405+ $tables, $fields, $conds, $join_conds, $query_options
406406 );
407407 }
408408
@@ -554,7 +554,7 @@
555555 $nondefaults = $opts->getChangedValues();
556556 $opts->consumeValues( array(
557557 'namespace', 'invert', 'associated', 'tagfilter',
558 - 'categories', 'categories_any'
 558+ 'categories', 'categories_any', 'tagfilterdropdown'
559559 ) );
560560
561561 $panel = array();
@@ -616,9 +616,10 @@
617617 $extraOpts['category'] = $this->categoryFilterForm( $opts );
618618 }
619619
620 - $tagFilter = ChangeTags::buildTagFilterSelector( $opts['tagfilter'] );
 620+ $tagFilter = ChangeTags::buildTagFilterWithDropdown( 'tag-filter-dropdown-list',
 621+ $opts['tagfilter'], $opts['tagfilterdropdown'] );
621622 if ( count( $tagFilter ) ) {
622 - $extraOpts['tagfilter'] = $tagFilter;
 623+ $extraOpts['tagfilter'] = implode( '&#160;', $tagFilter );
623624 }
624625
625626 wfRunHooks( 'SpecialRecentChangesPanel', array( &$extraOpts, $opts ) );
Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -103,6 +103,7 @@
104104 $this->opts['nsInvert'] = (bool) $request->getVal( 'nsInvert' );
105105
106106 $this->opts['tagfilter'] = (string) $request->getVal( 'tagfilter' );
 107+ $this->opts['tagfilterdropdown'] = (string) $request->getVal( 'tagfilterdropdown' );
107108
108109 // Allows reverts to have the bot flag in recent changes. It is just here to
109110 // be passed in the form at the top of the page
@@ -138,6 +139,9 @@
139140 if ( $this->opts['tagfilter'] !== '' ) {
140141 $apiParams['tagfilter'] = $this->opts['tagfilter'];
141142 }
 143+ if ( $this->opts['tagfilterdropdown'] !== '' && $this->opts['tagfilterdropdown'] !== 'other' ) {
 144+ $apiParams['tagfilter'] = $this->opts['tagfilterdropdown'];
 145+ }
142146 if ( $this->opts['namespace'] !== '' ) {
143147 $apiParams['namespace'] = $this->opts['namespace'];
144148 }
@@ -399,7 +403,11 @@
400404 $form .= "\t" . Html::hidden( $name, $value ) . "\n";
401405 }
402406
403 - $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] );
 407+ $tagFilter = ChangeTags::buildTagFilterWithDropdown(
 408+ 'tag-filter-dropdown-list',
 409+ $this->opts['tagfilter'],
 410+ $this->opts['tagfilterdropdown']
 411+ );
404412
405413 if ( $tagFilter ) {
406414 $filterSelection =
Index: trunk/phase3/languages/messages/MessagesQqq.php
@@ -4428,7 +4428,13 @@
44294429 'tags-hitcount' => 'Shown in the “Tagged changes” column in [[Special:Tags]]. For more information on tags see [//www.mediawiki.org/wiki/Manual:Tags Mediawiki].
44304430
44314431 * <code>$1</code> is the number of changes marked with the tag',
 4432+'tag-filter-dropdown-list' => 'A list of change tags to put in a dropdown list for selecting a tag to filter by.',
 4433+'tag-filter-newpages-dropdown-list' => 'A list of change tags to put in a dropdown list for selecting a tag to filter by on [[Special:NewPages]].',
 4434+'tag-filter-dropdown-other' => 'The "other" option in the dropdown list for selecting a tag to filter by. When a user selects this, he can type any tag in the text field next to it.
44324435
 4436+{{Identical|Other}}
 4437+',
 4438+
44334439 # Special:ComparePages
44344440 'comparepages' => 'The title of [[Special:ComparePages]]',
44354441 'compare-selector' => 'Header of the form on [[Special:ComparePages]]',
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -4634,6 +4634,9 @@
46354635 'tags-hitcount-header' => 'Tagged changes',
46364636 'tags-edit' => 'edit',
46374637 'tags-hitcount' => '$1 {{PLURAL:$1|change|changes}}',
 4638+'tag-filter-dropdown-other' => 'Other:',
 4639+'tag-filter-dropdown-list' => '',
 4640+'tag-filter-newpages-dropdown-list' => '',
46384641
46394642 # Special:ComparePages
46404643 'comparepages' => 'Compare pages',

Follow-up revisions

RevisionCommit summaryAuthorDate
r108857reverted r108850 as patch should be introduced after code freezermoen21:57, 13 January 2012

Comments

#Comment by Nikerabbit (talk | contribs)   21:30, 13 January 2012

maintenance/language/messages.inc needs updating too.

#Comment by Siebrand (talk | contribs)   21:34, 13 January 2012

There are two messages that need to be added in the ignored array of messageTypes.inc, too: 'tag-filter-dropdown-list' and 'tag-filter-newpages-dropdown-list' are empty and are meant to be filled as a local customisation without localisation.

#Comment by Siebrand (talk | contribs)   21:32, 13 January 2012

Recommending revert. This is a feature that should only be implemented after 1.19 has been branched.

Status & tagging log