/** * Creates the HTML table displaying the data of one subject. * * @param[in] $data SMWSemanticData The data to be displayed * @param[in] $left bool Should properties be displayed on the left side? * @param[in] $incoming bool Is this an incoming? Or an outgoing? * * @return string A string containing the HTML with the factbox */ private function displayData(SemanticData $data, $left = true, $incoming = false) { // Some of the CSS classes are different for the left or the right side. // In this case, there is an "i" after the "smwb-". This is set here. $ccsPrefix = $left ? 'smwb-' : 'smwb-i'; $html = "<table class=\"{$ccsPrefix}factbox\" cellpadding=\"0\" cellspacing=\"0\">\n"; $diProperties = $data->getProperties(); $noresult = true; foreach ($diProperties as $key => $diProperty) { $dvProperty = DataValueFactory::getInstance()->newDataValueByItem($diProperty, null); if ($dvProperty->isVisible()) { $dvProperty->setCaption($this->getPropertyLabel($dvProperty, $incoming)); $proptext = $dvProperty->getShortHTMLText(smwfGetLinker()) . "\n"; } elseif ($diProperty->getKey() == '_INST') { $proptext = smwfGetLinker()->specialLink('Categories'); } elseif ($diProperty->getKey() == '_REDI') { $proptext = smwfGetLinker()->specialLink('Listredirects', 'isredirect'); } else { continue; // skip this line } $head = '<th>' . $proptext . "</th>\n"; $body = "<td>\n"; $values = $data->getPropertyValues($diProperty); if ($incoming && count($values) >= $this->incomingValuesCount) { $moreIncoming = true; array_pop($values); } else { $moreIncoming = false; } $first = true; foreach ($values as $di) { if ($first) { $first = false; } else { $body .= ', '; } if ($incoming) { $dv = DataValueFactory::getInstance()->newDataValueByItem($di, null); } else { $dv = DataValueFactory::getInstance()->newDataValueByItem($di, $diProperty); } // For a redirect, disable the DisplayTitle to show the original (aka source) page if ($diProperty->getKey() == '_REDI') { $dv->setOption('smwgDVFeatures', $dv->getOptionBy('smwgDVFeatures') & ~SMW_DV_WPV_DTITLE); } $body .= "<span class=\"{$ccsPrefix}value\">" . $this->displayValue($dvProperty, $dv, $incoming) . "</span>\n"; } // Added in 2.3 // link to the remaining incoming pages if ($moreIncoming && \Hooks::run('SMW::Browse::BeforeIncomingPropertyValuesFurtherLinkCreate', array($diProperty, $this->subject->getDataItem(), &$body))) { $body .= \Html::element('a', array('href' => \SpecialPage::getSafeTitleFor('SearchByProperty')->getLocalURL(array('property' => $dvProperty->getWikiValue(), 'value' => $this->subject->getWikiValue()))), wfMessage('smw_browse_more')->text()); } $body .= "</td>\n"; // display row $html .= "<tr class=\"{$ccsPrefix}propvalue\">\n" . ($left ? $head . $body : $body . $head) . "</tr>\n"; $noresult = false; } // end foreach properties if ($noresult) { $html .= "<tr class=\"smwb-propvalue\"><th>   </th><td><em>" . wfMessage($incoming ? 'smw_browse_no_incoming' : 'smw_browse_no_outgoing')->escaped() . "</em></td></tr>\n"; } $html .= "</table>\n"; return $html; }