Physikerwelt has uploaded a new change for review. https://gerrit.wikimedia.org/r/133427
Change subject: API for MathPattern conversion ...................................................................... API for MathPattern conversion * The API allows for MathPattern to XQuery conversions. Change-Id: I252fe951faef5bb498802f024a028899f2e0999b --- M MathEngineDB2.php M MathSearch.php A MathSearchApi.php 3 files changed, 48 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch refs/changes/27/133427/1 diff --git a/MathEngineDB2.php b/MathEngineDB2.php index ace4d45..3a96854 100644 --- a/MathEngineDB2.php +++ b/MathEngineDB2.php @@ -72,7 +72,7 @@ global $wgMathSearchMWSUrl, $wgMathDebug; global $wgMathSearchDB2ConnStr; if ( ! MathSearchHooks::isDB2Supported() ) { - throw new error( 'DB2 php client is not installed.' ); + throw new MWException( 'DB2 php client is not installed.' ); } $conn = db2_connect($wgMathSearchDB2ConnStr, '', ''); $stmt = db2_exec($conn, $this->query->getXQuery() ); diff --git a/MathSearch.php b/MathSearch.php index f981fd4..556ca27 100644 --- a/MathSearch.php +++ b/MathSearch.php @@ -50,6 +50,7 @@ $wgAutoloadClasses['SpecialMathIndex'] = $dir . 'SpecialMathIndex.php'; $wgAutoloadClasses['MathEngineMws'] = $dir . 'MathEngineMws.php'; $wgAutoloadClasses['MathEngineDB2'] = $dir . 'MathEngineDB2.php'; +$wgAutoloadClasses['MathSearchApi'] = $dir . 'MathSearchApi.php'; $wgMessagesDirs['MathSeach'] = __DIR__ . '/i18n'; $wgExtensionMessagesFiles['MathSearch'] = $dir . 'MathSearch.i18n.php'; @@ -66,6 +67,7 @@ $wgSpecialPages['GetEquationsByQuery'] = 'GetEquationsByQuery'; $wgSpecialPages['MathDebug'] = 'SpecialMathDebug'; $wgSpecialPages['MathIndex'] = 'SpecialMathIndex'; +$wgAPIModules['mathquery'] = 'MathSearchApi'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'MathSearchHooks::onLoadExtensionSchemaUpdates'; $wgHooks['MathFormulaRendered'][] = 'MathSearchHooks::onMathFormulaRendered'; diff --git a/MathSearchApi.php b/MathSearchApi.php new file mode 100644 index 0000000..3fb1350 --- /dev/null +++ b/MathSearchApi.php @@ -0,0 +1,45 @@ +<?php +/** + * Created by PhpStorm. + * User: Moritz + * Date: 13.05.14 + * Time: 21:33 + */ +class MathSearchApi extends ApiBase { + public function execute() { + $mathPattern = $this->getMain()->getVal('mathpattern'); + $mathEngine = $this->getMain()->getVal('mathengine'); + $query = new MathQueryObject( $mathPattern ); + switch ( $mathEngine ){ + case 'db2': + $query->setXQueryDialect( 'db2' ); + break; + case 'basex': + $query->setXQueryDialect( 'basex' ); + } + //$cQuery = $query->getCQuery(); + $this->getResult()->addValue( null, 'xquery', array ( 'dialect' => $mathEngine , + 'xQuery'=>$query->getXQuery()) ); + } + + // Description + public function getDescription() { + return 'Convert mathpattern to xquery'; + } + + // Describe the parameter + public function getParamDescription() { + return array_merge( parent::getParamDescription(), array( + 'mathpattern' => 'mathpattern', + 'mathengine' => 'xquery dialect' + ) ); + } + + // Get examples + public function getExamples() { + return array( + 'api.php?action=mathquery&mathpattern=\sin(?x^2)&mathengine=basex' + => 'Generate the XQueryExpression for fquery $\sin(?x^2)$ in BaseX dialect.' + ); + } +} \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/133427 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I252fe951faef5bb498802f024a028899f2e0999b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MathSearch Gerrit-Branch: master Gerrit-Owner: Physikerwelt <w...@physikerwelt.de> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits