(bug 672) Add MathAfterTexvc hook
authorRob Church <robchurch@users.mediawiki.org>
Mon, 26 Jun 2006 15:50:03 +0000 (15:50 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Mon, 26 Jun 2006 15:50:03 +0000 (15:50 +0000)
RELEASE-NOTES
docs/hooks.txt
includes/Math.php

index 858f7c0..c3f7266 100644 (file)
@@ -570,6 +570,7 @@ Some default configuration options have changed:
 * Update to Esperanto translation (eo)
 * Check for preg_match() existence when installing and die out whining about PCRE
   if it's not there, instead of throwing a fatal error
+* (bug 672) Add MathAfterTexvc hook
 
 == Compatibility ==
 
index 16db940..2e7db30 100644 (file)
@@ -380,6 +380,11 @@ $user: user (object) who marked the edit patrolled
 $wcOnlySysopsCanPatrol: config setting indicating whether the user
  must be a sysop to patrol the edit
 
+'MathAfterTexvc': after texvc is executed when rendering mathematics
+$mathRenderer: instance of MathRenderer
+$errmsg: error message, in HTML (string). Nonempty indicates failure
+ of rendering the formula
+
 'OutputPageBeforeHTML': a page has been processed by the parser and
 the resulting HTML is about to be displayed.  
 $parserOutput: the parserOutput (object) that corresponds to the page 
index 1bf68b2..f9d6a60 100644 (file)
@@ -73,6 +73,7 @@ class MathRenderer {
                        }
 
                        $retval = substr ($contents, 0, 1);
+                       $errmsg = '';
                        if (($retval == 'C') || ($retval == 'M') || ($retval == 'L')) {
                                if ($retval == 'C')
                                        $this->conservativeness = 2;
@@ -106,14 +107,23 @@ class MathRenderer {
                        } else {
                                $errbit = htmlspecialchars( substr($contents, 1) );
                                switch( $retval ) {
-                                       case 'E': return $this->_error( 'math_lexing_error', $errbit );
-                                       case 'S': return $this->_error( 'math_syntax_error', $errbit );
-                                       case 'F': return $this->_error( 'math_unknown_function', $errbit );
-                                       default:  return $this->_error( 'math_unknown_error', $errbit );
+                                       case 'E': $errmsg = $this->_error( 'math_lexing_error', $errbit );
+                                       case 'S': $errmsg = $this->_error( 'math_syntax_error', $errbit );
+                                       case 'F': $errmsg = $this->_error( 'math_unknown_function', $errbit );
+                                       default:  $errmsg = $this->_error( 'math_unknown_error', $errbit );
                                }
                        }
 
-                       $this->hash = substr ($contents, 1, 32);
+                       if ( !$errmsg ) {
+                                $this->hash = substr ($contents, 1, 32);
+                       }
+
+                       $res = wfRunHooks( 'MathAfterTexvc', array( &$this, &$errmsg ) );
+
+                       if ( $errmsg ) {
+                                return $errmsg;
+                       }
+
                        if (!preg_match("/^[a-f0-9]{32}$/", $this->hash)) {
                                return $this->_error( 'math_unknown_error' );
                        }