r50051 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r50050‎ | r50051 | r50052 >
Date:19:37, 29 April 2009
Author:thomasv
Status:ok
Tags:
Comment:
fetch djvu text (bug 18046); using parser hook instead of ajax, and Http::get instead of curl
Modified paths:
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -680,11 +680,11 @@
681681
682682
683683 function pr_preloadText( $textbox1, $mTitle ) {
684 - global $wgDjvutxt;
 684+ global $wgDjvuTxt;
685685
686686 $page_namespace = preg_quote( wfMsgForContent( 'proofreadpage_namespace' ), '/' );
687687
688 - if ( $wgDjvutxt && preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) {
 688+ if ( $wgDjvuTxt && preg_match( "/^$page_namespace:(.*?)\/([0-9]*)$/", $mTitle->getPrefixedText(), $m ) ) {
689689
690690 $imageTitle = Title::makeTitleSafe( NS_IMAGE, $m[1] );
691691 if ( !$imageTitle ) {
@@ -693,15 +693,15 @@
694694
695695 $image = wfFindFile( $imageTitle );
696696 if ( $image && $image->exists() && $image->getMimeType() == 'image/vnd.djvu' ) {
697 - $srcPath = $image->getPath();
698 - $cmd = "( " .wfEscapeShellArg( $wgDjvutxt );
699 - $cmd .= " --page {$m[2]} ". wfEscapeShellArg( $srcPath )." )";
700 - wfProfileIn( 'ProofreadPage' );
701 - wfDebug( __METHOD__.": $cmd\n" );
702 - $out = wfShellExec( $cmd, $retval );
703 - wfProfileOut( 'ProofreadPage' );
704697
705 - if($retval==0) $textbox1 = $out;
 698+ $name = $image->thumbName( array( 'width' => '##WIDTH##', 'page' => $m[2] ) );
 699+ $name = str_replace( '##WIDTH##px', 'djvutxt', $name );
 700+ $name = str_replace( '.jpg', '.txt', $name );
 701+ $url = $image->getThumbUrl( $name );
 702+
 703+ if($url[0]=='/') $url = "http://localhost" . $url;
 704+ $text = Http::get($url);
 705+ if($text) $textbox1 = $text;
706706 }
707707 }
708708 return true;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r49669extract text layer from djvu file (see bug 18046)thomasv18:00, 20 April 2009
r50026Revert r49669, r49670 "extract text layer from djvu file (see bug 18046)"...brion22:54, 28 April 2009
r50050extract djvu text (bug 18046); escape possible script with htmlspecialchars i...thomasv19:33, 29 April 2009

Status & tagging log