r40374 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r40373‎ | r40374 | r40375 >
Date:10:51, 3 September 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
display Concept: pages like categories, with browsable three-cloumn result list
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_ConceptPage.php (added) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php
@@ -316,6 +316,8 @@
317317 $article = new SMWTypePage($title);
318318 } elseif ( $title->getNamespace() == SMW_NS_PROPERTY ) {
319319 $article = new SMWPropertyPage($title);
 320+ } elseif ( $title->getNamespace() == SMW_NS_CONCEPT ) {
 321+ $article = new SMWConceptPage($title);
320322 }
321323 return true;
322324 }
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
1119 + native
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php
@@ -109,7 +109,7 @@
110110 $ac = count($this->articles);
111111 if ($this->until != '') {
112112 if ($ac > $this->limit) { // (we assume that limit is at least 1)
113 - $first = $this->articles[1]->getDBkey();
 113+ $first = $this->articles[1]->getSortkey();
114114 } else {
115115 $first = '';
116116 }
@@ -117,7 +117,7 @@
118118 } elseif ( ($ac > $this->limit) || ($this->from != '') ) {
119119 $first = $this->from;
120120 if ( $ac > $this->limit) {
121 - $last = $this->articles[$ac-1]->getDBkey();
 121+ $last = $this->articles[$ac-1]->getSortkey();
122122 } else {
123123 $last = '';
124124 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -30,8 +30,7 @@
3131 define('SMW_SP_SUBCLASS_OF',18);
3232 define('SMW_SP_CONCEPT_DESC',19);
3333
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. */
3635 define('SMW_SP_HAS_CATEGORY',4); // name specific for categories, use "instance of" to distinguish from future explicit "subclass of"
3736
3837 // constants for displaying the factbox
@@ -108,6 +107,7 @@
109108 $wgAutoloadClasses['SMWOrderedListPage'] = $smwgIP . '/includes/articlepages/SMW_OrderedListPage.php';
110109 $wgAutoloadClasses['SMWTypePage'] = $smwgIP . '/includes/articlepages/SMW_TypePage.php';
111110 $wgAutoloadClasses['SMWPropertyPage'] = $smwgIP . '/includes/articlepages/SMW_PropertyPage.php';
 111+ $wgAutoloadClasses['SMWConceptPage'] = $smwgIP . '/includes/articlepages/SMW_ConceptPage.php';
112112 //// printers
113113 $wgAutoloadClasses['SMWResultPrinter'] = $smwgIP . '/includes/SMW_QueryPrinter.php';
114114 $wgAutoloadClasses['SMWTableResultPrinter'] = $smwgIP . '/includes/SMW_QP_Table.php';
@@ -357,17 +357,20 @@
358358
359359 // display concept box:
360360 $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);
365361 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+
366368 $result = '<div class="smwfact"><span class="smwfactboxhead">' . wfMsgForContent('smw_concept_description',$title->getText()) .
367369 (count($query->getErrors())>0?' ' . smwfEncodeMessages($query->getErrors()):'') .
368370 '</span>' . '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' . '<br />' .
369371 ($concept_docu?"<p>$concept_docu</p>":'') .
370372 '<pre>' . str_replace('[', '&#x005B;', $concept_text) . "</pre>\n" .
371 - $resultlink . '</div>';
 373+// $resultlink .
 374+ '</div>';
372375 return $result;
373376 }
374377
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php
@@ -125,10 +125,11 @@
126126 $smwgSearchByPropertyFuzzy = true;
127127
128128 ###
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.
131131 ##
132132 $smwgTypePagingLimit = 200; // same number as for categories
 133+$smwgConceptPagingLimit = 200; // same number as for categories
133134 $smwgPropertyPagingLimit = 25; // use smaller value since property lists need more space
134135 ##
135136
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_Messages.php
@@ -117,6 +117,8 @@
118118 'smw_attributearticlecount' => 'Showing $1 pages using this property.',
119119 'smw_subproperty_header' => 'Subproperties',
120120 '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.',
121123
122124 // Messages used in RSS feeds
123125 'smw_rss_description' => '$1 RSS feed',
@@ -809,11 +811,13 @@
810812 '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.',
811813 'smw_notemplategiven' => 'Der Parameter „template“ muss angegeben werden, damit diese Anfrage durchgeführt werden kann.',
812814 '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:',
814816 '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:',
816818 '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:',
818822 'smw_rss_description' => 'RSS-Feed von $1',
819823 'exportrdf' => 'Seite als RDF exportieren',
820824 '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>',

Status & tagging log