Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | $doit = false; |
79 | 79 | if (($categories) && ($ns == NS_CATEGORY)) |
80 | 80 | $doit = true; |
81 | | - if (($properties) && (($ns == SMW_NS_RELATION) || ($ns == SMW_NS_ATTRIBUTE))) |
| 81 | + if (($properties) && ($ns == SMW_NS_PROPERTY)) |
82 | 82 | $doit = true; |
83 | 83 | if (($types) && ($ns == SMW_NS_TYPE)) |
84 | 84 | $doit = true; |
Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_dumpRDF.php |
— | — | @@ -7,10 +7,9 @@ |
8 | 8 | * -o <filename> output file, stdout is used if omitted; |
9 | 9 | * file output is generally better and strongly recommended for large wikis |
10 | 10 | * --categories only do categories |
11 | | - * --relations only do relations |
12 | | - * --attributes only do attributes |
| 11 | + * --properties only do properties |
13 | 12 | * --types only do types |
14 | | - * --individuals only do pages that are no categories, relations, attributes, or types |
| 13 | + * --individuals only do pages that are no categories, properties, or types |
15 | 14 | */ |
16 | 15 | |
17 | 16 | $optionsWithArgs = array( 'o' ); // -o <output file> |
— | — | @@ -26,10 +25,8 @@ |
27 | 26 | |
28 | 27 | if ( $options['categories'] ) { |
29 | 28 | $export_ns = NS_CATEGORY; |
30 | | -} elseif ( $options['relations'] ) { |
31 | | - $export_ns = SMW_NS_RELATION; |
32 | | -} elseif ( $options['attributes'] ) { |
33 | | - $export_ns = SMW_NS_ATTRIBUTE; |
| 29 | +} elseif ( $options['properties'] ) { |
| 30 | + $export_ns = SMW_NS_PROPERTY; |
34 | 31 | } elseif ( $options['types'] ) { |
35 | 32 | $export_ns = SMW_NS_TYPE; |
36 | 33 | } elseif ( $options['individuals'] ) { |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php |
— | — | @@ -73,14 +73,14 @@ |
74 | 74 | |
75 | 75 | // prepare navigation bar |
76 | 76 | if ($offset > 0) |
77 | | - $navigation = '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty','offset=' . max(0,$offset-$limit) . '&limit=' . $limit . '&attribute=' . urlencode($attribute->getText()) .'&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_prev') . '</a>'; |
| 77 | + $navigation = '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty','offset=' . max(0,$offset-$limit) . '&limit=' . $limit . '&property=' . urlencode($attribute->getText()) .'&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_prev') . '</a>'; |
78 | 78 | else |
79 | 79 | $navigation = wfMsg('smw_result_prev'); |
80 | 80 | |
81 | 81 | $navigation .= ' <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '– ' . ($offset + min($count, $limit)) . '</b> '; |
82 | 82 | |
83 | 83 | if ($count>$limit) { |
84 | | - $navigation .= ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty', 'offset=' . ($offset+$limit) . '&limit=' . $limit . '&attribute=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_next') . '</a>'; |
| 84 | + $navigation .= ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty', 'offset=' . ($offset+$limit) . '&limit=' . $limit . '&property=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . wfMsg('smw_result_next') . '</a>'; |
85 | 85 | } else { |
86 | 86 | $navigation .= wfMsg('smw_result_next'); |
87 | 87 | } |
— | — | @@ -98,7 +98,7 @@ |
99 | 99 | $max = true; |
100 | 100 | } |
101 | 101 | if ( $limit != $l ) { |
102 | | - $navigation .= '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty','offset=' . $offset . '&limit=' . $l . '&attribute=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . $l . '</a>'; |
| 102 | + $navigation .= '<a href="' . htmlspecialchars($skin->makeSpecialUrl('SearchByProperty','offset=' . $offset . '&limit=' . $l . '&property=' . urlencode($attribute->getText()) . '&value=' . urlencode($value->getWikiValue()))) . '">' . $l . '</a>'; |
103 | 103 | } else { |
104 | 104 | $navigation .= '<b>' . $l . '</b>'; |
105 | 105 | } |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchTriple.php |
— | — | @@ -112,162 +112,6 @@ |
113 | 113 | |
114 | 114 | return $form; |
115 | 115 | } |
116 | | - |
117 | | - |
118 | | - function searchRelations($subject, $relation, $object) |
119 | | - { |
120 | | - global $wgUser; |
121 | | - |
122 | | - if ($subject!='') { |
123 | | - $stitle = Title::newFromText($subject); |
124 | | - } else { |
125 | | - $stitle = NULL; |
126 | | - } |
127 | | - if ($relation!='') { |
128 | | - $rtitle = Title::newFromText($relation,SMW_NS_RELATION); |
129 | | - } else { |
130 | | - $rtitle = NULL; |
131 | | - } |
132 | | - if ($object!='') { |
133 | | - $otitle = Title::newFromText($object); |
134 | | - } else { |
135 | | - $otitle = NULL; |
136 | | - } |
137 | | - |
138 | | - $res=smwfGetRelations($stitle,$rtitle,$otitle,true); |
139 | | - $result_header = wfMsg('smw_searchtriple_resultrel'); |
140 | | - |
141 | | - /* Print results */ |
142 | | - if ($res===false || count($res)<=0) { |
143 | | - return '<strong>' . $result_header . ':</strong> ' . wfMsg('notitlematches'); |
144 | | - } |
145 | | - |
146 | | - $sk =& $wgUser->getSkin(); |
147 | | - |
148 | | - $searchResult = ''; |
149 | | - $searchResult .= '<p><strong>' . $result_header . |
150 | | - '</strong></p>' . "\n"; |
151 | | - |
152 | | - $searchResult .= '<table summary="' . $result_header . '" cellpadding="0" style=" border:0px solid #000; border-collapse:collapse;">' . "\n"; |
153 | | - |
154 | | - global $wgContLang; |
155 | | - |
156 | | - foreach($res as $reldata) { |
157 | | - $t = Title::newFromID($reldata[0]); |
158 | | - if ($t != NULL) { |
159 | | - $s = $sk->makeKnownLink($t->getPrefixedText()); |
160 | | - } else { |
161 | | - $s = '?'; |
162 | | - } |
163 | | - $t = Title::newFromText($reldata[1],SMW_NS_RELATION); |
164 | | - if ($t != NULL) { |
165 | | - $r = $sk->makeLink($t->getPrefixedText(),$t->getText()); |
166 | | - } else { |
167 | | - $r = $reldata[1]; |
168 | | - } |
169 | | - $o = $sk->makeLink($wgContLang->getNsText($reldata[2]) . ':' . $reldata[3]); |
170 | | - |
171 | | - $searchResult .= '<tr><td style="text-align:right;"> ' . $s . ' </td><td style="padding:3px 20px; text-align:center;"> ' . $r . ' </td><td style="text-align:left;"> ' . $o . ' </td></tr>' . "\n"; |
172 | | - } |
173 | | - |
174 | | - $searchResult .= '</table>' . "\n"; |
175 | | - return $searchResult; |
176 | | - } |
177 | | - |
178 | | - function searchAttributes($subject, $attribute, $value) |
179 | | - { |
180 | | - global $wgUser; |
181 | | - |
182 | | - if ($subject!='') { |
183 | | - $stitle = Title::newFromText($subject); |
184 | | - } else { |
185 | | - $stitle=NULL; |
186 | | - } |
187 | | - // set unit and (XSD) value |
188 | | - if ($attribute == '') { |
189 | | - $atitle = NULL; |
190 | | - $unit = NULL; |
191 | | - if ($value == '') { $value = NULL; } |
192 | | - } else { |
193 | | - $atitle = Title::newFromText($attribute,SMW_NS_ATTRIBUTE); |
194 | | - $datavalue=SMWDataValue::newAttributeValue($attribute); |
195 | | - if ( $datavalue->getTypeID() == 'error') { |
196 | | - $unit=NULL; |
197 | | - $type=NULL; // unset type |
198 | | - if ($value=='') { $value=NULL; } |
199 | | - } else { |
200 | | - if ($value=='') { // value-wildcard |
201 | | - ////use the standard unit: |
202 | | - //$units=$type->getUnits(); |
203 | | - //$unit=$units['STDUNIT']; |
204 | | - ////ignore unit: |
205 | | - $unit=NULL; |
206 | | - $value=NULL; |
207 | | - } else { // some value string was given: try to parse it |
208 | | - // TODO: Performance (medium): setUserValue() calls the data type's processValue() which does a lot of conversion and tooltip work that's unused here. |
209 | | - $datavalue->setUserValue($value); |
210 | | - if ( $datavalue->isValid() === false ) { |
211 | | - // try to use unparsable values as units |
212 | | - $unit=$value; |
213 | | - $value=NULL; |
214 | | - } else { |
215 | | - $unit = $datavalue->getUnit(); |
216 | | - $value = $datavalue->getXSDValue(); |
217 | | - } |
218 | | - } |
219 | | - } |
220 | | - } |
221 | | - |
222 | | - $res=smwfGetAttributes($stitle,$atitle,$unit,NULL,$value,true); // do not care about the typeid here |
223 | | - $result_header = wfMsg('smw_searchtriple_resultatt'); |
224 | | - |
225 | | - /* Print results */ |
226 | | - if ($res===false || count($res)<=0) { |
227 | | - return '<strong>' . $result_header . ':</strong> ' . wfMsg('notitlematches'); |
228 | | - } |
229 | | - |
230 | | - $sk =& $wgUser->getSkin(); |
231 | | - |
232 | | - $searchResult = ''; |
233 | | - $searchResult .= '<p><strong>' . $result_header . |
234 | | - '</strong></p>' . "\n"; |
235 | | - |
236 | | - $searchResult .= '<table summary="' . $result_header . '" cellpadding="0" style=" border:0px solid #000; border-collapse:collapse;">' . "\n"; |
237 | | - |
238 | | - global $wgContLang; |
239 | | - |
240 | | - foreach($res as $attdata) { |
241 | | - $t = Title::newFromID($attdata[0]); |
242 | | - if ($t != NULL) { |
243 | | - $s = $sk->makeKnownLink($t->getPrefixedText()); |
244 | | - } else { |
245 | | - $s = '?'; |
246 | | - } |
247 | | - $t = Title::newFromText($attdata[1],SMW_NS_ATTRIBUTE); |
248 | | - if ($t != NULL) { |
249 | | - $r = $sk->makeLink($t->getPrefixedText(),$t->getText()); |
250 | | - } else { |
251 | | - $r = $attdata[1]; |
252 | | - } |
253 | | - |
254 | | - $parsed_value = SMWDataValue::newAttributeValue($attdata[1]); |
255 | | - $parsed_value->setXSDValue($attdata[4],$attdata[2]); |
256 | | - if ($parsed_value->isValid()) { |
257 | | - $o = $parsed_value->getValueDescription(); |
258 | | - //$o = $parsed_value->getStringValue(); //shorter |
259 | | - foreach ($parsed_value->getInfolinks() as $link) { |
260 | | - $o .= ' ' . $link->getHTML($sk); |
261 | | - } |
262 | | - } else { |
263 | | - $o = $attdata[4] . $attdata[2]; |
264 | | - } |
265 | | - |
266 | | - $searchResult .= '<tr><td style="text-align:right;"> ' . $s . ' </td><td style="padding:3px 20px; text-align:center;"> ' . $r . ' </td><td style="text-align:left;"> ' . $o . ' </td></tr>' . "\n"; |
267 | | - } |
268 | | - |
269 | | - $searchResult .= '</table>' . "\n"; |
270 | | - return $searchResult; |
271 | | - } |
272 | 116 | } |
273 | 117 | |
274 | 118 | |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php |
— | — | @@ -44,7 +44,7 @@ |
45 | 45 | |
46 | 46 | $vsep = '<div class="smwhr"><hr /></div>'; |
47 | 47 | |
48 | | - if (($article->isValid()) && ('' !== $articletext)) { // legal article given |
| 48 | + if ($article->isValid()) { |
49 | 49 | $options = new SMWRequestOptions(); |
50 | 50 | $atts = &smwfGetStore()->getProperties($article->getTitle(), $options); |
51 | 51 | $cats = &smwfGetStore()->getSpecialValues($article->getTitle(), SMW_SP_HAS_CATEGORY, $options); |
— | — | @@ -125,7 +125,7 @@ |
126 | 126 | $html .= $skin->makeKnownLinkObj($subject, smwfT($subject, TRUE)) . ' ' . $subjectlink->getHTML($skin); |
127 | 127 | if ($innercount<$subjectcount) $html .= ", \n"; |
128 | 128 | } else { |
129 | | - $html .= '<a href="' . $skin->makeSpecialUrl('SearchByRelation', 'type=' . urlencode($result->getPrefixedText()) . '&target=' . urlencode($article->getPrefixedText())) . '">' . wfMsg("smw_browse_more") . "</a>\n"; |
| 129 | + $html .= '<a href="' . $skin->makeSpecialUrl('SearchByProperty', 'property=' . urlencode($result->getPrefixedText()) . '&value=' . urlencode($article->getPrefixedText())) . '">' . wfMsg("smw_browse_more") . "</a>\n"; |
130 | 130 | } |
131 | 131 | } |
132 | 132 | // replace the last two whitespaces in the relation name with |
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php |
— | — | @@ -43,13 +43,8 @@ |
44 | 44 | } |
45 | 45 | $subject = Title::newFromText( $from ); |
46 | 46 | if (NULL != $subject) { $from = $subject->getText(); } else { $from = ''; } |
47 | | - $relation = Title::newFromText( $type, SMW_NS_ATTRIBUTE ); |
48 | | - $att = TRUE; |
| 47 | + $relation = Title::newFromText( $type, SMW_NS_PROPERTY ); |
49 | 48 | if (NULL != $relation) { |
50 | | - if (!$relation->exists()) { |
51 | | - $relation = Title::newFromText( $type, SMW_NS_RELATION ); |
52 | | - $att = FALSE; |
53 | | - } |
54 | 49 | $type = $relation->getText(); |
55 | 50 | } else { |
56 | 51 | $type = ''; |
— | — | @@ -70,10 +65,7 @@ |
71 | 66 | $options->limit = $limit+1; |
72 | 67 | $options->offset = $offset; |
73 | 68 | // get results (get one more, to see if we have to add a link to more) |
74 | | - if ($att) |
75 | | - $results = &smwfGetStore()->getAttributeValues($subject, $relation, $options); |
76 | | - else |
77 | | - $results = &smwfGetStore()->getRelationObjects($subject, $relation, $options); |
| 69 | + $results = &smwfGetStore()->getPropertyValues($subject, $relation, $options); |
78 | 70 | |
79 | 71 | // prepare navigation bar |
80 | 72 | if ($offset > 0) |
— | — | @@ -95,12 +87,12 @@ |
96 | 88 | } else { |
97 | 89 | $html .= "<ul>\n"; |
98 | 90 | foreach ($results as $result) { |
99 | | - if ($att) { |
100 | | - $html .= '<li>' . $result->getUserValue() . '</li>'; |
101 | | - } else { |
| 91 | + $html .= '<li>' . $result->getShortHTMLText($skin); |
| 92 | + if ($result->getTypeID() == '_wpg') { |
102 | 93 | $browselink = SMWInfolink::newBrowsingLink('+',$result->getPrefixedText()); |
103 | | - $html .= '<li>' . $skin->makeKnownLinkObj($result) . ' ' . $browselink->getHTML($skin) . "</li> \n"; |
| 94 | + $html .= $browselink->getHTML($skin); |
104 | 95 | } |
| 96 | + $html .= "</li> \n"; |
105 | 97 | } |
106 | 98 | $html .= "</ul>\n"; |
107 | 99 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php |
— | — | @@ -401,9 +401,9 @@ |
402 | 402 | } else { // fixed subject, namespace restriction, property query, or subquery |
403 | 403 | $sep = $this->readChunk('',false); //do not consume hit, "look ahead" |
404 | 404 | if ($sep == '::') { // relation statement |
405 | | - return $this->getRelationDescription($chunk, $setNS, $label); |
| 405 | + return $this->getPropertyDescription($chunk, $setNS, $label); |
406 | 406 | } elseif ($sep == ':=') { // attribute statement |
407 | | - return $this->getAttributeDescription($chunk, $setNS, $label); |
| 407 | + return $this->getPropertyDescription($chunk, $setNS, $label); |
408 | 408 | } else { // Fixed article/namespace restriction. $sep should be ]] or || |
409 | 409 | return $this->getArticleDescription($chunk, $setNS, $label); |
410 | 410 | } |
— | — | @@ -464,117 +464,300 @@ |
465 | 465 | * suitable description. The "::" is the first chunk on the current |
466 | 466 | * string. |
467 | 467 | */ |
468 | | - protected function getRelationDescription($relname, &$setNS, &$label) { |
469 | | - $innerdesc = NULL; |
470 | | - $rel = Title::newFromText($relname, SMW_NS_RELATION); |
471 | | - if ($rel === NULL) { |
472 | | - $this->m_errors[] .= 'Sorry, but ' . htmlspecialchars($relname) . ' is no valid page title.'; // TODO internationalise |
473 | | - return NULL;///TODO: read some more chunks and try to finish [[ ]] |
| 468 | +// protected function getRelationDescription($relname, &$setNS, &$label) { |
| 469 | +// $innerdesc = NULL; |
| 470 | +// $rel = Title::newFromText($relname, SMW_NS_RELATION); |
| 471 | +// if ($rel === NULL) { |
| 472 | +// $this->m_errors[] .= 'Sorry, but ' . htmlspecialchars($relname) . ' is no valid page title.'; // TODO internationalise |
| 473 | +// return NULL;///TODO: read some more chunks and try to finish [[ ]] |
| 474 | +// } |
| 475 | +// |
| 476 | +// $this->readChunk(); // consume seperator "::" |
| 477 | +// $continue = true; |
| 478 | +// while ($continue) { |
| 479 | +// $chunk = $this->readChunk(); |
| 480 | +// switch ($chunk) { |
| 481 | +// case '*': // print statement, abort processing |
| 482 | +// $chunk = $this->readChunk('\]\]|\|'); |
| 483 | +// if ($chunk == '|') { |
| 484 | +// $printlabel = $this->readChunk('\]\]'); |
| 485 | +// if ($printlabel != ']]') { |
| 486 | +// $chunk = $this->readChunk('\]\]'); |
| 487 | +// } else { |
| 488 | +// $printlabel = ''; |
| 489 | +// $chunk = ']]'; |
| 490 | +// } |
| 491 | +// } else { |
| 492 | +// $printlabel = $rel->getText(); |
| 493 | +// } |
| 494 | +// if ($chunk == ']]') { |
| 495 | +// return new SMWPrintRequest(SMW_PRINT_RELS, $printlabel, $rel); |
| 496 | +// } else { |
| 497 | +// $this->m_errors[] = 'Misshaped print statement.'; //TODO: internationalise |
| 498 | +// return NULL; |
| 499 | +// } |
| 500 | +// break; |
| 501 | +// case '+': // wildcard |
| 502 | +// if ($this->m_defaultns !== NULL) { |
| 503 | +// $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false); |
| 504 | +// } else { |
| 505 | +// $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false); |
| 506 | +// } |
| 507 | +// break; |
| 508 | +// case '<q>': // subquery, set default namespaces |
| 509 | +// $this->pushDelimiter('</q>'); |
| 510 | +// $setsubNS = true; |
| 511 | +// $sublabel = ''; |
| 512 | +// $innerdesc = $this->addDescription($innerdesc, $this->getSubqueryDescription($setsubNS, $sublabel), false); |
| 513 | +// break; |
| 514 | +// default: //normal object value, brings its own namespace |
| 515 | +// $obj = Title::newFromText($chunk); |
| 516 | +// if ($obj !== NULL) { |
| 517 | +// $innerdesc = $this->addDescription($innerdesc, new SMWNominalDescription($obj), false); |
| 518 | +// } |
| 519 | +// } |
| 520 | +// $chunk = $this->readChunk(); |
| 521 | +// $continue = ($chunk == '||'); |
| 522 | +// } |
| 523 | +// |
| 524 | +// if ($innerdesc === NULL) { // make a wildcard search |
| 525 | +// if ($this->m_defaultns !== NULL) { |
| 526 | +// $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false); |
| 527 | +// } else { |
| 528 | +// $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false); |
| 529 | +// } |
| 530 | +// $this->m_errors[] = 'Value of relation ' . $rel->getText() . ' was not understood.'; // TODO internationalise |
| 531 | +// } |
| 532 | +// $result = new SMWSomeRelation($rel,$innerdesc); |
| 533 | +// |
| 534 | +// return $this->finishLinkDescription($chunk, false, $result, $setNS, $label); |
| 535 | +// } |
| 536 | +// |
| 537 | +// protected function getAttributeDescription($propertyname, &$setNS, &$label) { |
| 538 | +// $this->readChunk(); // consume seperator ":=" |
| 539 | +// $att = Title::newFromText($propertyname, SMW_NS_PROPERTY); |
| 540 | +// if ($att === NULL) { |
| 541 | +// $this->m_errors[] .= 'Sorry, but ' . htmlspecialchars($propertyname) . ' is no valid page title.'; // TODO internationalise |
| 542 | +// return NULL; ///TODO: read some more chunks and try to finish [[ ]] |
| 543 | +// } |
| 544 | +// ///TODO: currently no support for disjunctions in data values (needs extension of query processor) |
| 545 | +// |
| 546 | +// // get values, including values with internal [[...]] |
| 547 | +// $open = 1; |
| 548 | +// $value = ''; |
| 549 | +// $continue = true; |
| 550 | +// while ( ($open > 0) && ($continue) ) { |
| 551 | +// $chunk = $this->readChunk('\[\[|\]\]|\|'); |
| 552 | +// switch ($chunk) { |
| 553 | +// case '[[': // open new [[ ]] |
| 554 | +// $open++; |
| 555 | +// break; |
| 556 | +// case ']]': // close [[ ]] |
| 557 | +// $open--; |
| 558 | +// break; |
| 559 | +// case '|': // terminates only outermost [[ ]] |
| 560 | +// if ($open == 1) { |
| 561 | +// $open = 0; |
| 562 | +// } |
| 563 | +// break; |
| 564 | +// case '': // this is not good ... TODO:report error |
| 565 | +// $continue = false; |
| 566 | +// break; |
| 567 | +// } |
| 568 | +// if ($open != 0) { |
| 569 | +// $value .= $chunk; |
| 570 | +// } |
| 571 | +// } |
| 572 | +// // note that at this point, we normally already read one more chunk behind the value |
| 573 | +// $list = preg_split('/^\*/',$value,2); |
| 574 | +// if (count($list) == 2) { //hit |
| 575 | +// $value = '*'; |
| 576 | +// $printmodifier = $list[1]; |
| 577 | +// } else { |
| 578 | +// $printmodifier = ''; |
| 579 | +// } |
| 580 | +// switch ($value) { |
| 581 | +// case '*': // print statement |
| 582 | +// if ($chunk == '|') { |
| 583 | +// $printlabel = $this->readChunk('\]\]'); |
| 584 | +// if ($printlabel != ']]') { |
| 585 | +// $chunk = $this->readChunk('\]\]'); |
| 586 | +// } else { |
| 587 | +// $printlabel = ''; |
| 588 | +// $chunk = ']]'; |
| 589 | +// } |
| 590 | +// } else { |
| 591 | +// $printlabel = $att->getText(); |
| 592 | +// } |
| 593 | +// if ($chunk == ']]') { |
| 594 | +// return new SMWPrintRequest(SMW_PRINT_ATTS, $printlabel, $att, $printmodifier); |
| 595 | +// } else { |
| 596 | +// $this->m_errors[] = 'Misshaped print statement.'; //TODO: internationalise |
| 597 | +// return NULL; |
| 598 | +// } |
| 599 | +// break; |
| 600 | +// case '+': // wildcard |
| 601 | +// $vd = new SMWValueDescription(SMWDataValueFactory::newPropertyObjectValue($att), SMW_CMP_ANY); |
| 602 | +// break; |
| 603 | +// default: // fixed value, possibly with comparator addons |
| 604 | +// // for now, treat comparators only if placed before whole value: |
| 605 | +// $list = preg_split('/^(<|>|!)/',$value, 2, PREG_SPLIT_DELIM_CAPTURE); |
| 606 | +// $comparator = SMW_CMP_EQ; |
| 607 | +// if (count($list) == 3) { // initial comparator found ($list[1] should be empty) |
| 608 | +// switch ($list[1]) { |
| 609 | +// case '<': |
| 610 | +// $comparator = SMW_CMP_LEQ; |
| 611 | +// $value = $list[2]; |
| 612 | +// break; |
| 613 | +// case '>': |
| 614 | +// $comparator = SMW_CMP_GEQ; |
| 615 | +// $value = $list[2]; |
| 616 | +// break; |
| 617 | +// case '!': |
| 618 | +// $comparator = SMW_CMP_NEQ; |
| 619 | +// $value = $list[2]; |
| 620 | +// break; |
| 621 | +// //default: not possible |
| 622 | +// } |
| 623 | +// } |
| 624 | +// // TODO: needs extension for n-ary values |
| 625 | +// $dv = SMWDataValueFactory::newPropertyObjectValue($att, $value); |
| 626 | +// if (!$dv->isValid()) { |
| 627 | +// $this->m_errors = $this->m_errors + $dv->getErrors(); |
| 628 | +// $vd = new SMWValueDescription($dv, SMW_CMP_ANY); |
| 629 | +// } else { |
| 630 | +// $vd = new SMWValueDescription($dv, $comparator); |
| 631 | +// } |
| 632 | +// } |
| 633 | +// |
| 634 | +// return $this->finishLinkDescription($chunk, false, new SMWSomeAttribute($att, $vd), $setNS, $label); |
| 635 | +// } |
| 636 | + |
| 637 | + /** |
| 638 | + * Parse a property description (the part of an inline query that |
| 639 | + * is in between "[[Some property:=" and the closing "]]" and create a |
| 640 | + * suitable description. The ":=" is the first chunk on the current |
| 641 | + * string. |
| 642 | + */ |
| 643 | + protected function getPropertyDescription($propertyname, &$setNS, &$label) { |
| 644 | + $this->readChunk(); // consume seperator ":=" |
| 645 | + $property = Title::newFromText($propertyname, SMW_NS_PROPERTY); |
| 646 | + if ($property === NULL) { |
| 647 | + $this->m_errors[] .= 'Sorry, but ' . htmlspecialchars($propertyname) . ' is no valid page title.'; // TODO internationalise |
| 648 | + return NULL; ///TODO: read some more chunks and try to finish [[ ]] |
474 | 649 | } |
475 | 650 | |
476 | | - $this->readChunk(); // consume seperator "::" |
| 651 | + $innerdesc = NULL; |
477 | 652 | $continue = true; |
| 653 | + $typeid = SMWDataValueFactory::getPropertyObjectTypeID($property); |
478 | 654 | while ($continue) { |
479 | 655 | $chunk = $this->readChunk(); |
480 | 656 | switch ($chunk) { |
481 | | - case '*': // print statement, abort processing |
482 | | - $chunk = $this->readChunk('\]\]|\|'); |
483 | | - if ($chunk == '|') { |
484 | | - $printlabel = $this->readChunk('\]\]'); |
485 | | - if ($printlabel != ']]') { |
486 | | - $chunk = $this->readChunk('\]\]'); |
487 | | - } else { |
488 | | - $printlabel = ''; |
489 | | - $chunk = ']]'; |
490 | | - } |
491 | | - } else { |
492 | | - $printlabel = $rel->getText(); |
493 | | - } |
494 | | - if ($chunk == ']]') { |
495 | | - return new SMWPrintRequest(SMW_PRINT_RELS, $printlabel, $rel); |
496 | | - } else { |
497 | | - $this->m_errors[] = 'Misshaped print statement.'; //TODO: internationalise |
498 | | - return NULL; |
499 | | - } |
500 | | - break; |
501 | | - case '+': // wildcard |
502 | | - if ($this->m_defaultns !== NULL) { |
| 657 | + case '+': // wildcard, add namespaces for page-type properties |
| 658 | + if ( ($this->m_defaultns !== NULL) && ($typeid == '_wpg') ) { |
503 | 659 | $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false); |
504 | 660 | } else { |
505 | 661 | $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false); |
506 | 662 | } |
| 663 | + $chunk = $this->readChunk(); |
507 | 664 | break; |
508 | 665 | case '<q>': // subquery, set default namespaces |
509 | | - $this->pushDelimiter('</q>'); |
510 | | - $setsubNS = true; |
511 | | - $sublabel = ''; |
512 | | - $innerdesc = $this->addDescription($innerdesc, $this->getSubqueryDescription($setsubNS, $sublabel), false); |
| 666 | + if ($typeid == '_wpg') { |
| 667 | + $this->pushDelimiter('</q>'); |
| 668 | + $setsubNS = true; |
| 669 | + $sublabel = ''; |
| 670 | + $innerdesc = $this->addDescription($innerdesc, $this->getSubqueryDescription($setsubNS, $sublabel), false); |
| 671 | + } else { // no subqueries allowed for non-pages |
| 672 | + $this->m_errors[] = 'Subqueries not supported for values of property ' . $propertyname . '.'; |
| 673 | + $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false); |
| 674 | + } |
| 675 | + $chunk = $this->readChunk(); |
513 | 676 | break; |
514 | | - default: //normal object value, brings its own namespace |
515 | | - $obj = Title::newFromText($chunk); |
516 | | - if ($obj !== NULL) { |
517 | | - $innerdesc = $this->addDescription($innerdesc, new SMWNominalDescription($obj), false); |
| 677 | + default: //normal object value or print statement |
| 678 | + // read value(s), possibly with inner [[...]] |
| 679 | + $open = 1; |
| 680 | + $value = $chunk; |
| 681 | + $continue2 = true; |
| 682 | + while ( ($open > 0) && ($continue2) ) { |
| 683 | + $chunk = $this->readChunk('\[\[|\]\]|\|\||\|'); |
| 684 | + switch ($chunk) { |
| 685 | + case '[[': // open new [[ ]] |
| 686 | + $open++; |
| 687 | + break; |
| 688 | + case ']]': // close [[ ]] |
| 689 | + $open--; |
| 690 | + break; |
| 691 | + case '|': case '||': // terminates only outermost [[ ]] |
| 692 | + if ($open == 1) { |
| 693 | + $open = 0; |
| 694 | + } |
| 695 | + break; |
| 696 | + case '': // this is not good ... TODO:report error |
| 697 | + $continue2 = false; |
| 698 | + break; |
| 699 | + } |
| 700 | + if ($open != 0) { |
| 701 | + $value .= $chunk; |
| 702 | + } |
| 703 | + } // note that at this point, we normally already read one more chunk behind the value |
| 704 | + |
| 705 | + // TODO: special treatment for naries needed ... |
| 706 | + $comparator = SMW_CMP_EQ; |
| 707 | + $printmodifier = ''; |
| 708 | + $this->prepareValue($value, $comparator, $printmodifier); |
| 709 | + if ($value == '*') { |
| 710 | + if ($chunk == '|') { |
| 711 | + $printlabel = $this->readChunk('\]\]'); |
| 712 | + if ($printlabel != ']]') { |
| 713 | + $chunk = $this->readChunk('\]\]'); |
| 714 | + } else { |
| 715 | + $printlabel = ''; |
| 716 | + $chunk = ']]'; |
| 717 | + } |
| 718 | + } else { |
| 719 | + $printlabel = $property->getText(); |
| 720 | + } |
| 721 | + if ($chunk == ']]') { |
| 722 | + return new SMWPrintRequest(SMW_PRINT_PROP, $printlabel, $property, $printmodifier); |
| 723 | + } else { |
| 724 | + $this->m_errors[] = 'Misshaped print statement.'; //TODO: internationalise |
| 725 | + return NULL; |
| 726 | + } |
| 727 | + } else { |
| 728 | + $dv = SMWDataValueFactory::newPropertyObjectValue($property, $value); |
| 729 | + if (!$dv->isValid()) { |
| 730 | + $this->m_errors = $this->m_errors + $dv->getErrors(); |
| 731 | + $vd = new SMWThingDescription(); |
| 732 | + } else { |
| 733 | + $vd = new SMWValueDescription($dv, $comparator); |
| 734 | + } |
| 735 | + $innerdesc = $this->addDescription($innerdesc, $vd, false); |
518 | 736 | } |
519 | 737 | } |
520 | | - $chunk = $this->readChunk(); |
521 | 738 | $continue = ($chunk == '||'); |
522 | 739 | } |
523 | 740 | |
524 | 741 | if ($innerdesc === NULL) { // make a wildcard search |
525 | | - if ($this->m_defaultns !== NULL) { |
| 742 | + if ( ($this->m_defaultns !== NULL) && ($typeid == '_wpg') ) { |
526 | 743 | $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false); |
527 | 744 | } else { |
528 | 745 | $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false); |
529 | 746 | } |
530 | | - $this->m_errors[] = 'Value of relation ' . $rel->getText() . ' was not understood.'; // TODO internationalise |
| 747 | + $this->m_errors[] = 'Value of relation ' . $property->getText() . ' was not understood.'; // TODO internationalise |
531 | 748 | } |
532 | | - $result = new SMWSomeRelation($rel,$innerdesc); |
| 749 | + $result = new SMWSomeProperty($property,$innerdesc); |
533 | 750 | |
534 | 751 | return $this->finishLinkDescription($chunk, false, $result, $setNS, $label); |
535 | 752 | } |
536 | | - |
| 753 | + |
| 754 | + |
537 | 755 | /** |
538 | | - * Parse an attribute description (the part of an inline query that |
539 | | - * is in between "[[Some Attribute:=" and the closing "]]" and create a |
540 | | - * suitable description. The ":=" is the first chunk on the current |
541 | | - * string. |
| 756 | + * Prepare a single value string, possibly extracting comparators and |
| 757 | + * printmodifier. $value is changed to consist only of the remaining |
| 758 | + * effective value string, or of "*" for print statements. |
542 | 759 | */ |
543 | | - protected function getAttributeDescription($attname, &$setNS, &$label) { |
544 | | - $this->readChunk(); // consume seperator ":=" |
545 | | - $att = Title::newFromText($attname, SMW_NS_ATTRIBUTE); |
546 | | - if ($att === NULL) { |
547 | | - $this->m_errors[] .= 'Sorry, but ' . htmlspecialchars($attname) . ' is no valid page title.'; // TODO internationalise |
548 | | - return NULL; ///TODO: read some more chunks and try to finish [[ ]] |
549 | | - } |
550 | | - ///TODO: currently no support for disjunctions in data values (needs extension of query processor) |
551 | | - |
552 | | - // get values, including values with internal [[...]] |
553 | | - $open = 1; |
554 | | - $value = ''; |
555 | | - $continue = true; |
556 | | - while ( ($open > 0) && ($continue) ) { |
557 | | - $chunk = $this->readChunk('\[\[|\]\]|\|'); |
558 | | - switch ($chunk) { |
559 | | - case '[[': // open new [[ ]] |
560 | | - $open++; |
561 | | - break; |
562 | | - case ']]': // close [[ ]] |
563 | | - $open--; |
564 | | - break; |
565 | | - case '|': // terminates only outermost [[ ]] |
566 | | - if ($open == 1) { |
567 | | - $open = 0; |
568 | | - } |
569 | | - break; |
570 | | - case '': // this is not good ... TODO:report error |
571 | | - $continue = false; |
572 | | - break; |
573 | | - } |
574 | | - if ($open != 0) { |
575 | | - $value .= $chunk; |
576 | | - } |
577 | | - } |
578 | | - // note that at this point, we normally already read one more chunk behind the value |
| 760 | + protected function prepareValue(&$value, &$comparator, &$printmodifier) { |
| 761 | + // get print modifier behind * |
579 | 762 | $list = preg_split('/^\*/',$value,2); |
580 | 763 | if (count($list) == 2) { //hit |
581 | 764 | $value = '*'; |
— | — | @@ -582,68 +765,34 @@ |
583 | 766 | } else { |
584 | 767 | $printmodifier = ''; |
585 | 768 | } |
586 | | - switch ($value) { |
587 | | - case '*': // print statement |
588 | | - if ($chunk == '|') { |
589 | | - $printlabel = $this->readChunk('\]\]'); |
590 | | - if ($printlabel != ']]') { |
591 | | - $chunk = $this->readChunk('\]\]'); |
592 | | - } else { |
593 | | - $printlabel = ''; |
594 | | - $chunk = ']]'; |
595 | | - } |
596 | | - } else { |
597 | | - $printlabel = $att->getText(); |
598 | | - } |
599 | | - if ($chunk == ']]') { |
600 | | - return new SMWPrintRequest(SMW_PRINT_ATTS, $printlabel, $att, $printmodifier); |
601 | | - } else { |
602 | | - $this->m_errors[] = 'Misshaped print statement.'; //TODO: internationalise |
603 | | - return NULL; |
604 | | - } |
605 | | - break; |
606 | | - case '+': // wildcard |
607 | | - $vd = new SMWValueDescription(SMWDataValueFactory::newPropertyObjectValue($att), SMW_CMP_ANY); |
608 | | - break; |
609 | | - default: // fixed value, possibly with comparator addons |
610 | | - // for now, treat comparators only if placed before whole value: |
611 | | - $list = preg_split('/^(<|>|!)/',$value, 2, PREG_SPLIT_DELIM_CAPTURE); |
612 | | - $comparator = SMW_CMP_EQ; |
613 | | - if (count($list) == 3) { // initial comparator found ($list[1] should be empty) |
614 | | - switch ($list[1]) { |
615 | | - case '<': |
616 | | - $comparator = SMW_CMP_LEQ; |
617 | | - $value = $list[2]; |
618 | | - break; |
619 | | - case '>': |
620 | | - $comparator = SMW_CMP_GEQ; |
621 | | - $value = $list[2]; |
622 | | - break; |
623 | | - case '!': |
624 | | - $comparator = SMW_CMP_NEQ; |
625 | | - $value = $list[2]; |
626 | | - break; |
627 | | - //default: not possible |
628 | | - } |
629 | | - } |
630 | | - // TODO: needs extension for n-ary values |
631 | | - $dv = SMWDataValueFactory::newPropertyObjectValue($att, $value); |
632 | | - if (!$dv->isValid()) { |
633 | | - $this->m_errors = $this->m_errors + $dv->getErrors(); |
634 | | - $vd = new SMWValueDescription($dv, SMW_CMP_ANY); |
635 | | - } else { |
636 | | - $vd = new SMWValueDescription($dv, $comparator); |
637 | | - } |
| 769 | + if ($value == '*') { // printout statement |
| 770 | + return; |
638 | 771 | } |
639 | | - |
640 | | - return $this->finishLinkDescription($chunk, false, new SMWSomeAttribute($att, $vd), $setNS, $label); |
| 772 | + $list = preg_split('/^(<|>|!)/',$value, 2, PREG_SPLIT_DELIM_CAPTURE); |
| 773 | + $comparator = SMW_CMP_EQ; |
| 774 | + if (count($list) == 3) { // initial comparator found ($list[1] should be empty) |
| 775 | + switch ($list[1]) { |
| 776 | + case '<': |
| 777 | + $comparator = SMW_CMP_LEQ; |
| 778 | + $value = $list[2]; |
| 779 | + break; |
| 780 | + case '>': |
| 781 | + $comparator = SMW_CMP_GEQ; |
| 782 | + $value = $list[2]; |
| 783 | + break; |
| 784 | + case '!': |
| 785 | + $comparator = SMW_CMP_NEQ; |
| 786 | + $value = $list[2]; |
| 787 | + break; |
| 788 | + //default: not possible |
| 789 | + } |
| 790 | + } |
641 | 791 | } |
642 | 792 | |
643 | 793 | /** |
644 | 794 | * Parse an article description (the part of an inline query that |
645 | 795 | * is in between "[[" and the closing "]]" if it is not specifying |
646 | | - * a category, relation, or attribute) and create a suitable |
647 | | - * description. |
| 796 | + * a category or property) and create a suitable description. |
648 | 797 | * The first chunk behind the "[[" has already been read and is |
649 | 798 | * passed as a parameter. |
650 | 799 | */ |
— | — | @@ -668,9 +817,9 @@ |
669 | 818 | $result = $this->addDescription($result, new SMWNamespaceDescription($idx), false); |
670 | 819 | } |
671 | 820 | } else { |
672 | | - $title = Title::newFromText($chunk); |
673 | | - if ($title !== NULL) { |
674 | | - $result = $this->addDescription($result, new SMWNominalDescription($title), false); |
| 821 | + $value = SMWDataValueFactory::newTypeIDValue('_wpg', $chunk); |
| 822 | + if ($value->isValid()) { |
| 823 | + $result = $this->addDescription($result, new SMWValueDescription($value), false); |
675 | 824 | } |
676 | 825 | } |
677 | 826 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | * Add a new error string to the error list. All error string must be wiki and |
83 | 83 | * html-safe! No further escaping will happen! |
84 | 84 | */ |
85 | | - protected function addError($errorstring) { |
| 85 | + public function addError($errorstring) { |
86 | 86 | $this->m_errors[] = $errorstring; |
87 | 87 | } |
88 | 88 | |
— | — | @@ -227,7 +227,7 @@ |
228 | 228 | * an empty string if no errors happened. |
229 | 229 | */ |
230 | 230 | public function getErrorText() { |
231 | | - return smwfEncodeMessages($this->m_errors); |
| 231 | + return smwfEncodeMessages($this->m_errors) . ' '; // is a hack to get non-empty table rows for better img placement in FF (any maybe elsewhere too); should not hurt |
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php |
— | — | @@ -41,11 +41,11 @@ |
42 | 42 | |
43 | 43 | public function getLongWikiText($linked = NULL) { |
44 | 44 | //TODO: support linking? |
45 | | - return $this->getErrorText() . ' '; // is a hack to get non-empty table rows for better img placement in FF (any maybe elsewhere too); should not hurt |
| 45 | + return $this->getErrorText(); |
46 | 46 | } |
47 | 47 | |
48 | 48 | public function getLongHTMLText($linker = NULL) { |
49 | | - return $this->getErrorText() . ' '; // is a hack to get non-empty table rows for better img placement in FF (any maybe elsewhere too); should not hurt |
| 49 | + return $this->getErrorText(); |
50 | 50 | } |
51 | 51 | |
52 | 52 | public function getXSDValue() { |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php |
— | — | @@ -12,7 +12,7 @@ |
13 | 13 | |
14 | 14 | /** |
15 | 15 | * This method will be called before an article is displayed or previewed. |
16 | | - * For display and preview we strip out the semantic relations and append them |
| 16 | + * For display and preview we strip out the semantic properties and append them |
17 | 17 | * at the end of the article. |
18 | 18 | * |
19 | 19 | * TODO: $strip_state is not used (and must not be used, since it is |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | |
26 | 26 | // In the regexp matches below, leading ':' escapes the markup, as |
27 | 27 | // known for Categories. |
28 | | - // Parse links to extract semantic relations |
| 28 | + // Parse links to extract semantic properties |
29 | 29 | $semanticLinkPattern = '(\[\[(([^:][^]]*):[=|:])+((?:[^|\[\]]|\[\[[^]]*\]\])*)(\|([^]]*))?\]\])'; |
30 | 30 | $text = preg_replace_callback($semanticLinkPattern, 'smwfParsePropertiesCallback', $text); |
31 | 31 | |
— | — | @@ -66,7 +66,7 @@ |
67 | 67 | |
68 | 68 | /** |
69 | 69 | * This method will be called after an article is saved |
70 | | - * and stores the semantic relations in the database. One |
| 70 | + * and stores the semantic properties in the database. One |
71 | 71 | * could consider creating an object for deferred saving |
72 | 72 | * as used in other places of MediaWiki. |
73 | 73 | */ |
— | — | @@ -78,7 +78,7 @@ |
79 | 79 | |
80 | 80 | /** |
81 | 81 | * This method will be called whenever an article is deleted so that |
82 | | - * semantic relations are cleared appropriately. |
| 82 | + * semantic properties are cleared appropriately. |
83 | 83 | */ |
84 | 84 | function smwfDeleteHook(&$article, &$user, &$reason) { |
85 | 85 | smwfGetStore()->deleteSubject($article->getTitle()); |
— | — | @@ -87,7 +87,7 @@ |
88 | 88 | |
89 | 89 | /** |
90 | 90 | * This method will be called whenever an article is moved so that |
91 | | - * semantic relations are moved accordingly. |
| 91 | + * semantic properties are moved accordingly. |
92 | 92 | */ |
93 | 93 | function smwfMoveHook(&$old_title, &$new_title, &$user, $pageid, $redirid) { |
94 | 94 | smwfGetStore()->changeTitle($old_title, $new_title); |
— | — | @@ -97,14 +97,14 @@ |
98 | 98 | // Special display for certain types of pages |
99 | 99 | |
100 | 100 | /** |
101 | | - * Register special classes for displaying semantic content on Relation/Attribute/Type pages |
| 101 | + * Register special classes for displaying semantic content on Property/Type pages |
102 | 102 | */ |
103 | 103 | function smwfShowListPage (&$title, &$article){ |
104 | 104 | global $smwgIP; |
105 | 105 | if ($title->getNamespace() == SMW_NS_TYPE){ |
106 | 106 | require_once($smwgIP . '/includes/articlepages/SMW_TypePage.php'); |
107 | 107 | $article = new SMWTypePage($title); |
108 | | - } elseif ( ($title->getNamespace() == SMW_NS_RELATION) || ($title->getNamespace() == SMW_NS_ATTRIBUTE) ) { |
| 108 | + } elseif ( $title->getNamespace() == SMW_NS_PROPERTY ) { |
109 | 109 | require_once($smwgIP . '/includes/articlepages/SMW_PropertyPage.php'); |
110 | 110 | $article = new SMWPropertyPage($title); |
111 | 111 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php |
— | — | @@ -75,8 +75,8 @@ |
76 | 76 | $v = str_replace(' ', '_', $value); //normalize slightly since messages distinguish '_' and ' ' |
77 | 77 | $result = SMWDataValueFactory::newSpecialValue($special,$v,$caption); |
78 | 78 | $v = $result->getXSDValue(); //possibly further sanitized, so let's be cautious |
79 | | - $result->setProcessedValues($value,$v); //set user value back to the input version |
80 | | - $result->setPrintoutString('[[' . $wgContLang->getNsText(NS_MEDIAWIKI) . ':smw_service_' . $v . "|$value]]"); |
| 79 | + //$result->setProcessedValues($value,$v); //set user value back to the input version |
| 80 | + //$result->setPrintoutString('[[' . $wgContLang->getNsText(NS_MEDIAWIKI) . ':smw_service_' . $v . "|$value]]"); |
81 | 81 | } else { // standard processing |
82 | 82 | $result = SMWDataValueFactory::newSpecialValue($special,$value,$caption); |
83 | 83 | } |
— | — | @@ -104,7 +104,8 @@ |
105 | 105 | |
106 | 106 | if ( count($msglines) < 2 ) { //error: no elements for this namespace |
107 | 107 | /// TODO: use new Error DV |
108 | | - $datavalue = SMWDataValueFactory::newTypeHandlerValue(new SMWErrorTypeHandler(wfMsgForContent('smw_unknown_importns',$onto_ns)),$value,$caption); |
| 108 | + $datavalue = SMWDataValueFactory::newTypeIDValue('__err',$value,$caption); |
| 109 | + $datavalue->addError(wfMsgForContent('smw_unknown_importns',$onto_ns)); |
109 | 110 | if ($smwgStoreActive) { |
110 | 111 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM,$datavalue); |
111 | 112 | } |
— | — | @@ -122,14 +123,12 @@ |
123 | 124 | // check whether type matches |
124 | 125 | switch ($namespace) { |
125 | 126 | case $wgContLang->getNsText(SMW_NS_TYPE): |
126 | | - $elemtype = SMW_NS_ATTRIBUTE; |
127 | | - $datatype = Title::newFromText($typestring, SMW_NS_TYPE); |
| 127 | + $elemtype = SMW_NS_PROPERTY; |
| 128 | + $datatype = SMWDataValueFactory::newSpecialValue(SMW_SP_HAS_TYPE, $typestring); |
128 | 129 | break; |
129 | | - case $wgContLang->getNsText(SMW_NS_ATTRIBUTE): // wrong: we need a datatype |
| 130 | + case $wgContLang->getNsText(SMW_NS_PROPERTY): |
| 131 | + $elemtype = SMW_NS_PROPERTY; |
130 | 132 | break; |
131 | | - case $wgContLang->getNsText(SMW_NS_RELATION): |
132 | | - $elemtype = SMW_NS_RELATION; |
133 | | - break; |
134 | 133 | case $wgContLang->getNsText(NS_CATEGORY): |
135 | 134 | $elemtype = NS_CATEGORY; |
136 | 135 | break; |
— | — | @@ -144,13 +143,13 @@ |
145 | 144 | $this_ns = SMWFactbox::$semdata->getSubject()->getNamespace(); |
146 | 145 | $error = NULL; |
147 | 146 | switch ($elemtype) { |
148 | | - case SMW_NS_ATTRIBUTE: case SMW_NS_RELATION: case NS_CATEGORY: |
| 147 | + case SMW_NS_PROPERTY: case NS_CATEGORY: |
149 | 148 | if ($this_ns != $elemtype) { |
150 | 149 | $error = wfMsgForContent('smw_nonright_importtype',$value, $wgContLang->getNsText($elemtype)); |
151 | 150 | } |
152 | 151 | break; |
153 | 152 | case NS_MAIN: |
154 | | - if ( (SMW_NS_ATTRIBUTE == $this_ns) || (SMW_NS_RELATION == $this_ns) || (NS_CATEGORY == $this_ns)) { |
| 153 | + if ( (SMW_NS_PROPERTY == $this_ns) || (NS_CATEGORY == $this_ns)) { |
155 | 154 | $error = wfMsgForContent('smw_wrong_importtype',$value, $wgContLang->getNsText($this_ns)); |
156 | 155 | } |
157 | 156 | break; |
— | — | @@ -159,39 +158,24 @@ |
160 | 159 | } |
161 | 160 | |
162 | 161 | if (NULL != $error) { |
163 | | - /// TODO: use new Error DV |
164 | | - $datavalue = SMWDataValueFactory::newTypeHandlerValue(new SMWErrorTypeHandler($error),$value,$caption); |
| 162 | + $datavalue = SMWDataValueFactory::newTypeIDValue('__err',$value,$caption); |
| 163 | + $datavalue->addError($error); |
165 | 164 | if ($smwgStoreActive) { |
166 | 165 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM, $datavalue); |
167 | 166 | } |
168 | 167 | return $datavalue; |
169 | 168 | } |
170 | 169 | |
171 | | - |
172 | | - ///TODO: use new DVs |
173 | | - |
174 | | - // Note: the following just overwrites any existing values for the given |
175 | | - // special properties, since they can only have one value anyway; this |
176 | | - // might hide errors -- should we care? |
177 | | - $sth = new SMWStringTypeHandler(); // making one is enough ... |
178 | | - |
179 | 170 | if ($smwgStoreActive) { |
180 | | - $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,$onto_uri); |
181 | | - SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_BASEURI,$datavalue); |
182 | | - $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,$onto_ns); |
183 | | - SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_NSID,$datavalue); |
184 | | - $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,$onto_section); |
185 | | - SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_SECTION,$datavalue); |
| 171 | + SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_BASEURI,SMWDataValueFactory::newTypeIDValue('_str',$onto_uri)); |
| 172 | + SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_NSID,SMWDataValueFactory::newTypeIDValue('_str',$onto_ns)); |
| 173 | + SMWFactbox::$semdata->addSpecialValue(SMW_SP_EXT_SECTION,SMWDataValueFactory::newTypeIDValue('_str',$onto_section)); |
186 | 174 | if (NULL !== $datatype) { |
187 | 175 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_HAS_TYPE,$datatype); |
188 | 176 | } |
189 | 177 | } |
190 | | - |
191 | 178 | // print the input (this property is usually not stored, see SMW_SQLStore.php) |
192 | | - $datavalue = SMWDataValueFactory::newTypeHandlerValue($sth,"[$onto_uri$onto_section $value]",$caption); |
193 | | - // TODO: Unfortunatelly, the following line can break the tooltip code if $onto_name has markup. -- mak |
194 | | - // if ('' != $onto_name) $datavalue->setPrintoutString($onto_name, 'onto_name'); |
195 | | - if ('' != $onto_name) $datavalue->setPrintoutString("[$onto_uri$onto_section $value] ($onto_name)"); |
| 179 | + $datavalue = SMWDataValueFactory::newTypeIDValue('_str',"[$onto_uri$onto_section $value] ($onto_name)",$caption); |
196 | 180 | if ($smwgStoreActive) { |
197 | 181 | SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM, $datavalue); |
198 | 182 | } |
— | — | @@ -287,21 +271,14 @@ |
288 | 272 | if (array_key_exists($specialProperty,$specprops)) { // only print specprops with an official name |
289 | 273 | $specialPropertyName = $specprops[$specialProperty]; |
290 | 274 | foreach ($valueArray as $value) { |
291 | | - if ($value instanceof SMWDataValue) { |
292 | | - $vt = $value->getLongWikiText(true); |
293 | | - if ($specialProperty != SMW_SP_HAS_TYPE) { |
294 | | - $vn = $wgContLang->getNsText(SMW_NS_ATTRIBUTE); |
295 | | - } else { |
296 | | - $vn = $wgContLang->getNsText(SMW_NS_RELATION); //HACK |
297 | | - } |
298 | | - } elseif ($value instanceof Title) { |
299 | | - $vt = '[[' . $value->getPrefixedText() . ']]'; |
300 | | - $vn = $wgContLang->getNsText(SMW_NS_RELATION); |
301 | | - } else { |
302 | | - $vt = $value; |
303 | | - $vn = $wgContLang->getNsText(SMW_NS_ATTRIBUTE); |
304 | | - } |
305 | | - $text .= '<tr><td class="smwspecname">[[' . $vn. ':' . $specialPropertyName . '|' . $specialPropertyName . ']]</td><td class="smwspecs">' . $vt . "</td></tr>\n"; |
| 275 | +// if ($value instanceof SMWDataValue) { |
| 276 | +// $vt = $value->getLongWikiText(true); |
| 277 | +// } elseif ($value instanceof Title) { |
| 278 | +// $vt = '[[' . $value->getPrefixedText() . ']]'; |
| 279 | +// } else { |
| 280 | +// $vt = $value; |
| 281 | +// } |
| 282 | + $text .= '<tr><td class="smwspecname">[[' . $wgContLang->getNsText(SMW_NS_PROPERTY) . ':' . $specialPropertyName . '|' . $specialPropertyName . ']]</td><td class="smwspecs">' . $value->getLongWikiText(true) . "</td></tr>\n"; |
306 | 283 | } |
307 | 284 | } |
308 | 285 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php |
— | — | @@ -11,13 +11,11 @@ |
12 | 12 | define('SMW_CMP_LEQ',2); // matches only datavalues that are less or equal than the given value |
13 | 13 | define('SMW_CMP_GEQ',3); // matches only datavalues that are greater or equal to the given value |
14 | 14 | define('SMW_CMP_NEQ',4); // matches only datavalues that are unequal to the given value |
15 | | -define('SMW_CMP_ANY',5); // matches every datavalue of the given datatype and, if set, desired unit |
16 | 15 | |
17 | 16 | // print request |
18 | 17 | define('SMW_PRINT_CATS', 0); // print all direct cateories of the current element |
19 | | -define('SMW_PRINT_RELS', 1); // print all relations objects of a certain relation of the current element |
20 | | -define('SMW_PRINT_ATTS', 2); // print all attribute values of a certain attribute of the current element |
21 | | -define('SMW_PRINT_THIS', 3); // print the current element |
| 18 | +define('SMW_PRINT_PROP', 1); // print all property values of a certain attribute of the current element |
| 19 | +define('SMW_PRINT_THIS', 2); // print the current element |
22 | 20 | |
23 | 21 | |
24 | 22 | /** |
— | — | @@ -64,8 +62,7 @@ |
65 | 63 | } |
66 | 64 | switch ($this->m_mode) { |
67 | 65 | case SMW_PRINT_CATS: return htmlspecialchars($this->m_label); // TODO: link to Special:Categories |
68 | | - case SMW_PRINT_RELS: return $linker->makeLinkObj($this->m_title, htmlspecialchars($this->m_label)); |
69 | | - case SMW_PRINT_ATTS: return $linker->makeKnownLinkObj($this->m_title, htmlspecialchars($this->m_label)); |
| 66 | + case SMW_PRINT_PROP: return $linker->makeLinkObj($this->m_title, htmlspecialchars($this->m_label)); |
70 | 67 | case SMW_PRINT_THIS: default: return htmlspecialchars($this->m_label); |
71 | 68 | } |
72 | 69 | |
— | — | @@ -80,7 +77,7 @@ |
81 | 78 | } else { |
82 | 79 | switch ($this->m_mode) { |
83 | 80 | case SMW_PRINT_CATS: return $this->m_label; // TODO: link to Special:Categories |
84 | | - case SMW_PRINT_RELS: case SMW_PRINT_ATTS: |
| 81 | + case SMW_PRINT_PROP: |
85 | 82 | return '[[' . $this->m_title->getPrefixedText() . '|' . $this->m_label . ']]'; |
86 | 83 | case SMW_PRINT_THIS: default: return $this->m_label; |
87 | 84 | } |
— | — | @@ -98,8 +95,11 @@ |
99 | 96 | |
100 | 97 | public function getTypeID() { |
101 | 98 | if ($this->m_typeid === false) { |
102 | | - $dv = SMWDataValueFactory::newPropertyObjectValue($this->m_title); |
103 | | - $this->m_typeid = $dv->getTypeID(); |
| 99 | + if ($this->m_mode == SMW_PRINT_PROP) { |
| 100 | + $this->m_typeid = SMWDataValueFactory::getPropertyObjectTypeID($this->m_title); |
| 101 | + } else { |
| 102 | + $this->m_typeid = '_wpg'; // return objects might be titles, but anyway |
| 103 | + } |
104 | 104 | } |
105 | 105 | return $this->m_typeid; |
106 | 106 | } |
— | — | @@ -285,37 +285,6 @@ |
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
289 | | - * Description of a class that contains exactly one explicitly given |
290 | | - * object. |
291 | | - * |
292 | | - * Corresponds to nominal concepts in OWL, and can be emulated for querying |
293 | | - * by using individuals directly in conjunctive queries (OWL) or SPARQL (RDF). |
294 | | - */ |
295 | | -class SMWNominalDescription extends SMWDescription { |
296 | | - protected $m_title; |
297 | | - |
298 | | - public function SMWNominalDescription(Title $individual) { |
299 | | - $this->m_title = $individual; |
300 | | - } |
301 | | - |
302 | | - public function getIndividual() { |
303 | | - return $this->m_title; |
304 | | - } |
305 | | - |
306 | | - public function getQueryString() { |
307 | | - if ($this->m_title !== NULL) { |
308 | | - return '[[:' . $this->m_title->getPrefixedText() . ']]'; |
309 | | - } else { |
310 | | - return ''; |
311 | | - } |
312 | | - } |
313 | | - |
314 | | - public function isSingleton() { |
315 | | - return true; |
316 | | - } |
317 | | -} |
318 | | - |
319 | | -/** |
320 | 289 | * Description of one data value, or of a range of data values. |
321 | 290 | * |
322 | 291 | * Technically this usually corresponds to unary concrete domain predicates |
— | — | @@ -323,15 +292,13 @@ |
324 | 293 | * In rare cases where SMW attributes represent object properties, this can |
325 | 294 | * also be similar to a nominal class. In RDF, concrete domain predicates that |
326 | 295 | * define ranges (like "greater or equal to") are not directly available. |
327 | | - * |
328 | | - * TODO: value wildcards probably need a different class |
329 | 296 | */ |
330 | 297 | class SMWValueDescription extends SMWDescription { |
331 | 298 | protected $m_datavalue; |
332 | 299 | protected $m_comparator; |
333 | 300 | |
334 | 301 | public function SMWValueDescription(SMWDataValue $datavalue, $comparator = SMW_CMP_EQ) { |
335 | | - $this->m_datavalue = $datavalue; // might be NULL for SMW_CMP_ANY |
| 302 | + $this->m_datavalue = $datavalue; |
336 | 303 | $this->m_comparator = $comparator; |
337 | 304 | } |
338 | 305 | |
— | — | @@ -346,9 +313,6 @@ |
347 | 314 | public function getQueryString() { |
348 | 315 | if ($this->m_datavalue !== NULL) { |
349 | 316 | switch ($this->m_comparator) { |
350 | | - case SMW_CMP_EQ: |
351 | | - $comparator = ''; |
352 | | - break; |
353 | 317 | case SMW_CMP_LEQ: |
354 | 318 | $comparator = '<'; |
355 | 319 | break; |
— | — | @@ -358,8 +322,9 @@ |
359 | 323 | case SMW_CMP_NEQ: |
360 | 324 | $comparator = '!'; // not supported yet? |
361 | 325 | break; |
362 | | - case SMW_CMP_ANY: default: |
363 | | - return '+'; |
| 326 | + default: case SMW_CMP_EQ: |
| 327 | + $comparator = ''; |
| 328 | + break; |
364 | 329 | } |
365 | 330 | return $comparator . $this->m_datavalue->getWikiValue(); |
366 | 331 | } else { |
— | — | @@ -372,11 +337,7 @@ |
373 | 338 | } |
374 | 339 | |
375 | 340 | public function getSize() { |
376 | | - if ($this->m_comparator == SMW_CMP_ANY) { |
377 | | - return 0; |
378 | | - } else { |
379 | | - return 1; |
380 | | - } |
| 341 | + return 1; |
381 | 342 | } |
382 | 343 | |
383 | 344 | } |
— | — | @@ -566,6 +527,95 @@ |
567 | 528 | } |
568 | 529 | |
569 | 530 | /** |
| 531 | + * Description of a set of instances that have an attribute with some value that |
| 532 | + * fits another (sub)description. |
| 533 | + * |
| 534 | + * Corresponds to existential quatification ("some" restriction) on concrete properties |
| 535 | + * in OWL. In conjunctive queries (OWL) and SPARQL (RDF), it is represented by using |
| 536 | + * variables in the object part of such properties. |
| 537 | + */ |
| 538 | +class SMWSomeProperty extends SMWDescription { |
| 539 | + protected $m_description; |
| 540 | + protected $m_property; |
| 541 | + |
| 542 | + public function SMWSomeProperty(Title $property, SMWDescription $description) { |
| 543 | + $this->m_property = $property; |
| 544 | + $this->m_description = $description; |
| 545 | + } |
| 546 | + |
| 547 | + public function getProperty() { |
| 548 | + return $this->m_property; |
| 549 | + } |
| 550 | + |
| 551 | + public function getDescription() { |
| 552 | + return $this->m_description; |
| 553 | + } |
| 554 | + |
| 555 | + public function getQueryString() { |
| 556 | + return '[[' . $this->m_property->getText() . ':=' . $this->m_description->getQueryString() . ']]'; |
| 557 | + } |
| 558 | + |
| 559 | + public function isSingleton() { |
| 560 | + return false; |
| 561 | + } |
| 562 | + |
| 563 | + public function getSize() { |
| 564 | + return 1+$this->getDescription()->getSize(); |
| 565 | + } |
| 566 | + |
| 567 | + public function getDepth() { |
| 568 | + return 1+$this->getDescription()->getDepth(); |
| 569 | + } |
| 570 | + |
| 571 | + public function prune(&$maxsize, &$maxdepth, &$log) { |
| 572 | + if (($maxsize <= 0)||($maxdepth <= 0)) { |
| 573 | + $log[] = $this->getQueryString(); |
| 574 | + return new SMWThingDescription(); |
| 575 | + } |
| 576 | + $maxsize--; |
| 577 | + $maxdepth--; |
| 578 | + $result = new SMWSomeProperty($this->m_property, $this->m_description->prune($maxsize,$maxdepth,$log)); |
| 579 | + $result->setPrintRequests($this->getPrintRequests()); |
| 580 | + return $result; |
| 581 | + } |
| 582 | +} |
| 583 | + |
| 584 | + |
| 585 | + |
| 586 | + |
| 587 | +/** |
| 588 | + * Description of a class that contains exactly one explicitly given |
| 589 | + * object. |
| 590 | + * |
| 591 | + * Corresponds to nominal concepts in OWL, and can be emulated for querying |
| 592 | + * by using individuals directly in conjunctive queries (OWL) or SPARQL (RDF). |
| 593 | + */ |
| 594 | +class SMWNominalDescription extends SMWDescription { |
| 595 | + protected $m_title; |
| 596 | + |
| 597 | + public function SMWNominalDescription(Title $individual) { |
| 598 | + trigger_error("SMWNominalDescription is deprecated.", E_USER_NOTICE); |
| 599 | + $this->m_title = $individual; |
| 600 | + } |
| 601 | + |
| 602 | + public function getIndividual() { |
| 603 | + return $this->m_title; |
| 604 | + } |
| 605 | + |
| 606 | + public function getQueryString() { |
| 607 | + if ($this->m_title !== NULL) { |
| 608 | + return '[[:' . $this->m_title->getPrefixedText() . ']]'; |
| 609 | + } else { |
| 610 | + return ''; |
| 611 | + } |
| 612 | + } |
| 613 | + |
| 614 | + public function isSingleton() { |
| 615 | + return true; |
| 616 | + } |
| 617 | +} |
| 618 | + |
| 619 | +/** |
570 | 620 | * Description of a set of instances that have a relation to at least one |
571 | 621 | * element that fits another (sub)description. |
572 | 622 | * |
— | — | @@ -578,6 +628,7 @@ |
579 | 629 | protected $m_relation; |
580 | 630 | |
581 | 631 | public function SMWSomeRelation(Title $relation, SMWDescription $description) { |
| 632 | + trigger_error("SMWSomeRelation is deprecated.", E_USER_NOTICE); |
582 | 633 | $this->m_relation = $relation; |
583 | 634 | $this->m_description = $description; |
584 | 635 | } |
— | — | @@ -636,6 +687,7 @@ |
637 | 688 | protected $m_attribute; |
638 | 689 | |
639 | 690 | public function SMWSomeAttribute(Title $attribute, SMWDescription $description) { |
| 691 | + trigger_error("SMWSomeAttribute is deprecated.", E_USER_NOTICE); |
640 | 692 | $this->m_attribute = $attribute; |
641 | 693 | $this->m_description = $description; |
642 | 694 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php |
— | — | @@ -77,14 +77,13 @@ |
78 | 78 | } |
79 | 79 | $db->freeResult($res); |
80 | 80 | } elseif ($specialprop === SMW_SP_SUBPROPERTY_OF) { // subproperty |
81 | | - $sql = 'subject_title=' . $db->addQuotes($subject->getDBKey()) . |
82 | | - 'AND namespace=' . $db->addQuotes($subject->getNamespace()); |
| 81 | + $sql = 'subject_title=' . $db->addQuotes($subject->getDBKey()); |
83 | 82 | $res = $db->select( 'smw_subprops', |
84 | 83 | 'object_title', |
85 | 84 | $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) ); |
86 | 85 | // rewrite results as array |
87 | 86 | while($row = $db->fetchObject($res)) { |
88 | | - $result[] = Title::makeTitle($subject->namespace, $row->object_title); |
| 87 | + $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->object_title); |
89 | 88 | } |
90 | 89 | $db->freeResult($res); |
91 | 90 | } else { // "normal" special property |
— | — | @@ -143,14 +142,13 @@ |
144 | 143 | } |
145 | 144 | $db->freeResult($res); |
146 | 145 | } elseif ($specialprop === SMW_SP_SUBPROPERTY_OF) { // subproperties |
147 | | - $sql = 'object_title=' . $db->addQuotes($value->getDBKey()) . |
148 | | - 'AND namespace=' . $db->addQuotes($value->getNamespace()); |
| 146 | + $sql = 'object_title=' . $db->addQuotes($value->getDBKey()); |
149 | 147 | $res = $db->select( 'smw_subprops', |
150 | 148 | 'subject_title', |
151 | 149 | $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) ); |
152 | 150 | // reqrite results as array |
153 | 151 | while($row = $db->fetchObject($res)) { |
154 | | - $result[] = Title::makeTitle($value->namespace, $row->subject_title); |
| 152 | + $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->subject_title); |
155 | 153 | } |
156 | 154 | $db->freeResult($res); |
157 | 155 | } else { |
— | — | @@ -192,7 +190,7 @@ |
193 | 191 | |
194 | 192 | $id = SMWDataValueFactory::getPropertyObjectTypeID($property); |
195 | 193 | switch ($id) { |
196 | | - case '_txt': // long text attribute |
| 194 | + case '_txt': // long text property |
197 | 195 | $res = $db->select( $db->tableName('smw_longstrings'), |
198 | 196 | 'value_blob', |
199 | 197 | 'subject_id=' . $db->addQuotes($subject->getArticleID()) . |
— | — | @@ -299,7 +297,7 @@ |
300 | 298 | case '_txt': |
301 | 299 | $res = $db->select( $db->tableName('smw_longstrings'), |
302 | 300 | 'DISTINCT subject_id', |
303 | | - $sql, 'SMW::getAllAttributeSubjects', |
| 301 | + $sql, 'SMW::getAllPropertySubjects', |
304 | 302 | $this->getSQLOptions($requestoptions,'subject_title') ); |
305 | 303 | if($db->numRows( $res ) > 0) { |
306 | 304 | while($row = $db->fetchObject($res)) { |
— | — | @@ -313,7 +311,7 @@ |
314 | 312 | $this->getSQLConditions($requestoptions,'subject_title','subject_title'); |
315 | 313 | $res = $db->select( $db->tableName('smw_relations'), |
316 | 314 | 'DISTINCT subject_id', |
317 | | - $sql, 'SMW::getAllAttributeSubjects', |
| 315 | + $sql, 'SMW::getAllPropertySubjects', |
318 | 316 | $this->getSQLOptions($requestoptions,'subject_title') ); |
319 | 317 | while($row = $db->fetchObject($res)) { |
320 | 318 | $result[] = Title::newFromId($row->subject_id); |
— | — | @@ -323,7 +321,7 @@ |
324 | 322 | default: |
325 | 323 | $res = $db->select( $db->tableName('smw_attributes'), |
326 | 324 | 'DISTINCT subject_id', |
327 | | - $sql, 'SMW::getAllAttributeSubjects', |
| 325 | + $sql, 'SMW::getAllPropertySubjects', |
328 | 326 | $this->getSQLOptions($requestoptions,'subject_title') ); |
329 | 327 | if($db->numRows( $res ) > 0) { |
330 | 328 | while($row = $db->fetchObject($res)) { |
— | — | @@ -345,7 +343,7 @@ |
346 | 344 | $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'attribute_title') ); |
347 | 345 | if ($db->numRows( $res ) > 0) { |
348 | 346 | while($row = $db->fetchObject($res)) { |
349 | | - $result[] = Title::newFromText($row->attribute_title, SMW_NS_ATTRIBUTE); |
| 347 | + $result[] = Title::newFromText($row->attribute_title, SMW_NS_PROPERTY); |
350 | 348 | } |
351 | 349 | } |
352 | 350 | $db->freeResult($res); |
— | — | @@ -354,7 +352,7 @@ |
355 | 353 | $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'attribute_title') ); |
356 | 354 | if ($db->numRows( $res ) > 0) { |
357 | 355 | while($row = $db->fetchObject($res)) { |
358 | | - $result[] = Title::newFromText($row->attribute_title, SMW_NS_ATTRIBUTE); |
| 356 | + $result[] = Title::newFromText($row->attribute_title, SMW_NS_PROPERTY); |
359 | 357 | } |
360 | 358 | } |
361 | 359 | $db->freeResult($res); |
— | — | @@ -363,10 +361,10 @@ |
364 | 362 | $this->getSQLConditions($requestoptions,'relation_title','relation_title'); |
365 | 363 | $res = $db->select( $db->tableName('smw_relations'), |
366 | 364 | 'DISTINCT relation_title', |
367 | | - $sql, 'SMW::getOutRelations', $this->getSQLOptions($requestoptions,'relation_title') ); |
| 365 | + $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'relation_title') ); |
368 | 366 | if($db->numRows( $res ) > 0) { |
369 | 367 | while($row = $db->fetchObject($res)) { |
370 | | - $result[] = Title::newFromText($row->relation_title, SMW_NS_ATTRIBUTE); |
| 368 | + $result[] = Title::newFromText($row->relation_title, SMW_NS_PROPERTY); |
371 | 369 | } |
372 | 370 | } |
373 | 371 | $db->freeResult($res); |
— | — | @@ -384,119 +382,15 @@ |
385 | 383 | |
386 | 384 | $res = $db->select( $db->tableName('smw_relations'), |
387 | 385 | 'DISTINCT relation_title', |
388 | | - $sql, 'SMW::getInRelations', $this->getSQLOptions($requestoptions,'relation_title') ); |
| 386 | + $sql, 'SMW::getInProperties', $this->getSQLOptions($requestoptions,'relation_title') ); |
389 | 387 | while($row = $db->fetchObject($res)) { |
390 | | - $result[] = Title::newFromText($row->relation_title, SMW_NS_RELATION); |
| 388 | + $result[] = Title::newFromText($row->relation_title, SMW_NS_PROPERTY); |
391 | 389 | } |
392 | 390 | $db->freeResult($res); |
393 | 391 | } |
394 | 392 | return $result; |
395 | 393 | } |
396 | 394 | |
397 | | -// function getRelationObjects(Title $subject, Title $relation, $requestoptions = NULL) { |
398 | | -// $db =& wfGetDB( DB_SLAVE ); |
399 | | -// $sql = 'subject_id=' . $db->addQuotes($subject->getArticleID()) . |
400 | | -// ' AND relation_title=' . $db->addQuotes($relation->getDBKey()) . |
401 | | -// $this->getSQLConditions($requestoptions,'object_title','object_title'); |
402 | | -// |
403 | | -// $res = $db->select( $db->tableName('smw_relations'), |
404 | | -// 'object_title, object_namespace', |
405 | | -// $sql, 'SMW::getRelationObjects', $this->getSQLOptions($requestoptions,'object_title') ); |
406 | | -// // rewrite result as array |
407 | | -// $result = array(); |
408 | | -// if($db->numRows( $res ) > 0) { |
409 | | -// while($row = $db->fetchObject($res)) { |
410 | | -// $result[] = Title::newFromText($row->object_title, $row->object_namespace); |
411 | | -// } |
412 | | -// } |
413 | | -// $db->freeResult($res); |
414 | | -// |
415 | | -// return $result; |
416 | | -// } |
417 | | - |
418 | | -// function getRelationSubjects(Title $relation, Title $object, $requestoptions = NULL) { |
419 | | -// $db =& wfGetDB( DB_SLAVE ); |
420 | | -// $sql = 'object_namespace=' . $db->addQuotes($object->getNamespace()) . |
421 | | -// ' AND object_title=' . $db->addQuotes($object->getDBKey()) . |
422 | | -// ' AND relation_title=' . $db->addQuotes($relation->getDBKey()) . |
423 | | -// $this->getSQLConditions($requestoptions,'subject_title','subject_title'); |
424 | | -// |
425 | | -// $res = $db->select( $db->tableName('smw_relations'), |
426 | | -// 'DISTINCT subject_id', |
427 | | -// $sql, 'SMW::getRelationSubjects', $this->getSQLOptions($requestoptions,'subject_title') ); |
428 | | -// // rewrite result as array |
429 | | -// $result = array(); |
430 | | -// if($db->numRows( $res ) > 0) { |
431 | | -// while($row = $db->fetchObject($res)) { |
432 | | -// $result[] = Title::newFromID($row->subject_id); |
433 | | -// } |
434 | | -// } |
435 | | -// $db->freeResult($res); |
436 | | -// |
437 | | -// return $result; |
438 | | -// } |
439 | | - |
440 | | -// function getAllRelationSubjects(Title $relation, $requestoptions = NULL) { |
441 | | -// $db =& wfGetDB( DB_SLAVE ); |
442 | | -// $sql = 'relation_title=' . $db->addQuotes($relation->getDBkey()) . |
443 | | -// $this->getSQLConditions($requestoptions,'subject_title','subject_title'); |
444 | | -// |
445 | | -// $res = $db->select( $db->tableName('smw_relations'), |
446 | | -// 'DISTINCT subject_id', |
447 | | -// $sql, 'SMW::getAllRelationSubjects', $this->getSQLOptions($requestoptions,'subject_title') ); |
448 | | -// // rewrite result as array |
449 | | -// $result = array(); |
450 | | -// if($db->numRows( $res ) > 0) { |
451 | | -// while($row = $db->fetchObject($res)) { |
452 | | -// $result[] = Title::newFromId($row->subject_id); |
453 | | -// } |
454 | | -// } |
455 | | -// $db->freeResult($res); |
456 | | -// |
457 | | -// return $result; |
458 | | -// } |
459 | | - |
460 | | -// function getOutRelations(Title $subject, $requestoptions = NULL) { |
461 | | -// $db =& wfGetDB( DB_SLAVE ); |
462 | | -// $sql = 'subject_id=' . $db->addQuotes($subject->getArticleID()) . |
463 | | -// $this->getSQLConditions($requestoptions,'relation_title','relation_title'); |
464 | | -// |
465 | | -// $res = $db->select( $db->tableName('smw_relations'), |
466 | | -// 'DISTINCT relation_title', |
467 | | -// $sql, 'SMW::getOutRelations', $this->getSQLOptions($requestoptions,'relation_title') ); |
468 | | -// // rewrite result as array |
469 | | -// $result = array(); |
470 | | -// if($db->numRows( $res ) > 0) { |
471 | | -// while($row = $db->fetchObject($res)) { |
472 | | -// $result[] = Title::newFromText($row->relation_title, SMW_NS_RELATION); |
473 | | -// } |
474 | | -// } |
475 | | -// $db->freeResult($res); |
476 | | -// |
477 | | -// return $result; |
478 | | -// } |
479 | | - |
480 | | -// function getInRelations(Title $object, $requestoptions = NULL) { |
481 | | -// $db =& wfGetDB( DB_SLAVE ); |
482 | | -// $sql = 'object_namespace=' . $db->addQuotes($object->getNamespace()) . |
483 | | -// ' AND object_title=' . $db->addQuotes($object->getDBKey()) . |
484 | | -// $this->getSQLConditions($requestoptions,'relation_title','relation_title'); |
485 | | -// |
486 | | -// $res = $db->select( $db->tableName('smw_relations'), |
487 | | -// 'DISTINCT relation_title', |
488 | | -// $sql, 'SMW::getInRelations', $this->getSQLOptions($requestoptions,'relation_title') ); |
489 | | -// // rewrite result as array |
490 | | -// $result = array(); |
491 | | -// if($db->numRows( $res ) > 0) { |
492 | | -// while($row = $db->fetchObject($res)) { |
493 | | -// $result[] = Title::newFromText($row->relation_title, SMW_NS_RELATION); |
494 | | -// } |
495 | | -// } |
496 | | -// $db->freeResult($res); |
497 | | -// |
498 | | -// return $result; |
499 | | -// } |
500 | | - |
501 | 395 | ///// Writing methods ///// |
502 | 396 | |
503 | 397 | function deleteSubject(Title $subject) { |
— | — | @@ -513,9 +407,23 @@ |
514 | 408 | $db->delete('smw_specialprops', |
515 | 409 | array('subject_id' => $subject->getArticleID()), |
516 | 410 | 'SMW::deleteSubject::Specialprops'); |
517 | | - if ( ($subject->getNamespace() == SMW_NS_ATTRIBUTE) || ($subject->getNamespace() == SMW_NS_RELATION) ) { |
| 411 | + $db->delete('smw_nary', |
| 412 | + array('subject_id' => $subject->getArticleID()), |
| 413 | + 'SMW::deleteSubject::NAry'); |
| 414 | + ///FIXME: check there were entries in smw_nary before continuing! |
| 415 | + /// "Affected rows" should be easy to get |
| 416 | + $db->delete('smw_nary_relations', |
| 417 | + array('subject_id' => $subject->getArticleID()), |
| 418 | + 'SMW::deleteSubject::NAryRelations'); |
| 419 | + $db->delete('smw_nary_attributes', |
| 420 | + array('subject_id' => $subject->getArticleID()), |
| 421 | + 'SMW::deleteSubject::NAryAttributes'); |
| 422 | + $db->delete('smw_nary_longstrings', |
| 423 | + array('subject_id' => $subject->getArticleID()), |
| 424 | + 'SMW::deleteSubject::NaryLongstrings'); |
| 425 | + if ( $subject->getNamespace() == SMW_NS_PROPERTY ) { |
518 | 426 | $db->delete('smw_subprops', |
519 | | - array('subject_title' => $subject->getDBKey(), 'namespace' => $subject->getNamespace()), |
| 427 | + array('subject_title' => $subject->getDBKey()), |
520 | 428 | 'SMW::deleteSubject::Subprops'); |
521 | 429 | } |
522 | 430 | } |
— | — | @@ -531,7 +439,13 @@ |
532 | 440 | $up_longstrings = array(); |
533 | 441 | $up_specials = array(); |
534 | 442 | $up_subprops = array(); |
| 443 | + $up_nary = array(); |
| 444 | + $up_nary_relations = array(); |
| 445 | + $up_nary_attributes = array(); |
| 446 | + $up_nary_longstrings = array(); |
535 | 447 | |
| 448 | + $nkey = 0; // "id" for blank node created for naries |
| 449 | + |
536 | 450 | //properties |
537 | 451 | foreach($data->getProperties() as $property) { |
538 | 452 | $propertyValueArray = $data->getPropertyValues($property); |
— | — | @@ -544,7 +458,7 @@ |
545 | 459 | 'subject_title' => $subject->getDBkey(), |
546 | 460 | 'attribute_title' => $property->getDBkey(), |
547 | 461 | 'value_blob' => $value->getXSDValue() ); |
548 | | - } elseif ($value->getTypeID() == '_wpg') { // f.k.a. "Relation" |
| 462 | + } elseif ($value->getTypeID() == '_wpg') { |
549 | 463 | $up_relations[] = |
550 | 464 | array( 'subject_id' => $subject->getArticleID(), |
551 | 465 | 'subject_namespace' => $subject->getNamespace(), |
— | — | @@ -552,6 +466,43 @@ |
553 | 467 | 'relation_title' => $property->getDBkey(), |
554 | 468 | 'object_namespace' => $value->getNamespace(), |
555 | 469 | 'object_title' => $value->getDBkey() ); |
| 470 | + } elseif ($value->getTypeID() == '__nry') { |
| 471 | + $up_nary[] = |
| 472 | + array( 'subject_id' => $subject->getArticleID(), |
| 473 | + 'subject_namespace' => $subject->getNamespace(), |
| 474 | + 'subject_title' => $subject->getDBkey(), |
| 475 | + 'attribute_title' => $property->getDBkey(), |
| 476 | + 'nary_key' => $nkey ); |
| 477 | + $npos = 0; |
| 478 | + foreach ($value->getDVs() as $dv) { |
| 479 | + switch ($dv->getTypeID()) { |
| 480 | + case '_wpg': |
| 481 | + $up_nary_relations[] = |
| 482 | + array( 'subject_id' => $subject->getArticleID(), |
| 483 | + 'nary_key' => $nkey, |
| 484 | + 'nary_pos' => $npos, |
| 485 | + 'object_namespace' => $dv->getNamespace(), |
| 486 | + 'object_title' => $dv->getDBkey() ); |
| 487 | + break; |
| 488 | + case '_txt': |
| 489 | + $up_nary_longstrings[] = |
| 490 | + array( 'subject_id' => $subject->getArticleID(), |
| 491 | + 'nary_key' => $nkey, |
| 492 | + 'nary_pos' => $npos, |
| 493 | + 'value_blob' => $dv->getXSDValue() ); |
| 494 | + break; |
| 495 | + default: |
| 496 | + $up_nary_attributes[] = |
| 497 | + array( 'subject_id' => $subject->getArticleID(), |
| 498 | + 'nary_key' => $nkey, |
| 499 | + 'nary_pos' => $npos, |
| 500 | + 'value_unit' => $dv->getUnit(), |
| 501 | + 'value_xsd' => $dv->getXSDValue(), |
| 502 | + 'value_num' => $dv->getNumericValue() ); |
| 503 | + } |
| 504 | + $npos++; |
| 505 | + } |
| 506 | + $nkey++; |
556 | 507 | } else { |
557 | 508 | $up_attributes[] = |
558 | 509 | array( 'subject_id' => $subject->getArticleID(), |
— | — | @@ -575,16 +526,14 @@ |
576 | 527 | // TODO: filtering here is bad for fully neglected properties (IMPORTED FROM) |
577 | 528 | break; |
578 | 529 | case SMW_SP_SUBPROPERTY_OF: |
579 | | - if ( ($subject->getNamespace() != SMW_NS_RELATION) && |
580 | | - ($subject->getNamespace() != SMW_NS_ATTRIBUTE) ) { |
| 530 | + if ( $subject->getNamespace() != SMW_NS_PROPERTY ) { |
581 | 531 | break; |
582 | 532 | } |
583 | 533 | $valueArray = $data->getSpecialValues($special); |
584 | 534 | foreach($valueArray as $value) { |
585 | | - if ( $subject->getNamespace() == $value->getNamespace()) { |
| 535 | + if ( $value->getNamespace() == SMW_NS_PROPERTY ) { |
586 | 536 | $up_subprops[] = |
587 | 537 | array('subject_title' => $subject->getDBkey(), |
588 | | - 'namespace' => $subject->getNamespace(), |
589 | 538 | 'object_title' => $value->getDBKey()); |
590 | 539 | } |
591 | 540 | } |
— | — | @@ -632,6 +581,18 @@ |
633 | 582 | if (count($up_subprops) > 0) { |
634 | 583 | $db->insert( 'smw_subprops', $up_subprops, 'SMW::updateSubPropData'); |
635 | 584 | } |
| 585 | + if (count($up_nary) > 0) { |
| 586 | + $db->insert( 'smw_nary', $up_nary, 'SMW::updateNAryData'); |
| 587 | + } |
| 588 | + if (count($up_nary_relations) > 0) { |
| 589 | + $db->insert( 'smw_nary_relations', $up_nary_relations, 'SMW::updateNAryRelData'); |
| 590 | + } |
| 591 | + if (count($up_nary_attributes) > 0) { |
| 592 | + $db->insert( 'smw_nary_attributes', $up_nary_attributes, 'SMW::updateNAryAttData'); |
| 593 | + } |
| 594 | + if (count($up_nary_longstrings) > 0) { |
| 595 | + $db->insert( 'smw_nary_longstrings', $up_nary_longstrings, 'SMW::updateNAryLongData'); |
| 596 | + } |
636 | 597 | } |
637 | 598 | |
638 | 599 | function changeTitle(Title $oldtitle, Title $newtitle, $keepid = true) { |
— | — | @@ -646,6 +607,7 @@ |
647 | 608 | // are not the ones from the old article and the new one (in reality, the |
648 | 609 | // $old_title refers to the newly generated redirect article, which does |
649 | 610 | // not have the old id that was stored in the database): |
| 611 | + // TODO: in its current for this is useless and it's incomplete for naries anyway |
650 | 612 | if (!$keepid) { |
651 | 613 | $old_id = $old_title->getArticleID(); |
652 | 614 | $new_id = $new_title->getArticleID(); |
— | — | @@ -661,9 +623,10 @@ |
662 | 624 | $db->update('smw_attributes', $val_array, $cond_array, 'SMW::changeTitle'); |
663 | 625 | $db->update('smw_longstrings', $val_array, $cond_array, 'SMW::changeTitle'); |
664 | 626 | $db->update('smw_specialprops', $val_array, $cond_array, 'SMW::changeTitle'); |
| 627 | + $db->update('smw_nary', $val_array, $cond_array, 'SMW::changeTitle'); |
665 | 628 | |
666 | | - if ( ($oldtitle->getNamespace() == SMW_NS_ATTRIBUTE) || ($oldtitle->getNamespace() == SMW_NS_RELATION) ) { |
667 | | - if ( $oldtitle->getNamespace() == $newtitle->getNamespace() ) { |
| 629 | + if ( $oldtitle->getNamespace() == SMW_NS_PROPERTY ) { |
| 630 | + if ( $newtitle->getNamespace() == SMW_NS_PROPERTY ) { |
668 | 631 | $db->update('smw_subprops', array('subject_title' => $newtitle->getDBkey()), array('subject_title' => $oldtitle->getDBkey()), 'SMW::changeTitle'); |
669 | 632 | } else { |
670 | 633 | $db->delete('smw_subprops', array('subject_title' => $oldtitle->getDBKey()), 'SMW::changeTitle'); |
— | — | @@ -778,13 +741,10 @@ |
779 | 742 | case SMW_PRINT_THIS: |
780 | 743 | $row[] = new SMWResultArray(array($qt), $pr); |
781 | 744 | break; |
782 | | - case SMW_PRINT_RELS: |
783 | | - $row[] = new SMWResultArray($this->getPropertyValues($qt,$pr->getTitle()), $pr); |
784 | | - break; |
785 | 745 | case SMW_PRINT_CATS: |
786 | 746 | $row[] = new SMWResultArray($this->getSpecialValues($qt,SMW_SP_HAS_CATEGORY), $pr); |
787 | 747 | break; |
788 | | - case SMW_PRINT_ATTS: |
| 748 | + case SMW_PRINT_PROP: |
789 | 749 | $row[] = new SMWResultArray($this->getPropertyValues($qt,$pr->getTitle(), NULL, $pr->getOutputFormat()), $pr); |
790 | 750 | break; |
791 | 751 | } |
— | — | @@ -802,7 +762,7 @@ |
803 | 763 | $this->reportProgress("Setting up standard database configuration for SMW ...\n\n",$verbose); |
804 | 764 | $db =& wfGetDB( DB_MASTER ); |
805 | 765 | |
806 | | - extract( $db->tableNames('smw_relations','smw_attributes','smw_longstrings','smw_specialprops','smw_subprops') ); |
| 766 | + extract( $db->tableNames('smw_relations', 'smw_attributes', 'smw_longstrings', 'smw_specialprops', 'smw_subprops', 'smw_nary', 'smw_nary_attributes', 'smw_nary_longstrings', 'smw_nary_relations') ); |
807 | 767 | |
808 | 768 | // create relation table |
809 | 769 | $this->setupTable($smw_relations, |
— | — | @@ -835,6 +795,36 @@ |
836 | 796 | 'value_blob' => 'MEDIUMBLOB'), $db, $verbose); |
837 | 797 | $this->setupIndex($smw_longstrings, array('subject_id','attribute_title'), $db); |
838 | 798 | |
| 799 | + // set up according tables for nary properties |
| 800 | + $this->setupTable($smw_nary, |
| 801 | + array('subject_id' => 'INT(8) UNSIGNED NOT NULL', |
| 802 | + 'subject_namespace' => 'INT(11) NOT NULL', |
| 803 | + 'subject_title' => 'VARCHAR(255) NOT NULL', |
| 804 | + 'attribute_title' => 'VARCHAR(255) NOT NULL', |
| 805 | + 'nary_key' => 'INT(8) UNSIGNED NOT NULL'), $db, $verbose); |
| 806 | + $this->setupIndex($smw_nary, array('subject_id','attribute_title','subject_id,nary_key'), $db); |
| 807 | + $this->setupTable($smw_nary_relations, |
| 808 | + array('subject_id' => 'INT(8) UNSIGNED NOT NULL', |
| 809 | + 'nary_key' => 'INT(8) UNSIGNED NOT NULL', |
| 810 | + 'nary_pos' => 'INT(8) UNSIGNED NOT NULL', |
| 811 | + 'object_namespace' => 'INT(11) NOT NULL', |
| 812 | + 'object_title' => 'VARCHAR(255) NOT NULL'), $db, $verbose); |
| 813 | + $this->setupIndex($smw_nary_relations, array('subject_id,nary_key','object_title,object_namespace'), $db); |
| 814 | + $this->setupTable($smw_nary_attributes, |
| 815 | + array('subject_id' => 'INT(8) UNSIGNED NOT NULL', |
| 816 | + 'nary_key' => 'INT(8) UNSIGNED NOT NULL', |
| 817 | + 'nary_pos' => 'INT(8) UNSIGNED NOT NULL', |
| 818 | + 'value_unit' => 'VARCHAR(63)', |
| 819 | + 'value_xsd' => 'VARCHAR(255) NOT NULL', |
| 820 | + 'value_num' => 'DOUBLE'), $db, $verbose); |
| 821 | + $this->setupIndex($smw_nary_attributes, array('subject_id,nary_key','value_num','value_xsd'), $db); |
| 822 | + $this->setupTable($smw_nary_longstrings, |
| 823 | + array('subject_id' => 'INT(8) UNSIGNED NOT NULL', |
| 824 | + 'nary_key' => 'INT(8) UNSIGNED NOT NULL', |
| 825 | + 'nary_pos' => 'INT(8) UNSIGNED NOT NULL', |
| 826 | + 'value_blob' => 'MEDIUMBLOB'), $db, $verbose); |
| 827 | + $this->setupIndex($smw_nary_longstrings, array('subject_id,nary_key'), $db); |
| 828 | + |
839 | 829 | // create table for special properties |
840 | 830 | $this->setupTable($smw_specialprops, |
841 | 831 | array('subject_id' => 'INT(8) UNSIGNED NOT NULL', |
— | — | @@ -847,9 +837,8 @@ |
848 | 838 | // create table for subproperty relationships |
849 | 839 | $this->setupTable($smw_subprops, |
850 | 840 | array('subject_title' => 'VARCHAR(255) NOT NULL', |
851 | | - 'namespace' => 'INT(11) NOT NULL', // will be obsolete when collapsing attribs+rels |
852 | 841 | 'object_title' => 'VARCHAR(255) NOT NULL'), $db, $verbose); |
853 | | - $this->setupIndex($smw_subprops, array('subject_title', 'namespace', 'object_title'), $db); |
| 842 | + $this->setupIndex($smw_subprops, array('subject_title', 'object_title'), $db); |
854 | 843 | |
855 | 844 | $this->reportProgress("Database initialised successfully.\n",$verbose); |
856 | 845 | return true; |
— | — | @@ -940,8 +929,9 @@ |
941 | 930 | } |
942 | 931 | $res = $db->select($db->tableName('redirect'), 'rd_namespace, rd_title', 'rd_from=' . $id, 'SMW::getRedirectTarget', $options); |
943 | 932 | if ($row = $db->fetchObject($res)) { |
944 | | - $result = Title::newFromText($row->rd_title, $row->rd_namespace); |
945 | | - if ($result !== NULL) { |
| 933 | + $result = SMWDataValueFactory::newTypeIDValue('_wpg'); |
| 934 | + $result->setValues($row->rd_title, $row->rd_namespace); |
| 935 | + if ($result->isValid()) { |
946 | 936 | return $result; |
947 | 937 | } |
948 | 938 | } |
— | — | @@ -1178,9 +1168,8 @@ |
1179 | 1169 | * @param &$where The string of computed WHERE conditions, appended to supplied string. |
1180 | 1170 | * @param $db The database object |
1181 | 1171 | * @param $curtables Array with names of aliases of tables refering to the 'current' element (the one to which the description basically applies). |
1182 | | - * @param $sort True if the subcondition should be used for sorting. This is only meaningful for queries that are below some relation or attribute statement. |
| 1172 | + * @param $sort True if the subcondition should be used for sorting. This is only meaningful for queries that are below some property statement. |
1183 | 1173 | * |
1184 | | - * @TODO: The extra table for long string attributes should be supported for checking existence of such an attribute (but not for comparing values, which is not needed for blobs). |
1185 | 1174 | * @TODO: Maybe there need to be optimisations in certain cases (atomic implementation for common nestings of descriptions?) |
1186 | 1175 | */ |
1187 | 1176 | protected function createSQLQuery(SMWDescription $description, &$from, &$where, &$db, &$curtables, $sort = false) { |
— | — | @@ -1202,59 +1191,57 @@ |
1203 | 1192 | if ($this->addJoin('PAGE', $from, $db, $curtables)) { |
1204 | 1193 | $where .= $curtables['PAGE'] . '.page_namespace=' . $db->addQuotes($description->getNamespace()); |
1205 | 1194 | } |
1206 | | - } elseif ($description instanceof SMWNominalDescription) { |
1207 | | - global $smwgQEqualitySupport; |
1208 | | - if ($smwgQEqualitySupport) { |
1209 | | - $page = $this->getRedirectTarget($description->getIndividual(), $db); |
1210 | | - } else { |
1211 | | - $page = $description->getIndividual(); |
1212 | | - } |
1213 | | - if (array_key_exists('PREVREL', $curtables)) { |
1214 | | - $cond = $curtables['PREVREL'] . '.object_title=' . |
1215 | | - $db->addQuotes($page->getDBKey()) . ' AND ' . |
1216 | | - $curtables['PREVREL'] . '.object_namespace=' . |
1217 | | - $page->getNamespace(); |
1218 | | - if ( $smwgQEqualitySupport && ($this->addJoin('REDIRECT', $from, $db, $curtables)) ) { |
1219 | | - $cond = '(' . $cond . ') OR (' . |
1220 | | - $curtables['REDIRECT'] . '.rd_title=' . |
1221 | | - $db->addQuotes($page->getDBKey()) . ' AND ' . |
1222 | | - $curtables['REDIRECT'] . '.rd_namespace=' . |
1223 | | - $page->getNamespace() . ')'; |
1224 | | - } |
1225 | | - $where .= $cond; |
1226 | | - } elseif ($this->addJoin('PAGE', $from, $db, $curtables)) { |
1227 | | - $where .= $curtables['PAGE'] . '.page_title=' . |
1228 | | - $db->addQuotes($page->getDBKey()) . ' AND ' . |
1229 | | - $curtables['PAGE'] . '.page_namespace=' . |
1230 | | - $page->getNamespace(); |
1231 | | - } |
1232 | 1195 | } elseif ($description instanceof SMWValueDescription) { |
1233 | 1196 | switch ($description->getDatavalue()->getTypeID()) { |
1234 | 1197 | case '_txt': // actually this should not happen; we cannot do anything here |
1235 | 1198 | break; |
| 1199 | + case '_wpg': |
| 1200 | + global $smwgQEqualitySupport; |
| 1201 | + if ($smwgQEqualitySupport) { |
| 1202 | + $page = $this->getRedirectTarget($description->getDatavalue(), $db); |
| 1203 | + } else { |
| 1204 | + $page = $description->getDatavalue(); |
| 1205 | + } |
| 1206 | + if (array_key_exists('PREVREL', $curtables)) { |
| 1207 | + $cond = $curtables['PREVREL'] . '.object_title=' . |
| 1208 | + $db->addQuotes($page->getDBKey()) . ' AND ' . |
| 1209 | + $curtables['PREVREL'] . '.object_namespace=' . |
| 1210 | + $page->getNamespace(); |
| 1211 | + if ( $smwgQEqualitySupport && ($this->addJoin('REDIRECT', $from, $db, $curtables)) ) { |
| 1212 | + $cond = '(' . $cond . ') OR (' . |
| 1213 | + $curtables['REDIRECT'] . '.rd_title=' . |
| 1214 | + $db->addQuotes($page->getDBKey()) . ' AND ' . |
| 1215 | + $curtables['REDIRECT'] . '.rd_namespace=' . |
| 1216 | + $page->getNamespace() . ')'; |
| 1217 | + } |
| 1218 | + $where .= $cond; |
| 1219 | + } elseif ($this->addJoin('PAGE', $from, $db, $curtables)) { |
| 1220 | + $where .= $curtables['PAGE'] . '.page_title=' . |
| 1221 | + $db->addQuotes($page->getDBKey()) . ' AND ' . |
| 1222 | + $curtables['PAGE'] . '.page_namespace=' . |
| 1223 | + $page->getNamespace(); |
| 1224 | + } |
| 1225 | + break; |
1236 | 1226 | default: |
1237 | 1227 | if ( $this->addJoin('ATTS', $from, $db, $curtables) ) { |
1238 | 1228 | switch ($description->getComparator()) { |
1239 | | - case SMW_CMP_EQ: $op = '='; break; |
1240 | 1229 | case SMW_CMP_LEQ: $op = '<='; break; |
1241 | 1230 | case SMW_CMP_GEQ: $op = '>='; break; |
1242 | 1231 | case SMW_CMP_NEQ: $op = '!='; break; |
1243 | | - case SMW_CMP_ANY: default: $op = NULL; break; |
| 1232 | + case SMW_CMP_EQ: default: $op = '='; break; |
1244 | 1233 | } |
1245 | | - if ($op !== NULL) { |
1246 | | - if ($description->getDatavalue()->isNumeric()) { |
1247 | | - $valuefield = 'value_num'; |
1248 | | - $value = $description->getDatavalue()->getNumericValue(); |
1249 | | - } else { |
1250 | | - $valuefield = 'value_xsd'; |
1251 | | - $value = $description->getDatavalue()->getXSDValue(); |
1252 | | - } |
1253 | | - ///TODO: implement check for unit |
1254 | | - $where .= $curtables['ATTS'] . '.' . $valuefield . $op . $db->addQuotes($value); |
1255 | | - if ($sort != '') { |
1256 | | - $this->m_sortfield = $curtables['ATTS'] . '.' . $valuefield; |
1257 | | - } |
| 1234 | + if ($description->getDatavalue()->isNumeric()) { |
| 1235 | + $valuefield = 'value_num'; |
| 1236 | + $value = $description->getDatavalue()->getNumericValue(); |
| 1237 | + } else { |
| 1238 | + $valuefield = 'value_xsd'; |
| 1239 | + $value = $description->getDatavalue()->getXSDValue(); |
1258 | 1240 | } |
| 1241 | + ///TODO: implement check for unit |
| 1242 | + $where .= $curtables['ATTS'] . '.' . $valuefield . $op . $db->addQuotes($value); |
| 1243 | + if ($sort != '') { |
| 1244 | + $this->m_sortfield = $curtables['ATTS'] . '.' . $valuefield; |
| 1245 | + } |
1259 | 1246 | } |
1260 | 1247 | } |
1261 | 1248 | } elseif ($description instanceof SMWConjunction) { |
— | — | @@ -1289,46 +1276,42 @@ |
1290 | 1277 | $subwhere = ''; |
1291 | 1278 | } |
1292 | 1279 | } |
1293 | | - } elseif ($description instanceof SMWSomeRelation) { |
1294 | | - if ($this->addJoin('RELS', $from, $db, $curtables)) { |
1295 | | - global $smwgQSubpropertyDepth; |
1296 | | - if ($smwgQSubpropertyDepth > 0) { |
1297 | | - $pt = $this->getPropertyTable($description->getRelation()->getDBKey(), $db); |
1298 | | - $from = '`' . $pt . '`, ' . $from; |
1299 | | - $where = "$pt.title=" . $curtables['RELS'] . '.relation_title'; |
1300 | | - } else { |
1301 | | - $where .= $curtables['RELS'] . '.relation_title=' . |
1302 | | - $db->addQuotes($description->getRelation()->getDBKey()); |
1303 | | - } |
1304 | | - $nexttables = array( 'PREVREL' => $curtables['RELS'] ); |
1305 | | - $this->createSQLQuery($description->getDescription(), $from, $subwhere, $db, $nexttables, ($this->m_sortkey == $description->getRelation()->getDBKey()) ); |
1306 | | - if ( $subwhere != '') { |
1307 | | - $where .= ' AND (' . $subwhere . ')'; |
1308 | | - } |
1309 | | - } |
1310 | | - } elseif ($description instanceof SMWSomeAttribute) { |
1311 | | - $id = SMWDataValueFactory::getPropertyObjectTypeID($description->getAttribute()); |
| 1280 | + } elseif ($description instanceof SMWSomeProperty) { |
| 1281 | + $id = SMWDataValueFactory::getPropertyObjectTypeID($description->getProperty()); |
1312 | 1282 | switch ($id) { |
| 1283 | + case '_wpg': |
| 1284 | + $table = 'RELS'; |
| 1285 | + $pcolumn = 'relation_title'; |
| 1286 | + $sub = true; //no recursion: we do not support further conditions on text-type values |
| 1287 | + break; |
1313 | 1288 | case '_txt': |
1314 | 1289 | $table = 'TEXT'; |
| 1290 | + $pcolumn = 'attribute_title'; |
1315 | 1291 | $sub = false; //no recursion: we do not support further conditions on text-type values |
1316 | 1292 | break; |
1317 | 1293 | default: |
1318 | 1294 | $table = 'ATTS'; |
| 1295 | + $pcolumn = 'attribute_title'; |
1319 | 1296 | $sub = true; |
1320 | 1297 | } |
1321 | 1298 | if ($this->addJoin($table, $from, $db, $curtables)) { |
1322 | 1299 | global $smwgQSubpropertyDepth; |
1323 | 1300 | if ($smwgQSubpropertyDepth > 0) { |
1324 | | - $pt = $this->getPropertyTable($description->getAttribute()->getDBKey(), $db); |
| 1301 | + $pt = $this->getPropertyTable($description->getProperty()->getDBKey(), $db); |
1325 | 1302 | $from = '`' . $pt . '`, ' . $from; |
1326 | | - $where = "$pt.title=" . $curtables[$table] . '.attribute_title'; |
| 1303 | + $where = "$pt.title=" . $curtables[$table] . '.' . $pcolumn; |
1327 | 1304 | } else { |
1328 | | - $where .= $curtables[$table] . '.attribute_title=' . |
1329 | | - $db->addQuotes($description->getAttribute()->getDBKey()); |
| 1305 | + $where .= $curtables[$table] . '.' . $pcolumn . '=' . |
| 1306 | + $db->addQuotes($description->getProperty()->getDBKey()); |
1330 | 1307 | } |
1331 | 1308 | if ($sub) { |
1332 | | - $this->createSQLQuery($description->getDescription(), $from, $subwhere, $db, $curtables, ($this->m_sortkey == $description->getAttribute()->getDBKey()) ); |
| 1309 | + $nexttables = array(); |
| 1310 | + if ($table == 'RELS') { // move deeper into property graph ... |
| 1311 | + $nexttables['PREVREL'] = $curtables['RELS']; |
| 1312 | + } else { // no other table should be used for the condition! |
| 1313 | + $nexttables[$table] = $curtables[$table]; |
| 1314 | + } |
| 1315 | + $this->createSQLQuery($description->getDescription(), $from, $subwhere, $db, $nexttables, ($this->m_sortkey == $description->getProperty()->getDBKey()) ); |
1333 | 1316 | if ( $subwhere != '') { |
1334 | 1317 | $where .= ' AND (' . $subwhere . ')'; |
1335 | 1318 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php |
— | — | @@ -152,10 +152,10 @@ |
153 | 153 | /** |
154 | 154 | * Get MediaWiki's ID for this value, if any. |
155 | 155 | */ |
156 | | - public function getID() { |
| 156 | + public function getArticleID() { |
157 | 157 | if ($this->m_id === false) { |
158 | 158 | if ($this->getTitle() !== NULL) { |
159 | | - $this->m_id = $this->m_title->getID(); |
| 159 | + $this->m_id = $this->m_title->getArticleID(); |
160 | 160 | } else { |
161 | 161 | $this->m_id = -1; |
162 | 162 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | * Global functions and constants for Semantic MediaWiki. |
5 | 5 | */ |
6 | 6 | |
7 | | -define('SMW_VERSION','0.7'); |
| 7 | +define('SMW_VERSION','1.0prealpha'); |
8 | 8 | |
9 | 9 | // constants for special properties, used for datatype assignment and storage |
10 | 10 | define('SMW_SP_HAS_TYPE',1); |
— | — | @@ -74,7 +74,7 @@ |
75 | 75 | |
76 | 76 | ///// register specials ///// |
77 | 77 | |
78 | | - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchTriple.php'); |
| 78 | + //require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchTriple.php'); // no longer supported |
79 | 79 | require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php'); |
80 | 80 | require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php'); |
81 | 81 | require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php'); |
— | — | @@ -227,8 +227,7 @@ |
228 | 228 | |
229 | 229 | // Support subpages only for talk pages by default |
230 | 230 | $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array( |
231 | | - SMW_NS_RELATION_TALK => true, |
232 | | - SMW_NS_ATTRIBUTE_TALK => true, |
| 231 | + SMW_NS_PROPERTY_TALK => true, |
233 | 232 | SMW_NS_TYPE_TALK => true |
234 | 233 | ); |
235 | 234 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php |
— | — | @@ -362,7 +362,7 @@ |
363 | 363 | |
364 | 364 | if ( !$eventline && ($this->m_tlstart == '') ) { // seek defaults |
365 | 365 | foreach ($res->getPrintRequests() as $pr) { |
366 | | - if ( ($pr->getMode() == SMW_PRINT_ATTS) && ($pr->getTypeID() == 'datetime') ) { |
| 366 | + if ( ($pr->getMode() == SMW_PRINT_PROP) && ($pr->getTypeID() == 'datetime') ) { |
367 | 367 | if ( ($this->m_tlend == '') && ($this->m_tlstart != '') && |
368 | 368 | ($this->m_tlstart != $pr->getTitle()->getText()) ) { |
369 | 369 | $this->m_tlend = $pr->getTitle()->getText(); |
— | — | @@ -423,7 +423,7 @@ |
424 | 424 | $header = $pr->getHTMLText($this->mLinker) . ' '; |
425 | 425 | } |
426 | 426 | // is this a start date? |
427 | | - if ( ($pr->getMode() == SMW_PRINT_ATTS) && |
| 427 | + if ( ($pr->getMode() == SMW_PRINT_PROP) && |
428 | 428 | ($pr->getTitle()->getText() == $this->m_tlstart) ) { |
429 | 429 | //FIXME: Timeline scripts should support XSD format explicitly. They |
430 | 430 | //currently seem to implement iso8601 which deviates from XSD in cases. |
— | — | @@ -433,7 +433,7 @@ |
434 | 434 | $hastime = true; |
435 | 435 | } |
436 | 436 | // is this the end date? |
437 | | - if ( ($pr->getMode() == SMW_PRINT_ATTS) && |
| 437 | + if ( ($pr->getMode() == SMW_PRINT_PROP) && |
438 | 438 | ($pr->getTitle()->getText() == $this->m_tlend) ) { |
439 | 439 | //NOTE: We can assume $object to be an SMWDataValue in this case. |
440 | 440 | $curmeta .= '<span class="smwtlend">' . $object->getXSDValue() . '</span>'; |
— | — | @@ -456,7 +456,7 @@ |
457 | 457 | $curdata .= $header . $objectlabel; |
458 | 458 | $output = true; |
459 | 459 | } |
460 | | - if ($eventline && ($pr->getMode() == SMW_PRINT_ATTS) && ($pr->getTypeID() == 'datetime') && ('' != $pr->getLabel()) && ($pr->getTitle()->getText() != $this->m_tlstart) && ($pr->getTitle()->getText() != $this->m_tlend) ) { |
| 460 | + if ($eventline && ($pr->getMode() == SMW_PRINT_PROP) && ($pr->getTypeID() == 'datetime') && ('' != $pr->getLabel()) && ($pr->getTitle()->getText() != $this->m_tlstart) && ($pr->getTitle()->getText() != $this->m_tlend) ) { |
461 | 461 | $events[] = array($object->getXSDValue(), $pr->getLabel(), $object->getNumericValue()); |
462 | 462 | } |
463 | 463 | $first_value = false; |
— | — | @@ -644,8 +644,7 @@ |
645 | 645 | while ( $row = $res->getNext() ) { |
646 | 646 | $first_col = true; |
647 | 647 | foreach ($row as $field) { |
648 | | - if ( ($field->getPrintRequest()->getMode() == SMW_PRINT_RELS) || |
649 | | - ($field->getPrintRequest()->getMode() == SMW_PRINT_THIS) ) { // ensure that we deal with titles |
| 648 | + if ( $field->getPrintRequest()->getTypeID() == '_wpg' ) { // ensure that we deal with title-likes |
650 | 649 | while ( ($object = $field->getNextObject()) !== false ) { |
651 | 650 | $result .= $embstart; |
652 | 651 | // create text version (this will improve with the unified datavalue framework) ... |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php |
— | — | @@ -196,6 +196,20 @@ |
197 | 197 | } |
198 | 198 | |
199 | 199 | /** |
| 200 | + * Quickly get the type value of some property without necessarily making another datavalue. |
| 201 | + * FIXME not efficient |
| 202 | + */ |
| 203 | + static public function getPropertyObjectTypeValue(Title $property) { |
| 204 | + $propertyname = $property->getText(); |
| 205 | + SMWDataValueFactory::newPropertyObjectValue($property); |
| 206 | + if (array_key_exists($propertyname, SMWDataValueFactory::$m_typelabels)) { |
| 207 | + return SMWDataValueFactory::$m_typelabels[$propertyname]; |
| 208 | + } else { // no type found |
| 209 | + return NULL; |
| 210 | + } |
| 211 | + } |
| 212 | + |
| 213 | + /** |
200 | 214 | * Create a value from a user-supplied string for which a type handler is known |
201 | 215 | * If no value is given, an empty container is created, the value of which |
202 | 216 | * can be set later on. |
— | — | @@ -226,6 +240,7 @@ |
227 | 241 | return SMWDataValueFactory::newPropertyObjectValue($property, $value, $caption); |
228 | 242 | } |
229 | 243 | |
| 244 | + |
230 | 245 | /** |
231 | 246 | * Register a new SMWDataValue class for dealing with some type. Will be included and |
232 | 247 | * instantiated dynamically if needed. |
— | — | @@ -239,6 +254,7 @@ |
240 | 255 | /// NOTE: the type constants are registered to translated labels in SMW_TypeValue.php. |
241 | 256 | /// However, types that are not available to users can also have ids for being registered here, but |
242 | 257 | /// these ids should start with two underscores. |
| 258 | +SMWDataValueFactory::registerDataValueClass('_txt','String','SMWStringValue'); |
243 | 259 | SMWDataValueFactory::registerDataValueClass('_str','String','SMWStringValue'); |
244 | 260 | // SMWDataValueFactory::registerDataValueClass('ema','URI','SMWURIValue'); |
245 | 261 | // SMWDataValueFactory::registerDataValueClass('uri','URI','SMWURIValue'); |
— | — | @@ -248,3 +264,4 @@ |
249 | 265 | |
250 | 266 | SMWDataValueFactory::registerDataValueClass('__typ','Types','SMWTypesValue'); |
251 | 267 | SMWDataValueFactory::registerDataValueClass('__nry','NAry','SMWNAryValue'); |
| 268 | +SMWDataValueFactory::registerDataValueClass('__err','Error','SMWErrorValue'); |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php |
— | — | @@ -12,21 +12,18 @@ |
13 | 13 | private $m_xsdvalue = ''; |
14 | 14 | |
15 | 15 | protected function parseUserValue($value) { |
16 | | - if ($this->m_caption === false) { |
17 | | - $this->m_caption = $value; |
18 | | - } |
19 | 16 | if ($value!='') { |
20 | 17 | $this->m_xsdvalue = smwfXMLContentEncode($value); |
21 | | - // 255 below matches smw_attributes.value_xsd definition in smwfMakeSemanticTables() |
22 | | - if (strlen($this->m_xsdvalue) > 255) { |
23 | | - $this->addError(wfMsgForContent('smw_maxstring', $this->m_xsdvalue)); |
24 | | - $this->m_value = $this->m_xsdvalue; |
25 | | - } else { |
26 | | - $this->m_value = $this->m_xsdvalue; |
| 18 | + if ( (strlen($this->m_xsdvalue) > 255) && ($this->m_typeid !== '_txt') ) { // limit size (for DB indexing) |
| 19 | + $this->addError(wfMsgForContent('smw_maxstring', mb_substr($value, 0, 42) . ' <span class="smwwarning">[…]</span> ' . mb_substr($value, mb_strlen($this->m_xsdvalue) - 42))); |
27 | 20 | } |
| 21 | + $this->m_value = $this->m_xsdvalue; |
28 | 22 | } else { |
29 | 23 | $this->addError(wfMsgForContent('smw_emptystring')); |
30 | 24 | } |
| 25 | + if ($this->m_caption === false) { |
| 26 | + $this->m_caption = $this->m_value; |
| 27 | + } |
31 | 28 | return true; |
32 | 29 | } |
33 | 30 | |
— | — | @@ -45,14 +42,14 @@ |
46 | 43 | } |
47 | 44 | |
48 | 45 | public function getShortHTMLText($linker = NULL) { |
49 | | - return htmlspecialchars($this->getShortWikiText($linker)); |
| 46 | + return $this->getShortWikiText($linker); // should be save (based on xsdvalue) |
50 | 47 | } |
51 | 48 | |
52 | 49 | public function getLongWikiText($linked = NULL) { |
53 | 50 | if (!$this->isValid()) { |
54 | 51 | return $this->getErrorText(); |
55 | 52 | } else { |
56 | | - return $this->m_value; |
| 53 | + return $this->getAbbValue($linked); |
57 | 54 | } |
58 | 55 | } |
59 | 56 | |
— | — | @@ -60,7 +57,7 @@ |
61 | 58 | if (!$this->isValid()) { |
62 | 59 | return $this->getErrorText(); |
63 | 60 | } else { |
64 | | - return htmlspecialchars($this->m_value); |
| 61 | + return $this->getAbbValue($linker); // should be save (based on xsdvalue) |
65 | 62 | } |
66 | 63 | } |
67 | 64 | |
— | — | @@ -88,8 +85,32 @@ |
89 | 86 | return false; |
90 | 87 | } |
91 | 88 | |
| 89 | + public function getInfolinks() { |
| 90 | + if ($this->m_typeid !== '_txt') { |
| 91 | + return SMWDataValue::getInfolinks(); |
| 92 | + } |
| 93 | + return $this->m_infolinks; |
| 94 | + } |
| 95 | + |
92 | 96 | public function exportToRDF($QName, ExportRDF $exporter) { |
93 | 97 | return "\t\t<$QName rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">$this->m_xsdvalue</$QName>\n"; |
94 | 98 | } |
95 | 99 | |
| 100 | + /** |
| 101 | + * Make a possibly shortened printout string for displaying the value. |
| 102 | + */ |
| 103 | + protected function getAbbValue($linked) { |
| 104 | + $len = mb_strlen($this->m_value); |
| 105 | + if ($len > 255) { |
| 106 | + if ( ($linked === NULL)||($linked === false) ) { |
| 107 | + return mb_substr($this->m_value, 0, 42) . ' <span class="smwwarning">…</span> ' . mb_substr($this->m_value, $len - 42); |
| 108 | + } else { |
| 109 | + return mb_substr($this->m_value, 0, 42) . ' <span class="smwttpersist"> … <span class="smwttcontent">' . $this->m_value . '</span></span> ' . mb_substr($this->m_value, $len - 42); |
| 110 | + } |
| 111 | + } else { |
| 112 | + return $this->m_value; |
| 113 | + } |
| 114 | + } |
| 115 | + |
| 116 | + |
96 | 117 | } |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php |
— | — | @@ -119,10 +119,8 @@ |
120 | 120 | NS_HELP_TALK => false, |
121 | 121 | NS_CATEGORY => true, |
122 | 122 | NS_CATEGORY_TALK => false, |
123 | | - SMW_NS_RELATION => true, |
124 | | - SMW_NS_RELATION_TALK => false, |
125 | | - SMW_NS_ATTRIBUTE => true, |
126 | | - SMW_NS_ATTRIBUTE_TALK => false, |
| 123 | + SMW_NS_PROPERTY => true, |
| 124 | + SMW_NS_PROPERTY_TALK => false, |
127 | 125 | SMW_NS_TYPE => true, |
128 | 126 | SMW_NS_TYPE_TALK => false |
129 | 127 | ); |