Example #1
0
 /**
  * This method is called by the bot framework. 
  */
 public function run($paramArray, $isAsync, $delay)
 {
     echo "...started!\n";
     var_dump($paramArray);
     $result = "";
     global $iaigIP;
     $iaigLog = fopen("{$iaigIP}/IAIBot.log", "a");
     fprintf($iaigLog, "Import Bot started.\n");
     $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
     $this->setNumberOfTasks(1);
     // Two sub-tasks: update template, update images
     $this->addSubTask(2);
     global $iaigWikiApi;
     $ai = new IAIArticleImporter($iaigWikiApi);
     try {
         echo "Importing from {$iaigWikiApi}\n";
         // Import templates of article
         $article = $paramArray["article"];
         echo "Start report\n";
         $ai->startReport();
         echo "Import templates\n";
         $ai->importTemplates(array($article));
         $this->worked(1);
         $log->addGardeningIssueAboutValue($this->id, IAI_IMPORTBOT_PROCESSED_TASK, Title::newFromText($article), "Templates");
         echo "import Images\n";
         // Import images of article
         $ai->importImagesForArticle(array($article));
         $log->addGardeningIssueAboutValue($this->id, IAI_IMPORTBOT_PROCESSED_TASK, Title::newFromText($article), "Images");
         echo "Create report\n";
         $this->worked(1);
     } catch (Exception $e) {
         echo "Caught an exception: \n" . $e->getMessage();
     }
     $report = $ai->createReport(true);
     $log->addGardeningIssueAboutArticle($this->id, IAI_IMPORTBOT_REPORT, Title::newFromText($report));
     echo "...done.\n";
     fclose($iaigLog);
     return $result;
 }
