* addWikitext instead of addHTML
[lhc/web/wiklou.git] / includes / Math.php
index 9b7a996..3506394 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 /**
  * Contain everything related to <math> </math> parsing
+ * @package MediaWiki
  */
 
 /**
@@ -9,6 +10,8 @@
  * rendering form is picked and returned.
  * 
  * by Tomasz Wegrzanowski, with additions by Brion Vibber (2003, 2004)
+ *
+ * @package MediaWiki
  */
 class MathRenderer {
        var $mode = MW_MATH_MODERN;
@@ -30,6 +33,7 @@ class MathRenderer {
        function render() {
                global $wgMathDirectory, $wgTmpDirectory, $wgInputEncoding;
                global $wgTexvc;
+               $fname = 'MathRenderer::render';
        
                if( $this->mode == MW_MATH_SOURCE ) {
                        # No need to render or parse anything more!
@@ -92,11 +96,11 @@ class MathRenderer {
                                        $this->conservativeness = 0;
                                $this->mathml = NULL;
                        } else if ($retval == 'X') {
-                               $outhtml = NULL;
+                               $this->html = NULL;
                                $this->mathml = substr ($contents, 33);
                                $this->conservativeness = 0;
                        } else if ($retval == '+') {
-                               $this->outhtml = NULL;
+                               $this->html = NULL;
                                $this->mathml = NULL;
                                $this->conservativeness = 0;
                        } else {
@@ -119,20 +123,22 @@ class MathRenderer {
                        }
                        
                        # Now save it back to the DB:
-                       $outmd5_sql = pack('H32', $this->hash);
-               
-                       $md5_sql = pack('H32', $this->md5); # Binary packed, not hex
+                       if ( !wfReadOnly() ) {
+                               $outmd5_sql = pack('H32', $this->hash);
                        
-                       $dbw =& wfGetDB( DB_MASTER );
-                       $dbw->replace( 'math', array( 'math_inputhash' ),
-                         array( 
-                               'math_inputhash' => $md5_sql, 
-                               'math_outputhash' => $outmd5_sql,
-                               'math_html_conservativeness' => $this->conservativeness,
-                               'math_html' => $outhtml,
-                               'math_mathml' => $mathml,
-                         ), $fname, array( 'IGNORE' ) 
-                       );
+                               $md5_sql = pack('H32', $this->md5); # Binary packed, not hex
+                               
+                               $dbw =& wfGetDB( DB_MASTER );
+                               $dbw->replace( 'math', array( 'math_inputhash' ),
+                                 array( 
+                                       'math_inputhash' => $md5_sql, 
+                                       'math_outputhash' => $outmd5_sql,
+                                       'math_html_conservativeness' => $this->conservativeness,
+                                       'math_html' => $this->html,
+                                       'math_mathml' => $this->mathml,
+                                 ), $fname, array( 'IGNORE' ) 
+                               );
+                       }
                        
                }
                
@@ -153,7 +159,7 @@ class MathRenderer {
 
                $this->md5 = md5( $this->tex );
                $dbr =& wfGetDB( DB_SLAVE );
-               $rpage = $dbr->getArray( 'math', 
+               $rpage = $dbr->selectRow( 'math', 
                        array( 'math_outputhash','math_html_conservativeness','math_html','math_mathml' ),
                        array( 'math_inputhash' => pack("H32", $this->md5)), # Binary packed, not hex
                        $fname