r34277 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34276‎ | r34277 | r34278 >
Date:22:14, 5 May 2008
Author:brion
Status:old
Tags:
Comment:
Revert r34267, r34268, r34269, r34270 for now.
I don't like the UI chhanges here; the file usage links simply disappear from their current location with no warning or explanation, while the in-page TOC at the top suddenly starts linking to a different page, totally unexpectedly.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/includes/SpecialWhatlinkshere.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1518,11 +1518,9 @@
15191519 'nolinkshere-ns',
15201520 'isredirect',
15211521 'istemplate',
1522 - 'isimage',
15231522 'whatlinkshere-prev',
15241523 'whatlinkshere-next',
15251524 'whatlinkshere-links',
1526 - 'whatlinkshere-hideimages',
15271525 'whatlinkshere-hideredirs',
15281526 'whatlinkshere-hidetrans',
15291527 'whatlinkshere-hidelinks',
Index: trunk/phase3/includes/SpecialWhatlinkshere.php
@@ -51,7 +51,6 @@
5252 $opts->add( 'hideredirs', false );
5353 $opts->add( 'hidetrans', false );
5454 $opts->add( 'hidelinks', false );
55 - $opts->add( 'hideimages', false );
5655
5756 $opts->fetchValuesFromRequest( $this->request );
5857 $opts->validateIntBounds( 'limit', 0, 5000 );
@@ -95,7 +94,6 @@
9695 $hidelinks = $this->opts->getValue( 'hidelinks' );
9796 $hideredirs = $this->opts->getValue( 'hideredirs' );
9897 $hidetrans = $this->opts->getValue( 'hidetrans' );
99 - $hideimages = $target->getNamespace() != NS_IMAGE || $this->opts->getValue( 'hideimages' );
10098
10199 $fetchlinks = !$hidelinks || !$hideredirs;
102100
@@ -117,10 +115,6 @@
118116 'tl_title' => $target->getDBkey(),
119117 );
120118
121 - $ilConds = array(
122 - 'page_id=il_from',
123 - 'il_to' => $target->getDBkey(),
124 - );
125119
126120 $namespace = $this->opts->getValue( 'namespace' );
127121 if ( is_int($namespace) ){
@@ -155,19 +149,13 @@
156150 $tlConds, __METHOD__, $options );
157151 }
158152
159 - if( !$hideimages ) {
160 - $options['ORDER BY'] = 'il_from';
161 - $ilRes = $dbr->select( array( 'imagelinks', 'page' ), $fields,
162 - $ilConds, __METHOD__, $options );
163 - }
164 -
165 - if( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) && ( $hideimages || !$dbr->numRows( $ilRes ) ) ) {
 153+ if( ( !$fetchlinks || !$dbr->numRows( $plRes ) ) && ( $hidetrans || !$dbr->numRows( $tlRes ) ) ) {
166154 if ( 0 == $level ) {
167155 $wgOut->addHTML( $this->whatlinkshereForm() );
168156 $errMsg = is_int($namespace) ? 'nolinkshere-ns' : 'nolinkshere';
169157 $wgOut->addWikiMsg( $errMsg, $this->target->getPrefixedText() );
170158 // Show filters only if there are links
171 - if( $hidelinks || $hidetrans || $hideredirs || $hideimages )
 159+ if( $hidelinks || $hidetrans || $hideredirs )
172160 $wgOut->addHTML( $this->getFilterPanel() );
173161 }
174162 return;
@@ -179,7 +167,6 @@
180168 if( $fetchlinks ) {
181169 while ( $row = $dbr->fetchObject( $plRes ) ) {
182170 $row->is_template = 0;
183 - $row->is_image = 0;
184171 $rows[$row->page_id] = $row;
185172 }
186173 $dbr->freeResult( $plRes );
@@ -188,19 +175,10 @@
189176 if( !$hidetrans ) {
190177 while ( $row = $dbr->fetchObject( $tlRes ) ) {
191178 $row->is_template = 1;
192 - $row->is_image = 0;
193179 $rows[$row->page_id] = $row;
194180 }
195181 $dbr->freeResult( $tlRes );
196182 }
197 - if( !$hideimages ) {
198 - while ( $row = $dbr->fetchObject( $ilRes ) ) {
199 - $row->is_template = 0;
200 - $row->is_image = 1;
201 - $rows[$row->page_id] = $row;
202 - }
203 - $dbr->freeResult( $ilRes );
204 - }
205183
206184 // Sort by key and then change the keys to 0-based indices
207185 ksort( $rows );
@@ -259,7 +237,7 @@
260238 static $msgcache = null;
261239 if ( $msgcache === null ) {
262240 static $msgs = array( 'isredirect', 'istemplate', 'semicolon-separator',
263 - 'whatlinkshere-links', 'isimage' );
 241+ 'whatlinkshere-links' );
264242 $msgcache = array();
265243 foreach ( $msgs as $msg ) {
266244 $msgcache[$msg] = wfMsgHtml( $msg );
@@ -276,8 +254,6 @@
277255 $props[] = $msgcache['isredirect'];
278256 if ( $row->is_template )
279257 $props[] = $msgcache['istemplate'];
280 - if( $row->is_image )
281 - $props[] = $msgcache['isimage'];
282258
283259 if ( count( $props ) ) {
284260 $propsText = '(' . implode( $msgcache['semicolon-separator'], $props ) . ')';
@@ -390,10 +366,7 @@
391367 unset($changed['target']); // Already in the request title
392368
393369 $links = array();
394 - $types = array( 'hidetrans', 'hidelinks', 'hideredirs' );
395 - if( $this->target->getNamespace() == NS_IMAGE )
396 - $types[] = 'hideimages';
397 - foreach( $types as $type ) {
 370+ foreach( array( 'hidetrans', 'hidelinks', 'hideredirs' ) as $type ) {
398371 $chosen = $this->opts->getValue( $type );
399372 $msg = wfMsgHtml( "whatlinkshere-{$type}", $chosen ? $show : $hide );
400373 $overrides = array( $type => !$chosen );
Index: trunk/phase3/includes/ImagePage.php
@@ -87,7 +87,7 @@
8888
8989 $this->closeShowImage();
9090 $this->imageHistory();
91 -
 91+ $this->imageLinks();
9292
9393 if ( $showmeta ) {
9494 global $wgStylePath, $wgStyleVersion;
@@ -111,12 +111,10 @@
112112 */
113113 function showTOC( $metadata ) {
114114 global $wgLang;
115 - $wlh = SpecialPage::getTitleFor( 'Whatlinkshere' );
116 - $backlinksUrl = $wlh->getLocalUrl( 'hidelinks=1&hidetrans=1&target=' . urlencode( $this->mTitle->getFullText() ) );
117115 $r = '<ul id="filetoc">
118116 <li><a href="#file">' . $wgLang->getNsText( NS_IMAGE ) . '</a></li>
119117 <li><a href="#filehistory">' . wfMsgHtml( 'filehist' ) . '</a></li>
120 - <li><a href="' . htmlspecialchars( $backlinksUrl ) . '">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
 118+ <li><a href="#filelinks">' . wfMsgHtml( 'imagelinks' ) . '</a></li>' .
121119 ($metadata ? ' <li><a href="#metadata">' . wfMsgHtml( 'metadata' ) . '</a></li>' : '') . '
122120 </ul>';
123121 return $r;
@@ -494,6 +492,36 @@
495493
496494 }
497495
 496+ function imageLinks()
 497+ {
 498+ global $wgUser, $wgOut;
 499+
 500+ $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" );
 501+
 502+ $dbr = wfGetDB( DB_SLAVE );
 503+ $page = $dbr->tableName( 'page' );
 504+ $imagelinks = $dbr->tableName( 'imagelinks' );
 505+
 506+ $sql = "SELECT page_namespace,page_title FROM $imagelinks,$page WHERE il_to=" .
 507+ $dbr->addQuotes( $this->mTitle->getDBkey() ) . " AND il_from=page_id";
 508+ $sql = $dbr->limitResult($sql, 500, 0);
 509+ $res = $dbr->query( $sql, "ImagePage::imageLinks" );
 510+
 511+ if ( 0 == $dbr->numRows( $res ) ) {
 512+ $wgOut->addHtml( '<p>' . wfMsg( "nolinkstoimage" ) . "</p>\n" );
 513+ return;
 514+ }
 515+ $wgOut->addHTML( '<p>' . wfMsg( 'linkstoimage' ) . "</p>\n<ul>" );
 516+
 517+ $sk = $wgUser->getSkin();
 518+ while ( $s = $dbr->fetchObject( $res ) ) {
 519+ $name = Title::MakeTitle( $s->page_namespace, $s->page_title );
 520+ $link = $sk->makeKnownLinkObj( $name, "" );
 521+ $wgOut->addHTML( "<li>{$link}</li>\n" );
 522+ }
 523+ $wgOut->addHTML( "</ul>\n" );
 524+ }
 525+
498526 /**
499527 * Delete the file, or an earlier version of it
500528 */
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2422,8 +2422,8 @@
24232423 cannot move a page over itself.',
24242424 'immobile_namespace' => 'Source or destination title is of a special type;
24252425 cannot move pages from and into that namespace.',
2426 -'imagenocrossnamespace' => 'Cannot move file to non-file namespace',
2427 -'imagetypemismatch' => 'The new file extension does not match its type',
 2426+'imagenocrossnamespace' => "Cannot move file to non-file namespace",
 2427+'imagetypemismatch' => "The new file extension does not match its type",
24282428
24292429 # Export
24302430 'export' => 'Export pages',
Index: trunk/phase3/RELEASE-NOTES
@@ -103,7 +103,6 @@
104104 shared when $wgSharedDB is enabled.
105105 * Drop-down AJAX search suggestions (turn on $wgEnableMWSuggest)
106106 * More relevant search snippets (turn on $wgAdvancedSearchHighlighting)
107 -* Image links are now displayed using Special:Whatlinkshere
108107
109108 === Bug fixes in 1.13 ===
110109

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r34267Show image links on Special:WhatLinksHere:...vasilievvv19:47, 5 May 2008
r34268Fix XHTML per ialexvasilievvv19:56, 5 May 2008
r34269Maybe it's better not to commit new features at 23:00?vasilievvv20:01, 5 May 2008
r34270And messages.inc ? ;)ialex20:05, 5 May 2008

Status & tagging log