r37188 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r37187‎ | r37188 | r37189 >
Date:18:10, 6 July 2008
Author:mkroetzsch
Status:old
Tags:
Comment:
Support for user defined sortkey for all SMW queries and views. Required some major changes:
* SMWWikiPageValue now can keep sortkeys
* SMWSQLStore2 now can store and use sortkeys
* all get...Subjects storage functions now return SMWWikiPageValues (no Titles)
* SMWSemanticData now uses SMWWikiPageValue as subject
* Many minor changes to use SMWWikiPageValue instead of Title
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_TypePage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -130,9 +130,9 @@
131131 // no need to show the navigation bars when there is not enough to navigate
132132 if (($offset>0) || ($count>$limit)) $html .= '<br />' . $navigation;
133133 $html .= "<ul>\n";
134 - foreach ($res as $t) {
135 - $browselink = SMWInfolink::newBrowsingLink('+',$t->getPrefixedText());
136 - $html .= '<li>' . $skin->makeKnownLinkObj($t) . '&nbsp;&nbsp;' . $browselink->getHTML($skin) . "</li> \n";
 134+ foreach ($res as $dv) {
 135+ $browselink = SMWInfolink::newBrowsingLink('+',$dv->getShortHTMLText());
 136+ $html .= '<li>' . $dv->getShortHTMLText($skin) . '&nbsp;&nbsp;' . $browselink->getHTML($skin) . "</li> \n";
137137 }
138138 $html .= "</ul>\n";
139139 if (($offset>0) || ($count>$limit)) $html .= $navigation;
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -111,8 +111,8 @@
112112 if ((0==$offset) && ($count > 0)) {
113113 foreach ($redin as $red) {
114114 $count -= 1;
115 - $browselink = SMWInfolink::newBrowsinglink('+', $red->getFulltext());
116 - $html .= $skin->makeKnownLinkObj( $red ) . '&nbsp;' . $browselink->getHTML($skin);
 115+ $browselink = SMWInfolink::newBrowsinglink('+', $red->getShortHTMLText());
 116+ $html .= $red->getShortHTMLText($skin) . '&nbsp;' . $browselink->getHTML($skin);
117117 if ($count > 0) $html .= ', ';
118118 }
119119 $html .= ' &nbsp;<strong>' . $skin->specialLink( 'Listredirects', 'isredirect' ) . '</strong>';
@@ -131,8 +131,8 @@
132132 foreach ($subjects as $subject) {
133133 $innercount += 1;
134134 if (($innercount < $innerlimit) || !$more) {
135 - $subjectlink = SMWInfolink::newBrowsingLink('+',$subject->getPrefixedText());
136 - $html .= $skin->makeKnownLinkObj($subject, smwfT($subject, TRUE)) . '&nbsp;' . $subjectlink->getHTML($skin);
 135+ $subjectlink = SMWInfolink::newBrowsingLink('+',$subject->getShortHTMLText());
 136+ $html .= $skin->makeKnownLinkObj($subject, smwfT($subject->getTitle(), TRUE)) . '&nbsp;' . $subjectlink->getHTML($skin);
137137 if ($innercount<$subjectcount) $html .= ", \n";
138138 } else {
139139 $html .= '<a href="' . $skin->makeSpecialUrl('SearchByProperty', 'property=' . urlencode($result->getPrefixedText()) . '&value=' . urlencode($article->getLongWikiText())) . '">' . wfMsg("smw_browse_more") . "</a>\n";
Index: trunk/extensions/SemanticMediaWiki/includes/export/SMW_Exporter.php
@@ -47,24 +47,21 @@
4848 */
4949 static public function makeExportData(/*SMWSemanticData*/ $semdata, $modifier = '') {
5050 SMWExporter::initBaseURIs();
51 - ///TODO: currently the subject is a Title; should change to SMWWikiPageValue (needs Factbox changes)
52 - $subject = SMWDataValueFactory::newTypeIDValue('_wpg');
53 - $subj_title = $semdata->getSubject();
54 - $subject->setValues($subj_title->getDBKey(), $subj_title->getNamespace());
 51+ $subject = $semdata->getSubject();
5552 $result = $subject->getExportData();
5653
5754 // first set some general parameters for export
5855 global $smwgOWLFullExport; // export like individual (even if Category/Property)
59 - $indexp = ((($subj_title->getNamespace() != SMW_NS_PROPERTY) &&
60 - ($subj_title->getNamespace() != NS_CATEGORY)) || $smwgOWLFullExport);
 56+ $indexp = ((($subject->getNamespace() != SMW_NS_PROPERTY) &&
 57+ ($subject->getNamespace() != NS_CATEGORY)) || $smwgOWLFullExport);
6158 $category_pe = NULL;
6259 $subprop_pe = NULL;
63 - switch ($subj_title->getNamespace()) {
 60+ switch ($subject->getNamespace()) {
6461 case NS_CATEGORY: case SMW_NS_CONCEPT:
6562 $category_pe = SMWExporter::getSpecialElement('rdfs','subClassOf');
6663 $equality_pe = SMWExporter::getSpecialElement('owl','equivalentClass');
6764 $maintype_pe = SMWExporter::getSpecialElement('owl','Class');
68 - $label = $subj_title->getText();
 65+ $label = $subject->getText();
6966 break;
7067 case SMW_NS_PROPERTY:
7168 if ($indexp) {
@@ -74,13 +71,13 @@
7572 $equality_pe = SMWExporter::getSpecialElement('owl','equivalentProperty');
7673 $types = $semdata->getPropertyValues(SMW_SP_HAS_TYPE);
7774 $maintype_pe = SMWExporter::getSpecialElement('owl', SMWExporter::getOWLPropertyType(end($types)));
78 - $label = $subj_title->getText();
 75+ $label = $subject->getText();
7976 break;
8077 default:
8178 $category_pe = SMWExporter::getSpecialElement('rdf','type');
8279 $equality_pe = SMWExporter::getSpecialElement('owl','sameAs');
8380 $maintype_pe = SMWExporter::getSpecialElement('swivt','Subject');
84 - $label = $subj_title->getPrefixedText();
 81+ $label = $subject->getWikiValue();
8582 }
8683
8784 // export standard properties
@@ -89,6 +86,7 @@
9087 $label .= ' (' . $modifier . ')';
9188 }
9289 $ed = new SMWExpData(new SMWExpLiteral($label));
 90+ $subj_title = $subject->getTitle();
9391 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdfs','label'), $ed);
9492 $ed = new SMWExpData(new SMWExpResource('&wikiurl;' . $subj_title->getPrefixedURL()));
9593 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('swivt','page'), $ed);
@@ -96,7 +94,7 @@
9795 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdfs','isDefinedBy'), $ed);
9896 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdf','type'), new SMWExpData($maintype_pe));
9997 if ($modifier != '') { // make variant and possibly add meta data on base properties
100 - if ($subj_title->getNamespace() == SMW_NS_PROPERTY) {
 98+ if ($subject->getNamespace() == SMW_NS_PROPERTY) {
10199 $ed = new SMWExpData(new SMWExpLiteral($modifier, NULL, 'http://www.w3.org/2001/XMLSchema#string'));
102100 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('swivt','modifier'), $ed);
103101 $result->addPropertyObjectValue(SMWExporter::getSpecialElement('swivt','baseProperty'), new SMWExpData($result->getSubject()));
@@ -133,11 +131,11 @@
134132 $pe = $subprop_pe;
135133 break;
136134 case SMW_SP_REDIRECTS_TO: /// TODO: currently no check for avoiding OWL DL illegal redirects is done
137 - if ( $subj_title->getNamespace() == SMW_NS_PROPERTY ) {
 135+ if ( $subject->getNamespace() == SMW_NS_PROPERTY ) {
138136 $pe = NULL; // checking the typing here is too cumbersome, smart stores will smush the properties anyway, and the others will not handle them equivalently
139137 } else {
140138 $pe = $equality_pe;
141 - $cat_only = ($subj_title->getNamespace() == NS_CATEGORY);
 139+ $cat_only = ($subject->getNamespace() == NS_CATEGORY);
142140 }
143141 break;
144142 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php
@@ -35,11 +35,14 @@
3636 * Initialisation method. Must be called before anything else happens.
3737 */
3838 static function initStorage($title) {
39 - // reset only if title is new
 39+ // reset only if title is new and not the notorious NO TITLE thing the MW parser creates
 40+ if ( $title->getText() == 'NO TITLE' ) return;
4041 if ( (SMWFactbox::$semdata === NULL) ||
41 - (SMWFactbox::$semdata->getSubject()->getText() != $title->getText()) ||
 42+ (SMWFactbox::$semdata->getSubject()->getDBkey() != $title->getDBkey()) ||
4243 (SMWFactbox::$semdata->getSubject()->getNamespace() != $title->getNamespace()) ) {
43 - SMWFactbox::$semdata = new SMWSemanticData($title); // reset data
 44+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 45+ $dv->setValues($title->getDBkey(), $title->getNamespace());
 46+ SMWFactbox::$semdata = new SMWSemanticData($dv); // reset data
4447 SMWFactbox::$m_printed = false;
4548 }
4649 //SMWFactbox::$m_new = false; // do not reset, keep (order of hooks can be strange ...)
@@ -251,9 +254,9 @@
252255 SMWFactbox::$m_printed = true;
253256
254257 smwfRequireHeadItem(SMW_HEADER_STYLE);
255 - $rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . SMWFactbox::$semdata->getSubject()->getPrefixedText(), 'rdflink');
 258+ $rdflink = SMWInfolink::newInternalLink(wfMsgForContent('smw_viewasrdf'), $wgContLang->getNsText(NS_SPECIAL) . ':ExportRDF/' . SMWFactbox::$semdata->getSubject()->getWikiValue(), 'rdflink');
256259
257 - $browselink = SMWInfolink::newBrowsingLink(SMWFactbox::$semdata->getSubject()->getText(), SMWFactbox::$semdata->getSubject()->getPrefixedText(), 'swmfactboxheadbrowse');
 260+ $browselink = SMWInfolink::newBrowsingLink(SMWFactbox::$semdata->getSubject()->getText(), SMWFactbox::$semdata->getSubject()->getWikiValue(), 'swmfactboxheadbrowse');
258261 // The "\n" is to ensure that lists on the end of articles are terminated
259262 // before the div starts. It would of course be much cleaner to print the
260263 // factbox in another way, similar to the way that categories are printed
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_TypePage.php
@@ -50,8 +50,8 @@
5151 } else {
5252 $this->articles = $store->getSpecialSubjects(SMW_SP_HAS_TYPE, $typevalue, $options);
5353 }
54 - foreach ($this->articles as $title) {
55 - $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $title->getText() ) );
 54+ foreach ($this->articles as $dv) {
 55+ $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $dv->getSortkey() ) );
5656 }
5757 }
5858
@@ -151,7 +151,7 @@
152152 $r .= "<h3>" . htmlspecialchars( $this->articles_start_char[$index] ) . " $cont_msg</h3>\n<ul>";
153153 $prev_start_char = $this->articles_start_char[$index];
154154 }
155 - $r .= "<li>" . $this->getArticleLink($this->articles[$index]) . "</li>\n";
 155+ $r .= "<li>" . $this->articles[$index]->getLongHTMLText($this->getSkin()) . "</li>\n";
156156 }
157157 if( !$atColumnTop ) {
158158 $r .= "</ul>\n";
@@ -167,21 +167,16 @@
168168 */
169169 private function shortList($start, $end) {
170170 $r = '<h3>' . htmlspecialchars( $this->articles_start_char[$start] ) . "</h3>\n";
171 - $r .= '<ul><li>'. $this->getArticleLink($this->articles[$start]) . '</li>';
 171+ $r .= '<ul><li>'. $this->articles[$start]->getLongHTMLText($this->getSkin()) . '</li>';
172172 for ($index = $start+1; $index < $end; $index++ ) {
173173 if ($this->articles_start_char[$index] != $this->articles_start_char[$index - 1]) {
174174 $r .= "</ul><h3>" . htmlspecialchars( $this->articles_start_char[$index] ) . "</h3>\n<ul>";
175175 }
176 - $r .= '<li>' . $this->getArticleLink( $this->articles[$index] ) . '</li>';
 176+ $r .= '<li>' . $this->articles[$index]->getLongHTMLText($this->getSkin()) . '</li>';
177177 }
178178 $r .= '</ul>';
179179 return $r;
180180 }
181 -
182 - private function getArticleLink($title) {
183 - global $wgContLang;
184 - return $this->getSkin()->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) );
185 - }
186181
187182 }
188183
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php
@@ -60,8 +60,8 @@
6161 $this->articles = array_reverse($this->articles);
6262 }
6363
64 - foreach ($this->articles as $title) {
65 - $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $title->getText() ) );
 64+ foreach ($this->articles as $dv) {
 65+ $this->articles_start_char[] = $wgContLang->convert( $wgContLang->firstChar( $dv->getSortkey() ) );
6666 }
6767 }
6868
@@ -115,9 +115,10 @@
116116 $prevchar = $this->articles_start_char[$index];
117117 }
118118 // Property name
119 - $searchlink = SMWInfolink::newBrowsingLink('+',$this->articles[$index]->getPrefixedText());
120 - $r .= '<tr><td class="smwpropname">' . $this->getSkin()->makeKnownLinkObj( $this->articles[$index],
121 - $wgContLang->convert( $this->articles[$index]->getPrefixedText() ) ) .
 119+ $searchlink = SMWInfolink::newBrowsingLink('+',$this->articles[$index]->getShortHTMLText());
 120+ $r .= '<tr><td class="smwpropname">' . $this->articles[$index]->getShortHTMLText($this->getSkin()) .
 121+ /*$this->getSkin()->makeKnownLinkObj( $this->articles[$index]->getTitle,
 122+ $wgContLang->convert( $this->articles[$index]->getLongHTMLText() ) ) .*/
