Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 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;
 }
 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);
     $this->getOutput()->prependHTML($this->getTypesLink());
     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());
     $result .= $this->displayExtraInformationAbout($typeValue);
     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;
 }
 /**
  * Get the HTML for displaying values of this property, based on the
  * current from/until and limit settings.
  *
  * @return string
  */
 protected function getPropertyValueList()
 {
     if ($this->limit > 0) {
         // limit==0: configuration setting to disable this completely
         $options = SMWPageLister::getRequestOptions($this->limit, $this->from, $this->until);
         $diWikiPages = $this->store->getAllPropertySubjects($this->mProperty, $options);
         if (!$options->ascending) {
             $diWikiPages = array_reverse($diWikiPages);
         }
     } else {
         return '';
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $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>' . wfMessage('smw_attribute_header', $titleText)->text() . "</h2>\n<p>";
         if (!$this->mProperty->isUserDefined()) {
             $result .= wfMessage('smw_isspecprop')->text() . ' ';
         }
         $result .= wfMessage('smw_attributearticlecount')->numParams($resultNumber)->text() . "</p>\n" . $navigation . $this->subjectObjectList($diWikiPages) . $navigation . "\n</div>";
     }
     return $result;
 }
 /**
  * Get the HTML for displaying values of this property, based on the
  * current from/until and limit settings.
  *
  * @return string
  */
 protected function getPropertyValueList()
 {
     global $smwgPropertyPagingLimit, $wgRequest;
     // limit==0: configuration setting to disable this completely
     if ($this->limit < 1) {
         return '';
     }
     $diWikiPages = array();
     $options = SMWPageLister::getRequestOptions($this->limit, $this->from, $this->until);
     $options->limit = $wgRequest->getVal('limit', $smwgPropertyPagingLimit);
     $options->offset = $wgRequest->getVal('offset', '0');
     if (($value = $wgRequest->getVal('value', '')) !== '') {
         $diWikiPages = $this->doQuerySubjectListWithValue($value, $options);
     } else {
         $diWikiPages = $this->store->getAllPropertySubjects($this->mProperty, $options);
     }
     if (!$options->ascending) {
         $diWikiPages = array_reverse($diWikiPages);
     }
     $result = '';
     if (count($diWikiPages) > 0) {
         $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);
         $dvWikiPage = DataValueFactory::getInstance()->newDataValueByItem($this->mProperty);
         // Allow the DV formatter to access a specific language code
         $dvWikiPage->setOption(DataValue::OPT_USER_LANGUAGE, Localizer::getInstance()->getUserLanguage()->getCode());
         $titleText = htmlspecialchars($dvWikiPage->getWikiValue());
         $resultNumber = min($this->limit, count($diWikiPages));
         $result .= "<a name=\"SMWResults\"></a><div id=\"mw-pages\">\n" . '<h2>' . wfMessage('smw_attribute_header', $titleText)->text() . "</h2>\n<p>";
         $result .= $this->getNavigationLinks('smw_attributearticlecount', $diWikiPages, $smwgPropertyPagingLimit) . $this->subjectObjectList($diWikiPages) . "\n</div>";
     }
     return $result;
 }