2011-04-09 00:39:40 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* MediaWiki math extension
|
|
|
|
*
|
2015-04-14 19:42:48 +00:00
|
|
|
* (c) 2002-2015 various MediaWiki contributors
|
2011-04-09 00:39:40 +00:00
|
|
|
* GPLv2 license; info in main package.
|
|
|
|
*/
|
|
|
|
|
2015-04-14 19:42:48 +00:00
|
|
|
use MediaWiki\Logger\LoggerFactory;
|
|
|
|
|
2011-04-09 00:39:40 +00:00
|
|
|
class MathHooks {
|
2015-09-21 16:14:01 +00:00
|
|
|
const MATHCACHEKEY = 'math=';
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2015-09-21 16:14:01 +00:00
|
|
|
public static function mathConstantToString( $value, array $defs, $prefix, $default ) {
|
2015-07-22 22:10:46 +00:00
|
|
|
foreach ( $defs as $defKey => $defValue ) {
|
2015-09-21 16:14:01 +00:00
|
|
|
if ( !defined( $defKey ) ) {
|
2015-07-22 22:10:46 +00:00
|
|
|
define( $defKey, $defValue );
|
|
|
|
} elseif ( $defValue !== constant( $defKey ) ) {
|
|
|
|
throw new Exception( 'Math constant "'. $defKey . '" has unexpected value "' .
|
|
|
|
constant( $defKey ) . '" instead of "' . $defValue );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$invDefs = array_flip( $defs );
|
|
|
|
if ( is_int( $value ) ){
|
2015-09-21 16:14:01 +00:00
|
|
|
if ( array_key_exists( $value, $invDefs ) ) {
|
2015-07-22 22:10:46 +00:00
|
|
|
$value = $invDefs[$value];
|
|
|
|
} else {
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( is_string( $value ) ){
|
|
|
|
$newValues = array();
|
|
|
|
foreach ( $defs as $k => $v ) {
|
|
|
|
$newValues[$k] = preg_replace_callback( '/_(.)/', function ( $matches ) {
|
|
|
|
return strtoupper( $matches[1] );
|
|
|
|
}, strtolower( substr( $k, strlen( $prefix ) ) ) );
|
|
|
|
}
|
|
|
|
if ( array_key_exists( $value, $defs ) ) {
|
|
|
|
return $newValues[$value];
|
2015-09-21 16:14:01 +00:00
|
|
|
} elseif ( in_array( $value, $newValues ) ){
|
2015-07-22 22:10:46 +00:00
|
|
|
return $value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function mathStyleToString( $style, $default = 'inlineDisplaystyle' ) {
|
2015-09-21 16:14:01 +00:00
|
|
|
$defs = array(
|
2015-07-22 22:10:46 +00:00
|
|
|
'MW_MATHSTYLE_INLINE_DISPLAYSTYLE' => 0, // default large operator inline
|
|
|
|
'MW_MATHSTYLE_DISPLAY' => 1, // large operators centered in a new line
|
|
|
|
'MW_MATHSTYLE_INLINE' => 2, // small operators inline
|
2015-07-22 22:10:46 +00:00
|
|
|
'MW_MATHSTYLE_LINEBREAK' => 3, // break long lines (experimental)
|
2015-07-22 22:10:46 +00:00
|
|
|
);
|
|
|
|
return self::mathConstantToString( $style, $defs, $prefix = 'MW_MATHSTYLE_', $default );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function mathCheckToString( $style, $default = 'always' ) {
|
2015-09-21 16:14:01 +00:00
|
|
|
$defs = array(
|
2015-07-22 22:10:46 +00:00
|
|
|
'MW_MATH_CHECK_ALWAYS' => 0,
|
|
|
|
'MW_MATH_CHECK_NEVER' => 1,
|
|
|
|
'MW_MATH_CHECK_NEW' => 2,
|
|
|
|
);
|
|
|
|
return self::mathConstantToString( $style, $defs, $prefix = 'MW_MATH_CHECK_', $default );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function mathModeToString( $mode, $default = 'png' ) {
|
2015-09-28 22:29:07 +00:00
|
|
|
// The following deprecated modes have been removed:
|
|
|
|
// 'MW_MATH_SIMPLE' => 1
|
|
|
|
// 'MW_MATH_HTML' => 2
|
|
|
|
// 'MW_MATH_MODERN' => 4
|
|
|
|
// 'MW_MATH_MATHJAX' => 6
|
|
|
|
// 'MW_MATH_LATEXML_JAX' => 8
|
2015-07-22 22:10:46 +00:00
|
|
|
|
2015-09-21 16:14:01 +00:00
|
|
|
$defs = array(
|
2015-07-22 22:10:46 +00:00
|
|
|
'MW_MATH_PNG' => 0,
|
|
|
|
'MW_MATH_SOURCE' => 3,
|
|
|
|
'MW_MATH_MATHML' => 5,
|
|
|
|
'MW_MATH_LATEXML'=> 7 );
|
|
|
|
|
|
|
|
return self::mathConstantToString( $mode, $defs, $prefix = 'MW_MATH_', $default );
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function mathModeToHashKey( $mode, $default = 0 ) {
|
2015-09-21 16:14:01 +00:00
|
|
|
$defs = array(
|
2015-07-22 22:10:46 +00:00
|
|
|
'png' => 0,
|
|
|
|
'source' => 3,
|
|
|
|
'mathml' => 5,
|
|
|
|
'latexml'=> 7 );
|
|
|
|
|
|
|
|
if ( array_key_exists( $mode, $defs ) ){
|
|
|
|
return $defs[$mode];
|
|
|
|
} else {
|
|
|
|
return $default;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-02 17:18:51 +00:00
|
|
|
/*
|
|
|
|
* Generate a user dependent hash cache key.
|
|
|
|
* The hash key depends on the rendering mode.
|
|
|
|
* @param &$confstr The to-be-hashed key string that is being constructed
|
|
|
|
* @param User $user reference to the current user
|
|
|
|
* @param array &$forOptions userOptions used on that page
|
|
|
|
*/
|
|
|
|
public static function onPageRenderingHash( &$confstr, $user = false, &$forOptions = array() ) {
|
|
|
|
global $wgUser;
|
|
|
|
|
|
|
|
// To be independent of the MediaWiki core version,
|
|
|
|
// we check if the core caching logic for math is still available.
|
2014-02-09 19:02:15 +00:00
|
|
|
if ( ! is_callable( 'ParserOptions::getMath' ) && in_array( 'math', $forOptions ) ) {
|
2014-01-02 17:18:51 +00:00
|
|
|
if ( $user === false ) {
|
|
|
|
$user = $wgUser;
|
|
|
|
}
|
|
|
|
|
2015-07-22 22:10:46 +00:00
|
|
|
$mathString = self::mathModeToString( $user->getOption( 'math' ) );
|
|
|
|
$mathOption = self::mathModeToHashKey( $mathString, 0 );
|
2014-01-02 17:18:51 +00:00
|
|
|
// Check if the key already contains the math option part
|
|
|
|
if (
|
|
|
|
!preg_match(
|
2015-09-21 16:14:01 +00:00
|
|
|
'/(^|!)' . self::MATHCACHEKEY . $mathOption . '(!|$)/',
|
2014-01-02 17:18:51 +00:00
|
|
|
$confstr
|
|
|
|
)
|
|
|
|
) {
|
2015-09-21 16:14:01 +00:00
|
|
|
// The math part of cache key starts with "math="
|
|
|
|
// followed by a star or a number for the math mode
|
|
|
|
if ( preg_match( '/(^|!)' . self::MATHCACHEKEY . '[*\d]m?(!|$)/', $confstr ) ) {
|
2014-01-02 17:18:51 +00:00
|
|
|
$confstr = preg_replace(
|
2015-09-21 16:14:01 +00:00
|
|
|
'/(^|!)' . self::MATHCACHEKEY . '[*\d]m?(!|$)/',
|
|
|
|
'\1' . self::MATHCACHEKEY . $mathOption . '\2',
|
2014-01-02 17:18:51 +00:00
|
|
|
$confstr
|
|
|
|
);
|
|
|
|
} else {
|
2015-09-21 16:14:01 +00:00
|
|
|
$confstr .= '!' . self::MATHCACHEKEY . $mathOption;
|
2014-01-02 17:18:51 +00:00
|
|
|
}
|
|
|
|
|
2015-04-14 19:42:48 +00:00
|
|
|
LoggerFactory::getInstance( 'Math' )->debug( "New cache key: $confstr" );
|
2014-01-02 17:18:51 +00:00
|
|
|
} else {
|
2015-04-14 19:42:48 +00:00
|
|
|
LoggerFactory::getInstance( 'Math' )->debug( "Cache key found: $confstr" );
|
2014-01-02 17:18:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-04-09 15:13:22 +00:00
|
|
|
/**
|
2014-01-02 17:18:51 +00:00
|
|
|
* Set up $wgMathPath and $wgMathDirectory globals if they're not already set.
|
2011-04-09 15:13:22 +00:00
|
|
|
*/
|
2011-04-09 00:39:40 +00:00
|
|
|
static function setup() {
|
2014-01-02 17:18:51 +00:00
|
|
|
global $wgMathPath, $wgMathDirectory,
|
|
|
|
$wgUploadPath, $wgUploadDirectory;
|
|
|
|
|
2011-04-09 15:13:22 +00:00
|
|
|
if ( $wgMathPath === false ) {
|
|
|
|
$wgMathPath = "{$wgUploadPath}/math";
|
|
|
|
}
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2011-04-09 15:13:22 +00:00
|
|
|
if ( $wgMathDirectory === false ) {
|
|
|
|
$wgMathDirectory = "{$wgUploadDirectory}/math";
|
|
|
|
}
|
2011-04-09 00:39:40 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 15:13:22 +00:00
|
|
|
/**
|
|
|
|
* Register the <math> tag with the Parser.
|
|
|
|
*
|
2011-07-17 21:11:24 +00:00
|
|
|
* @param $parser Parser instance of Parser
|
2011-04-09 15:13:22 +00:00
|
|
|
* @return Boolean: true
|
|
|
|
*/
|
|
|
|
static function onParserFirstCallInit( $parser ) {
|
2011-04-09 00:39:40 +00:00
|
|
|
$parser->setHook( 'math', array( 'MathHooks', 'mathTagHook' ) );
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2011-04-09 00:39:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2011-04-09 15:13:22 +00:00
|
|
|
* Callback function for the <math> parser hook.
|
|
|
|
*
|
2012-10-27 14:30:50 +00:00
|
|
|
* @param $content (the LaTeX input)
|
2011-04-09 15:13:22 +00:00
|
|
|
* @param $attributes
|
2014-01-02 17:18:51 +00:00
|
|
|
* @param Parser $parser
|
2014-02-03 23:22:26 +00:00
|
|
|
* @return array
|
2011-04-09 00:39:40 +00:00
|
|
|
*/
|
|
|
|
static function mathTagHook( $content, $attributes, $parser ) {
|
2014-01-02 17:18:51 +00:00
|
|
|
|
|
|
|
if ( trim( $content ) === '' ) { // bug 8372
|
|
|
|
return '';
|
2012-10-27 14:30:50 +00:00
|
|
|
}
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2015-07-22 22:10:46 +00:00
|
|
|
$mode = self::mathModeToString( $parser->getUser()->getOption( 'math' ) );
|
2014-01-02 17:18:51 +00:00
|
|
|
// Indicate that this page uses math.
|
|
|
|
// This affects the page caching behavior.
|
|
|
|
if ( is_callable( 'ParserOptions::getMath' ) ) {
|
|
|
|
$parser->getOptions()->getMath();
|
|
|
|
} else {
|
|
|
|
$parser->getOptions()->optionUsed( 'math' );
|
|
|
|
}
|
|
|
|
|
|
|
|
$renderer = MathRenderer::getRenderer( $content, $attributes, $mode );
|
2014-01-03 14:29:03 +00:00
|
|
|
|
2014-09-06 01:59:13 +00:00
|
|
|
$checkResult = $renderer->checkTex();
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2014-09-06 01:59:13 +00:00
|
|
|
if ( $checkResult !== true ) {
|
|
|
|
// Returns the error message
|
|
|
|
return $renderer->getLastError();
|
2014-01-03 14:29:03 +00:00
|
|
|
}
|
2014-09-06 01:59:13 +00:00
|
|
|
|
2014-06-05 21:06:43 +00:00
|
|
|
if ( $renderer->render() ) {
|
2015-04-14 19:42:48 +00:00
|
|
|
LoggerFactory::getInstance( 'Math' )->info( "Rendering successful. Writing output" );
|
2014-06-05 21:06:43 +00:00
|
|
|
$renderedMath = $renderer->getHtmlOutput();
|
|
|
|
} else {
|
2015-04-14 19:42:48 +00:00
|
|
|
LoggerFactory::getInstance( 'Math' )->warning(
|
2015-03-16 21:43:20 +00:00
|
|
|
"Rendering failed. Printing error message." );
|
2014-06-05 21:06:43 +00:00
|
|
|
return $renderer->getLastError();
|
|
|
|
}
|
2015-02-08 18:01:14 +00:00
|
|
|
Hooks::run( 'MathFormulaPostRender',
|
|
|
|
array( $parser, &$renderer, &$renderedMath ) );// Enables indexing of math formula
|
2014-03-17 06:14:02 +00:00
|
|
|
$parser->getOutput()->addModuleStyles( array( 'ext.math.styles' ) );
|
2015-07-22 22:10:46 +00:00
|
|
|
if ( $mode == 'mathml' ) {
|
2014-10-20 20:40:53 +00:00
|
|
|
$parser->getOutput()->addModuleStyles( array( 'ext.math.desktop.styles' ) );
|
2014-10-12 09:26:57 +00:00
|
|
|
$parser->getOutput()->addModules( array( 'ext.math.scripts' ) );
|
|
|
|
}
|
2014-06-05 21:06:43 +00:00
|
|
|
// Writes cache if rendering was successful
|
2013-03-12 04:38:45 +00:00
|
|
|
$renderer->writeCache();
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2014-02-03 23:22:26 +00:00
|
|
|
return array( $renderedMath, "markerType" => 'nowiki' );
|
2011-04-09 00:39:40 +00:00
|
|
|
}
|
|
|
|
|
2011-04-09 15:13:22 +00:00
|
|
|
/**
|
|
|
|
* Add the new math rendering options to Special:Preferences.
|
|
|
|
*
|
|
|
|
* @param $user Object: current User object
|
|
|
|
* @param $defaultPreferences Object: Preferences object
|
|
|
|
* @return Boolean: true
|
|
|
|
*/
|
2011-04-09 00:39:40 +00:00
|
|
|
static function onGetPreferences( $user, &$defaultPreferences ) {
|
2015-07-22 22:10:46 +00:00
|
|
|
global $wgDefaultUserOptions;
|
2011-04-09 00:39:40 +00:00
|
|
|
$defaultPreferences['math'] = array(
|
|
|
|
'type' => 'radio',
|
2012-10-04 12:11:36 +00:00
|
|
|
'options' => array_flip( self::getMathNames() ),
|
2011-04-09 00:39:40 +00:00
|
|
|
'label' => ' ',
|
|
|
|
'section' => 'rendering/math',
|
|
|
|
);
|
2014-05-05 09:38:20 +00:00
|
|
|
// If the default option is not in the valid options the
|
|
|
|
// user interface throws an exception (BUG 64844)
|
2015-07-22 22:10:46 +00:00
|
|
|
$mode = MathHooks::mathModeToString( $wgDefaultUserOptions['math'] );
|
2015-09-21 16:14:01 +00:00
|
|
|
if ( ! in_array( $mode, MathRenderer::getValidModes() ) ) {
|
2015-04-14 19:42:48 +00:00
|
|
|
LoggerFactory::getInstance( 'Math' )->error( 'Misconfiguration: '.
|
2015-07-22 22:10:46 +00:00
|
|
|
"\$wgDefaultUserOptions['math'] is not in " . MathRenderer::getValidModes() . ".\n".
|
2015-03-16 21:43:20 +00:00
|
|
|
"Please check your LocalSetting.php file." );
|
2014-05-05 09:38:20 +00:00
|
|
|
// Display the checkbox in the first option.
|
2015-07-22 22:10:46 +00:00
|
|
|
$validModes = MathRenderer::getValidModes();
|
|
|
|
$wgDefaultUserOptions['math'] = $validModes[0];
|
2014-05-05 09:38:20 +00:00
|
|
|
}
|
2011-04-09 00:39:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-04-09 19:57:35 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* List of message keys for the various math output settings.
|
|
|
|
*
|
|
|
|
* @return array of strings
|
|
|
|
*/
|
2014-05-28 18:12:39 +00:00
|
|
|
public static function getMathNames() {
|
2014-04-08 13:57:15 +00:00
|
|
|
$names = array();
|
2015-07-22 22:10:46 +00:00
|
|
|
foreach ( MathRenderer::getValidModes() as $mode ) {
|
|
|
|
$names[ $mode ] = wfMessage( 'mw_math_' . $mode )->escaped();
|
2013-05-14 21:49:06 +00:00
|
|
|
}
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2012-03-05 20:34:29 +00:00
|
|
|
return $names;
|
2011-04-09 19:57:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* MaintenanceRefreshLinksInit handler; optimize settings for refreshLinks batch job.
|
|
|
|
*
|
|
|
|
* @param Maintenance $maint
|
|
|
|
* @return boolean hook return code
|
|
|
|
*/
|
|
|
|
static function onMaintenanceRefreshLinksInit( $maint ) {
|
|
|
|
global $wgUser;
|
|
|
|
|
2014-01-02 17:18:51 +00:00
|
|
|
# Don't generate TeX PNGs (the lack of a sensible current directory causes errors anyway)
|
2015-07-22 22:10:46 +00:00
|
|
|
$wgUser->setOption( 'math', 'source' );
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2011-04-09 19:57:35 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-04-22 21:37:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* LoadExtensionSchemaUpdates handler; set up math table on install/upgrade.
|
|
|
|
*
|
2011-07-17 21:11:24 +00:00
|
|
|
* @param $updater DatabaseUpdater
|
2015-01-10 01:55:54 +00:00
|
|
|
* @throws Exception
|
2011-04-22 21:37:16 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2011-06-07 17:33:34 +00:00
|
|
|
static function onLoadExtensionSchemaUpdates( $updater = null ) {
|
2015-07-22 22:10:46 +00:00
|
|
|
|
2012-10-27 14:30:50 +00:00
|
|
|
if ( is_null( $updater ) ) {
|
2015-01-10 01:55:54 +00:00
|
|
|
throw new Exception( 'Math extension is only necessary in 1.18 or above' );
|
2011-06-07 17:33:34 +00:00
|
|
|
}
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2014-05-20 10:37:44 +00:00
|
|
|
$map = array( 'mysql', 'sqlite', 'postgres', 'oracle', 'mssql' );
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2011-04-22 21:37:16 +00:00
|
|
|
$type = $updater->getDB()->getType();
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2015-01-22 18:56:13 +00:00
|
|
|
if ( !in_array( $type, $map ) ) {
|
|
|
|
throw new Exception( "Math extension does not currently support $type database." );
|
|
|
|
}
|
|
|
|
$sql = __DIR__ . '/db/math.' . $type . '.sql';
|
|
|
|
$updater->addExtensionTable( 'math', $sql );
|
2015-07-22 22:10:46 +00:00
|
|
|
if ( in_array( 'latexml', MathRenderer::getValidModes() ) ) {
|
2015-01-22 18:56:13 +00:00
|
|
|
if ( in_array( $type, array( 'mysql', 'sqlite', 'postgres' ) ) ) {
|
|
|
|
$sql = __DIR__ . '/db/mathlatexml.' . $type . '.sql';
|
|
|
|
$updater->addExtensionTable( 'mathlatexml', $sql );
|
|
|
|
if ( $type == 'mysql' ){
|
|
|
|
$sql = __DIR__ . '/db/patches/mathlatexml.mathml-length-adjustment.mysql.sql';
|
|
|
|
$updater->modifyExtensionField( 'mathlatexml', 'math_mathml', $sql );
|
2014-05-21 10:16:15 +00:00
|
|
|
}
|
2015-01-22 18:56:13 +00:00
|
|
|
} else {
|
|
|
|
throw new Exception( "Math extension does not currently support $type database for LaTeXML." );
|
2014-05-21 10:16:15 +00:00
|
|
|
}
|
2015-01-22 18:56:13 +00:00
|
|
|
}
|
2015-09-21 16:14:01 +00:00
|
|
|
if ( in_array( 'mathml', MathRenderer::getValidModes() ) ) {
|
2015-01-22 18:56:13 +00:00
|
|
|
if ( in_array( $type, array( 'mysql', 'sqlite', 'postgres' ) ) ) {
|
|
|
|
$sql = __DIR__ . '/db/mathoid.' . $type . '.sql';
|
|
|
|
$updater->addExtensionTable( 'mathoid', $sql );
|
|
|
|
} else {
|
|
|
|
throw new Exception( "Math extension does not currently support $type database for Mathoid." );
|
2014-05-27 05:53:46 +00:00
|
|
|
}
|
2011-04-22 21:37:16 +00:00
|
|
|
}
|
2015-01-22 18:56:13 +00:00
|
|
|
|
2011-04-22 21:37:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-21 10:16:15 +00:00
|
|
|
* Add 'math' and 'mathlatexml' tables to the list of tables that need to be copied to
|
2011-04-22 21:37:16 +00:00
|
|
|
* temporary tables for parser tests to run.
|
|
|
|
*
|
|
|
|
* @param array $tables
|
|
|
|
* @return bool
|
|
|
|
*/
|
2011-05-23 17:05:39 +00:00
|
|
|
static function onParserTestTables( &$tables ) {
|
2011-04-22 21:37:16 +00:00
|
|
|
$tables[] = 'math';
|
2014-05-21 10:16:15 +00:00
|
|
|
$tables[] = 'mathlatexml';
|
2011-04-22 21:37:16 +00:00
|
|
|
return true;
|
|
|
|
}
|
2011-09-13 21:03:38 +00:00
|
|
|
|
2013-02-16 22:55:39 +00:00
|
|
|
/**
|
|
|
|
* Links to the unit test files for the test cases.
|
|
|
|
*
|
|
|
|
* @param string $files
|
|
|
|
* @return boolean (true)
|
|
|
|
*/
|
|
|
|
static function onRegisterUnitTests( &$files ) {
|
|
|
|
$testDir = __DIR__ . '/tests/';
|
|
|
|
$files = array_merge( $files, glob( "$testDir/*Test.php" ) );
|
2014-01-02 17:18:51 +00:00
|
|
|
|
2013-02-16 22:55:39 +00:00
|
|
|
return true;
|
|
|
|
}
|
2014-01-25 23:09:06 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @global type $wgOut
|
|
|
|
* @param type $toolbar
|
|
|
|
*/
|
|
|
|
static function onEditPageBeforeEditToolbar( &$toolbar ) {
|
|
|
|
global $wgOut;
|
|
|
|
$wgOut->addModules( array( 'ext.math.editbutton.enabler' ) );
|
|
|
|
}
|
2015-07-22 22:10:46 +00:00
|
|
|
|
|
|
|
public static function registerExtension() {
|
|
|
|
global $wgDefaultUserOptions, $wgMathValidModes, $wgMathDisableTexFilter;
|
|
|
|
$wgMathValidModes = MathRenderer::getValidModes();
|
2015-09-28 22:29:07 +00:00
|
|
|
if ( $wgMathDisableTexFilter == true ) { // ensure backwards compatibility
|
2015-07-22 22:10:46 +00:00
|
|
|
$wgMathDisableTexFilter = 1;
|
|
|
|
}
|
|
|
|
$wgMathDisableTexFilter = MathRenderer::getDisableTexFilter();
|
|
|
|
$wgDefaultUserOptions['math'] = self::mathModeToString( $wgDefaultUserOptions['math'] );
|
|
|
|
}
|
2011-04-09 00:39:40 +00:00
|
|
|
}
|