r52497 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r52496‎ | r52497 | r52498 >
Date:19:50, 27 June 2009
Author:thomasv
Status:deferred
Tags:
Comment:
create a separate hook function, that aborts if the index is a djvu index. remove unused counters
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -9,7 +9,7 @@
1010 $wgExtensionMessagesFiles['ProofreadPage'] = dirname( __FILE__ ) . '/ProofreadPage.i18n.php';
1111
1212 $wgHooks['BeforePageDisplay'][] = 'pr_beforePageDisplay';
13 -$wgHooks['GetLinkColours'][] = 'pr_getLinkColours';
 13+$wgHooks['GetLinkColours'][] = 'pr_getLinkColoursHook';
1414 $wgHooks['ImageOpenShowImageInlineBefore'][] = 'pr_imageMessage';
1515 $wgHooks['ArticleSaveComplete'][] = 'pr_articleSave';
1616 $wgHooks['EditFormPreloadText'][] = 'pr_preloadText';
@@ -387,10 +387,10 @@
388388
389389
390390 /**
391 - * Return the quality colour codes to pages linked from an index page
392 - * Update page counts in pr_index table
 391+ * Hook function
393392 */
394 -function pr_getLinkColours( $page_ids, &$colours ) {
 393+function pr_getLinkColoursHook( $page_ids, &$colours ) {
 394+
395395 global $wgTitle;
396396
397397 if ( !isset( $wgTitle ) ) {
@@ -400,12 +400,26 @@
401401
402402 // abort if we are not an index page
403403 $index_namespace = preg_quote( wfMsgForContent( 'proofreadpage_index_namespace' ), '/' );
404 - if ( !preg_match( "/^$index_namespace:(.*?)$/", $wgTitle->getPrefixedText() ) ) {
 404+ if ( !preg_match( "/^$index_namespace:(.*?)$/", $wgTitle->getPrefixedText(), $m ) ) {
405405 return true;
406406 }
 407+ // abort too if we are a djvu index
 408+ $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
 409+ if ( $imageTitle ) {
 410+ $image = wfFindFile( $imageTitle );
 411+ if ( $image && $image->isMultiPage() ) {
 412+ return true;
 413+ }
 414+ }
 415+ pr_getLinkColours( $page_ids, $colours );
 416+ return true;
 417+}
 418+
407419
408 - // counters
409 - $n = $n0 = $n1 = $n2 = $n3 = $n4 = 0;
 420+/**
 421+ * Return the quality colour codes to pages linked from an index page
 422+ */
 423+function pr_getLinkColours( $page_ids, &$colours ) {
410424
411425 $dbr = wfGetDB( DB_SLAVE );
412426 $catlinks = $dbr->tableName( 'categorylinks' );
@@ -414,8 +428,6 @@
415429 $page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' );
416430 if ( preg_match( "/^$page_namespace:(.*?)$/", $pdbk ) ) {
417431 $colours[$pdbk] = 'quality1';
418 - $n++;
419 -
420432 if ( !isset( $query ) ) {
421433 $query = "SELECT cl_from, cl_to FROM $catlinks WHERE cl_from IN(";
422434 } else {
@@ -434,29 +446,22 @@
435447 switch( $x->cl_to ) {
436448 case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality0_category' ) ):
437449 $colours[$pdbk] = 'quality0';
438 - $n0++;
439450 break;
440451 case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality1_category' ) ):
441452 $colours[$pdbk] = 'quality1';
442 - $n1++;
443453 break;
444454 case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality2_category' ) ):
445455 $colours[$pdbk] = 'quality2';
446 - $n2++;
447456 break;
448457 case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality3_category' ) ):
449458 $colours[$pdbk] = 'quality3';
450 - $n3++;
451459 break;
452460 case str_replace( ' ' , '_' , wfMsgForContent( 'proofreadpage_quality4_category' ) ):
453461 $colours[$pdbk] = 'quality4';
454 - $n4++;
455462 break;
456463 }
457464 }
458465 }
459 -
460 - return true;
461466 }
462467
463468 function pr_imageMessage( &$imgpage , &$wgOut ) {

Status & tagging log