r111385 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111384‎ | r111385 | r111386 >
Date:16:28, 13 February 2012
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Modified paths:
  • /branches/REL1_19/extensions (modified) (history)
  • /branches/REL1_19/extensions/OggHandler/OggHandler.php (modified) (history)
  • /branches/REL1_19/extensions/OggHandler/OggHandler_body.php (modified) (history)
  • /branches/REL1_19/extensions/PagedTiffHandler/PagedTiffHandler.php (modified) (history)
  • /branches/REL1_19/extensions/PagedTiffHandler/PagedTiffHandler_body.php (modified) (history)
  • /branches/REL1_19/phase3/thumb.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/OggHandler/OggHandler.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/OggHandler/OggHandler_body.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/PagedTiffHandler/PagedTiffHandler.php (modified) (history)
  • /branches/wmf/1.19wmf1/extensions/PagedTiffHandler/PagedTiffHandler_body.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.19wmf1/extensions/OggHandler/OggHandler.php
@@ -30,6 +30,8 @@
3131 $wgExtensionMessagesFiles['OggHandlerMagic'] = "$oggDir/OggHandler.i18n.magic.php";
3232 $wgParserOutputHooks['OggHandler'] = array( 'OggHandler', 'outputHook' );
3333
 34+$wgHooks['ExtractThumbParameters'][] = 'OggHandler::onExtractThumbParameters';
 35+
3436 $wgExtensionCredits['media'][] = array(
3537 'path' => __FILE__,
3638 'name' => 'OggHandler',
Index: branches/wmf/1.19wmf1/extensions/OggHandler/OggHandler_body.php
@@ -510,6 +510,28 @@
511511 $instance->setHeaders( $outputPage );
512512 }
513513 }
 514+
 515+ /**
 516+ * Handler for the ExtractThumbParameters hook
 517+ *
 518+ * @param $thumbname string URL-decoded basename of URI
 519+ * @param &$params Array Currently parsed thumbnail params
 520+ */
 521+ public static function onExtractThumbParameters( $thumbname, array &$params ) {
 522+ if ( !preg_match( '/\.(?:ogg|ogv|oga)$/i', $params['f'] ) ) {
 523+ return true; // not an ogg file
 524+ }
 525+ // Check if the parameters can be extracted from the thumbnail name...
 526+ if ( preg_match( '!^(mid|seek=[0-9.]+)-[^/]*$!', $thumbname, $m ) ) {
 527+ list( /* all */, $timeFull ) = $m;
 528+ if ( $timeFull != 'mid' ) {
 529+ list( $seek, $thumbtime ) = explode( '=', $timeFull, 2 );
 530+ $params['thumbtime'] = $thumbtime;
 531+ }
 532+ return false; // valid thumbnail URL
 533+ }
 534+ return true; // pass through to next handler
 535+ }
514536 }
515537
516538 class OggTransformOutput extends MediaTransformOutput {
Property changes on: branches/wmf/1.19wmf1/extensions/OggHandler/OggHandler_body.php
___________________________________________________________________
Modified: svn:mergeinfo
517539 Merged /trunk/extensions/OggHandler/OggHandler_body.php:r111199
Index: branches/wmf/1.19wmf1/extensions/PagedTiffHandler/PagedTiffHandler_body.php
@@ -697,4 +697,25 @@
698698 $data = $this->getMetaArray( $image );
699699 return PagedTiffImage::getPageSize( $data, $page );
700700 }
 701+
 702+ /**
 703+ * Handler for the ExtractThumbParameters hook
 704+ *
 705+ * @param $thumbname string URL-decoded basename of URI
 706+ * @param &$params Array Currently parsed thumbnail params
 707+ */
 708+ public static function onExtractThumbParameters( $thumbname, array &$params ) {
 709+ if ( !preg_match( '/\.(?:tiff|tif)$/i', $params['f'] ) ) {
 710+ return true; // not an tiff file
 711+ }
 712+ // Check if the parameters can be extracted from the thumbnail name...
 713+ if ( preg_match( '!^(lossy|lossless)-page(\d+)-(\d+)px-[^/]*$!', $thumbname, $m ) ) {
 714+ list( /* all */, $lossy, $pagenum, $size ) = $matches;
 715+ $params['lossy'] = $lossy;
 716+ $params['width'] = $size;
 717+ $params['page'] = $pagenum;
 718+ return false; // valid thumbnail URL
 719+ }
 720+ return true; // pass through to next handler
 721+ }
701722 }
Index: branches/wmf/1.19wmf1/extensions/PagedTiffHandler/PagedTiffHandler.php
@@ -130,3 +130,5 @@
131131 //$wgHooks['PagedTiffHandlerRenderCommand'][] = 'PagedTiffHandler::renderCommand';
132132 //$wgHooks['PagedTiffHandlerTiffData'][] = 'PagedTiffImage::tiffData';
133133 //$wgHooks['PagedTiffHandlerExifData'][] = 'PagedTiffImage::exifData';
 134+
 135+$wgHooks['ExtractThumbParameters'][] = 'PagedTiffHandler::onExtractThumbParameters';