Example #2
0
 private function getGardeningIssueContainerForTitle($options, $request, $title)
 {
     $gi_class = $request->getVal('class') == 0 ? NULL : $request->getVal('class') + $this->base - 1;
     $gi_store = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
     $gic = array();
     $gis = $gi_store->getGardeningIssues('smw_wscachebot', NULL, $gi_class, $title, SMW_GARDENINGLOG_SORTFORTITLE, NULL);
     $gic[] = new GardeningIssueContainer($title, $gis);
     return $gic;
 }
 /**
  * this methods constructs the special page webservice repository
  *
  */
 public function execute($par)
 {
     global $wgRequest, $wgOut;
     $wgOut->setPageTitle("Data Import Repository");
     $webTestDebug = $wgRequest->getVal('webTestDebug');
     if (!is_null($webTestDebug)) {
         $webTestDebug = true;
     }
     global $wgCookiePrefix;
     global $wgArticlePath;
     $gardeningURL = Title::makeTitleSafe(NS_SPECIAL, "Gardening")->getFullURL();
     $allowed = false;
     global $wgUser;
     $user = $wgUser;
     if ($user != null) {
         $groupsOfUser = $user->getGroups();
         foreach ($groupsOfUser as $key => $group) {
             if ($group == SMW_WS_SYSOP) {
                 $allowed = true;
             }
         }
     }
     $html = "";
     $html .= "<table id=\"menue\" class=\"TabContainer\"><tr>";
     $html .= "<td id=\"web-service-tab\" class=\"ActiveTab\" onclick=\"webServiceRepSpecial.displayWebServiceTab()\">Web Service definitions</td>";
     $html .= "<td></td>";
     $html .= "<td id=\"term-import-tab\" class=\"InactiveTab\" onclick=\"webServiceRepSpecial.displayTermImportTab()\" onmouseover=\"webServiceRepSpecial.highlightTab(event)\">Term Import definitions</td>";
     $html .= "<td></td></tr></table>";
     global $smwgDIIP;
     // handle web service repository
     require_once $smwgDIIP . '/specials/WebServices/SMW_WSStorage.php';
     $webServices = WSStorage::getDatabase()->getWebServices();
     ksort($webServices);
     $html .= "<span id=\"web-service-tab-content\">";
     $html .= "<h2><span class=\"mw-headline\">" . wfMsg('smw_wwsr_intro') . "</span></h2>";
     $html .= "<p>" . wfMsg('smw_wwsr_rep_intro') . "</p>";
     $html .= '<p><a href="' . Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . '">' . wfMsg('smw_wwsr_rep_create_link') . '</a></p>';
     if ($allowed) {
         $html .= "<table id=\"webservicetable\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_update_manual') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_delete') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_confirm') . "</th></tr>";
     } else {
         $html .= "<table id=\"webservicetable\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th></tr>";
     }
     foreach ($webServices as $ws) {
         $title = Title::newFromID($ws->getArticleID());
         if (!is_null($title)) {
             $wsUrl = $title->getFullURL();
             $wsName = substr($ws->getName(), 11, strlen($ws->getName()));
             $html .= "<tr id=\"ws-row-" . $ws->getArticleID() . "\"><td><a href=\"" . $wsUrl . "\">" . $wsName . "</a></td>";
             $cacheResults = WSStorage::getDatabase()->getResultsFromCache($ws->getArticleID());
             $oldestUpdate = "";
             if (count($cacheResults) > 0) {
                 $oldestUpdate = $cacheResults[0]["lastUpdate"];
                 if (strlen($oldestUpdate) > 0) {
                     $oldestUpdate = wfTimestamp(TS_DB, $oldestUpdate);
                 }
             }
             $latestUpdate = "";
             if (sizeof($cacheResults) > 1) {
                 $latestUpdate = $cacheResults[sizeof($cacheResults) - 1]["lastUpdate"];
                 if (strlen($latestUpdate) > 0) {
                     $latestUpdate = wfTimestamp(TS_DB, $cacheResults[sizeof($cacheResults) - 1]["lastUpdate"]);
                     if (strlen($oldestUpdate) > 0) {
                         $latestUpdate = " - " . $latestUpdate;
                     }
                 }
             }
             $html .= "<td>" . $oldestUpdate . $latestUpdate . "</td>";
             if ($allowed) {
                 $wsUpdateBot = new WSUpdateBot();
                 $html .= "<td style=\"text-align: center\"><button id=\"update" . $ws->getArticleID() . "\" type=\"button\" name=\"update\" onclick=\"webServiceRepSpecial.updateCache('" . $wsUpdateBot->getBotID() . "', 'WS_WSID=" . $ws->getArticleID() . "')\" alt=\"" . wfMsg('smw_wwsr_update') . "\" title=\"" . wfMsg('smw_wwsr_update_tooltip') . "\">" . wfMsg('smw_wwsr_update') . "</button>";
                 $html .= "<div id=\"updating" . $ws->getArticleID() . "\" style=\"display: none; text-align: center\"><a href=\"" . $gardeningURL . "\">" . wfMsg('smw_wwsr_updating') . "</a></div></td>";
             }
             global $wgArticlePath;
             if (strpos($wgArticlePath, "?") > 0) {
                 $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "&wwsdId=" . $ws->getArticleID();
             } else {
                 $url = Title::makeTitleSafe(NS_SPECIAL, "DefineWebService")->getFullURL() . "?wwsdId=" . $ws->getArticleID();
             }
             $html .= "<td style=\"text-align: center\"><button id=\"edit" . $ws->getArticleID() . "\" type=\"button\" name=\"edit\" onclick=\"window.location.href = '" . $url . "';\" alt=\"" . wfMsg('smw_wwsr_rep_edit') . "\" title=\"" . wfMsg('smw_wwsr_rep_edit_tooltip') . "\">" . wfMsg('smw_wwsr_rep_edit') . "</button>";
             if ($allowed) {
                 $html .= "<td style=\"text-align: center\">  <button type=\"button\"  onclick=\"webServiceRepSpecial.deleteWWSD(" . $ws->getArticleID() . ")\" alt=\"" . wfMsg('smw_wwsr_delete') . "\" title=\"" . wfMsg('smw_wwsr_delete_tooltip') . "\">" . wfMsg('smw_wwsr_delete') . "</button></td>";
             }
             if ($allowed) {
                 if ($ws->getConfirmationStatus() != "true") {
                     $html .= "<td style=\"text-align: center\" id=\"confirmText" . $ws->getArticleID() . "\">  <button type=\"button\" id=\"confirmButton" . $ws->getArticleID() . "\" onclick=\"webServiceRepSpecial.confirmWWSD(" . $ws->getArticleID() . ")\" alt=\"" . wfMsg('smw_wwsr_confirm') . "\" title=\"" . wfMsg('smw_wwsr_confirm_tooltip') . "\">" . wfMsg('smw_wwsr_confirm') . "</button></td></tr>";
                 } else {
                     $html .= "<td style=\"text-align: center\" alt=\"" . wfMsg('smw_wwsr_confirm') . "\" title=\"" . wfMsg('smw_wwsr_confirm_tooltip') . "\">" . wfMsg('smw_wwsr_confirmed') . "</td></tr>";
                 }
             } else {
                 $html .= "</tr>";
             }
         }
     }
     $html .= "</table>";
     $html .= "</span>";
     //Term Import definition tab
     $html .= "<span id=\"term-import-tab-content\" style=\"display: none\">";
     $html .= "<h2><span class=\"mw-headline\">" . wfMsg('smw_tir_intro') . "</span></h2>";
     $html .= "<p>" . wfMsg('smw_tir_rep_intro') . "</p>";
     $html .= '<p><a href="' . Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . '">' . wfMsg('smw_tir_rep_create_link') . '</a></p>';
     if ($allowed) {
         $html .= "<table id=\"termimporttable\" width=\"100%\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_update_manual') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_rep_edit') . "</th><th style=\"text-align: center\">" . wfMsg('smw_wwsr_delete') . "</th></tr>";
     } else {
         $html .= "<table id=\"termimporttable\" width=\"100%\" class=\"smwtable\"><tr><th>" . wfMsg('smw_wwsr_name') . "</th><th>" . wfMsg('smw_wwsr_lastupdate') . "</th></tr>";
     }
     $log = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
     SMWQueryProcessor::processFunctionParams(array("[[Category:TermImport]]"), $querystring, $params, $printouts);
     $queryResult = explode("|", SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI));
     unset($queryResult[0]);
     foreach ($queryResult as $tiArticleName) {
         $tiArticleName = substr($tiArticleName, 0, strpos($tiArticleName, "]]"));
         $html .= "<tr id=\"ti-row-" . $tiArticleName . "\">";
         $tiUrl = Title::newFromText("TermImport:" . $tiArticleName)->getFullURL();
         $html .= "<td><a href=\"" . $tiUrl . "\">" . $tiArticleName . "</a></td>";
         SMWQueryProcessor::processFunctionParams(array("[[belongsToTermImport::TermImport:" . $tiArticleName . "]]", "?hasImportDate", "limit=1", "sort=hasImportDate", "order=descending", "format=list", "mainlabel=-"), $querystring, $params, $printouts);
         $queryResult = SMWQueryProcessor::getResultFromQueryString($querystring, $params, $printouts, SMW_OUTPUT_WIKI);
         // timestamp creation depends on property type (page or date)
         $queryResult = trim(substr($queryResult, strpos($queryResult, "]]") + 2));
         if (strpos($queryResult, "[[:") === 0) {
             //type page
             $queryResult = trim(substr($queryResult, strpos($queryResult, "|") + 1));
             $queryResult = trim(substr($queryResult, 0, strpos($queryResult, "]")));
         } else {
             //type date
             $queryResult = trim(substr($queryResult, 0, strpos($queryResult, "[")));
         }
         $html .= "<td>" . $queryResult . "</td>";
         if ($allowed) {
             $tiUpdateBot = new TermImportUpdateBot();
             $html .= "<td style=\"text-align: center\"><button id=\"update-ti-" . $tiArticleName . "\" \r\n\t\t\t\t\ttype=\"button\" name=\"update-ti\" \r\n\t\t\t\t\tonclick=\"webServiceRepSpecial.updateTermImport('" . $tiArticleName . "')\" alt=\"" . wfMsg('smw_wwsr_update') . "\" title=\"" . wfMsg('smw_wwsr_update_tooltip_ti') . "\">" . wfMsg('smw_wwsr_update') . "</button>";
             $html .= "<div id=\"updating-ti-" . $tiArticleName . "\" style=\"display: none; text-align: center\"><a href=\"" . $gardeningURL . "\">" . wfMsg('smw_wwsr_updating') . "</a></div></td>";
             global $wgArticlePath;
             if (strpos($wgArticlePath, "?") > 0) {
                 $url = Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . "&tiname=" . $tiArticleName;
             } else {
                 $url = Title::makeTitleSafe(NS_SPECIAL, "TermImport")->getFullURL() . "?tiname=" . $tiArticleName;
             }
             $html .= "<td style=\"text-align: center\"><button id=\"edit" . $tiArticleName . "\" type=\"button\" name=\"edit\" onclick=\"window.location.href = '" . $url . "';\" alt=\"" . wfMsg('smw_wwsr_rep_edit') . "\" title=\"" . wfMsg('smw_wwsr_rep_edit_tooltip_ti') . "\">" . wfMsg('smw_wwsr_rep_edit') . "</button></td>";
             $html .= "<td style=\"text-align: center\"><button type=\"button\" name=\"delete\" onclick=\"webServiceRepSpecial.deleteTermImport('" . $tiArticleName . "')\" alt=\"" . wfMsg('smw_wwsr_delete') . "\" title=\"" . wfMsg('smw_wwsr_rep_delete_tooltip_ti') . "\">" . wfMsg('smw_wwsr_delete') . "</button></td>";
         }
         $html .= "</tr>";
     }
     $html .= "</table>";
     $html .= "</span>";
     $wgOut->addHTML($html);
 }
 /**
  * Serializes the tree structure (without root node)
  */
 public function serializeAsXML($type)
 {
     $id = uniqid(rand());
     $count = 0;
     $result = "";
     $gi_store = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
     foreach ($this->children as $title => $treeObject) {
         $isExpanded = count($treeObject->children) == 0 ? "false" : "true";
         $title_esc = htmlspecialchars($treeObject->getTitle()->getDBkey());
         $titleURLEscaped = htmlspecialchars(SMWOntologyBrowserXMLGenerator::urlescape($treeObject->getTitle()->getDBkey()));
         $issues = $gi_store->getGardeningIssues('smw_consistencybot', NULL, NULL, $treeObject->getTitle());
         $gi_issues = SMWOntologyBrowserErrorHighlighting::getGardeningIssuesAsXML($issues);
         $result .= "<{$type} title_url=\"{$titleURLEscaped}\" title=\"" . $title_esc . "\" img=\"{$type}.gif\" id=\"ID_{$id}{$count}\" expanded=\"{$isExpanded}\">";
         $result .= $gi_issues;
         $result .= $treeObject->serializeAsXML($type);
         $result .= "</{$type}>";
         $count++;
     }
     return $result;
 }
 public static function getGardeningIssuesAccess()
 {
     if (self::$gi_interface == NULL) {
         self::$gi_interface = new SGAGardeningIssuesAccess();
     }
     return self::$gi_interface;
 }
 /**
  * Encapsulates an annotation as XML.
  *
  * @param $instance
  * @param $annotation
  * @param $smwValues
  *
  * @return XML string (fragment)
  */
 private static function encapsulateAsAnnotation(Title $instance, Title $annotationTitle, $smwValues)
 {
     $id = uniqid(rand());
     $count = 0;
     $singleProperties = "";
     $multiProperties = "";
     $isFormula = false;
     $chemistryParser = new ChemEqParser();
     $gi_store = SGAGardeningIssuesAccess::getGardeningIssuesAccess();
     foreach ($smwValues as $smwValue) {
         //list($smwValue, $uri) = $tuple;
         if ($smwValue instanceof SMWRecordValue) {
             // n-ary property
             $needRepaste = false;
             $parameters = "";
             foreach ($smwValue->getDVs() as $params) {
                 if ($params == NULL) {
                     $parameters .= "<param></param>";
                     continue;
                 }
                 if ($params->getTypeID() == '_che') {
                     $isFormula = true;
                     $chemistryParser->checkEquation(array_shift($params->getDBkeys()));
                     $formulaAsHTML = html_entity_decode($chemistryParser->getHtmlFormat());
                     $value = "<![CDATA[" . $formulaAsHTML . "]]>";
                 } else {
                     if ($params->getTypeID() == '_chf') {
                         $isFormula = true;
                         $chemistryParser->checkFormula(array_shift($params->getDBkeys()));
                         $formulaAsHTML = html_entity_decode($chemistryParser->getHtmlFormat());
                         $value = "<![CDATA[" . $formulaAsHTML . "]]>";
                     } else {
                         // escape potential HTML in a CDATA section
                         $value = "<![CDATA[" . html_entity_decode(array_shift($params->getDBkeys())) . " " . html_entity_decode($params->getUnit()) . "]]>";
                     }
                 }
                 // check if re-paste is needed
                 $needRepaste |= html_entity_decode(array_shift($params->getDBkeys())) != array_shift($params->getDBkeys()) || $params->getUnit() != '';
                 // check if target is a wikipage and built param
                 $isLink = $params instanceof SMWWikiPageValue ? "isLink=\"true\"" : "";
                 $parameters .= "<param {$isLink}>{$value}</param>";
             }
             $repasteMarker = $isFormula || $needRepaste ? "needRepaste=\"true\"" : "";
             $title = htmlspecialchars($annotationTitle->getDBkey());
             $titleURLEscaped = htmlspecialchars(self::urlescape($annotationTitle->getDBkey()));
             $issues = $gi_store->getGardeningIssuesForPairs('smw_consistencybot', array(SMW_GARDISSUE_WRONG_DOMAIN_VALUE, SMW_GARDISSUE_TOO_LOW_CARD, SMW_GARDISSUE_TOO_HIGH_CARD, SMW_GARD_ISSUE_MISSING_PARAM, SMW_GARDISSUE_WRONG_TARGET_VALUE), NULL, array($instance, $annotationTitle));
             $gi_issues = SMWOntologyBrowserErrorHighlighting::getAnnotationIssuesAsXML($issues, $smwValue);
             // no metadata available on n-ary properties
             $multiProperties .= "<annotation  title_url=\"{$titleURLEscaped}\" title=\"" . $title . "\" id=\"ID_{$id}{$count}\" {$repasteMarker}>" . $parameters . "{$gi_issues}</annotation>";
         } else {
             if ($smwValue instanceof SMWWikiPageValue || $smwValue->getTypeID() == '_uri') {
                 // relation
                 $title = htmlspecialchars($annotationTitle->getDBkey());
                 $titleURLEscaped = htmlspecialchars(self::urlescape($annotationTitle->getDBkey()));
                 $issues = $gi_store->getGardeningIssuesForPairs('smw_consistencybot', array(SMW_GARDISSUE_WRONG_DOMAIN_VALUE, SMW_GARDISSUE_TOO_LOW_CARD, SMW_GARDISSUE_TOO_HIGH_CARD, SMW_GARDISSUE_WRONG_TARGET_VALUE), NULL, array($instance, $annotationTitle));
                 $gi_issues = SMWOntologyBrowserErrorHighlighting::getAnnotationIssuesAsXML($issues, $smwValue);
                 // metadata
                 // check if metadata patch is applied
                 $metadataTags = "<metadata id=\"" . $id . "_meta_" . $count . "\">";
                 if (method_exists($smwValue, "getMetadataMap")) {
                     // read metadata
                     foreach ($smwValue->getMetadataMap() as $mdProperty => $mdValues) {
                         foreach ($mdValues as $mdValue) {
                             $metadataTags .= "<property name=\"" . htmlspecialchars($mdProperty) . "\">" . htmlspecialchars($mdValue) . "</property>";
                         }
                     }
                 }
                 $metadataTags .= "</metadata>";
                 if ($smwValue instanceof SMWWikiPageValue && !is_null($smwValue->getTitle())) {
                     $targetNotExists = $smwValue->getTitle()->exists() ? "" : "notexists=\"true\"";
                     $singleProperties .= "<annotation  title_url=\"{$titleURLEscaped}\" title=\"" . $title . "\" id=\"ID_{$id}{$count}\">" . "<param isLink=\"true\" {$targetNotExists}><![CDATA[" . $smwValue->getTitle()->getPrefixedDBkey() . "]]></param>" . $gi_issues . $metadataTags . "</annotation>";
                 } else {
                     if ($smwValue->getTypeID() == '_uri') {
                         // any URI
                         $uri = $smwValue->getWikiValue();
                         if (strpos($uri, "#") !== false) {
                             $local = substr($uri, strpos($uri, "#") + 1);
                         } else {
                             if (strrpos($uri, "/") !== false) {
                                 $local = substr($uri, strrpos($uri, "/") + 1);
                             } else {
                                 $local = $uri;
                             }
                         }
                         $uri_att = 'uri="' . htmlspecialchars($uri) . '"';
                         $singleProperties .= "<annotation  title_url=\"{$titleURLEscaped}\" title=\"" . $title . "\" id=\"ID_{$id}{$count}\">" . "<param isLink=\"true\" {$uri_att}><![CDATA[" . $local . "]]></param>" . $metadataTags . "</annotation>";
                     }
                 }
             } else {
                 if ($smwValue != NULL) {
                     // normal attribute
                     if ($smwValue->getTypeID() == '_che') {
                         $isFormula = true;
                         $chemistryParser->checkEquation(array_shift($smwValue->getDBkeys()));
                         $formulaAsHTML = html_entity_decode($chemistryParser->getHtmlFormat());
                         $value = "<![CDATA[" . $formulaAsHTML . "]]>";
                     }
                     if ($smwValue->getTypeID() == '_che') {
                         $isFormula = true;
                         $chemistryParser->checkEquation(array_shift($smwValue->getDBkeys()));
                         $formulaAsHTML = html_entity_decode($chemistryParser->getHtmlFormat());
                         $value = "<![CDATA[" . $formulaAsHTML . "]]>";
                     } else {
                         if ($smwValue->getTypeID() == '_chf') {
                             $isFormula = true;
                             $chemistryParser->checkFormula(array_shift($smwValue->getDBkey()));
                             $formulaAsHTML = html_entity_decode($chemistryParser->getHtmlFormat());
                             $value = "<![CDATA[" . $formulaAsHTML . "]]>";
                         } else {
                             // escape potential HTML in a CDATA section
                             if ($smwValue->getTypeID() == '__typ') {
                                 //SMW_DV_Types
                                 $value = implode(",", $smwValue->getTypeLabels());
                                 $value = strip_tags($value, "<sub><sup><b><i>");
                                 $value = "<![CDATA[" . html_entity_decode($value) . " " . $smwValue->getUnit() . "]]>";
                             }
                             if ($smwValue->getTypeID() == '__tls') {
                                 // SMW_DV_TypeList
                                 $value = "<![CDATA[" . html_entity_decode($smwValue->getWikiValue()) . "]]>";
                             } else {
                                 // small hack for datetime type. It may occur that there is a T at the end.
                                 if ($smwValue->getTypeID() == '_dat') {
                                     $val = array_shift($smwValue->getDBkeys());
                                     $xsdValue = substr($val, -1) == 'T' ? str_replace('T', '', $val) : $val;
                                 } else {
                                     $xsdValue = array_shift($smwValue->getDBkeys());
                                 }
                                 $value = strip_tags($xsdValue, "<sub><sup><b><i>");
                                 $value = "<![CDATA[" . html_entity_decode($value) . " " . $smwValue->getUnit() . "]]>";
                             }
                         }
                     }
                     //special attribute mark for all things needed to get re-pasted in FF.
                     $repasteMarker = $isFormula || strip_tags(array_shift($smwValue->getDBkeys())) != array_shift($smwValue->getDBkeys()) || $smwValue->getUnit() != '' ? "needRepaste=\"true\"" : "";
                     $title = htmlspecialchars($annotationTitle->getDBkey());
                     $titleURLEscaped = htmlspecialchars(self::urlescape($annotationTitle->getDBkey()));
                     $issues = $gi_store->getGardeningIssuesForPairs('smw_consistencybot', array(SMW_GARDISSUE_WRONG_DOMAIN_VALUE, SMW_GARDISSUE_TOO_LOW_CARD, SMW_GARDISSUE_TOO_HIGH_CARD, SMW_GARDISSUE_WRONG_UNIT), NULL, array($instance, $annotationTitle));
                     // gardening issues
                     $gi_issues = SMWOntologyBrowserErrorHighlighting::getAnnotationIssuesAsXML($issues, $smwValue);
                     // metadata
                     // check if metadata patch is applied
                     $metadataTags = "<metadata id=\"" . $id . "_meta_" . $count . "\">";
                     if (method_exists($smwValue, "getMetadataMap")) {
                         // read metadata
                         foreach ($smwValue->getMetadataMap() as $mdProperty => $mdValues) {
                             foreach ($mdValues as $mdValue) {
                                 $metadataTags .= "<property name=\"" . htmlspecialchars($mdProperty) . "\">" . htmlspecialchars($mdValue) . "</property>";
                             }
                         }
                     }
                     $metadataTags .= "</metadata>";
                     $singleProperties .= "<annotation  title_url=\"{$titleURLEscaped}\" title=\"" . $title . "\" id=\"ID_" . $id . $count . "\" {$repasteMarker}>" . "<param>" . $value . "</param>" . $gi_issues . $metadataTags . "</annotation>";
                 }
             }
         }
         $count++;
     }
     return $singleProperties . $multiProperties;
 }