Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php |
— | — | @@ -316,6 +316,8 @@ |
317 | 317 | $article = new SMWTypePage($title); |
318 | 318 | } elseif ( $title->getNamespace() == SMW_NS_PROPERTY ) { |
319 | 319 | $article = new SMWPropertyPage($title); |
| 320 | + } elseif ( $title->getNamespace() == SMW_NS_CONCEPT ) { |
| 321 | + $article = new SMWConceptPage($title); |
320 | 322 | } |
321 | 323 | return true; |
322 | 324 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_ConceptPage.php |
— | — | @@ -0,0 +1,117 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * Special handling for relation/attribute description pages. |
| 5 | + * Some code based on CategoryPage.php |
| 6 | + * |
| 7 | + * @author: Markus Krötzsch |
| 8 | + * @file |
| 9 | + * @ingroup SMW |
| 10 | + */ |
| 11 | + |
| 12 | +/** |
| 13 | + * Implementation of MediaWiki's Article that shows additional information on |
| 14 | + * Concept: pages. Very simliar to CategoryPage. |
| 15 | + */ |
| 16 | +class SMWConceptPage extends SMWOrderedListPage { |
| 17 | + |
| 18 | + /** |
| 19 | + * Use higher limit. This operation is very similar to showing members of categories. |
| 20 | + */ |
| 21 | + protected function initParameters() { |
| 22 | + global $smwgConceptPagingLimit; |
| 23 | + $this->limit = $smwgConceptPagingLimit; |
| 24 | + return true; |
| 25 | + } |
| 26 | + |
| 27 | + /** |
| 28 | + * Fill the internal arrays with the set of articles to be displayed (possibly plus one additional |
| 29 | + * article that indicates further results). |
| 30 | + */ |
| 31 | + protected function doQuery() { |
| 32 | + $store = smwfGetStore(); |
| 33 | + |
| 34 | + $desc = new SMWConceptDescription($this->mTitle); |
| 35 | + if ($this->from != '') { |
| 36 | + $dv = SMWDataValueFactory::newTypeIDValue('_wpg'); |
| 37 | + $dv->setValues($this->from, NS_MAIN, false, '', $this->from); // make a dummy wiki page as boundary |
| 38 | + $fromdesc = new SMWValueDescription($dv, SMW_CMP_GEQ); |
| 39 | + $desc = new SMWConjunction(array($desc,$fromdesc)); |
| 40 | + $order = 'ASC'; |
| 41 | + } elseif ($this->until != '') { |
| 42 | + $dv = SMWDataValueFactory::newTypeIDValue('_wpg'); |
| 43 | + $dv->setValues($this->until, NS_MAIN, false, '', $this->until); // make a dummy wiki page as boundary |
| 44 | + $fromdesc = new SMWValueDescription($dv, SMW_CMP_LEQ); |
| 45 | + $neqdesc = new SMWValueDescription($dv, SMW_CMP_NEQ); // do not include boundary in this case |
| 46 | + $desc = new SMWConjunction(array($desc,$fromdesc,$neqdesc)); |
| 47 | + $order = 'DESC'; |
| 48 | + } else { |
| 49 | + $order = 'ASC'; |
| 50 | + } |
| 51 | + $desc->addPrintRequest(new SMWPrintRequest(SMWPrintRequest::PRINT_THIS, '')); |
| 52 | + $query = new SMWQuery($desc); |
| 53 | + $query->sortkeys[''] = $order; |
| 54 | + $query->setLimit($this->limit+1); |
| 55 | + |
| 56 | + $result = $store->getQueryResult($query); |
| 57 | + $row = $result->getNext(); |
| 58 | + while ( $row !== false ) { |
| 59 | + $this->articles[] = end($row)->getNextObject(); |
| 60 | + $row = $result->getNext(); |
| 61 | + } |
| 62 | + if ($order == 'DESC') { |
| 63 | + $this->articles = array_reverse($this->articles); |
| 64 | + } |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Generates the headline for the page list and the HTML encoded list of pages which |
| 69 | + * shall be shown. |
| 70 | + */ |
| 71 | + protected function getPages() { |
| 72 | + wfProfileIn( __METHOD__ . ' (SMW)'); |
| 73 | + wfLoadExtensionMessages('SemanticMediaWiki'); |
| 74 | + $r = ''; |
| 75 | + $ti = htmlspecialchars( $this->mTitle->getText() ); |
| 76 | + $nav = $this->getNavigationLinks(); |
| 77 | + $r .= '<a name="SMWResults"></a>' . $nav . "<div id=\"mw-pages\">\n"; |
| 78 | + |
| 79 | + $r .= '<h2>' . wfMsg('smw_concept_header',$ti) . "</h2>\n"; |
| 80 | + $r .= wfMsg('smw_conceptarticlecount', min($this->limit, count($this->articles))) . "\n"; |
| 81 | + |
| 82 | + $r .= $this->formatList(); |
| 83 | + $r .= "\n</div>" . $nav; |
| 84 | + wfProfileOut( __METHOD__ . ' (SMW)'); |
| 85 | + return $r; |
| 86 | + } |
| 87 | + |
| 88 | + /** |
| 89 | + * Format a list of articles chunked by letter, either as a |
| 90 | + * bullet list or a columnar format, depending on the length. |
| 91 | + * |
| 92 | + * @param int $cutoff |
| 93 | + * @return string |
| 94 | + */ |
| 95 | + private function formatList( $cutoff = 6 ) { |
| 96 | + $end = count($this->articles); |
| 97 | + if ($end > $this->limit) { |
| 98 | + if ($this->until != '') { |
| 99 | + $start = 1; |
| 100 | + } else { |
| 101 | + $start = 0; |
| 102 | + $end --; |
| 103 | + } |
| 104 | + } else { |
| 105 | + $start = 0; |
| 106 | + } |
| 107 | + |
| 108 | + if ( count ( $this->articles ) > $cutoff ) { |
| 109 | + return $this->columnList( $start, $end, $this->articles ); |
| 110 | + } elseif ( count($this->articles) > 0) { |
| 111 | + // for short lists of articles |
| 112 | + return $this->shortList( $start, $end, $this->articles ); |
| 113 | + } |
| 114 | + return ''; |
| 115 | + } |
| 116 | + |
| 117 | +} |
| 118 | + |
Property changes on: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_ConceptPage.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 119 | + native |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | $ac = count($this->articles); |
111 | 111 | if ($this->until != '') { |
112 | 112 | if ($ac > $this->limit) { // (we assume that limit is at least 1) |
113 | | - $first = $this->articles[1]->getDBkey(); |
| 113 | + $first = $this->articles[1]->getSortkey(); |
114 | 114 | } else { |
115 | 115 | $first = ''; |
116 | 116 | } |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | } elseif ( ($ac > $this->limit) || ($this->from != '') ) { |
119 | 119 | $first = $this->from; |
120 | 120 | if ( $ac > $this->limit) { |
121 | | - $last = $this->articles[$ac-1]->getDBkey(); |
| 121 | + $last = $this->articles[$ac-1]->getSortkey(); |
122 | 122 | } else { |
123 | 123 | $last = ''; |
124 | 124 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -30,8 +30,7 @@ |
31 | 31 | define('SMW_SP_SUBCLASS_OF',18); |
32 | 32 | define('SMW_SP_CONCEPT_DESC',19); |
33 | 33 | |
34 | | -// old names, will be removed *two* releases after given version |
35 | | -// SMW 1.1.2 |
| 34 | +/** @deprecated This constant will be removed in SMW 1.4. Use SMW_SP_INSTANCE_OF or SMW_SP_SUBCLASS_OF as appropriate. */ |
36 | 35 | define('SMW_SP_HAS_CATEGORY',4); // name specific for categories, use "instance of" to distinguish from future explicit "subclass of" |
37 | 36 | |
38 | 37 | // constants for displaying the factbox |
— | — | @@ -108,6 +107,7 @@ |
109 | 108 | $wgAutoloadClasses['SMWOrderedListPage'] = $smwgIP . '/includes/articlepages/SMW_OrderedListPage.php'; |
110 | 109 | $wgAutoloadClasses['SMWTypePage'] = $smwgIP . '/includes/articlepages/SMW_TypePage.php'; |
111 | 110 | $wgAutoloadClasses['SMWPropertyPage'] = $smwgIP . '/includes/articlepages/SMW_PropertyPage.php'; |
| 111 | + $wgAutoloadClasses['SMWConceptPage'] = $smwgIP . '/includes/articlepages/SMW_ConceptPage.php'; |
112 | 112 | //// printers |
113 | 113 | $wgAutoloadClasses['SMWResultPrinter'] = $smwgIP . '/includes/SMW_QueryPrinter.php'; |
114 | 114 | $wgAutoloadClasses['SMWTableResultPrinter'] = $smwgIP . '/includes/SMW_QP_Table.php'; |
— | — | @@ -357,17 +357,20 @@ |
358 | 358 | |
359 | 359 | // display concept box: |
360 | 360 | $rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . $title->getPrefixedText(), 'rdflink'); |
361 | | - $qresult = smwfGetStore()->getQueryResult($query); |
362 | | - $printer = SMWQueryProcessor::getResultPrinter('list', SMWQueryProcessor::CONCEPT_DESC, $qresult); |
363 | | - $printer->setShowErrors(false); |
364 | | - $resultlink = $printer->getResult($qresult, array('sep' => ',_'), SMW_OUTPUT_WIKI); |
365 | 361 | smwfRequireHeadItem(SMW_HEADER_STYLE); |
| 362 | + |
| 363 | +// $qresult = smwfGetStore()->getQueryResult($query); |
| 364 | +// $printer = SMWQueryProcessor::getResultPrinter('list', SMWQueryProcessor::CONCEPT_DESC, $qresult); |
| 365 | +// $printer->setShowErrors(false); |
| 366 | +// $resultlink = $printer->getResult($qresult, array('sep' => ',_'), SMW_OUTPUT_WIKI); |
| 367 | + |
366 | 368 | $result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent('smw_concept_description',$title->getText()) . |
367 | 369 | (count($query->getErrors())>0?' ' . smwfEncodeMessages($query->getErrors()):'') . |
368 | 370 | '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' . |
369 | 371 | ($concept_docu?"<p>$concept_docu</p>":'') . |
370 | 372 | '<pre>' . str_replace('[', '[', $concept_text) . "</pre>\n" . |
371 | | - $resultlink . '</div>'; |
| 373 | +// $resultlink . |
| 374 | + '</div>'; |
372 | 375 | return $result; |
373 | 376 | } |
374 | 377 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php |
— | — | @@ -125,10 +125,11 @@ |
126 | 126 | $smwgSearchByPropertyFuzzy = true; |
127 | 127 | |
128 | 128 | ### |
129 | | -# Number results shown in the listings on pages of properties (attributes or |
130 | | -# relations) and types. |
| 129 | +# Number results shown in the listings on pages in the namespaces Property, |
| 130 | +# Type, and Concept. |
131 | 131 | ## |
132 | 132 | $smwgTypePagingLimit = 200; // same number as for categories |
| 133 | +$smwgConceptPagingLimit = 200; // same number as for categories |
133 | 134 | $smwgPropertyPagingLimit = 25; // use smaller value since property lists need more space |
134 | 135 | ## |
135 | 136 | |
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php |
— | — | @@ -117,6 +117,8 @@ |
118 | 118 | 'smw_attributearticlecount' => 'Showing $1 pages using this property.', |
119 | 119 | 'smw_subproperty_header' => 'Subproperties', |
120 | 120 | 'smw_subpropertyarticlecount' => 'This property has the following $1 subproperties.', |
| 121 | + 'smw_concept_header' => 'Pages of concept "$1"', |
| 122 | + 'smw_conceptarticlecount' => 'Showing $1 pages belonging to that concept.', |
121 | 123 | |
122 | 124 | // Messages used in RSS feeds |
123 | 125 | 'smw_rss_description' => '$1 RSS feed', |
— | — | @@ -809,11 +811,13 @@ |
810 | 812 | 'smw_devel_warning' => 'Diese Funktion befindet sich zur Zeit in Entwicklung und ist eventuell noch nicht voll einsatzfähig. Eventuell ist es ratsam, den Inhalt des Wikis vor der Benutzung dieser Funktion zu sichern.', |
811 | 813 | 'smw_notemplategiven' => 'Der Parameter „template“ muss angegeben werden, damit diese Anfrage durchgeführt werden kann.', |
812 | 814 | 'smw_type_header' => 'Attribute mit dem Datentyp „$1“', |
813 | | - 'smw_typearticlecount' => 'Es werden $1 Attribute mit diesem Datentyp angezeigt.', |
| 815 | + 'smw_typearticlecount' => 'Es werden $1 Attribute mit diesem Datentyp angezeigt:', |
814 | 816 | 'smw_attribute_header' => 'Seiten mit dem Attribut „$1“', |
815 | | - 'smw_attributearticlecount' => 'Es werden $1 Seiten angezeigt, die dieses Attribut verwenden.', |
| 817 | + 'smw_attributearticlecount' => 'Es werden $1 Seiten angezeigt, die dieses Attribut verwenden:', |
816 | 818 | 'smw_subproperty_header' => 'Unterattribute', |
817 | | - 'smw_subpropertyarticlecount' => 'Dieses Attribut hat folgende $1 Unterattribute.', |
| 819 | + 'smw_subpropertyarticlecount' => 'Dieses Attribut hat folgende $1 Unterattribute:', |
| 820 | + 'smw_concept_header' => 'Seiten des Konzepts „$1“', |
| 821 | + 'smw_conceptarticlecount' => 'Es werden $1 Seiten angezeigt, die zu diesem Konzept gehören:', |
818 | 822 | 'smw_rss_description' => 'RSS-Feed von $1', |
819 | 823 | 'exportrdf' => 'Seite als RDF exportieren', |
820 | 824 | 'smw_exportrdf_docu' => '<p>Hier können Informationen über einzelne Seiten im RDF-Format abgerufen werden. Bitte gib die Namen der gewünschten Seiten <i>zeilenweise</i> ein.</p>', |