122123 '&nbsp;' . $searchlink->getHTML($this->getSkin()) .
123124 '</td><td class="smwprops">';
124125 // Property values
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php
@@ -672,7 +672,7 @@
673673 foreach ($this->m_sortkeys as $propkey => $order) {
674674 if (!array_key_exists($propkey,$qobj->sortfields)) { // find missing property to sort by
675675 if ($propkey == '') { // sort by first result column (page titles)
676 - $qobj->sortfields[$propkey] = "$qobj->alias.smw_title";
 676+ $qobj->sortfields[$propkey] = "$qobj->alias.smw_sortkey";
677677 } else { // try to extend query
678678 $extrawhere = '';
679679 $sorttitle = Title::newFromText($propkey, SMW_NS_PROPERTY);
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -51,10 +51,12 @@
5252
5353 if ( $subject instanceof Title ) {
5454 $subjectid = $subject->getArticleID(); // avoid queries for nonexisting pages
55 - $result = new SMWSemanticData($subject);
 55+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 56+ $dv->setValues($subject->getDBkey(), $subject->getNamespace());
 57+ $result = new SMWSemanticData($dv);
5658 } elseif ($subject instanceof SMWWikiPageValue) {
5759 $subjectid = $subject->getArticleID(); // avoid queries for nonexisting pages
58 - $result = new SMWSemanticData($subject->getTitle());
 60+ $result = new SMWSemanticData($subject);
5961 } else {
6062 $subjectid = 0;
6163 $result = NULL;
@@ -309,7 +311,9 @@
310312 'rd_namespace,rd_title',
311313 $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) );
312314 while($row = $db->fetchObject($res)) {
313 - $result[] = Title::makeTitle($row->rd_namespace, $row->rd_title);
 315+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 316+ $dv->setValues($row->rd_title, $row->rd_namespace);
 317+ $result[] = $dv;
314318 }
315319 $db->freeResult($res);
316320 } elseif ($specialprop === SMW_SP_SUBPROPERTY_OF) { // subproperty
@@ -318,7 +322,9 @@
319323 'object_title',
320324 $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) );
321325 while($row = $db->fetchObject($res)) {
322 - $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->object_title);
 326+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 327+ $dv->setValues($row->object_title, SMW_NS_PROPERTY);
 328+ $result[] = $dv;
