Physikerwelt has uploaded a new change for review.
https://gerrit.wikimedia.org/r/189414
Change subject: Improve FormulaInfo page
......................................................................
Improve FormulaInfo page
* Display only current revisions
Change-Id: Ibf41f548b440fd205209a69a1a985e839a8108f6
---
M FormulaInfo.php
M MathObject.php
2 files changed, 45 insertions(+), 12 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MathSearch
refs/changes/14/189414/1
diff --git a/FormulaInfo.php b/FormulaInfo.php
index 3cb6753..8a40330 100644
--- a/FormulaInfo.php
+++ b/FormulaInfo.php
@@ -54,6 +54,13 @@
}
}
+ /**
+ * @param $oldID
+ * @param $eid
+ *
+ * @return bool
+ * @throws MWException
+ */
public function DisplayInfo( $oldID, $eid ) {
global $wgMathDebug, $wgExtensionAssetsPath;
$out = $this->getOutput();
@@ -77,7 +84,11 @@
return false;
}
$out->addWikiText( "Occurrences on the following pages:" );
- wfDebugLog( "MathSearch", var_export( $mo->getAllOccurences(),
true ) );
+ $all = $mo->getAllOccurences();
+ foreach( $all as $occ ){
+ /** @type MathObject $occ */
+ $out->addWikiText( '*' . $occ->printLink2Page( false )
);
+ }
// $wgOut->addWikiText('<b>:'.var_export($res,true).'</b>');
$out->addWikiText( 'TeX (as stored in database):
<syntaxhighlight lang="latex">' . $mo->getTex() . '</syntaxhighlight>' );
$out->addWikiText( 'MathML (' . self::getlengh(
$mo->getMathml() ) . ') :', false );
diff --git a/MathObject.php b/MathObject.php
index d350689..21b07d2 100644
--- a/MathObject.php
+++ b/MathObject.php
@@ -209,9 +209,12 @@
/**
* Gets all occurences of the tex.
- * @return array(MathObject)
+ *
+ * @param bool $currentOnly
+ *
+ * @return array
*/
- public function getAllOccurences($printOutput = true) {
+ public function getAllOccurences( $currentOnly = true ) {
$out = array( );
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select(
@@ -219,12 +222,12 @@
);
foreach ( $res as $row ) {
- //self::DebugPrint( var_export( $row, true ) );
$var = self::constructformpagerow( $row );
if ( $var ) {
- if ($printOutput) $var->printLink2Page( false );
+ if ( $currentOnly === false ||
$var->isCurrent() ){
array_push( $out, $var );
}
+ }
}
return $out;
}
@@ -238,14 +241,14 @@
}
}
- public function printLink2Page( $hidePage = true ) {
- global $wgOut;
- $wgOut->addHtml( " " );
+ /**
+ * @param bool $hidePage
+ *
+ * @return string
+ */public function printLink2Page( $hidePage = true ) {
$pageString = $hidePage ? "" : $this->getPageTitle() . " ";
- $wgOut->addWikiText( "[[" . $this->getPageTitle() . "#math" .
$this->getAnchorID()
- . "|" . $pageString . "Eq: " . $this->getAnchorID() .
"]] ", false );
- // $wgOut->addHtml( MathLaTeXML::embedMathML( $this->mathml ) );
- $wgOut->addHtml( "<br />" );
+ $anchor = MathSearchHooks::generateMathAnchorString(
$this->getRevisionID(), $this->getAnchorID() );
+ return "[[{$this->getPageTitle()}{$anchor}|{$pageString}Eq:
{$this->getAnchorID()}]]";
}
/**
@@ -333,4 +336,23 @@
. 'JOIN mathvarstat on varstat_featurename =
`mathobservation_featurename` and varstat_featuretype =
`mathobservation_featuretype` '
. 'GROUP by `mathobservation_featurename`,
`mathobservation_featuretype`, mathindex_revision_id ORDER BY CNT DESC' );
}
+
+ /**
+ * @return null|Revision
+ */
+ public function getRevision(){
+ return Revision::newFromId( $this->revisionID );
+ }
+
+ /**
+ * @return bool
+ */
+ public function isCurrent(){
+ $rev = Revision::newFromId( $this->revisionID );
+ if ( is_null( $rev ) ){
+ return false;
+ } else {
+ return $rev->isCurrent();
+ }
+ }
}
--
To view, visit https://gerrit.wikimedia.org/r/189414
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf41f548b440fd205209a69a1a985e839a8108f6
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MathSearch
Gerrit-Branch: master
Gerrit-Owner: Physikerwelt <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits