Index: trunk/phase3/includes/media/DjVu.php |
— | — | @@ -52,8 +52,6 @@ |
53 | 53 | $m = false; |
54 | 54 | if ( preg_match( '/^page(\d+)-(\d+)px$/', $str, $m ) ) { |
55 | 55 | return array( 'width' => $m[2], 'page' => $m[1] ); |
56 | | - } else if ( preg_match( '/^page(\d+)-djvutxt$/', $str, $m ) ) { |
57 | | - return array( 'djvutxt' => 1, 'page' => $m[1] ); |
58 | 56 | } else { |
59 | 57 | return false; |
60 | 58 | } |
— | — | @@ -66,21 +64,8 @@ |
67 | 65 | ); |
68 | 66 | } |
69 | 67 | |
70 | | - function normaliseParams( $image, &$params ) { |
71 | | - global $wgDjvuTxt; |
72 | | - if( $params['djvutxt'] && $wgDjvuTxt) { |
73 | | - if ( !isset( $params['page'] ) ) { |
74 | | - $params['page'] = 1; |
75 | | - } |
76 | | - $params['width'] = 0; |
77 | | - $params['height'] = 0; |
78 | | - return true; |
79 | | - } |
80 | | - else return parent::normaliseParams( $image, $params ); |
81 | | - } |
82 | | - |
83 | 68 | function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { |
84 | | - global $wgDjvuRenderer, $wgDjvuPostProcessor, $wgDjvuTxt; |
| 69 | + global $wgDjvuRenderer, $wgDjvuPostProcessor; |
85 | 70 | |
86 | 71 | // Fetch XML and check it, to give a more informative error message than the one which |
87 | 72 | // normaliseParams will inevitably give. |
— | — | @@ -109,36 +94,18 @@ |
110 | 95 | return new MediaTransformError( 'thumbnail_error', $width, $height, wfMsg( 'thumbnail_dest_directory' ) ); |
111 | 96 | } |
112 | 97 | |
113 | | - if( $params['djvutxt'] && $wgDjvuTxt ) { |
114 | | - # Extract djvu text |
115 | | - $cmd = wfEscapeShellArg( $wgDjvuTxt ) . " --page={$page} " . wfEscapeShellArg( $srcPath ) ; |
116 | | - wfProfileIn( 'djvutxt' ); |
117 | | - wfDebug( __METHOD__.": $cmd\n" ); |
118 | | - $err = wfShellExec( $cmd, $retval ); |
119 | | - wfProfileOut( 'djvutxt' ); |
120 | | - # Escape html characters |
121 | | - $txt = htmlspecialchars( $err ); |
122 | | - # Write result to file |
123 | | - if($retval == 0) { |
124 | | - $f = fopen($dstPath, 'w'); |
125 | | - fwrite($f, $txt); |
126 | | - fclose($f); |
127 | | - } |
| 98 | + # Use a subshell (brackets) to aggregate stderr from both pipeline commands |
| 99 | + # before redirecting it to the overall stdout. This works in both Linux and Windows XP. |
| 100 | + $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page} -size={$width}x{$height} " . |
| 101 | + wfEscapeShellArg( $srcPath ); |
| 102 | + if ( $wgDjvuPostProcessor ) { |
| 103 | + $cmd .= " | {$wgDjvuPostProcessor}"; |
128 | 104 | } |
129 | | - else { |
130 | | - # Use a subshell (brackets) to aggregate stderr from both pipeline commands |
131 | | - # before redirecting it to the overall stdout. This works in both Linux and Windows XP. |
132 | | - $cmd = '(' . wfEscapeShellArg( $wgDjvuRenderer ) . " -format=ppm -page={$page} -size={$width}x{$height} " . |
133 | | - wfEscapeShellArg( $srcPath ); |
134 | | - if ( $wgDjvuPostProcessor ) { |
135 | | - $cmd .= " | {$wgDjvuPostProcessor}"; |
136 | | - } |
137 | | - $cmd .= ' > ' . wfEscapeShellArg($dstPath) . ') 2>&1'; |
138 | | - wfProfileIn( 'ddjvu' ); |
139 | | - wfDebug( __METHOD__.": $cmd\n" ); |
140 | | - $err = wfShellExec( $cmd, $retval ); |
141 | | - wfProfileOut( 'ddjvu' ); |
142 | | - } |
| 105 | + $cmd .= ' > ' . wfEscapeShellArg($dstPath) . ') 2>&1'; |
| 106 | + wfProfileIn( 'ddjvu' ); |
| 107 | + wfDebug( __METHOD__.": $cmd\n" ); |
| 108 | + $err = wfShellExec( $cmd, $retval ); |
| 109 | + wfProfileOut( 'ddjvu' ); |
143 | 110 | |
144 | 111 | $removed = $this->removeBadFile( $dstPath, $retval ); |
145 | 112 | if ( $retval != 0 || $removed ) { |