323329 }
324330 $db->freeResult($res);
325331 } else { // "normal" special property
@@ -358,7 +364,9 @@
359365 while($row = $db->fetchObject($res)) {
360366 $t = Title::newFromID($row->cl_from);
361367 if ($t !== NULL) {
362 - $result[] = $t;
 368+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 369+ $dv->setValues($t->getDBkey(), NS_CATEGORY, $row->cl_from);
 370+ $result[] = $dv;
363371 }
364372 }
365373 $db->freeResult($res);
@@ -372,7 +380,9 @@
373381 while($row = $db->fetchObject($res)) {
374382 $t = Title::newFromID($row->rd_from);
375383 if ($t !== NULL) {
376 - $result[] = $t;
 384+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 385+ $dv->setValues($t->getDBkey(), NS_CATEGORY, $row->rd_from);
 386+ $result[] = $dv;
377387 }
378388 }
379389 $db->freeResult($res);
@@ -383,7 +393,9 @@
384394 $sql, 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) );
385395 // reqrite results as array
386396 while($row = $db->fetchObject($res)) {
387 - $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->subject_title);
 397+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 398+ $dv->setValues($row->subject_title, SMW_NS_PROPERTY);
 399+ $result[] = $dv;
388400 }
389401 $db->freeResult($res);
390402 } else {
@@ -405,16 +417,15 @@
406418 }
407419
408420 $sql = 'property_id=' . $db->addQuotes($specialprop) .
409 - ' AND value_string=' . $db->addQuotes($stringvalue) .
410 - $this->getSQLConditions($requestoptions,'subject_title','subject_title');
411 - $res = $db->select( 'smw_specialprops',
412 - 'DISTINCT subject_id',
413 - $sql, 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions,'subject_title') );
 421+ ' AND value_string=' . $db->addQuotes($stringvalue) . ' AND page_id=subject_id' .
 422+ $this->getSQLConditions($requestoptions,'page_title','page_title');
 423+ $res = $db->select( array('smw_specialprops','page'),
 424+ 'DISTINCT subject_id,page_title,page_namespace',
 425+ $sql, 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions,'page_title') );
414426 while($row = $db->fetchObject($res)) {
415 - $t = Title::newFromID($row->subject_id);
416 - if ($t !== NULL) {
417 - $result[] = $t;
418 - }
 427+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 428+ $dv->setValues($row->page_title, $row->page_namespace, $row->subject_id);
 429+ $result[] = $dv;
419430 }
420431 $db->freeResult($res);
421432 }
@@ -579,7 +590,7 @@
580591 $this->getSQLConditions($requestoptions,'subject_title','subject_title');
581592
582593 $res = $db->select( 'smw_relations',
583 - 'DISTINCT subject_id',
 594+ 'DISTINCT subject_id, subject_title, subject_namespace',
584595 $sql, 'SMW::getPropertySubjects',
585596 $this->getSQLOptions($requestoptions,'subject_title') );
586597 break;
@@ -611,7 +622,7 @@
612623 }
613624 $count++;
614625 }
615 - $res = $db->query("SELECT DISTINCT $narytable.subject_id FROM $from WHERE $where",
 626+ $res = $db->query("SELECT DISTINCT $narytable.subject_id, $narytable.subject_title, $narytable.subject_namespace FROM $from WHERE $where",
616627 'SMW::getPropertySubjects',
617628 $this->getSQLOptions($requestoptions,'subject_title'));
618629 break;
@@ -621,17 +632,16 @@
622633 ' AND attribute_title=' . $db->addQuotes($property->getDBkey()) .
623634 $this->getSQLConditions($requestoptions,'subject_title','subject_title');
624635 $res = $db->select( $db->tableName('smw_attributes'),
625 - 'DISTINCT subject_id',
 636+ 'DISTINCT subject_id, subject_title, subject_namespace',
626637 $sql, 'SMW::getPropertySubjects',
627638 $this->getSQLOptions($requestoptions,'subject_title') );
628639 break;
629640 }
630641 $result = array();
631642 while($row = $db->fetchObject($res)) {
632 - $t = Title::newFromID($row->subject_id);
633 - if ($t !== NULL) {
634 - $result[] = $t;
635 - }
 643+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 644+ $dv->setValues($row->subject_title, $row->subject_namespace, $row->subject_id);
 645+ $result[] = $dv;
636646 }
637647 $db->freeResult($res);
638648 wfProfileOut("SMWSQLStore::getPropertySubjects (SMW)");
@@ -665,16 +675,15 @@
666676 }
667677
668678 $res = $db->select( $db->tableName($tablename),
669 - 'DISTINCT subject_id',
 679+ 'DISTINCT subject_id,subject_title,subject_namespace',
670680 $pcolumn .'=' . $db->addQuotes($property->getDBkey()) . $extraconds,
671681 'SMW::getAllPropertySubjects',
672682 $this->getSQLOptions($requestoptions,'subject_title') );
673683 $result = array();
674684 while($row = $db->fetchObject($res)) {
675 - $t = Title::newFromId($row->subject_id);
676 - if ($t !== NULL) {
677 - $result[] = $t;
678 - }
 685+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 686+ $dv->setValues($row->subject_title, $row->subject_namespace, $row->subject_id);
 687+ $result[] = $dv;
679688 }
680689 $db->freeResult($res);
681690 wfProfileOut("SMWSQLStore::getAllPropertySubjects (SMW)");
@@ -871,7 +880,7 @@
872881 }
873882 } else { // special property
874883 switch ($property) {
875 - case SMW_SP_IMPORTED_FROM: case SMW_SP_INSTANCE_OF: case SMW_SP_SUBCLASS_OF: case SMW_SP_REDIRECTS_TO: case SMW_SP_CONCEPT_DESC:
 884+ case SMW_SP_IMPORTED_FROM: case SMW_SP_INSTANCE_OF: case SMW_SP_SUBCLASS_OF: case SMW_SP_REDIRECTS_TO: case SMW_SP_CONCEPT_DESC: case SMW_SP_DEFAULT_SORT:
876885 // don't store this, just used for display;
877886 // TODO: filtering here is bad for fully neglected properties (IMPORTED FROM)
878887 // NOTE: concept descriptions are ignored by that storage implementation
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php
@@ -133,8 +133,8 @@
134134
135135 /**
136136 * Get an array of all pages that have a certain special value for a given special property
137 - * (identified as usual by an integer constant). The result is an array of titles. The tpye of
138 - * the input value depends on the kind of special property that was requested
 137+ * (identified as usual by an integer constant). The result is an array of SMWWikiPageValue
 138+ * objects. The type of the input value depends on the kind of special property that was requested.
139139 */
140140 abstract function getSpecialSubjects($specialprop, SMWDataValue $value, $requestoptions = NULL);
141141
@@ -150,14 +150,14 @@
151151
152152 /**
153153 * Get an array of all subjects that have the given value for the given property. The
154 - * result is an array of Title objects. If NULL is given as a value, all subjects having
 154+ * result is an array of SMWWikiPageValue objects. If NULL is given as a value, all subjects having
155155 * that property are returned.
156156 */
157157 abstract function getPropertySubjects(Title $property, $value, $requestoptions = NULL);
158158
159159 /**
160160 * Get an array of all subjects that have some value for the given property. The
161 - * result is an array of Title objects.
 161+ * result is an array of SMWWikiPageValue objects.
162162 */
163163 abstract function getAllPropertySubjects(Title $property, $requestoptions = NULL);
164164
@@ -198,7 +198,9 @@
199199 * but the id of the page might be used internally by the store.
200200 */
201201 function clearData(Title $subject, $newpage) {
202 - $emptydata = new SMWSemanticData($subject);
 202+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 203+ $dv->setValues($subject->getDBkey(), $subject->getNamespace());
 204+ $emptydata = new SMWSemanticData($dv);
203205 $this->updateData($emptydata, $newpage);
204206 }
205207
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -50,10 +50,11 @@
5151
5252 if ( $subject instanceof Title ) {
5353 $sid = $this->getSMWPageID($subject->getDBkey(),$subject->getNamespace(),$subject->getInterwiki());
54 - $stitle = $subject;
 54+ $svalue = SMWDataValueFactory::newTypeIDValue('_wpg');
 55+ $svalue->setValues($subject->getDBkey(), $subject->getNamespace());;
5556 } elseif ($subject instanceof SMWWikiPageValue) {
5657 $sid = $this->getSMWPageID($subject->getDBkey(),$subject->getNamespace(),$subject->getInterwiki());
57 - $stitle = $subject->getTitle();
 58+ $svalue = $subject;
5859 } else {
5960 $sid = 0;
6061 $result = NULL;
@@ -61,7 +62,7 @@
6263 if ($sid == 0) { // no data, safe our time
6364 /// NOTE: we consider redirects for getting $sid, so $sid == 0 also means "no redirects"
6465 wfProfileOut("SMWSQLStore2::getSemanticData (SMW)");
65 - return isset($stitle)?(new SMWSemanticData($stitle)):NULL;
 66+ return isset($svalue)?(new SMWSemanticData($svalue)):NULL;
6667 }
6768
6869 if ($filter !== false) { //array as described in docu for SMWStore
@@ -97,7 +98,7 @@
9899 }
99100
100101 if (!array_key_exists($sid, $this->m_semdata)) { // new cache entry
101 - $this->m_semdata[$sid] = new SMWSemanticData($stitle, false);
 102+ $this->m_semdata[$sid] = new SMWSemanticData($svalue, false);
102103 $this->m_sdstate[$sid] = $tasks;
103104 } else { // do only remaining tasks
104105 $newtasks = $tasks & ~$this->m_sdstate[$sid];
@@ -299,26 +300,28 @@
300301 if ($specialprop === SMW_SP_INSTANCE_OF) { // class membership
301302 $oid = $this->getSMWPageID($value->getDBkey(),NS_CATEGORY,$value->getInterwiki());
302303 if ( ($oid != 0) && ($value->getNamespace() == NS_CATEGORY) ) {
303 - $res = $db->select( array('smw_inst2','smw_ids'), 'smw_title,smw_namespace',
 304+ $res = $db->select( array('smw_inst2','smw_ids'), 'smw_title,smw_namespace,smw_sortkey',
304305 's_id=smw_id AND o_id=' . $db->addQuotes($oid),
305306 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) );
306307 while($row = $db->fetchObject($res)) {
307 - $result[] = Title::makeTitle($row->smw_namespace, $row->smw_title);
 308+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 309+ $dv->setValues($row->smw_title, $row->smw_namespace, false, '', $row->smw_sortkey);
 310+ $result[] = $dv;
308311 }
309312 $db->freeResult($res);
310313 }
311314 } elseif ($specialprop === SMW_SP_REDIRECTS_TO) { // redirections
312315 $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki(),false);
313316 /// NOTE: we do not use the canonical (redirect-aware) id here!
 317+ /// NOTE: we ignore sortkeys here -- this appears to be ok
314318 if ($oid != 0) {
315319 $res = $db->select( array('smw_redi2'), 's_title,s_namespace',
316320 'o_id=' . $db->addQuotes($oid),
317321 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) );
318322 while($row = $db->fetchObject($res)) {
319 - $t = Title::makeTitle($row->s_namespace,$row->s_title);
320 - if ($t !== NULL) {
321 - $result[] = $t;
322 - }
 323+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 324+ $dv->setValues($row->s_title, $row->s_namespace);
 325+ $result[] = $dv;
323326 }
324327 $db->freeResult($res);
325328 }
@@ -327,11 +330,13 @@
328331 $namespace = ($specialprop === SMW_SP_SUBCLASS_OF)?NS_CATEGORY:SMW_NS_PROPERTY;
329332 $oid = $this->getSMWPageID($value->getDBkey(),$namespace,$value->getInterwiki());
330333 if ( ($oid != 0) && ($value->getNamespace() == $namespace) ) {
331 - $res = $db->select( array('smw_subs2','smw_ids'), 'smw_title',
 334+ $res = $db->select( array('smw_subs2','smw_ids'), array('smw_title','smw_sortkey'),
332335 's_id=smw_id AND o_id=' . $db->addQuotes($oid),
333336 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) );
334337 while($row = $db->fetchObject($res)) {
335 - $result[] = Title::makeTitle($namespace, $row->smw_title);
 338+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 339+ $dv->setValues($row->smw_title, $namespace, false, '', $row->smw_sortkey);
 340+ $result[] = $dv;
336341 }
337342 $db->freeResult($res);
338343 }
@@ -346,15 +351,14 @@
347352 }
348353 $sql = 'smw_id=s_id AND sp_id=' . $db->addQuotes($specialprop) .
349354 ' AND value_string=' . $db->addQuotes($stringvalue) .
350 - $this->getSQLConditions($requestoptions,'smw_title','smw_title');
351 - $res = $db->select( array('smw_spec2','smw_ids'), 'DISTINCT smw_title,smw_namespace',
 355+ $this->getSQLConditions($requestoptions,'smw_sortkey','smw_sortkey');
 356+ $res = $db->select( array('smw_spec2','smw_ids'), 'DISTINCT smw_title,smw_namespace,smw_sortkey',
352357 $sql, 'SMW::getSpecialSubjects',
353 - $this->getSQLOptions($requestoptions,'smw_title') );
 358+ $this->getSQLOptions($requestoptions,'smw_sortkey') );
354359 while($row = $db->fetchObject($res)) {
355 - $t = Title::makeTitle($row->smw_namespace,$row->smw_title);
356 - if ($t !== NULL) {
357 - $result[] = $t;
358 - }
 360+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 361+ $dv->setValues($row->smw_title, $row->smw_namespace, false, '', $row->smw_sortkey);
 362+ $result[] = $dv;
359363 }
360364 $db->freeResult($res);
361365 }
@@ -406,8 +410,8 @@
407411 $res = $db->select( array('smw_rels2', 'smw_ids'),
408412 'smw_namespace, smw_title, smw_iw',
409413 'p_id=' . $db->addQuotes($pid) . ' AND o_id=smw_id' .
410 - $this->getSQLConditions($requestoptions,'smw_title','smw_title'),
411 - 'SMW::getPropertyValues', $this->getSQLOptions($requestoptions,'smw_title') );
 414+ $this->getSQLConditions($requestoptions,'smw_sortkey','smw_sortkey'),
 415+ 'SMW::getPropertyValues', $this->getSQLOptions($requestoptions,'smw_sortkey') );
