r70653 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r70652‎ | r70653 | r70654 >
Date:22:35, 7 August 2010
Author:platonides
Status:ok
Tags:
Comment:
Make thumbsize option go through ParserOptions.
Yet another parameter for makeImageLink2...
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)
  • /trunk/phase3/includes/parser/Parser.php (modified) (history)
  • /trunk/phase3/includes/parser/ParserOptions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/parser/Parser.php
@@ -4777,7 +4777,7 @@
47784778 wfRunHooks( 'ParserMakeImageParams', array( $title, $file, &$params ) );
47794779
47804780 # Linker does the rest
4781 - $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery );
 4781+ $ret = $sk->makeImageLink2( $title, $file, $params['frame'], $params['handler'], $time, $descQuery, $this->mOptions->getThumbSize() );
47824782
47834783 # Give the handler a chance to modify the parser object
47844784 if ( $handler ) {
Index: trunk/phase3/includes/parser/ParserOptions.php
@@ -31,6 +31,7 @@
3232 var $mExternalLinkTarget; # Target attribute for external links
3333 var $mMath; # User math preference (as integer)
3434 var $mUserLang; # Language code of the User language.
 35+ var $mThumbSize; # Thumb size preferred by the user.
3536
3637 var $mUser; # Stored user object, just used to initialise the skin
3738 var $mIsPreview; # Parsing the page for a "preview" operation
@@ -58,6 +59,7 @@
5960 function getCleanSignatures() { return $this->mCleanSignatures; }
6061 function getExternalLinkTarget() { return $this->mExternalLinkTarget; }
6162 function getMath() { return $this->mMath; }
 63+ function getThumbSize() { return $this->mThumbSize; }
6264
6365 function getIsPreview() { return $this->mIsPreview; }
6466 function getIsSectionPreview() { return $this->mIsSectionPreview; }
@@ -115,6 +117,7 @@
116118 function setExternalLinkTarget( $x ) { return wfSetVar( $this->mExternalLinkTarget, $x ); }
117119 function setMath( $x ) { return wfSetVar( $this->mMath, $x ); }
118120 function setUserLang( $x ) { return wfSetVar( $this->mUserLang, $x ); }
 121+ function setThumbSize() { return wfSetVar( $this->mThumbSize, $x ); }
119122
120123 function setIsPreview( $x ) { return wfSetVar( $this->mIsPreview, $x ); }
121124 function setIsSectionPreview( $x ) { return wfSetVar( $this->mIsSectionPreview, $x ); }
Index: trunk/phase3/includes/Linker.php
@@ -433,7 +433,7 @@
434434 * @param $query String: query params for desc url
435435 * @return String: HTML for an image, with links, wrappers, etc.
436436 */
437 - function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "" ) {
 437+ function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false, $query = "", $widthOption = null ) {
438438 $res = null;
439439 if( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title,
440440 &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) {
@@ -467,10 +467,8 @@
468468 $hp['width'] = $file->getWidth( $page );
469469
470470 if( isset( $fp['thumbnail'] ) || isset( $fp['framed'] ) || isset( $fp['frameless'] ) || !$hp['width'] ) {
471 - $wopt = $wgUser->getOption( 'thumbsize' );
472 -
473 - if( !isset( $wgThumbLimits[$wopt] ) ) {
474 - $wopt = User::getDefaultOption( 'thumbsize' );
 471+ if( !isset( $widthOption ) || !isset( $wgThumbLimits[$widthOption] ) ) {
 472+ $widthOption = User::getDefaultOption( 'thumbsize' );
475473 }
476474
477475 // Reduce width for upright images when parameter 'upright' is used
@@ -480,8 +478,8 @@
481479 // Use width which is smaller: real image width or user preference width
482480 // For caching health: If width scaled down due to upright parameter, round to full __0 pixel to avoid the creation of a lot of odd thumbs
483481 $prefWidth = isset( $fp['upright'] ) ?
484 - round( $wgThumbLimits[$wopt] * $fp['upright'], -1 ) :
485 - $wgThumbLimits[$wopt];
 482+ round( $wgThumbLimits[$widthOption] * $fp['upright'], -1 ) :
 483+ $wgThumbLimits[$widthOption];
486484 if ( $hp['width'] <= 0 || $prefWidth < $hp['width'] ) {
487485 if( !isset( $hp['height'] ) ) {
488486 $hp['width'] = $prefWidth;

Follow-up revisions

RevisionCommit summaryAuthorDate
r70780Follow up r70653. Missing line.platonides20:39, 9 August 2010
r70783Use only the page relevant pieces in the parser cache key. Eg. two users with...platonides21:53, 9 August 2010
r70954No need for $wgUser since r70653platonides14:00, 12 August 2010

Status & tagging log