jenkins-bot has submitted this change and it was merged.
Change subject: Add special-page to display topics and mquery tag
......................................................................
Add special-page to display topics and mquery tag
* Adds a the special page Special:DisplayTopics
* Introduces a new tag <mquery> that displays
LaTeXML and MWS queries
* i18n will follow
Change-Id: Idf9729a5aaef5c3dad1de1d60f5a55d707efe21e
---
M MathSearch.hooks.php
M MathSearch.php
A includes/special/SpecialDisplayTopics.php
3 files changed, 96 insertions(+), 0 deletions(-)
Approvals:
Physikerwelt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MathSearch.hooks.php b/MathSearch.hooks.php
index 77574ab..b68c4d5 100644
--- a/MathSearch.hooks.php
+++ b/MathSearch.hooks.php
@@ -230,4 +230,45 @@
) );
} );
}
+
+ /**
+ * Register the <mquery> tag with the Parser.
+ *
+ * @param $parser Parser instance of Parser
+ * @return Boolean: true
+ */
+ static function onParserFirstCallInit( $parser ) {
+ $parser->setHook( 'mquery', array( 'MathSearchHooks',
'mQueryTagHook' ) );
+ wfDebugLog('MathSearch','mquery tag registered');
+ return true;
+ }
+
+ /**
+ * Callback function for the <mquery> parser hook.
+ *
+ * @param $content (the LaTeX+MWS query input)
+ * @param $attributes
+ * @param Parser $parser
+ * @return array
+ */
+ static function mQueryTagHook( $content, $attributes, $parser ) {
+ global $wgMathDefaultLaTeXMLSetting;
+ if ( trim( $content ) === '' ) { // bug 8372
+ return '';
+ }
+ wfDebugLog('MathSearch','Render mquery tag.');
+ wfProfileIn( __METHOD__ );
+ //TODO: Report %\n problem to LaTeXML upstream
+ $content = preg_replace( '/%\n/', '', $content );
+ $renderer = new MathLaTeXML( $content );
+ $mQuerySettings = $wgMathDefaultLaTeXMLSetting;
+ $mQuerySettings['preload'][] = 'mws.sty';
+ $renderer->setLaTeXMLSettings($mQuerySettings);
+ $renderer->render( );
+ $renderedMath = $renderer->getHtmlOutput();
+ wfProfileOut( __METHOD__ );
+
+ return array( $renderedMath, "markerType" => 'nowiki' );
+ }
+
}
diff --git a/MathSearch.php b/MathSearch.php
index 845015a..9499fbf 100644
--- a/MathSearch.php
+++ b/MathSearch.php
@@ -48,6 +48,7 @@
$wgAutoloadClasses['GetEquationsByQuery'] = $dir . 'GetEquationsByQuery.php';
$wgAutoloadClasses['SpecialMathDebug'] = $dir . 'SpecialMathDebug.php';
$wgAutoloadClasses['SpecialMathIndex'] = $dir . 'SpecialMathIndex.php';
+$wgAutoloadClasses['SpecialDisplayTopics'] = $dir .
'/includes/special/SpecialDisplayTopics.php';
$wgAutoloadClasses['MathEngineMws'] = $dir .
'/includes/engines/MathEngineMws.php';
$wgAutoloadClasses['MathEngineDB2'] = $dir .
'/includes/engines/MathEngineDB2.php';
$wgAutoloadClasses['MathEngineBaseX'] = $dir .
'/includes/engines/MathEngineBaseX.php';
@@ -66,17 +67,21 @@
$wgSpecialPageGroups['XQueryGenerator'] = 'mathsearch';
$wgSpecialPageGroups['MathDebug'] = 'mathsearch';
$wgSpecialPageGroups['MathIndex'] = 'mathsearch';
+$wgSpecialPageGroups['DisplayTopics'] = 'mathsearch';
+
$wgSpecialPages['MathSearch'] = 'SpecialMathSearch';
$wgSpecialPages['FormulaInfo'] = 'FormulaInfo';
$wgSpecialPages['GetEquationsByQuery'] = 'GetEquationsByQuery';
$wgSpecialPages['MathDebug'] = 'SpecialMathDebug';
$wgSpecialPages['MathIndex'] = 'SpecialMathIndex';
+$wgSpecialPages['DisplayTopics'] = 'SpecialDisplayTopics';
$wgAPIModules['mathquery'] = 'MathSearchApi';
$wgHooks['LoadExtensionSchemaUpdates'][] =
'MathSearchHooks::onLoadExtensionSchemaUpdates';
$wgHooks['MathFormulaRendered']['updateIndex'] =
'MathSearchHooks::updateMathIndex';
$wgHooks['MathFormulaRendered']['addLink'] =
'MathSearchHooks::addLinkToFormulaInfoPage';
$wgHooks['UnitTestsList'][] = 'MathSearchHooks::onRegisterUnitTests';
+$wgHooks['ParserFirstCallInit'][] = 'MathSearchHooks::onParserFirstCallInit';
$wgGroupPermissions['user']['MathDebug'] = true;
diff --git a/includes/special/SpecialDisplayTopics.php
b/includes/special/SpecialDisplayTopics.php
new file mode 100644
index 0000000..9460827
--- /dev/null
+++ b/includes/special/SpecialDisplayTopics.php
@@ -0,0 +1,50 @@
+<?php
+/**
+ * Lets the user import a CSV file with the results
+ *
+ * @author Moritz Schubotz
+ */
+class SpecialDisplayTopics extends SpecialPage {
+ /** @type ImportCsv $importer */
+ private $importer;
+ /** @type bool $runId */
+ protected $runId = false;
+
+ /**
+ * @param string $name
+ */
+ public function __construct( $name = 'DisplayTopics' ) {
+ parent::__construct( $name );
+ }
+
+ /**
+ * @param null|string $query
+ *
+ * @throws MWException
+ * @throws PermissionsError
+ */
+ function execute( $query ) {
+ $this->setHeaders();
+ if ( ! ( $this->getUser()->isAllowed( 'mathwmcsubmit' ) ) ) {
+ throw new PermissionsError( 'mathwmcsubmit' );
+ }
+
+ $this->getOutput()->addWikiText( wfMessage( 'math-wmc-Queries'
)->text() );
+ $dbw = wfGetDB( DB_MASTER );
+ $cols = array('#','fId','query','inputtex');
+ $res = $dbw->query( <<<'SQL'
+SELECT
+ qId,
+ concat('[[Special:Permalink/', oldId, '#math.', oldId, '.', fId, '|',
p.page_title, '-',fId, ']]'),
+ concat('<mquery>', texQuery, '</mquery>' ),
+ concat('<math>', math_inputtex, '</math>')
+FROM math_wmc_ref ref
+ NATURAL JOIN mathlatexml L
+ JOIN revision rev ON ref.oldId = rev.rev_id
+ JOIN page p on rev.rev_page = p.page_id
+SQL
+);
+ $this->getOutput()->addWikiText(
MathSearchUtils::dbRowToWikiTable($res,$cols) );
+ }
+
+}
--
To view, visit https://gerrit.wikimedia.org/r/189233
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Idf9729a5aaef5c3dad1de1d60f5a55d707efe21e
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
Gerrit-Reviewer: Physikerwelt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits