r85735 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r85734‎ | r85735 | r85736 >
Date:19:57, 9 April 2011
Author:brion
Status:ok
Tags:
Comment:
Followup to r85706 and friends: now that Math messages have been moved to extension, move out the settings list and constants.

* MW_MATH_* constants are now defined in Math extension
* Language::getMathNames() is removed
* mathNames section in message files is removed
* A hardcoded preference override in refreshLinks moved to MaintenanceRefreshLinksInit hook
Modified paths:
  • /trunk/extensions/Math/Math.hooks.php (modified) (history)
  • /trunk/extensions/Math/Math.php (modified) (history)
  • /trunk/phase3/includes/Defines.php (modified) (history)
  • /trunk/phase3/includes/LocalisationCache.php (modified) (history)
  • /trunk/phase3/languages/Language.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/refreshLinks.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/refreshLinks.php
@@ -66,8 +66,8 @@
6767 $dbr = wfGetDB( DB_SLAVE );
6868 $start = intval( $start );
6969
70 - # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
71 - $wgUser->setOption( 'math', MW_MATH_SOURCE );
 70+ // Give extensions a chance to optimize settings
 71+ wfRunHooks( 'MaintenanceRefreshLinksInit', array( $this ) );
7272
7373 # Don't generate extension images (e.g. Timeline)
7474 $wgParser->clearTagHooks();
Index: trunk/phase3/includes/Defines.php
@@ -96,17 +96,6 @@
9797 );
9898
9999 /**@{
100 - * Maths constants
101 - */
102 -define( 'MW_MATH_PNG', 0 );
103 -define( 'MW_MATH_SIMPLE', 1 );
104 -define( 'MW_MATH_HTML', 2 );
105 -define( 'MW_MATH_SOURCE', 3 );
106 -define( 'MW_MATH_MODERN', 4 );
107 -define( 'MW_MATH_MATHML', 5 );
108 -/**@}*/
109 -
110 -/**@{
111100 * Cache type
112101 */
113102 define( 'CACHE_ANYTHING', -1 ); // Use anything, as long as it works
Index: trunk/phase3/includes/LocalisationCache.php
@@ -81,7 +81,7 @@
8282 * All item keys
8383 */
8484 static public $allKeys = array(
85 - 'fallback', 'namespaceNames', 'mathNames', 'bookstoreList',
 85+ 'fallback', 'namespaceNames', 'bookstoreList',
8686 'magicWords', 'messages', 'rtl', 'capitalizeAllNouns', 'digitTransformTable',
8787 'separatorTransformTable', 'fallback8bitEncoding', 'linkPrefixExtension',
8888 'defaultUserOptionOverrides', 'linkTrail', 'namespaceAliases',
@@ -94,7 +94,7 @@
9595 * Keys for items which consist of associative arrays, which may be merged
9696 * by a fallback sequence.
9797 */
98 - static public $mergeableMapKeys = array( 'messages', 'namespaceNames', 'mathNames',
 98+ static public $mergeableMapKeys = array( 'messages', 'namespaceNames',
9999 'dateFormats', 'defaultUserOptionOverrides', 'imageFiles',
100100 'preloadedMessages',
101101 );
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -122,18 +122,6 @@
123123 $namespaceGenderAliases = array();
124124
125125 /**
126 - * Deprecated, use the message array
127 - */
128 -$mathNames = array(
129 - MW_MATH_PNG => 'mw_math_png',
130 - MW_MATH_SIMPLE => 'mw_math_simple',
131 - MW_MATH_HTML => 'mw_math_html',
132 - MW_MATH_SOURCE => 'mw_math_source',
133 - MW_MATH_MODERN => 'mw_math_modern',
134 - MW_MATH_MATHML => 'mw_math_mathml'
135 -);
136 -
137 -/**
138126 * A list of date format preference keys which can be selected in user
139127 * preferences. New preference keys can be added, provided they are supported
140128 * by the language class's timeanddate(). Only the 5 keys listed below are
Index: trunk/phase3/languages/Language.php
@@ -495,10 +495,6 @@
496496 );
497497 }
498498
499 - function getMathNames() {
500 - return self::$dataCache->getItem( $this->mCode, 'mathNames' );
501 - }
502 -
503499 function getDatePreferences() {
504500 return self::$dataCache->getItem( $this->mCode, 'datePreferences' );
505501 }
Index: trunk/extensions/Math/Math.php
@@ -26,6 +26,17 @@
2727 'url' => 'http://www.mediawiki.org/wiki/Extension:Math',
2828 );
2929
 30+/**@{
 31+ * Maths constants
 32+ */
 33+define( 'MW_MATH_PNG', 0 );
 34+define( 'MW_MATH_SIMPLE', 1 );
 35+define( 'MW_MATH_HTML', 2 );
 36+define( 'MW_MATH_SOURCE', 3 );
 37+define( 'MW_MATH_MODERN', 4 );
 38+define( 'MW_MATH_MATHML', 5 );
 39+/**@}*/
 40+
3041 /** For back-compat */
3142 $wgUseTeX = true;
3243
Index: trunk/extensions/Math/Math.hooks.php
@@ -60,10 +60,41 @@
6161 global $wgLang;
6262 $defaultPreferences['math'] = array(
6363 'type' => 'radio',
64 - 'options' => array_flip( array_map( 'wfMsgHtml', $wgLang->getMathNames() ) ),
 64+ 'options' => array_flip( array_map( 'wfMsgHtml', self::getMathNames() ) ),
6565 'label' => ' ',
6666 'section' => 'rendering/math',
6767 );
6868 return true;
6969 }
 70+
 71+ /**
 72+ * List of message keys for the various math output settings.
 73+ *
 74+ * @return array of strings
 75+ */
 76+ private static function getMathNames() {
 77+ return array(
 78+ MW_MATH_PNG => 'mw_math_png',
 79+ MW_MATH_SIMPLE => 'mw_math_simple',
 80+ MW_MATH_HTML => 'mw_math_html',
 81+ MW_MATH_SOURCE => 'mw_math_source',
 82+ MW_MATH_MODERN => 'mw_math_modern',
 83+ MW_MATH_MATHML => 'mw_math_mathml'
 84+ );
 85+ }
 86+
 87+ /**
 88+ * MaintenanceRefreshLinksInit handler; optimize settings for refreshLinks batch job.
 89+ *
 90+ * @param Maintenance $maint
 91+ * @return boolean hook return code
 92+ */
 93+ static function onMaintenanceRefreshLinksInit( $maint ) {
 94+ global $wgUser;
 95+
 96+ # Don't generate TeX PNGs (lack of a sensible current directory causes errors anyway)
 97+ $wgUser->setOption( 'math', MW_MATH_SOURCE );
 98+
 99+ return true;
 100+ }
70101 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r85706Initial stab at breaking math/texvc out to Math extension....brion00:39, 9 April 2011

Status & tagging log