412416 while($row = $db->fetchObject($res)) {
413417 $dv = SMWDataValueFactory::newPropertyObjectValue($property);
414418 $dv->setOutputFormat($outputformat);
@@ -567,12 +571,11 @@
568572 }
569573 $count++;
570574 }
571 - $res = $db->query("SELECT DISTINCT i.smw_title AS title,i.smw_namespace AS namespace FROM $from WHERE $where", 'SMW::getPropertySubjects', $this->getSQLOptions($requestoptions,'title'));
 575+ $res = $db->query("SELECT DISTINCT i.smw_title AS title,i.smw_namespace AS namespace,i.smw_sortkey AS sortkey FROM $from WHERE $where", 'SMW::getPropertySubjects', $this->getSQLOptions($requestoptions,'smw_sortkey'));
572576 while($row = $db->fetchObject($res)) {
573 - $t = Title::makeTitle($row->namespace,$row->title);
574 - if ($t !== NULL) {
575 - $result[] = $t;
576 - }
 577+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 578+ $dv->setValues($row->title, $row->namespace, false, '', $row->sortkey);
 579+ $result[] = $dv;
577580 }
578581 $db->freeResult($res);
579582 break;
@@ -587,14 +590,13 @@
588591
589592 if ($table != '') {
590593 $res = $db->select( array($table,'smw_ids'),
591 - 'DISTINCT smw_title,smw_namespace',
592 - 's_id=smw_id AND ' . $sql . $this->getSQLConditions($requestoptions,'smw_title','smw_title'), 'SMW::getPropertySubjects',
593 - $this->getSQLOptions($requestoptions,'smw_title') );
 594+ 'DISTINCT smw_title,smw_namespace,smw_sortkey',
 595+ 's_id=smw_id AND ' . $sql . $this->getSQLConditions($requestoptions,'smw_sortkey','smw_sortkey'), 'SMW::getPropertySubjects',
 596+ $this->getSQLOptions($requestoptions,'smw_sortkey') );
