r48486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r48485‎ | r48486 | r48487 >
Date:14:04, 17 March 2009
Author:thomasv
Status:resolved (Comments)
Tags:
Comment:
if available, extract text using djvutxt
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -12,7 +12,11 @@
1313 $wgHooks['GetLinkColours'][] = 'pr_getLinkColours';
1414 $wgHooks['ImageOpenShowImageInlineBefore'][] = 'pr_imageMessage';
1515 $wgHooks['ArticleSaveComplete'][] = 'pr_articleSave';
 16+$wgHooks['EditFormPreloadText'][] = 'pr_preloadText';
1617
 18+$wgDjvutxt = 'djvutxt';
 19+
 20+
1721 $wgExtensionCredits['other'][] = array(
1822 'name' => 'ProofreadPage',
1923 'author' => 'ThomasV',
@@ -648,3 +652,32 @@
649653
650654 }
651655
 656+
 657+
 658+function pr_preloadText( $textbox1, $mTitle ) {
 659+ global $wgDjvutxt;
 660+
 661+ $page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' );
 662+
 663+ if ( preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) {
 664+
 665+ $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
 666+ if ( !$imageTitle ) {
 667+ return true;
 668+ }
 669+
 670+ $image = Image::newFromTitle( $imageTitle );
 671+ if ( $image->exists() ) {
 672+ $srcPath = $image->getPath();
 673+ $cmd = "( " .wfEscapeShellArg( $wgDjvutxt );
 674+ $cmd .= " --page={$m[2]} ". wfEscapeShellArg( $srcPath )." )";
 675+ wfProfileIn( 'ProofreadPage' );
 676+ wfDebug( __METHOD__.": $cmd\n" );
 677+ $err = wfShellExec( $cmd, $retval );
 678+ wfProfileOut( 'ProofreadPage' );
 679+
 680+ if($retval==0) $textbox1 = $err;
 681+ }
 682+ }
 683+ return true;
 684+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r48533Cleanup to r48486:...demon20:36, 18 March 2009

Comments

#Comment by Brion VIBBER (talk | contribs)   21:59, 17 March 2009

Doesn't seem to be a way to disable this, or say apply it only to djvu files...

#Comment by 😂 (talk | contribs)   20:37, 18 March 2009

Cleaned up in r48533

Status & tagging log