protected function getTypeProperties($typeLabel) { global $wgRequest, $smwgTypePagingLimit; if ($smwgTypePagingLimit <= 0) { return ''; } // not too useful, but we comply to this request $from = $wgRequest->getVal('from'); $until = $wgRequest->getVal('until'); $typeValue = SMWDataValueFactory::newTypeIDValue('__typ', $typeLabel); $store = smwfGetStore(); $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until); $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options); if (!$options->ascending) { $diWikiPages = array_reverse($diWikiPages); } $result = ''; if (count($diWikiPages) > 0) { $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until); $title = $this->getTitleFor('Types', $typeLabel); $title->setFragment('#SMWResults'); // Make navigation point to the result list. $navigation = $pageLister->getNavigationLinks($title); $resultNumber = min($smwgTypePagingLimit, count($diWikiPages)); $typeName = $typeValue->getLongWikiText(); $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_type_header', $typeName) . "</h2>\n<p>" . wfMsgExt('smw_typearticlecount', array('parsemag'), $resultNumber) . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>"; } return $result; }
/** * Returns the HTML which is added to $wgOut after the article text. * * @return string */ protected function getHtml() { wfProfileIn(__METHOD__ . ' (SMW)'); if ($this->limit > 0) { // limit==0: configuration setting to disable this completely $store = smwfGetStore(); $description = new SMWConceptDescription($this->getDataItem()); $query = SMWPageLister::getQuery($description, $this->limit, $this->from, $this->until); $queryResult = $store->getQueryResult($query); $diWikiPages = $queryResult->getResults(); if ($this->until !== '') { $diWikiPages = array_reverse($diWikiPages); } $errors = $queryResult->getErrors(); } else { $diWikiPages = array(); $errors = array(); } $pageLister = new SMWPageLister($diWikiPages, null, $this->limit, $this->from, $this->until); $this->mTitle->setFragment('#SMWResults'); // Make navigation point to the result list. $navigation = $pageLister->getNavigationLinks($this->mTitle); $titleText = htmlspecialchars($this->mTitle->getText()); $resultNumber = min($this->limit, count($diWikiPages)); $result = "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMsg('smw_concept_header', $titleText) . "</h2>\n" . wfMsgExt('smw_conceptarticlecount', array('parsemag'), $resultNumber) . smwfEncodeMessages($errors) . "\n" . $navigation . $pageLister->formatList() . $navigation . "</div>\n"; wfProfileOut(__METHOD__ . ' (SMW)'); return $result; }
protected function getTypeProperties($typeLabel) { global $wgRequest, $smwgTypePagingLimit; if ($smwgTypePagingLimit <= 0) { return ''; // not too useful, but we comply to this request } $from = $wgRequest->getVal('from'); $until = $wgRequest->getVal('until'); $typeValue = DataValueFactory::getInstance()->newTypeIDValue('__typ', $typeLabel); if (!$typeValue->isValid()) { return $this->msg('smw-special-types-no-such-type')->escaped(); } $store = \SMW\StoreFactory::getStore(); $options = SMWPageLister::getRequestOptions($smwgTypePagingLimit, $from, $until); $diWikiPages = $store->getPropertySubjects(new SMWDIProperty('_TYPE'), $typeValue->getDataItem(), $options); if (!$options->ascending) { $diWikiPages = array_reverse($diWikiPages); } $escapedTypeLabel = htmlspecialchars($typeValue->getWikiValue()); $canonicalLabel = DataTypeRegistry::getInstance()->findCanonicalLabelById($typeValue->getDataItem()->getFragment()); $typeKey = 'smw-sp-types' . strtolower($typeValue->getDataItem()->getFragment()); $messageKey = wfMessage($typeKey)->exists() ? $typeKey : 'smw-sp-types-default'; $result = \Html::rawElement('div', array('class' => 'smw-sp-types-intro' . $typeKey), wfMessage($messageKey, str_replace('_', ' ', $escapedTypeLabel))->parse() . ' ' . wfMessage('smw-sp-types-help', str_replace(' ', '_', $canonicalLabel))->parse()); if (count($diWikiPages) > 0) { $pageLister = new SMWPageLister($diWikiPages, null, $smwgTypePagingLimit, $from, $until); $title = $this->getTitleFor('Types', $typeLabel); $title->setFragment('#SMWResults'); // Make navigation point to the result list. $navigation = $pageLister->getNavigationLinks($title); $resultNumber = min($smwgTypePagingLimit, count($diWikiPages)); $typeName = $typeValue->getLongWikiText(); $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMessage('smw_type_header', $typeName)->text() . "</h2>\n<p>" . wfMessage('smw_typearticlecount')->numParams($resultNumber)->text() . "</p>\n" . $navigation . $pageLister->formatList() . $navigation . "\n</div>"; } return $result; }