594597 while($row = $db->fetchObject($res)) {
595 - $t = Title::makeTitle($row->smw_namespace,$row->smw_title);
596 - if ($t !== NULL) {
597 - $result[] = $t;
598 - }
 598+ $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
 599+ $dv->setValues($row->smw_title, $row->smw_namespace, false, '', $row->smw_sortkey);
 600+ $result[] = $dv;
599601 }
600602 $db->freeResult($res);
601603 }
@@ -618,13 +620,13 @@
619621 }
620622
621623 $db =& wfGetDB( DB_SLAVE );
622 - $sql = 's_id=' . $db->addQuotes($sid) . ' AND p_id=smw_id' . $this->getSQLConditions($requestoptions,'smw_title','smw_title');
 624+ $sql = 's_id=' . $db->addQuotes($sid) . ' AND p_id=smw_id' . $this->getSQLConditions($requestoptions,'smw_sortkey','smw_sortkey');
623625
624626 $result = array();
625627 // NOTE: the following also includes naries, which are now kepn in smw_rels2
626628 foreach (array('smw_atts2','smw_text2','smw_rels2') as $table) {
627629 $res = $db->select( array($table,'smw_ids'), 'DISTINCT smw_title',
628 - $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'smw_title') );
 630+ $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'smw_sortkey') );
629631 if ($db->numRows( $res ) > 0) {
630632 while($row = $db->fetchObject($res)) {
631633 $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->smw_title);
@@ -643,9 +645,9 @@
644646 if ($value->getTypeID() == '_wpg') {
645647 $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki());
646648 $sql = 'p_id=smw_id AND o_id=' . $db->addQuotes($oid) .
647 - $this->getSQLConditions($requestoptions,'smw_title','smw_title');
 649+ $this->getSQLConditions($requestoptions,'smw_sortkey','smw_sortkey');
648650 $res = $db->select( array('smw_rels2','smw_ids'), 'DISTINCT smw_title',
649 - $sql, 'SMW::getInProperties', $this->getSQLOptions($requestoptions,'smw_title') );
 651+ $sql, 'SMW::getInProperties', $this->getSQLOptions($requestoptions,'smw_sortkey') );
650652 while($row = $db->fetchObject($res)) {
651653 $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->smw_title);
652654 }
@@ -681,7 +683,7 @@
682684 $this->updateRedirects($subject->getDBKey(),$subject->getNamespace());
683685 }
684686 // always make an ID (pages without ID cannot be in qurey results, not even in fixed value queries!):
685 - $sid = $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),'');
 687+ $sid = $this->makeSMWPageID($subject->getDBkey(),$subject->getNamespace(),'',true,$subject->getSortkey());