Property changes on: branches/wmf/1.19wmf1/extensions
___________________________________________________________________
Modified: svn:mergeinfo
134136 Merged /trunk/extensions:r111199
Index: branches/REL1_19/extensions/OggHandler/OggHandler.php
@@ -30,6 +30,8 @@
3131 $wgExtensionMessagesFiles['OggHandlerMagic'] = "$oggDir/OggHandler.i18n.magic.php";
3232 $wgParserOutputHooks['OggHandler'] = array( 'OggHandler', 'outputHook' );
3333
 34+$wgHooks['ExtractThumbParameters'][] = 'OggHandler::onExtractThumbParameters';
 35+
3436 $wgExtensionCredits['media'][] = array(
3537 'path' => __FILE__,
3638 'name' => 'OggHandler',
Index: branches/REL1_19/extensions/OggHandler/OggHandler_body.php
@@ -510,6 +510,28 @@
511511 $instance->setHeaders( $outputPage );
512512 }
513513 }
 514+
 515+ /**
 516+ * Handler for the ExtractThumbParameters hook
 517+ *
 518+ * @param $thumbname string URL-decoded basename of URI
 519+ * @param &$params Array Currently parsed thumbnail params
 520+ */
 521+ public static function onExtractThumbParameters( $thumbname, array &$params ) {
 522+ if ( !preg_match( '/\.(?:ogg|ogv|oga)$/i', $params['f'] ) ) {
 523+ return true; // not an ogg file
 524+ }
 525+ // Check if the parameters can be extracted from the thumbnail name...
 526+ if ( preg_match( '!^(mid|seek=[0-9.]+)-[^/]*$!', $thumbname, $m ) ) {
 527+ list( /* all */, $timeFull ) = $m;
 528+ if ( $timeFull != 'mid' ) {
 529+ list( $seek, $thumbtime ) = explode( '=', $timeFull, 2 );
 530+ $params['thumbtime'] = $thumbtime;
 531+ }
 532+ return false; // valid thumbnail URL
 533+ }
 534+ return true; // pass through to next handler
 535+ }
514536 }
515537
516538 class OggTransformOutput extends MediaTransformOutput {
Property changes on: branches/REL1_19/extensions/OggHandler/OggHandler_body.php
___________________________________________________________________
Modified: svn:mergeinfo
517539 Merged /trunk/extensions/OggHandler/OggHandler_body.php:r111199
Index: branches/REL1_19/extensions/PagedTiffHandler/PagedTiffHandler_body.php
@@ -697,4 +697,25 @@
698698 $data = $this->getMetaArray( $image );
699699 return PagedTiffImage::getPageSize( $data, $page );
700700 }
 701+
 702+ /**
 703+ * Handler for the ExtractThumbParameters hook
 704+ *
 705+ * @param $thumbname string URL-decoded basename of URI
 706+ * @param &$params Array Currently parsed thumbnail params
 707+ */
 708+ public static function onExtractThumbParameters( $thumbname, array &$params ) {
 709+ if ( !preg_match( '/\.(?:tiff|tif)$/i', $params['f'] ) ) {
 710+ return true; // not an tiff file
 711+ }
 712+ // Check if the parameters can be extracted from the thumbnail name...
 713+ if ( preg_match( '!^(lossy|lossless)-page(\d+)-(\d+)px-[^/]*$!', $thumbname, $m ) ) {
 714+ list( /* all */, $lossy, $pagenum, $size ) = $matches;
 715+ $params['lossy'] = $lossy;
 716+ $params['width'] = $size;
 717+ $params['page'] = $pagenum;
 718+ return false; // valid thumbnail URL
 719+ }
 720+ return true; // pass through to next handler
 721+ }
701722 }
Index: branches/REL1_19/extensions/PagedTiffHandler/PagedTiffHandler.php
@@ -130,3 +130,5 @@
131131 //$wgHooks['PagedTiffHandlerRenderCommand'][] = 'PagedTiffHandler::renderCommand';
132132 //$wgHooks['PagedTiffHandlerTiffData'][] = 'PagedTiffImage::tiffData';
133133 //$wgHooks['PagedTiffHandlerExifData'][] = 'PagedTiffImage::exifData';
 134+
 135+$wgHooks['ExtractThumbParameters'][] = 'PagedTiffHandler::onExtractThumbParameters';
Property changes on: branches/REL1_19/extensions
___________________________________________________________________
Modified: svn:mergeinfo
134136 Merged /trunk/extensions:r111199
Index: branches/REL1_19/phase3/thumb.php
@@ -271,7 +271,6 @@
272272 }
273273
274274 // Check if the parameters can be extracted from the thumbnail name...
275 - // @TODO: remove 'page' stuff and make ProofreadPage handle it via hook.
276275 if ( preg_match( '!^(page(\d*)-)*(\d*)px-[^/]*$!', $thumbname, $matches ) ) {
277276 list( /* all */, $pagefull, $pagenum, $size ) = $matches;
278277 $params['width'] = $size;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111199* Removed thumb.php comment about ProofreadPage, page numbers are more general....aaron20:52, 10 February 2012
r111384Followup r111199...reedy16:22, 13 February 2012

Comments

#Comment by Reedy (talk | contribs)   16:29, 13 February 2012

Merges r111384 also

Status & tagging log