Require at least PHP 5.2.3. There's not much point increasing the minimum to 5.2...
[lhc/web/wiklou.git] / includes / DjVuImage.php
index c202024..59f49af 100644 (file)
@@ -226,6 +226,8 @@ class DjVuImage {
         */
        function retrieveMetaData() {
                global $wgDjvuToXML, $wgDjvuDump, $wgDjvuTxt;
+               wfProfileIn( __METHOD__ );
+               
                if ( isset( $wgDjvuDump ) ) {
                        # djvudump is faster as of version 3.5
                        # http://sourceforge.net/tracker/index.php?func=detail&aid=1704049&group_id=32953&atid=406583
@@ -266,18 +268,20 @@ class DjVuImage {
                                        | # Or page can be empty ; in this case, djvutxt dumps ()
                                        \(\s*()\)/sx
 EOR;
-                               $txt = preg_replace_callback( $reg,
-                                       create_function('$matches', 'return \'<PAGE value="\'.htmlspecialchars($matches[1]).\'" />\';'),
-                                       $txt );
-
+                               $txt = preg_replace_callback( $reg, array( $this, 'pageTextCallback' ), $txt );
                                $txt = "<DjVuTxt>\n<HEAD></HEAD>\n<BODY>\n" . $txt . "</BODY>\n</DjVuTxt>\n";
                                $xml = preg_replace( "/<DjVuXML>/", "<mw-djvu><DjVuXML>", $xml );
                                $xml = $xml . $txt. '</mw-djvu>' ;
                        }
                }
+               wfProfileOut( __METHOD__ );
                return $xml;
        }
 
+       function pageTextCallback( $matches ) {
+               return '<PAGE value="' . htmlspecialchars( $matches[1] ) . '" />';
+       }
+
        /**
         * Hack to temporarily work around djvutoxml bug
         */