/** * Creates the HTML for a bullet list with all the results of the set * query. Values can be highlighted to show exact matches among nearby * ones. * * @param array $results (array of (array of one or two SMWDataValues)) * @param integer $number How many results should be displayed? -1 for all * @param boolean $first If less results should be displayed than * given, should they show the first $number results, or the last * $number results? * @param boolean $highlight Should the results be highlighted? * * @return string HTML with the bullet list, including header */ private function makeResultList($results, $number, $first, $highlight = false) { if ($number > 0) { $results = $first ? array_slice($results, 0, $number) : array_slice($results, $number); } $html = ''; foreach ($results as $result) { $listitem = $result[0]->getLongHTMLText($this->linker); if ($this->canShowSearchByPropertyLink($result[0])) { $value = $result[0] instanceof StringValue ? $result[0]->getWikiValueForLengthOf(72) : $result[0]->getWikiValue(); $listitem .= '  ' . Infolink::newPropertySearchLink('+', $this->pageRequestOptions->propertyString, $value)->getHTML($this->linker); } elseif ($result[0]->getTypeID() === '_wpg') { // Add browsing link for wikipage results // Note: non-wikipage results are possible using inverse properties $listitem .= '  ' . Infolink::newBrowsingLink('+', $result[0]->getLongWikiText())->getHTML($this->linker); } // Show value if not equal to the value that was searched // or if the current results are to be highlighted: if (array_key_exists(1, $result) && $result[1] instanceof DataValue && !$result[1]->getDataItem() instanceof \SMWDIError && (!$this->pageRequestOptions->value->getDataItem()->equals($result[1]->getDataItem()) || $highlight)) { $listitem .= " <em><small>" . $this->messageBuilder->getMessage('parentheses')->rawParams($result[1]->getLongHTMLText($this->linker))->escaped() . "</small></em>"; } // Highlight values if ($highlight) { $listitem = "<strong>{$listitem}</strong>"; } $html .= "<li>{$listitem}</li>"; } return "<ul>{$html}</ul>"; }
/** * Renders a table header for a given subject * * @since 1.9 * * @param DIWikiPage $subject */ protected function getTableHeader(DIWikiPage $subject) { $dataValue = $this->dataValueFactory->newDataItemValue($subject, null); $browselink = SMWInfolink::newBrowsingLink($dataValue->getText(), $dataValue->getWikiValue(), 'swmfactboxheadbrowse'); $this->tableBuilder->addHeaderItem('span', $this->messageBuilder->getMessage('smw_factbox_head', $browselink->getWikiText())->inContentLanguage()->text(), array('class' => 'smwfactboxhead')); $rdflink = SMWInfolink::newInternalLink($this->messageBuilder->getMessage('smw_viewasrdf')->inContentLanguage()->text(), $subject->getTitle()->getPageLanguage()->getNsText(NS_SPECIAL) . ':ExportRDF/' . $dataValue->getWikiValue(), 'rdflink'); $this->tableBuilder->addHeaderItem('span', $rdflink->getWikiText(), array('class' => 'smwrdflink')); }
/** * Renders a table header for a given subject * * @since 1.9 * * @param DIWikiPage $subject */ protected function getTableHeader(DIWikiPage $subject) { $dataValue = $this->dataValueFactory->newDataItemValue($subject, null); $browselink = SMWInfolink::newBrowsingLink($dataValue->getText(), $dataValue->getWikiValue(), 'swmfactboxheadbrowse'); $this->htmlTableRenderer->addHeaderItem('div', $this->messageBuilder->getMessage('smw_factbox_head', $browselink->getWikiText())->text(), array('class' => 'smwfactboxhead')); $rdflink = SMWInfolink::newInternalLink($this->messageBuilder->getMessage('smw_viewasrdf')->text(), Localizer::getInstance()->getNamespaceTextById(NS_SPECIAL) . ':ExportRDF/' . $dataValue->getWikiValue(), 'rdflink'); $this->htmlTableRenderer->addHeaderItem('div', $rdflink->getWikiText(), array('class' => 'smwrdflink')); }
/** * @since 2.1 * * @return string */ public function getForm() { $content = ''; foreach ($this->content as $value) { $content .= is_callable($value) ? $value($this) : $value; } if ($this->useFieldset) { $content = Xml::fieldset($this->messageBuilder->getMessage($this->name)->text(), $content, array('id' => $this->defaultPrefix . "-fieldset-{$this->name}")); } $form = Xml::tags('form', array('id' => $this->defaultPrefix . "-{$this->name}", 'name' => $this->name, 'method' => in_array($this->method, array('get', 'post')) ? $this->method : 'get', 'action' => htmlspecialchars($this->actionUrl ? $this->actionUrl : $GLOBALS['wgScript'])), Html::hidden('title', strtok($this->title->getPrefixedText(), '/')) . $content); $this->clear(); return $form; }
public function testNullLanguageThrowsException() { $instance = new MessageBuilder(); $this->setExpectedException('RuntimeException'); $instance->getMessage('properties'); }