686688 $db =& wfGetDB( DB_MASTER );
687689
688690 // do bulk updates:
@@ -754,7 +756,7 @@
755757 switch ($property) {
756758 case SMW_SP_IMPORTED_FROM: // don't store this, just used for display;
757759 /// TODO: filtering here is bad for fully neglected properties (IMPORTED FROM)
758 - case SMW_SP_REDIRECTS_TO: // handled by updateRedirects above
 760+ case SMW_SP_REDIRECTS_TO: // handled above
759761 break;
760762 case SMW_SP_INSTANCE_OF:
761763 foreach($propertyValueArray as $value) {
@@ -1051,12 +1053,13 @@
10521054 array('smw_id' => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT',
10531055 'smw_namespace' => 'INT(11) NOT NULL',
10541056 'smw_title' => 'VARCHAR(255) binary NOT NULL',
1055 - 'smw_iw' => 'CHAR(32)'
 1057+ 'smw_iw' => 'CHAR(32)',
 1058+ 'smw_sortkey' => 'VARCHAR(255) binary NOT NULL'
10561059 ), $db, $verbose);
1057 - $this->setupIndex($smw_ids, array('smw_id','smw_title,smw_namespace,smw_iw'), $db);
 1060+ $this->setupIndex($smw_ids, array('smw_id','smw_title,smw_namespace,smw_iw', 'smw_sortkey'), $db);
10581061
10591062 $this->setupTable($smw_redi2, // fast redirect resolution
1060 - array('s_title' => 'VARCHAR(255) binary NOT NULL',
 1063+ array('s_title' => 'VARCHAR(255) binary NOT NULL',
10611064 's_namespace' => 'INT(11) NOT NULL',
10621065 'o_id' => 'INT(8) UNSIGNED NOT NULL',), $db, $verbose);
10631066 $this->setupIndex($smw_redi2, array('s_title,s_namespace','o_id'), $db);
@@ -1199,7 +1202,10 @@
12001203 foreach ($data as $item) {
12011204 $numeric = false;
12021205 $ok = true;
1203 - if ($item instanceof SMWDataValue) {
 1206+ if ($item instanceof SMWWikiPageValue) {
 1207+ $label = $item->getSortkey();
 1208+ $value = $label;
 1209+ } elseif ($item instanceof SMWDataValue) {
12041210 $label = $item->getXSDValue();
12051211 if ($item->isNumeric()) {
12061212 $value = $item->getNumericValue();
@@ -1412,6 +1418,15 @@
14131419 * If no such ID exists, 0 is returned.
14141420 */
14151421 public function getSMWPageID($title, $namespace, $iw, $canonical=true) {
 1422+ $sort = '';
 1423+ return $this->getSMWPageIDandSort($title, $namespace, $iw, $sort, $canonical);
 1424+ }
 1425+
 1426+ /**
 1427+ * Like getSMWPageID, but also sets the Call-By-Ref parameter $sort to the current
 1428+ * sortkey.
 1429+ */
 1430+ public function getSMWPageIDandSort($title, $namespace, $iw, &$sort, $canonical) {
14161431 global $smwgQEqualitySupport;
14171432 wfProfileIn('SMWSQLStore2::getSMWPageID (SMW)');
14181433 $ckey = "$iw $namespace $title C";
@@ -1428,13 +1443,15 @@
14291444 $id = 0;
14301445 $redirect = false;
14311446 if ($iw != '') {
1432 - $res = $db->select('smw_ids', 'smw_id', 'smw_title=' . $db->addQuotes($title) . ' AND ' . 'smw_namespace=' . $db->addQuotes($namespace) . ' AND smw_iw=' . $db->addQuotes($iw), 'SMW::getSMWPageID', array('LIMIT'=>1));
 1447+ $res = $db->select('smw_ids', array('smw_id','smw_sortkey'), 'smw_title=' . $db->addQuotes($title) . ' AND ' . 'smw_namespace=' . $db->addQuotes($namespace) . ' AND smw_iw=' . $db->addQuotes($iw), 'SMW::getSMWPageID', array('LIMIT'=>1));
14331448 if ($row = $db->fetchObject($res)) {
14341449 $id = $row->smw_id;
 1450+ $sort = $row->smw_sortkey;
14351451 }
14361452 } else { // check for potential redirects also
1437 - $res = $db->select('smw_ids', array('smw_id', 'smw_iw'), 'smw_title=' . $db->addQuotes($title) . ' AND ' . 'smw_namespace=' . $db->addQuotes($namespace) . ' AND (smw_iw=' . $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWREDIIW) . ')', 'SMW::getSMWPageID', array('LIMIT'=>1));
 1453+ $res = $db->select('smw_ids', array('smw_id', 'smw_iw', 'smw_sortkey'), 'smw_title=' . $db->addQuotes($title) . ' AND ' . 'smw_namespace=' . $db->addQuotes($namespace) . ' AND (smw_iw=' . $db->addQuotes('') . ' OR smw_iw=' . $db->addQuotes(SMW_SQL2_SMWREDIIW) . ')', 'SMW::getSMWPageID', array('LIMIT'=>1));
14381454 if ($row = $db->fetchObject($res)) {
 1455+ $sort = $row->smw_sortkey;
14391456 if ( ($row->smw_iw == '') || (!$canonical) || ($smwgQEqualitySupport == SMW_EQ_NONE) ) {
14401457 $id = $row->smw_id;
14411458 if ($row->smw_iw == '') {
@@ -1470,20 +1487,27 @@
14711488 * If $canonical is set to true, redirects are taken into account to find the
14721489 * canonical alias ID for the given page.
14731490 * If no such ID exists, a new ID is created and returned.
 1491+ * In any case, the current sortkey is set to the given one unless $sortkey
 1492+ * is empty.
14741493 * NOTE: using this with $canonical==false may make sense, especially when
14751494 * the title is a redirect target (we do not want chains of redirects)
14761495 */
1477 - protected function makeSMWPageID($title, $namespace, $iw, $canonical=true) {
 1496+ protected function makeSMWPageID($title, $namespace, $iw, $canonical=true, $sortkey = '') {
14781497 wfProfileIn('SMWSQLStore2::makeSMWPageID (SMW)');
1479 - $id = $this->getSMWPageID($title, $namespace, $iw, $canonical);
 1498+ $oldsort = '';
 1499+ $id = $this->getSMWPageIDandSort($title, $namespace, $iw, $oldsort, $canonical);
14801500 if ($id == 0) {
14811501 $db =& wfGetDB( DB_MASTER );
1482 - $db->insert('smw_ids', array('smw_id' => 0, 'smw_title' => $title, 'smw_namespace' => $namespace, 'smw_iw' => $iw), 'SMW::makeSMWPageID');
 1502+ $sortkey = $sortkey?$sortkey:$title;
 1503+ $db->insert('smw_ids', array('smw_id' => 0, 'smw_title' => $title, 'smw_namespace' => $namespace, 'smw_iw' => $iw, 'smw_sortkey' => $sortkey), 'SMW::makeSMWPageID');
14831504 $id = $db->insertId();
14841505 $this->m_ids["$iw $namespace $title -"] = $id; // fill that cache, even if canonical was given
14851506 if ($canonical) { // this ID is also authorative for the canonical version
14861507 $this->m_ids["$iw $namespace $title C"] = $id;
14871508 }
 1509+ } elseif ( ($sortkey != '') && ($sortkey != $oldsort) ) {
 1510+ $db =& wfGetDB( DB_MASTER );
 1511+ $db->update('smw_ids', array('smw_sortkey' => $sortkey), array('smw_id' => $id), 'SMW::makeSMWPageID');
14881512 }
14891513 wfProfileOut('SMWSQLStore2::makeSMWPageID (SMW)');
14901514 return $id;
@@ -1546,7 +1570,7 @@
15471571 * Delete all semantic data stored for the given subject.
15481572 * Used for update purposes.
15491573 */
1550 - protected function deleteSemanticData(Title $subject) {
 1574+ protected function deleteSemanticData($subject) {
15511575 $db =& wfGetDB( DB_MASTER );
15521576 /// NOTE: redirects are handled by updateRedirects(), not here!
15531577 //$db->delete('smw_redi2', array('s_title' => $subject->getDBkey(),'s_namespace' => $subject->getNamespace()), 'SMW::deleteSubject::Redi2');
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php
@@ -24,9 +24,9 @@
2525 /// since objects can remain stubs until someone really acesses their value
2626 static protected $m_propertyprefix = false; // cache for the local version of "Property:"
2727
28 - protected $subject;
 28+ protected $subject; // SMWWikiPageValue object
2929
30 - public function __construct(Title $subject, $noduplicates = true) {
 30+ public function __construct(SMWWikiPageValue $subject, $noduplicates = true) {
3131 $this->subject = $subject;
3232 $this->m_noduplicates = $noduplicates;
3333 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -403,7 +403,7 @@
404404 * (1) insert HTML headers (CSS, JavaScript, and meta tags) into parser
405405 * output. This is our preferred method of working off the required scripts, since it
406406 * exploits parser caching.
407 - * (2) Fetch category information from parser output.
 407+ * (2) Fetch category information and other final settings from parser output.
408408 */
409409 function smwfParserAfterTidy(&$parser, &$text) {
410410 global $smwgHeadItems, $smwgStoreActive;
@@ -423,6 +423,8 @@
424424 SMWFactbox::$semdata->addSpecialValue(SMW_SP_SUBCLASS_OF,$dv);
425425 }
426426 }
 427+ $sortkey = ($parser->mDefaultSort?$parser->mDefaultSort:SMWFactbox::$semdata->getSubject()->getText());
 428+ SMWFactbox::$semdata->getSubject()->setSortkey($sortkey);
427429 return true;
428430 }
429431
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -17,6 +17,7 @@
1818 private $m_textform = ''; // the isolated title as text
1919 private $m_dbkeyform = ''; // the isolated title in DB form
2020 private $m_interwiki = ''; // interwiki prefix or '', actually stored in SMWSQLStore2
 21+ private $m_sortkey = ''; // key for alphabetical sorting
2122 private $m_fragment = ''; // not stored, but kept for printout on page
2223 private $m_prefixedtext = ''; // full titletext with prefixes, including interwiki prefix
2324 private $m_namespace = NS_MAIN;
@@ -65,6 +66,7 @@
6667 $this->m_dbkeyform = $this->m_stubdata[0];
6768 $this->m_namespace = $this->m_stubdata[1];
6869 $this->m_interwiki = $this->m_stubdata[3];
 70+ $this->m_sortkey = $this->m_stubdata[4];
6971 $this->m_textform = str_replace('_', ' ', $this->m_dbkeyform);
7072 if ($this->m_interwiki == '') {
7173 $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform);
@@ -260,6 +262,14 @@
261263 $this->unstub();
262264 return $this->m_dbkeyform;
263265 }
 266+
 267+ /**
 268+ * Get text label for this value.
 269+ */
 270+ public function getText() {
 271+ $this->unstub();
 272+ return str_replace('_',' ',$this->m_dbkeyform);
 273+ }
264274
265275 /**
266276 * Get interwiki prefix or empty string.
@@ -270,14 +280,29 @@
271281 }
272282
273283 /**
 284+ * Get sortkey or make one as default.
 285+ */
 286+ public function getSortkey() {
 287+ $this->unstub();
 288+ return $this->m_sortkey?$this->m_sortkey:$this->m_dbkeyform;
 289+ }
 290+
 291+ /**
 292+ * Set sortkey
 293+ */
 294+ public function setSortkey($sortkey) {
 295+ $this->unstub(); // unstub first, since the stubarray also may hold a sortkey
 296+ $this->m_sortkey = $sortkey;
 297+ }
 298+
 299+ /**
274300 * Set all basic values for this datavalue to the extent these are
275301 * available. Simplifies and speeds up creation from stored data.
276302 */
277 - public function setValues($dbkey, $namespace, $id = false, $interwiki = '') {
 303+ public function setValues($dbkey, $namespace, $id = false, $interwiki = '', $sortkey = '') {
278304 $this->setXSDValue($dbkey,''); // just used to trigger standard parent class methods!
279305 /// TODO: rethink our standard set interfaces for datavalues to make wikipage fit better with the rest
280 - $this->m_stubdata = array($dbkey, $namespace, $id, $interwiki);
281 - $this->unstub();
 306+ $this->m_stubdata = array($dbkey, $namespace, $id, $interwiki, $sortkey);
282307 }
283308
284309 }

Status & tagging log