Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php |
— | — | @@ -130,9 +130,9 @@ |
131 | 131 | // no need to show the navigation bars when there is not enough to navigate |
132 | 132 | if (($offset>0) || ($count>$limit)) $html .= '<br />' . $navigation; |
133 | 133 | $html .= "<ul>\n"; |
134 | | - foreach ($res as $t) { |
135 | | - $browselink = SMWInfolink::newBrowsingLink('+',$t->getPrefixedText()); |
136 | | - $html .= '<li>' . $skin->makeKnownLinkObj($t) . ' ' . $browselink->getHTML($skin) . "</li> \n"; |
| 134 | + foreach ($res as $dv) { |
| 135 | + $browselink = SMWInfolink::newBrowsingLink('+',$dv->getShortHTMLText()); |
| 136 | + $html .= '<li>' . $dv->getShortHTMLText($skin) . ' ' . $browselink->getHTML($skin) . "</li> \n"; |
137 | 137 | } |
138 | 138 | $html .= "</ul>\n"; |
139 | 139 | if (($offset>0) || ($count>$limit)) $html .= $navigation; |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php |
— | — | @@ -111,8 +111,8 @@ |
112 | 112 | if ((0==$offset) && ($count > 0)) { |
113 | 113 | foreach ($redin as $red) { |
114 | 114 | $count -= 1; |
115 | | - $browselink = SMWInfolink::newBrowsinglink('+', $red->getFulltext()); |
116 | | - $html .= $skin->makeKnownLinkObj( $red ) . ' ' . $browselink->getHTML($skin); |
| 115 | + $browselink = SMWInfolink::newBrowsinglink('+', $red->getShortHTMLText()); |
| 116 | + $html .= $red->getShortHTMLText($skin) . ' ' . $browselink->getHTML($skin); |
117 | 117 | if ($count > 0) $html .= ', '; |
118 | 118 | } |
119 | 119 | $html .= ' <strong>' . $skin->specialLink( 'Listredirects', 'isredirect' ) . '</strong>'; |
— | — | @@ -131,8 +131,8 @@ |
132 | 132 | foreach ($subjects as $subject) { |
133 | 133 | $innercount += 1; |
134 | 134 | if (($innercount < $innerlimit) || !$more) { |
135 | | - $subjectlink = SMWInfolink::newBrowsingLink('+',$subject->getPrefixedText()); |
136 | | - $html .= $skin->makeKnownLinkObj($subject, smwfT($subject, TRUE)) . ' ' . $subjectlink->getHTML($skin); |
| 135 | + $subjectlink = SMWInfolink::newBrowsingLink('+',$subject->getShortHTMLText()); |
| 136 | + $html .= $skin->makeKnownLinkObj($subject, smwfT($subject->getTitle(), TRUE)) . ' ' . $subjectlink->getHTML($skin); |
137 | 137 | if ($innercount<$subjectcount) $html .= ", \n"; |
138 | 138 | } else { |
139 | 139 | $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 @@ |
48 | 48 | */ |
49 | 49 | static public function makeExportData(/*SMWSemanticData*/ $semdata, $modifier = '') { |
50 | 50 | 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(); |
55 | 52 | $result = $subject->getExportData(); |
56 | 53 | |
57 | 54 | // first set some general parameters for export |
58 | 55 | 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); |
61 | 58 | $category_pe = NULL; |
62 | 59 | $subprop_pe = NULL; |
63 | | - switch ($subj_title->getNamespace()) { |
| 60 | + switch ($subject->getNamespace()) { |
64 | 61 | case NS_CATEGORY: case SMW_NS_CONCEPT: |
65 | 62 | $category_pe = SMWExporter::getSpecialElement('rdfs','subClassOf'); |
66 | 63 | $equality_pe = SMWExporter::getSpecialElement('owl','equivalentClass'); |
67 | 64 | $maintype_pe = SMWExporter::getSpecialElement('owl','Class'); |
68 | | - $label = $subj_title->getText(); |
| 65 | + $label = $subject->getText(); |
69 | 66 | break; |
70 | 67 | case SMW_NS_PROPERTY: |
71 | 68 | if ($indexp) { |
— | — | @@ -74,13 +71,13 @@ |
75 | 72 | $equality_pe = SMWExporter::getSpecialElement('owl','equivalentProperty'); |
76 | 73 | $types = $semdata->getPropertyValues(SMW_SP_HAS_TYPE); |
77 | 74 | $maintype_pe = SMWExporter::getSpecialElement('owl', SMWExporter::getOWLPropertyType(end($types))); |
78 | | - $label = $subj_title->getText(); |
| 75 | + $label = $subject->getText(); |
79 | 76 | break; |
80 | 77 | default: |
81 | 78 | $category_pe = SMWExporter::getSpecialElement('rdf','type'); |
82 | 79 | $equality_pe = SMWExporter::getSpecialElement('owl','sameAs'); |
83 | 80 | $maintype_pe = SMWExporter::getSpecialElement('swivt','Subject'); |
84 | | - $label = $subj_title->getPrefixedText(); |
| 81 | + $label = $subject->getWikiValue(); |
85 | 82 | } |
86 | 83 | |
87 | 84 | // export standard properties |
— | — | @@ -89,6 +86,7 @@ |
90 | 87 | $label .= ' (' . $modifier . ')'; |
91 | 88 | } |
92 | 89 | $ed = new SMWExpData(new SMWExpLiteral($label)); |
| 90 | + $subj_title = $subject->getTitle(); |
93 | 91 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdfs','label'), $ed); |
94 | 92 | $ed = new SMWExpData(new SMWExpResource('&wikiurl;' . $subj_title->getPrefixedURL())); |
95 | 93 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('swivt','page'), $ed); |
— | — | @@ -96,7 +94,7 @@ |
97 | 95 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdfs','isDefinedBy'), $ed); |
98 | 96 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('rdf','type'), new SMWExpData($maintype_pe)); |
99 | 97 | 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) { |
101 | 99 | $ed = new SMWExpData(new SMWExpLiteral($modifier, NULL, 'http://www.w3.org/2001/XMLSchema#string')); |
102 | 100 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('swivt','modifier'), $ed); |
103 | 101 | $result->addPropertyObjectValue(SMWExporter::getSpecialElement('swivt','baseProperty'), new SMWExpData($result->getSubject())); |
— | — | @@ -133,11 +131,11 @@ |
134 | 132 | $pe = $subprop_pe; |
135 | 133 | break; |
136 | 134 | 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 ) { |
138 | 136 | $pe = NULL; // checking the typing here is too cumbersome, smart stores will smush the properties anyway, and the others will not handle them equivalently |
139 | 137 | } else { |
140 | 138 | $pe = $equality_pe; |
141 | | - $cat_only = ($subj_title->getNamespace() == NS_CATEGORY); |
| 139 | + $cat_only = ($subject->getNamespace() == NS_CATEGORY); |
142 | 140 | } |
143 | 141 | break; |
144 | 142 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php |
— | — | @@ -35,11 +35,14 @@ |
36 | 36 | * Initialisation method. Must be called before anything else happens. |
37 | 37 | */ |
38 | 38 | 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; |
40 | 41 | if ( (SMWFactbox::$semdata === NULL) || |
41 | | - (SMWFactbox::$semdata->getSubject()->getText() != $title->getText()) || |
| 42 | + (SMWFactbox::$semdata->getSubject()->getDBkey() != $title->getDBkey()) || |
42 | 43 | (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 |
44 | 47 | SMWFactbox::$m_printed = false; |
45 | 48 | } |
46 | 49 | //SMWFactbox::$m_new = false; // do not reset, keep (order of hooks can be strange ...) |
— | — | @@ -251,9 +254,9 @@ |
252 | 255 | SMWFactbox::$m_printed = true; |
253 | 256 | |
254 | 257 | 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'); |
256 | 259 | |
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'); |
258 | 261 | // The "\n" is to ensure that lists on the end of articles are terminated |
259 | 262 | // before the div starts. It would of course be much cleaner to print the |
260 | 263 | // 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 @@ |
51 | 51 | } else { |
52 | 52 | $this->articles = $store->getSpecialSubjects(SMW_SP_HAS_TYPE, $typevalue, $options); |
53 | 53 | } |
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() ) ); |
56 | 56 | } |
57 | 57 | } |
58 | 58 | |
— | — | @@ -151,7 +151,7 @@ |
152 | 152 | $r .= "<h3>" . htmlspecialchars( $this->articles_start_char[$index] ) . " $cont_msg</h3>\n<ul>"; |
153 | 153 | $prev_start_char = $this->articles_start_char[$index]; |
154 | 154 | } |
155 | | - $r .= "<li>" . $this->getArticleLink($this->articles[$index]) . "</li>\n"; |
| 155 | + $r .= "<li>" . $this->articles[$index]->getLongHTMLText($this->getSkin()) . "</li>\n"; |
156 | 156 | } |
157 | 157 | if( !$atColumnTop ) { |
158 | 158 | $r .= "</ul>\n"; |
— | — | @@ -167,21 +167,16 @@ |
168 | 168 | */ |
169 | 169 | private function shortList($start, $end) { |
170 | 170 | $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>'; |
172 | 172 | for ($index = $start+1; $index < $end; $index++ ) { |
173 | 173 | if ($this->articles_start_char[$index] != $this->articles_start_char[$index - 1]) { |
174 | 174 | $r .= "</ul><h3>" . htmlspecialchars( $this->articles_start_char[$index] ) . "</h3>\n<ul>"; |
175 | 175 | } |
176 | | - $r .= '<li>' . $this->getArticleLink( $this->articles[$index] ) . '</li>'; |
| 176 | + $r .= '<li>' . $this->articles[$index]->getLongHTMLText($this->getSkin()) . '</li>'; |
177 | 177 | } |
178 | 178 | $r .= '</ul>'; |
179 | 179 | return $r; |
180 | 180 | } |
181 | | - |
182 | | - private function getArticleLink($title) { |
183 | | - global $wgContLang; |
184 | | - return $this->getSkin()->makeKnownLinkObj( $title, $wgContLang->convert( $title->getText() ) ); |
185 | | - } |
186 | 181 | |
187 | 182 | } |
188 | 183 | |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php |
— | — | @@ -60,8 +60,8 @@ |
61 | 61 | $this->articles = array_reverse($this->articles); |
62 | 62 | } |
63 | 63 | |
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() ) ); |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
— | — | @@ -115,9 +115,10 @@ |
116 | 116 | $prevchar = $this->articles_start_char[$index]; |
117 | 117 | } |
118 | 118 | // 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() ) ) .*/ |
122 | 123 | ' ' . $searchlink->getHTML($this->getSkin()) . |
123 | 124 | '</td><td class="smwprops">'; |
124 | 125 | // Property values |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -672,7 +672,7 @@ |
673 | 673 | foreach ($this->m_sortkeys as $propkey => $order) { |
674 | 674 | if (!array_key_exists($propkey,$qobj->sortfields)) { // find missing property to sort by |
675 | 675 | 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"; |
677 | 677 | } else { // try to extend query |
678 | 678 | $extrawhere = ''; |
679 | 679 | $sorttitle = Title::newFromText($propkey, SMW_NS_PROPERTY); |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -51,10 +51,12 @@ |
52 | 52 | |
53 | 53 | if ( $subject instanceof Title ) { |
54 | 54 | $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); |
56 | 58 | } elseif ($subject instanceof SMWWikiPageValue) { |
57 | 59 | $subjectid = $subject->getArticleID(); // avoid queries for nonexisting pages |
58 | | - $result = new SMWSemanticData($subject->getTitle()); |
| 60 | + $result = new SMWSemanticData($subject); |
59 | 61 | } else { |
60 | 62 | $subjectid = 0; |
61 | 63 | $result = NULL; |
— | — | @@ -309,7 +311,9 @@ |
310 | 312 | 'rd_namespace,rd_title', |
311 | 313 | $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) ); |
312 | 314 | 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; |
314 | 318 | } |
315 | 319 | $db->freeResult($res); |
316 | 320 | } elseif ($specialprop === SMW_SP_SUBPROPERTY_OF) { // subproperty |
— | — | @@ -318,7 +322,9 @@ |
319 | 323 | 'object_title', |
320 | 324 | $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) ); |
321 | 325 | 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; |
323 | 329 | } |
324 | 330 | $db->freeResult($res); |
325 | 331 | } else { // "normal" special property |
— | — | @@ -358,7 +364,9 @@ |
359 | 365 | while($row = $db->fetchObject($res)) { |
360 | 366 | $t = Title::newFromID($row->cl_from); |
361 | 367 | if ($t !== NULL) { |
362 | | - $result[] = $t; |
| 368 | + $dv = SMWDataValueFactory::newTypeIDValue('_wpg'); |
| 369 | + $dv->setValues($t->getDBkey(), NS_CATEGORY, $row->cl_from); |
| 370 | + $result[] = $dv; |
363 | 371 | } |
364 | 372 | } |
365 | 373 | $db->freeResult($res); |
— | — | @@ -372,7 +380,9 @@ |
373 | 381 | while($row = $db->fetchObject($res)) { |
374 | 382 | $t = Title::newFromID($row->rd_from); |
375 | 383 | if ($t !== NULL) { |
376 | | - $result[] = $t; |
| 384 | + $dv = SMWDataValueFactory::newTypeIDValue('_wpg'); |
| 385 | + $dv->setValues($t->getDBkey(), NS_CATEGORY, $row->rd_from); |
| 386 | + $result[] = $dv; |
377 | 387 | } |
378 | 388 | } |
379 | 389 | $db->freeResult($res); |
— | — | @@ -383,7 +393,9 @@ |
384 | 394 | $sql, 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) ); |
385 | 395 | // reqrite results as array |
386 | 396 | 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; |
388 | 400 | } |
389 | 401 | $db->freeResult($res); |
390 | 402 | } else { |
— | — | @@ -405,16 +417,15 @@ |
406 | 418 | } |
407 | 419 | |
408 | 420 | $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') ); |
414 | 426 | 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; |
419 | 430 | } |
420 | 431 | $db->freeResult($res); |
421 | 432 | } |
— | — | @@ -579,7 +590,7 @@ |
580 | 591 | $this->getSQLConditions($requestoptions,'subject_title','subject_title'); |
581 | 592 | |
582 | 593 | $res = $db->select( 'smw_relations', |
583 | | - 'DISTINCT subject_id', |
| 594 | + 'DISTINCT subject_id, subject_title, subject_namespace', |
584 | 595 | $sql, 'SMW::getPropertySubjects', |
585 | 596 | $this->getSQLOptions($requestoptions,'subject_title') ); |
586 | 597 | break; |
— | — | @@ -611,7 +622,7 @@ |
612 | 623 | } |
613 | 624 | $count++; |
614 | 625 | } |
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", |
616 | 627 | 'SMW::getPropertySubjects', |
617 | 628 | $this->getSQLOptions($requestoptions,'subject_title')); |
618 | 629 | break; |
— | — | @@ -621,17 +632,16 @@ |
622 | 633 | ' AND attribute_title=' . $db->addQuotes($property->getDBkey()) . |
623 | 634 | $this->getSQLConditions($requestoptions,'subject_title','subject_title'); |
624 | 635 | $res = $db->select( $db->tableName('smw_attributes'), |
625 | | - 'DISTINCT subject_id', |
| 636 | + 'DISTINCT subject_id, subject_title, subject_namespace', |
626 | 637 | $sql, 'SMW::getPropertySubjects', |
627 | 638 | $this->getSQLOptions($requestoptions,'subject_title') ); |
628 | 639 | break; |
629 | 640 | } |
630 | 641 | $result = array(); |
631 | 642 | 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; |
636 | 646 | } |
637 | 647 | $db->freeResult($res); |
638 | 648 | wfProfileOut("SMWSQLStore::getPropertySubjects (SMW)"); |
— | — | @@ -665,16 +675,15 @@ |
666 | 676 | } |
667 | 677 | |
668 | 678 | $res = $db->select( $db->tableName($tablename), |
669 | | - 'DISTINCT subject_id', |
| 679 | + 'DISTINCT subject_id,subject_title,subject_namespace', |
670 | 680 | $pcolumn .'=' . $db->addQuotes($property->getDBkey()) . $extraconds, |
671 | 681 | 'SMW::getAllPropertySubjects', |
672 | 682 | $this->getSQLOptions($requestoptions,'subject_title') ); |
673 | 683 | $result = array(); |
674 | 684 | 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; |
679 | 688 | } |
680 | 689 | $db->freeResult($res); |
681 | 690 | wfProfileOut("SMWSQLStore::getAllPropertySubjects (SMW)"); |
— | — | @@ -871,7 +880,7 @@ |
872 | 881 | } |
873 | 882 | } else { // special property |
874 | 883 | 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: |
876 | 885 | // don't store this, just used for display; |
877 | 886 | // TODO: filtering here is bad for fully neglected properties (IMPORTED FROM) |
878 | 887 | // NOTE: concept descriptions are ignored by that storage implementation |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php |
— | — | @@ -133,8 +133,8 @@ |
134 | 134 | |
135 | 135 | /** |
136 | 136 | * 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. |
139 | 139 | */ |
140 | 140 | abstract function getSpecialSubjects($specialprop, SMWDataValue $value, $requestoptions = NULL); |
141 | 141 | |
— | — | @@ -150,14 +150,14 @@ |
151 | 151 | |
152 | 152 | /** |
153 | 153 | * 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 |
155 | 155 | * that property are returned. |
156 | 156 | */ |
157 | 157 | abstract function getPropertySubjects(Title $property, $value, $requestoptions = NULL); |
158 | 158 | |
159 | 159 | /** |
160 | 160 | * 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. |
162 | 162 | */ |
163 | 163 | abstract function getAllPropertySubjects(Title $property, $requestoptions = NULL); |
164 | 164 | |
— | — | @@ -198,7 +198,9 @@ |
199 | 199 | * but the id of the page might be used internally by the store. |
200 | 200 | */ |
201 | 201 | 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); |
203 | 205 | $this->updateData($emptydata, $newpage); |
204 | 206 | } |
205 | 207 | |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -50,10 +50,11 @@ |
51 | 51 | |
52 | 52 | if ( $subject instanceof Title ) { |
53 | 53 | $sid = $this->getSMWPageID($subject->getDBkey(),$subject->getNamespace(),$subject->getInterwiki()); |
54 | | - $stitle = $subject; |
| 54 | + $svalue = SMWDataValueFactory::newTypeIDValue('_wpg'); |
| 55 | + $svalue->setValues($subject->getDBkey(), $subject->getNamespace());; |
55 | 56 | } elseif ($subject instanceof SMWWikiPageValue) { |
56 | 57 | $sid = $this->getSMWPageID($subject->getDBkey(),$subject->getNamespace(),$subject->getInterwiki()); |
57 | | - $stitle = $subject->getTitle(); |
| 58 | + $svalue = $subject; |
58 | 59 | } else { |
59 | 60 | $sid = 0; |
60 | 61 | $result = NULL; |
— | — | @@ -61,7 +62,7 @@ |
62 | 63 | if ($sid == 0) { // no data, safe our time |
63 | 64 | /// NOTE: we consider redirects for getting $sid, so $sid == 0 also means "no redirects" |
64 | 65 | wfProfileOut("SMWSQLStore2::getSemanticData (SMW)"); |
65 | | - return isset($stitle)?(new SMWSemanticData($stitle)):NULL; |
| 66 | + return isset($svalue)?(new SMWSemanticData($svalue)):NULL; |
66 | 67 | } |
67 | 68 | |
68 | 69 | if ($filter !== false) { //array as described in docu for SMWStore |
— | — | @@ -97,7 +98,7 @@ |
98 | 99 | } |
99 | 100 | |
100 | 101 | 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); |
102 | 103 | $this->m_sdstate[$sid] = $tasks; |
103 | 104 | } else { // do only remaining tasks |
104 | 105 | $newtasks = $tasks & ~$this->m_sdstate[$sid]; |
— | — | @@ -299,26 +300,28 @@ |
300 | 301 | if ($specialprop === SMW_SP_INSTANCE_OF) { // class membership |
301 | 302 | $oid = $this->getSMWPageID($value->getDBkey(),NS_CATEGORY,$value->getInterwiki()); |
302 | 303 | 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', |
304 | 305 | 's_id=smw_id AND o_id=' . $db->addQuotes($oid), |
305 | 306 | 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) ); |
306 | 307 | 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; |
308 | 311 | } |
309 | 312 | $db->freeResult($res); |
310 | 313 | } |
311 | 314 | } elseif ($specialprop === SMW_SP_REDIRECTS_TO) { // redirections |
312 | 315 | $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki(),false); |
313 | 316 | /// NOTE: we do not use the canonical (redirect-aware) id here! |
| 317 | + /// NOTE: we ignore sortkeys here -- this appears to be ok |
314 | 318 | if ($oid != 0) { |
315 | 319 | $res = $db->select( array('smw_redi2'), 's_title,s_namespace', |
316 | 320 | 'o_id=' . $db->addQuotes($oid), |
317 | 321 | 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) ); |
318 | 322 | 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; |
323 | 326 | } |
324 | 327 | $db->freeResult($res); |
325 | 328 | } |
— | — | @@ -327,11 +330,13 @@ |
328 | 331 | $namespace = ($specialprop === SMW_SP_SUBCLASS_OF)?NS_CATEGORY:SMW_NS_PROPERTY; |
329 | 332 | $oid = $this->getSMWPageID($value->getDBkey(),$namespace,$value->getInterwiki()); |
330 | 333 | 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'), |
332 | 335 | 's_id=smw_id AND o_id=' . $db->addQuotes($oid), |
333 | 336 | 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions) ); |
334 | 337 | 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; |
336 | 341 | } |
337 | 342 | $db->freeResult($res); |
338 | 343 | } |
— | — | @@ -346,15 +351,14 @@ |
347 | 352 | } |
348 | 353 | $sql = 'smw_id=s_id AND sp_id=' . $db->addQuotes($specialprop) . |
349 | 354 | ' 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', |
352 | 357 | $sql, 'SMW::getSpecialSubjects', |
353 | | - $this->getSQLOptions($requestoptions,'smw_title') ); |
| 358 | + $this->getSQLOptions($requestoptions,'smw_sortkey') ); |
354 | 359 | 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; |
359 | 363 | } |
360 | 364 | $db->freeResult($res); |
361 | 365 | } |
— | — | @@ -406,8 +410,8 @@ |
407 | 411 | $res = $db->select( array('smw_rels2', 'smw_ids'), |
408 | 412 | 'smw_namespace, smw_title, smw_iw', |
409 | 413 | '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') ); |
412 | 416 | while($row = $db->fetchObject($res)) { |
413 | 417 | $dv = SMWDataValueFactory::newPropertyObjectValue($property); |
414 | 418 | $dv->setOutputFormat($outputformat); |
— | — | @@ -567,12 +571,11 @@ |
568 | 572 | } |
569 | 573 | $count++; |
570 | 574 | } |
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')); |
572 | 576 | 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; |
577 | 580 | } |
578 | 581 | $db->freeResult($res); |
579 | 582 | break; |
— | — | @@ -587,14 +590,13 @@ |
588 | 591 | |
589 | 592 | if ($table != '') { |
590 | 593 | $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') ); |
594 | 597 | 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; |
599 | 601 | } |
600 | 602 | $db->freeResult($res); |
601 | 603 | } |
— | — | @@ -618,13 +620,13 @@ |
619 | 621 | } |
620 | 622 | |
621 | 623 | $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'); |
623 | 625 | |
624 | 626 | $result = array(); |
625 | 627 | // NOTE: the following also includes naries, which are now kepn in smw_rels2 |
626 | 628 | foreach (array('smw_atts2','smw_text2','smw_rels2') as $table) { |
627 | 629 | $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') ); |
629 | 631 | if ($db->numRows( $res ) > 0) { |
630 | 632 | while($row = $db->fetchObject($res)) { |
631 | 633 | $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->smw_title); |
— | — | @@ -643,9 +645,9 @@ |
644 | 646 | if ($value->getTypeID() == '_wpg') { |
645 | 647 | $oid = $this->getSMWPageID($value->getDBkey(),$value->getNamespace(),$value->getInterwiki()); |
646 | 648 | $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'); |
648 | 650 | $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') ); |
650 | 652 | while($row = $db->fetchObject($res)) { |
651 | 653 | $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->smw_title); |
652 | 654 | } |
— | — | @@ -681,7 +683,7 @@ |
682 | 684 | $this->updateRedirects($subject->getDBKey(),$subject->getNamespace()); |
683 | 685 | } |
684 | 686 | // 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()); |
686 | 688 | $db =& wfGetDB( DB_MASTER ); |
687 | 689 | |
688 | 690 | // do bulk updates: |
— | — | @@ -754,7 +756,7 @@ |
755 | 757 | switch ($property) { |
756 | 758 | case SMW_SP_IMPORTED_FROM: // don't store this, just used for display; |
757 | 759 | /// 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 |
759 | 761 | break; |
760 | 762 | case SMW_SP_INSTANCE_OF: |
761 | 763 | foreach($propertyValueArray as $value) { |
— | — | @@ -1051,12 +1053,13 @@ |
1052 | 1054 | array('smw_id' => 'INT(8) UNSIGNED NOT NULL KEY AUTO_INCREMENT', |
1053 | 1055 | 'smw_namespace' => 'INT(11) NOT NULL', |
1054 | 1056 | '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' |
1056 | 1059 | ), $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); |
1058 | 1061 | |
1059 | 1062 | $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', |
1061 | 1064 | 's_namespace' => 'INT(11) NOT NULL', |
1062 | 1065 | 'o_id' => 'INT(8) UNSIGNED NOT NULL',), $db, $verbose); |
1063 | 1066 | $this->setupIndex($smw_redi2, array('s_title,s_namespace','o_id'), $db); |
— | — | @@ -1199,7 +1202,10 @@ |
1200 | 1203 | foreach ($data as $item) { |
1201 | 1204 | $numeric = false; |
1202 | 1205 | $ok = true; |
1203 | | - if ($item instanceof SMWDataValue) { |
| 1206 | + if ($item instanceof SMWWikiPageValue) { |
| 1207 | + $label = $item->getSortkey(); |
| 1208 | + $value = $label; |
| 1209 | + } elseif ($item instanceof SMWDataValue) { |
1204 | 1210 | $label = $item->getXSDValue(); |
1205 | 1211 | if ($item->isNumeric()) { |
1206 | 1212 | $value = $item->getNumericValue(); |
— | — | @@ -1412,6 +1418,15 @@ |
1413 | 1419 | * If no such ID exists, 0 is returned. |
1414 | 1420 | */ |
1415 | 1421 | 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) { |
1416 | 1431 | global $smwgQEqualitySupport; |
1417 | 1432 | wfProfileIn('SMWSQLStore2::getSMWPageID (SMW)'); |
1418 | 1433 | $ckey = "$iw $namespace $title C"; |
— | — | @@ -1428,13 +1443,15 @@ |
1429 | 1444 | $id = 0; |
1430 | 1445 | $redirect = false; |
1431 | 1446 | 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)); |
1433 | 1448 | if ($row = $db->fetchObject($res)) { |
1434 | 1449 | $id = $row->smw_id; |
| 1450 | + $sort = $row->smw_sortkey; |
1435 | 1451 | } |
1436 | 1452 | } 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)); |
1438 | 1454 | if ($row = $db->fetchObject($res)) { |
| 1455 | + $sort = $row->smw_sortkey; |
1439 | 1456 | if ( ($row->smw_iw == '') || (!$canonical) || ($smwgQEqualitySupport == SMW_EQ_NONE) ) { |
1440 | 1457 | $id = $row->smw_id; |
1441 | 1458 | if ($row->smw_iw == '') { |
— | — | @@ -1470,20 +1487,27 @@ |
1471 | 1488 | * If $canonical is set to true, redirects are taken into account to find the |
1472 | 1489 | * canonical alias ID for the given page. |
1473 | 1490 | * 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. |
1474 | 1493 | * NOTE: using this with $canonical==false may make sense, especially when |
1475 | 1494 | * the title is a redirect target (we do not want chains of redirects) |
1476 | 1495 | */ |
1477 | | - protected function makeSMWPageID($title, $namespace, $iw, $canonical=true) { |
| 1496 | + protected function makeSMWPageID($title, $namespace, $iw, $canonical=true, $sortkey = '') { |
1478 | 1497 | wfProfileIn('SMWSQLStore2::makeSMWPageID (SMW)'); |
1479 | | - $id = $this->getSMWPageID($title, $namespace, $iw, $canonical); |
| 1498 | + $oldsort = ''; |
| 1499 | + $id = $this->getSMWPageIDandSort($title, $namespace, $iw, $oldsort, $canonical); |
1480 | 1500 | if ($id == 0) { |
1481 | 1501 | $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'); |
1483 | 1504 | $id = $db->insertId(); |
1484 | 1505 | $this->m_ids["$iw $namespace $title -"] = $id; // fill that cache, even if canonical was given |
1485 | 1506 | if ($canonical) { // this ID is also authorative for the canonical version |
1486 | 1507 | $this->m_ids["$iw $namespace $title C"] = $id; |
1487 | 1508 | } |
| 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'); |
1488 | 1512 | } |
1489 | 1513 | wfProfileOut('SMWSQLStore2::makeSMWPageID (SMW)'); |
1490 | 1514 | return $id; |
— | — | @@ -1546,7 +1570,7 @@ |
1547 | 1571 | * Delete all semantic data stored for the given subject. |
1548 | 1572 | * Used for update purposes. |
1549 | 1573 | */ |
1550 | | - protected function deleteSemanticData(Title $subject) { |
| 1574 | + protected function deleteSemanticData($subject) { |
1551 | 1575 | $db =& wfGetDB( DB_MASTER ); |
1552 | 1576 | /// NOTE: redirects are handled by updateRedirects(), not here! |
1553 | 1577 | //$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 @@ |
25 | 25 | /// since objects can remain stubs until someone really acesses their value |
26 | 26 | static protected $m_propertyprefix = false; // cache for the local version of "Property:" |
27 | 27 | |
28 | | - protected $subject; |
| 28 | + protected $subject; // SMWWikiPageValue object |
29 | 29 | |
30 | | - public function __construct(Title $subject, $noduplicates = true) { |
| 30 | + public function __construct(SMWWikiPageValue $subject, $noduplicates = true) { |
31 | 31 | $this->subject = $subject; |
32 | 32 | $this->m_noduplicates = $noduplicates; |
33 | 33 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -403,7 +403,7 @@ |
404 | 404 | * (1) insert HTML headers (CSS, JavaScript, and meta tags) into parser |
405 | 405 | * output. This is our preferred method of working off the required scripts, since it |
406 | 406 | * exploits parser caching. |
407 | | - * (2) Fetch category information from parser output. |
| 407 | + * (2) Fetch category information and other final settings from parser output. |
408 | 408 | */ |
409 | 409 | function smwfParserAfterTidy(&$parser, &$text) { |
410 | 410 | global $smwgHeadItems, $smwgStoreActive; |
— | — | @@ -423,6 +423,8 @@ |
424 | 424 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_SUBCLASS_OF,$dv); |
425 | 425 | } |
426 | 426 | } |
| 427 | + $sortkey = ($parser->mDefaultSort?$parser->mDefaultSort:SMWFactbox::$semdata->getSubject()->getText()); |
| 428 | + SMWFactbox::$semdata->getSubject()->setSortkey($sortkey); |
427 | 429 | return true; |
428 | 430 | } |
429 | 431 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -17,6 +17,7 @@ |
18 | 18 | private $m_textform = ''; // the isolated title as text |
19 | 19 | private $m_dbkeyform = ''; // the isolated title in DB form |
20 | 20 | private $m_interwiki = ''; // interwiki prefix or '', actually stored in SMWSQLStore2 |
| 21 | + private $m_sortkey = ''; // key for alphabetical sorting |
21 | 22 | private $m_fragment = ''; // not stored, but kept for printout on page |
22 | 23 | private $m_prefixedtext = ''; // full titletext with prefixes, including interwiki prefix |
23 | 24 | private $m_namespace = NS_MAIN; |
— | — | @@ -65,6 +66,7 @@ |
66 | 67 | $this->m_dbkeyform = $this->m_stubdata[0]; |
67 | 68 | $this->m_namespace = $this->m_stubdata[1]; |
68 | 69 | $this->m_interwiki = $this->m_stubdata[3]; |
| 70 | + $this->m_sortkey = $this->m_stubdata[4]; |
69 | 71 | $this->m_textform = str_replace('_', ' ', $this->m_dbkeyform); |
70 | 72 | if ($this->m_interwiki == '') { |
71 | 73 | $this->m_title = Title::makeTitle($this->m_namespace, $this->m_dbkeyform); |
— | — | @@ -260,6 +262,14 @@ |
261 | 263 | $this->unstub(); |
262 | 264 | return $this->m_dbkeyform; |
263 | 265 | } |
| 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 | + } |
264 | 274 | |
265 | 275 | /** |
266 | 276 | * Get interwiki prefix or empty string. |
— | — | @@ -270,14 +280,29 @@ |
271 | 281 | } |
272 | 282 | |
273 | 283 | /** |
| 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 | + /** |
274 | 300 | * Set all basic values for this datavalue to the extent these are |
275 | 301 | * available. Simplifies and speeds up creation from stored data. |
276 | 302 | */ |
277 | | - public function setValues($dbkey, $namespace, $id = false, $interwiki = '') { |
| 303 | + public function setValues($dbkey, $namespace, $id = false, $interwiki = '', $sortkey = '') { |
278 | 304 | $this->setXSDValue($dbkey,''); // just used to trigger standard parent class methods! |
279 | 305 | /// 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); |
282 | 307 | } |
283 | 308 | |
284 | 309 | } |