r22495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22494‎ | r22495 | r22496 >
Date:02:57, 28 May 2007
Author:kim
Status:old
Tags:
Comment:
concept links box. Still left in some debugging code.
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/Wikidata.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/WikiDataAPI.php
@@ -1198,5 +1198,17 @@
11991199 }
12001200 return $newSets;
12011201 }
 1202+function &getDefinedMeaningDataAssociatedByConcept($dm, $dc) {
 1203+ $meanings=array();
 1204+ $map=getDataSetsAssociatedByConcept($dm, $dc);
 1205+ foreach ($map as $map_dc => $map_dataset) {
 1206+ $dmData=new DefinedMeaningData();
 1207+ $dmData->setDataset($map_dataset);
 1208+ $dmData->setId($map_dataset->getDefinedMeaningId());
 1209+ $meanings[$map_dc]=$dmData;
 1210+ }
 1211+ return $meanings;
 1212+}
12021213
 1214+
12031215 ?>
Index: trunk/extensions/Wikidata/OmegaWiki/DefinedMeaning.php
@@ -147,15 +147,17 @@
148148
149149 $html="<div class=\"dataset-panel\">";;
150150 $html.="<table border=\"0\"><tr><th class=\"dataset-panel-heading\">$ow_conceptpanel</th></tr>";
151 - $dataSets=getDataSetsAssociatedByConcept($dm,$dc);
152151 $sk=$wgUser->getSkin();
153 - foreach ($dataSets as $dataset) {
 152+ $meanings=getDefinedMeaningDataAssociatedByConcept($dm,$dc);
 153+ foreach ($meanings as $dm) {
 154+ $dataset=$dm->getDataset();
154155 $active=($dataset->getPrefix()==$dc->getPrefix());
155156 $name=$dataset->fetchName();
 157+ #$name="woo";
156158 $prefix=$dataset->getPrefix();
157159
158160 $class= $active ? 'dataset-panel-active' : 'dataset-panel-inactive';
159 - $slot = $active ? "$name" : $sk->makeLinkObj($wgTitle,$name,"dataset=$prefix");
 161+ $slot = $active ? "$name" : $sk->makeLinkObj($dm->getTitle(),$name,"dataset=$prefix");
160162 $html.="<tr><td class=\"$class\">$slot</td></tr>";
161163 }
162164 $html.="</table>";
Index: trunk/extensions/Wikidata/OmegaWiki/Wikidata.php
@@ -3,6 +3,7 @@
44 require_once("forms.php");
55 require_once("Transaction.php");
66 require_once("OmegaWikiAttributes.php");
 7+require_once("WikiDataAPI.php");
78
89 class DefaultWikidataApplication {
910 protected $showRecordLifeSpan;
@@ -431,4 +432,112 @@
432433
433434 }
434435
 436+/**
 437+ * A representation and easy access to all defined-meaning related data in one handy spot
 438+ * or would be. Currently only holds data that is eally needed. Please expand and
 439+ * use to replace WiKiDataAPI.
 440+ * Sometimes a getter or setter will query the database and/or attempt to deduce additional
 441+ * information based on what it already knows, but don't count on that (yet).
 442+ */
 443+
 444+class DefinedMeaningData {
 445+ private $languageId=null; # 85 = English, a pretty safe default.
 446+ private $languageCode=null; #the associated wikiId
 447+ private $spelling=null;
 448+ private $id=null;
 449+ private $dataset=null;
 450+
 451+ /** return spelling of associated expression in particular langauge
 452+ * not nescesarily the correct langauge.
 453+ */
 454+ public function getSpelling() {
 455+ if ($this->spelling==null) {
 456+
 457+ $id=$this->getId();
 458+ if ($id==null)
 459+ return null;
 460+
 461+ $languageCode=$this->getLanguageCode();
 462+ if ($languageCode==null)
 463+ return null; # this should probably never happen
 464+
 465+ $dataset=$this->getDataset();
 466+ if ($dataset==null)
 467+ return null;
 468+
 469+ $this->spelling=getSpellingForLanguage($id, $languageCode, "en", $dataset);
 470+ }
 471+ return $this->spelling;
 472+ }
 473+
 474+ public function makeLinkObj() {
 475+ global
 476+ $wgUser;
 477+
 478+ $skin=$wgUser->getSkin();
 479+ if ($skin==null)
 480+ return null; # This is a bit of a guess
 481+
 482+ $title=$this->getTitle();
 483+ if ($title==null)
 484+ return null;
 485+
 486+ $dataset=$this->getDataset();
 487+ if ($dataset==null)
 488+ return null;
 489+
 490+ $prefix=$dataset->getPrefix();
 491+ $name=$this->getSpelling();
 492+
 493+ $skin->makeLinkObj($title, $name , "dataset=$prefix");
 494+ }
 495+
 496+
 497+ public function &getTitle() {
 498+ $name=$this->getSpelling();
 499+ $id=$this->getId();
 500+ $text="DefinedMeaning:$name ($id)";
 501+ wfDebug($text);
 502+ $title=Title::newFromText($text);
 503+ return $title;
 504+ }
 505+
 506+ public function setId($id) {
 507+ $this->id=$id;
 508+ }
 509+
 510+ public function getId() {
 511+ return $this->id;
 512+ }
 513+
 514+ public function setDataset(&$dataset) {
 515+ $this->dataset=$dataset;
 516+ }
 517+
 518+ public function &getDataset() {
 519+ return $this->dataset;
 520+ }
 521+
 522+ public function setLanguageId($langaugeId) {
 523+ $this->langaugeId=$languageId;
 524+ }
 525+
 526+ public function getLanguageId() {
 527+ return $this->languageId;
 528+ }
 529+
 530+ public function setLanguageCode($languageCode) {
 531+ return $this->langaugeCode;
 532+ }
 533+
 534+ public function getLanguageCode() {
 535+ if ($this->languageCode==null) {
 536+ global
 537+ $wgUser;
 538+ $this->languageCode=$wgUser->getOption('language');
 539+ }
 540+ return $this->languageCode;
 541+ }
 542+}
 543+
435544 ?>