r24144 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24143‎ | r24144 | r24145 >
Date:06:18, 16 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Bulk update. Further integration of Attribute/Relation into Property. First storage functions for nary
properties. Many fixes.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/maintenance/SMW_dumpRDF.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchTriple.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_refreshData.php
@@ -77,7 +77,7 @@
7878 $doit = false;
7979 if (($categories) && ($ns == NS_CATEGORY))
8080 $doit = true;
81 - if (($properties) && (($ns == SMW_NS_RELATION) || ($ns == SMW_NS_ATTRIBUTE)))
 81+ if (($properties) && ($ns == SMW_NS_PROPERTY))
8282 $doit = true;
8383 if (($types) && ($ns == SMW_NS_TYPE))
8484 $doit = true;
Index: trunk/extensions/SemanticMediaWiki/maintenance/SMW_dumpRDF.php
@@ -7,10 +7,9 @@
88 * -o <filename> output file, stdout is used if omitted;
99 * file output is generally better and strongly recommended for large wikis
1010 * --categories only do categories
11 - * --relations only do relations
12 - * --attributes only do attributes
 11+ * --properties only do properties
1312 * --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
1514 */
1615
1716 $optionsWithArgs = array( 'o' ); // -o <output file>
@@ -26,10 +25,8 @@
2726
2827 if ( $options['categories'] ) {
2928 $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;
3431 } elseif ( $options['types'] ) {
3532 $export_ns = SMW_NS_TYPE;
3633 } elseif ( $options['individuals'] ) {
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByProperty.php
@@ -73,14 +73,14 @@
7474
7575 // prepare navigation bar
7676 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>';
7878 else
7979 $navigation = wfMsg('smw_result_prev');
8080
8181 $navigation .= '&nbsp;&nbsp;&nbsp;&nbsp; <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '&ndash; ' . ($offset + min($count, $limit)) . '</b>&nbsp;&nbsp;&nbsp;&nbsp;';
8282
8383 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>';
8585 } else {
8686 $navigation .= wfMsg('smw_result_next');
8787 }
@@ -98,7 +98,7 @@
9999 $max = true;
100100 }
101101 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>';
103103 } else {
104104 $navigation .= '<b>' . $l . '</b>';
105105 }
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchTriple.php
@@ -112,162 +112,6 @@
113113
114114 return $form;
115115 }
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 .= ' &nbsp;&nbsp;' . $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 - }
272116 }
273117
274118
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -44,7 +44,7 @@
4545
4646 $vsep = '<div class="smwhr"><hr /></div>';
4747
48 - if (($article->isValid()) && ('' !== $articletext)) { // legal article given
 48+ if ($article->isValid()) {
4949 $options = new SMWRequestOptions();
5050 $atts = &smwfGetStore()->getProperties($article->getTitle(), $options);
5151 $cats = &smwfGetStore()->getSpecialValues($article->getTitle(), SMW_SP_HAS_CATEGORY, $options);
@@ -125,7 +125,7 @@
126126 $html .= $skin->makeKnownLinkObj($subject, smwfT($subject, TRUE)) . '&nbsp;' . $subjectlink->getHTML($skin);
127127 if ($innercount<$subjectcount) $html .= ", \n";
128128 } 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";
130130 }
131131 }
132132 // replace the last two whitespaces in the relation name with
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialPageProperty.php
@@ -43,13 +43,8 @@
4444 }
4545 $subject = Title::newFromText( $from );
4646 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 );
4948 if (NULL != $relation) {
50 - if (!$relation->exists()) {
51 - $relation = Title::newFromText( $type, SMW_NS_RELATION );
52 - $att = FALSE;
53 - }
5449 $type = $relation->getText();
5550 } else {
5651 $type = '';
@@ -70,10 +65,7 @@
7166 $options->limit = $limit+1;
7267 $options->offset = $offset;
7368 // 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);
7870
7971 // prepare navigation bar
8072 if ($offset > 0)
@@ -95,12 +87,12 @@
9688 } else {
9789 $html .= "<ul>\n";
9890 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') {
10293 $browselink = SMWInfolink::newBrowsingLink('+',$result->getPrefixedText());
103 - $html .= '<li>' . $skin->makeKnownLinkObj($result) . '&nbsp;&nbsp;' . $browselink->getHTML($skin) . "</li> \n";
 94+ $html .= $browselink->getHTML($skin);
10495 }
 96+ $html .= "</li> \n";
10597 }
10698 $html .= "</ul>\n";
10799 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -401,9 +401,9 @@
402402 } else { // fixed subject, namespace restriction, property query, or subquery
403403 $sep = $this->readChunk('',false); //do not consume hit, "look ahead"
404404 if ($sep == '::') { // relation statement
405 - return $this->getRelationDescription($chunk, $setNS, $label);
 405+ return $this->getPropertyDescription($chunk, $setNS, $label);
406406 } elseif ($sep == ':=') { // attribute statement
407 - return $this->getAttributeDescription($chunk, $setNS, $label);
 407+ return $this->getPropertyDescription($chunk, $setNS, $label);
408408 } else { // Fixed article/namespace restriction. $sep should be ]] or ||
409409 return $this->getArticleDescription($chunk, $setNS, $label);
410410 }
@@ -464,117 +464,300 @@
465465 * suitable description. The "::" is the first chunk on the current
466466 * string.
467467 */
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 [[ ]]
474649 }
475650
476 - $this->readChunk(); // consume seperator "::"
 651+ $innerdesc = NULL;
477652 $continue = true;
 653+ $typeid = SMWDataValueFactory::getPropertyObjectTypeID($property);
478654 while ($continue) {
479655 $chunk = $this->readChunk();
480656 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') ) {
503659 $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false);
504660 } else {
505661 $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false);
506662 }
 663+ $chunk = $this->readChunk();
507664 break;
508665 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();
513676 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);
518736 }
519737 }
520 - $chunk = $this->readChunk();
521738 $continue = ($chunk == '||');
522739 }
523740
524741 if ($innerdesc === NULL) { // make a wildcard search
525 - if ($this->m_defaultns !== NULL) {
 742+ if ( ($this->m_defaultns !== NULL) && ($typeid == '_wpg') ) {
526743 $innerdesc = $this->addDescription($innerdesc, $this->m_defaultns, false);
527744 } else {
528745 $innerdesc = $this->addDescription($innerdesc, new SMWThingDescription(), false);
529746 }
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
531748 }
532 - $result = new SMWSomeRelation($rel,$innerdesc);
 749+ $result = new SMWSomeProperty($property,$innerdesc);
533750
534751 return $this->finishLinkDescription($chunk, false, $result, $setNS, $label);
535752 }
536 -
 753+
 754+
537755 /**
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.
542759 */
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 *
579762 $list = preg_split('/^\*/',$value,2);
580763 if (count($list) == 2) { //hit
581764 $value = '*';
@@ -582,68 +765,34 @@
583766 } else {
584767 $printmodifier = '';
585768 }
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;
638771 }
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+ }
641791 }
642792
643793 /**
644794 * Parse an article description (the part of an inline query that
645795 * 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.
648797 * The first chunk behind the "[[" has already been read and is
649798 * passed as a parameter.
650799 */
@@ -668,9 +817,9 @@
669818 $result = $this->addDescription($result, new SMWNamespaceDescription($idx), false);
670819 }
671820 } 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);
675824 }
676825 }
677826
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -81,7 +81,7 @@
8282 * Add a new error string to the error list. All error string must be wiki and
8383 * html-safe! No further escaping will happen!
8484 */
85 - protected function addError($errorstring) {
 85+ public function addError($errorstring) {
8686 $this->m_errors[] = $errorstring;
8787 }
8888
@@ -227,7 +227,7 @@
228228 * an empty string if no errors happened.
229229 */
230230 public function getErrorText() {
231 - return smwfEncodeMessages($this->m_errors);
 231+ return smwfEncodeMessages($this->m_errors) . '&nbsp;'; // &nbsp; is a hack to get non-empty table rows for better img placement in FF (any maybe elsewhere too); should not hurt
232232 }
233233
234234 /**
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_Error.php
@@ -41,11 +41,11 @@
4242
4343 public function getLongWikiText($linked = NULL) {
4444 //TODO: support linking?
45 - return $this->getErrorText() . '&nbsp;'; // &nbsp; 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();
4646 }
4747
4848 public function getLongHTMLText($linker = NULL) {
49 - return $this->getErrorText() . '&nbsp;'; // &nbsp; 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();
5050 }
5151
5252 public function getXSDValue() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Hooks.php
@@ -12,7 +12,7 @@
1313
1414 /**
1515 * 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
1717 * at the end of the article.
1818 *
1919 * TODO: $strip_state is not used (and must not be used, since it is
@@ -24,7 +24,7 @@
2525
2626 // In the regexp matches below, leading ':' escapes the markup, as
2727 // known for Categories.
28 - // Parse links to extract semantic relations
 28+ // Parse links to extract semantic properties
2929 $semanticLinkPattern = '(\[\[(([^:][^]]*):[=|:])+((?:[^|\[\]]|\[\[[^]]*\]\])*)(\|([^]]*))?\]\])';
3030 $text = preg_replace_callback($semanticLinkPattern, 'smwfParsePropertiesCallback', $text);
3131
@@ -66,7 +66,7 @@
6767
6868 /**
6969 * 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
7171 * could consider creating an object for deferred saving
7272 * as used in other places of MediaWiki.
7373 */
@@ -78,7 +78,7 @@
7979
8080 /**
8181 * This method will be called whenever an article is deleted so that
82 - * semantic relations are cleared appropriately.
 82+ * semantic properties are cleared appropriately.
8383 */
8484 function smwfDeleteHook(&$article, &$user, &$reason) {
8585 smwfGetStore()->deleteSubject($article->getTitle());
@@ -87,7 +87,7 @@
8888
8989 /**
9090 * This method will be called whenever an article is moved so that
91 - * semantic relations are moved accordingly.
 91+ * semantic properties are moved accordingly.
9292 */
9393 function smwfMoveHook(&$old_title, &$new_title, &$user, $pageid, $redirid) {
9494 smwfGetStore()->changeTitle($old_title, $new_title);
@@ -97,14 +97,14 @@
9898 // Special display for certain types of pages
9999
100100 /**
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
102102 */
103103 function smwfShowListPage (&$title, &$article){
104104 global $smwgIP;
105105 if ($title->getNamespace() == SMW_NS_TYPE){
106106 require_once($smwgIP . '/includes/articlepages/SMW_TypePage.php');
107107 $article = new SMWTypePage($title);
108 - } elseif ( ($title->getNamespace() == SMW_NS_RELATION) || ($title->getNamespace() == SMW_NS_ATTRIBUTE) ) {
 108+ } elseif ( $title->getNamespace() == SMW_NS_PROPERTY ) {
109109 require_once($smwgIP . '/includes/articlepages/SMW_PropertyPage.php');
110110 $article = new SMWPropertyPage($title);
111111 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php
@@ -75,8 +75,8 @@
7676 $v = str_replace(' ', '_', $value); //normalize slightly since messages distinguish '_' and ' '
7777 $result = SMWDataValueFactory::newSpecialValue($special,$v,$caption);
7878 $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]]");
8181 } else { // standard processing
8282 $result = SMWDataValueFactory::newSpecialValue($special,$value,$caption);
8383 }
@@ -104,7 +104,8 @@
105105
106106 if ( count($msglines) < 2 ) { //error: no elements for this namespace
107107 /// 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));
109110 if ($smwgStoreActive) {
110111 SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM,$datavalue);
111112 }
@@ -122,14 +123,12 @@
123124 // check whether type matches
124125 switch ($namespace) {
125126 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);
128129 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;
130132 break;
131 - case $wgContLang->getNsText(SMW_NS_RELATION):
132 - $elemtype = SMW_NS_RELATION;
133 - break;
134133 case $wgContLang->getNsText(NS_CATEGORY):
135134 $elemtype = NS_CATEGORY;
136135 break;
@@ -144,13 +143,13 @@
145144 $this_ns = SMWFactbox::$semdata->getSubject()->getNamespace();
146145 $error = NULL;
147146 switch ($elemtype) {
148 - case SMW_NS_ATTRIBUTE: case SMW_NS_RELATION: case NS_CATEGORY:
 147+ case SMW_NS_PROPERTY: case NS_CATEGORY:
149148 if ($this_ns != $elemtype) {
150149 $error = wfMsgForContent('smw_nonright_importtype',$value, $wgContLang->getNsText($elemtype));
151150 }
152151 break;
153152 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)) {
155154 $error = wfMsgForContent('smw_wrong_importtype',$value, $wgContLang->getNsText($this_ns));
156155 }
157156 break;
@@ -159,39 +158,24 @@
160159 }
161160
162161 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);
165164 if ($smwgStoreActive) {
166165 SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM, $datavalue);
167166 }
168167 return $datavalue;
169168 }
170169
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 -
179170 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));
186174 if (NULL !== $datatype) {
187175 SMWFactbox::$semdata->addSpecialValue(SMW_SP_HAS_TYPE,$datatype);
188176 }
189177 }
190 -
191178 // 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);
196180 if ($smwgStoreActive) {
197181 SMWFactbox::$semdata->addSpecialValue(SMW_SP_IMPORTED_FROM, $datavalue);
198182 }
@@ -287,21 +271,14 @@
288272 if (array_key_exists($specialProperty,$specprops)) { // only print specprops with an official name
289273 $specialPropertyName = $specprops[$specialProperty];
290274 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";
306283 }
307284 }
308285 }
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -11,13 +11,11 @@
1212 define('SMW_CMP_LEQ',2); // matches only datavalues that are less or equal than the given value
1313 define('SMW_CMP_GEQ',3); // matches only datavalues that are greater or equal to the given value
1414 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
1615
1716 // print request
1817 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
2220
2321
2422 /**
@@ -64,8 +62,7 @@
6563 }
6664 switch ($this->m_mode) {
6765 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));
7067 case SMW_PRINT_THIS: default: return htmlspecialchars($this->m_label);
7168 }
7269
@@ -80,7 +77,7 @@
8178 } else {
8279 switch ($this->m_mode) {
8380 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:
8582 return '[[' . $this->m_title->getPrefixedText() . '|' . $this->m_label . ']]';
8683 case SMW_PRINT_THIS: default: return $this->m_label;
8784 }
@@ -98,8 +95,11 @@
9996
10097 public function getTypeID() {
10198 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+ }
104104 }
105105 return $this->m_typeid;
106106 }
@@ -285,37 +285,6 @@
286286 }
287287
288288 /**
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 -/**
320289 * Description of one data value, or of a range of data values.
321290 *
322291 * Technically this usually corresponds to unary concrete domain predicates
@@ -323,15 +292,13 @@
324293 * In rare cases where SMW attributes represent object properties, this can
325294 * also be similar to a nominal class. In RDF, concrete domain predicates that
326295 * define ranges (like "greater or equal to") are not directly available.
327 - *
328 - * TODO: value wildcards probably need a different class
329296 */
330297 class SMWValueDescription extends SMWDescription {
331298 protected $m_datavalue;
332299 protected $m_comparator;
333300
334301 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;
336303 $this->m_comparator = $comparator;
337304 }
338305
@@ -346,9 +313,6 @@
347314 public function getQueryString() {
348315 if ($this->m_datavalue !== NULL) {
349316 switch ($this->m_comparator) {
350 - case SMW_CMP_EQ:
351 - $comparator = '';
352 - break;
353317 case SMW_CMP_LEQ:
354318 $comparator = '<';
355319 break;
@@ -358,8 +322,9 @@
359323 case SMW_CMP_NEQ:
360324 $comparator = '!'; // not supported yet?
361325 break;
362 - case SMW_CMP_ANY: default:
363 - return '+';
 326+ default: case SMW_CMP_EQ:
 327+ $comparator = '';
 328+ break;
364329 }
365330 return $comparator . $this->m_datavalue->getWikiValue();
366331 } else {
@@ -372,11 +337,7 @@
373338 }
374339
375340 public function getSize() {
376 - if ($this->m_comparator == SMW_CMP_ANY) {
377 - return 0;
378 - } else {
379 - return 1;
380 - }
 341+ return 1;
381342 }
382343
383344 }
@@ -566,6 +527,95 @@
567528 }
568529
569530 /**
 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+/**
570620 * Description of a set of instances that have a relation to at least one
571621 * element that fits another (sub)description.
572622 *
@@ -578,6 +628,7 @@
579629 protected $m_relation;
580630
581631 public function SMWSomeRelation(Title $relation, SMWDescription $description) {
 632+ trigger_error("SMWSomeRelation is deprecated.", E_USER_NOTICE);
582633 $this->m_relation = $relation;
583634 $this->m_description = $description;
584635 }
@@ -636,6 +687,7 @@
637688 protected $m_attribute;
638689
639690 public function SMWSomeAttribute(Title $attribute, SMWDescription $description) {
 691+ trigger_error("SMWSomeAttribute is deprecated.", E_USER_NOTICE);
640692 $this->m_attribute = $attribute;
641693 $this->m_description = $description;
642694 }
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -77,14 +77,13 @@
7878 }
7979 $db->freeResult($res);
8080 } 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());
8382 $res = $db->select( 'smw_subprops',
8483 'object_title',
8584 $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) );
8685 // rewrite results as array
8786 while($row = $db->fetchObject($res)) {
88 - $result[] = Title::makeTitle($subject->namespace, $row->object_title);
 87+ $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->object_title);
8988 }
9089 $db->freeResult($res);
9190 } else { // "normal" special property
@@ -143,14 +142,13 @@
144143 }
145144 $db->freeResult($res);
146145 } 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());
149147 $res = $db->select( 'smw_subprops',
150148 'subject_title',
151149 $sql, 'SMW::getSpecialValues', $this->getSQLOptions($requestoptions) );
152150 // reqrite results as array
153151 while($row = $db->fetchObject($res)) {
154 - $result[] = Title::makeTitle($value->namespace, $row->subject_title);
 152+ $result[] = Title::makeTitle(SMW_NS_PROPERTY, $row->subject_title);
155153 }
156154 $db->freeResult($res);
157155 } else {
@@ -192,7 +190,7 @@
193191
194192 $id = SMWDataValueFactory::getPropertyObjectTypeID($property);
195193 switch ($id) {
196 - case '_txt': // long text attribute
 194+ case '_txt': // long text property
197195 $res = $db->select( $db->tableName('smw_longstrings'),
198196 'value_blob',
199197 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
@@ -299,7 +297,7 @@
300298 case '_txt':
301299 $res = $db->select( $db->tableName('smw_longstrings'),
302300 'DISTINCT subject_id',
303 - $sql, 'SMW::getAllAttributeSubjects',
 301+ $sql, 'SMW::getAllPropertySubjects',
304302 $this->getSQLOptions($requestoptions,'subject_title') );
305303 if($db->numRows( $res ) > 0) {
306304 while($row = $db->fetchObject($res)) {
@@ -313,7 +311,7 @@
314312 $this->getSQLConditions($requestoptions,'subject_title','subject_title');
315313 $res = $db->select( $db->tableName('smw_relations'),
316314 'DISTINCT subject_id',
317 - $sql, 'SMW::getAllAttributeSubjects',
 315+ $sql, 'SMW::getAllPropertySubjects',
318316 $this->getSQLOptions($requestoptions,'subject_title') );
319317 while($row = $db->fetchObject($res)) {
320318 $result[] = Title::newFromId($row->subject_id);
@@ -323,7 +321,7 @@
324322 default:
325323 $res = $db->select( $db->tableName('smw_attributes'),
326324 'DISTINCT subject_id',
327 - $sql, 'SMW::getAllAttributeSubjects',
 325+ $sql, 'SMW::getAllPropertySubjects',
328326 $this->getSQLOptions($requestoptions,'subject_title') );
329327 if($db->numRows( $res ) > 0) {
330328 while($row = $db->fetchObject($res)) {
@@ -345,7 +343,7 @@
346344 $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'attribute_title') );
347345 if ($db->numRows( $res ) > 0) {
348346 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);
350348 }
351349 }
352350 $db->freeResult($res);
@@ -354,7 +352,7 @@
355353 $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'attribute_title') );
356354 if ($db->numRows( $res ) > 0) {
357355 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);
359357 }
360358 }
361359 $db->freeResult($res);
@@ -363,10 +361,10 @@
364362 $this->getSQLConditions($requestoptions,'relation_title','relation_title');
365363 $res = $db->select( $db->tableName('smw_relations'),
366364 'DISTINCT relation_title',
367 - $sql, 'SMW::getOutRelations', $this->getSQLOptions($requestoptions,'relation_title') );
 365+ $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'relation_title') );
368366 if($db->numRows( $res ) > 0) {
369367 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);
371369 }
372370 }
373371 $db->freeResult($res);
@@ -384,119 +382,15 @@
385383
386384 $res = $db->select( $db->tableName('smw_relations'),
387385 'DISTINCT relation_title',
388 - $sql, 'SMW::getInRelations', $this->getSQLOptions($requestoptions,'relation_title') );
 386+ $sql, 'SMW::getInProperties', $this->getSQLOptions($requestoptions,'relation_title') );
389387 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);
391389 }
392390 $db->freeResult($res);
393391 }
394392 return $result;
395393 }
396394
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 -
501395 ///// Writing methods /////
502396
503397 function deleteSubject(Title $subject) {
@@ -513,9 +407,23 @@
514408 $db->delete('smw_specialprops',
515409 array('subject_id' => $subject->getArticleID()),
516410 '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 ) {
518426 $db->delete('smw_subprops',
519 - array('subject_title' => $subject->getDBKey(), 'namespace' => $subject->getNamespace()),
 427+ array('subject_title' => $subject->getDBKey()),
520428 'SMW::deleteSubject::Subprops');
521429 }
522430 }
@@ -531,7 +439,13 @@
532440 $up_longstrings = array();
533441 $up_specials = array();
534442 $up_subprops = array();
 443+ $up_nary = array();
 444+ $up_nary_relations = array();
 445+ $up_nary_attributes = array();
 446+ $up_nary_longstrings = array();
535447
 448+ $nkey = 0; // "id" for blank node created for naries
 449+
536450 //properties
537451 foreach($data->getProperties() as $property) {
538452 $propertyValueArray = $data->getPropertyValues($property);
@@ -544,7 +458,7 @@
545459 'subject_title' => $subject->getDBkey(),
546460 'attribute_title' => $property->getDBkey(),
547461 'value_blob' => $value->getXSDValue() );
548 - } elseif ($value->getTypeID() == '_wpg') { // f.k.a. "Relation"
 462+ } elseif ($value->getTypeID() == '_wpg') {
549463 $up_relations[] =
550464 array( 'subject_id' => $subject->getArticleID(),
551465 'subject_namespace' => $subject->getNamespace(),
@@ -552,6 +466,43 @@
553467 'relation_title' => $property->getDBkey(),
554468 'object_namespace' => $value->getNamespace(),
555469 '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++;
556507 } else {
557508 $up_attributes[] =
558509 array( 'subject_id' => $subject->getArticleID(),
@@ -575,16 +526,14 @@
576527 // TODO: filtering here is bad for fully neglected properties (IMPORTED FROM)
577528 break;
578529 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 ) {
581531 break;
582532 }
583533 $valueArray = $data->getSpecialValues($special);
584534 foreach($valueArray as $value) {
585 - if ( $subject->getNamespace() == $value->getNamespace()) {
 535+ if ( $value->getNamespace() == SMW_NS_PROPERTY ) {
586536 $up_subprops[] =
587537 array('subject_title' => $subject->getDBkey(),
588 - 'namespace' => $subject->getNamespace(),
589538 'object_title' => $value->getDBKey());
590539 }
591540 }
@@ -632,6 +581,18 @@
633582 if (count($up_subprops) > 0) {
634583 $db->insert( 'smw_subprops', $up_subprops, 'SMW::updateSubPropData');
635584 }
 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+ }
636597 }
637598
638599 function changeTitle(Title $oldtitle, Title $newtitle, $keepid = true) {
@@ -646,6 +607,7 @@
647608 // are not the ones from the old article and the new one (in reality, the
648609 // $old_title refers to the newly generated redirect article, which does
649610 // 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
650612 if (!$keepid) {
651613 $old_id = $old_title->getArticleID();
652614 $new_id = $new_title->getArticleID();
@@ -661,9 +623,10 @@
662624 $db->update('smw_attributes', $val_array, $cond_array, 'SMW::changeTitle');
663625 $db->update('smw_longstrings', $val_array, $cond_array, 'SMW::changeTitle');
664626 $db->update('smw_specialprops', $val_array, $cond_array, 'SMW::changeTitle');
 627+ $db->update('smw_nary', $val_array, $cond_array, 'SMW::changeTitle');
665628
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 ) {
668631 $db->update('smw_subprops', array('subject_title' => $newtitle->getDBkey()), array('subject_title' => $oldtitle->getDBkey()), 'SMW::changeTitle');
669632 } else {
670633 $db->delete('smw_subprops', array('subject_title' => $oldtitle->getDBKey()), 'SMW::changeTitle');
@@ -778,13 +741,10 @@
779742 case SMW_PRINT_THIS:
780743 $row[] = new SMWResultArray(array($qt), $pr);
781744 break;
782 - case SMW_PRINT_RELS:
783 - $row[] = new SMWResultArray($this->getPropertyValues($qt,$pr->getTitle()), $pr);
784 - break;
785745 case SMW_PRINT_CATS:
786746 $row[] = new SMWResultArray($this->getSpecialValues($qt,SMW_SP_HAS_CATEGORY), $pr);
787747 break;
788 - case SMW_PRINT_ATTS:
 748+ case SMW_PRINT_PROP:
789749 $row[] = new SMWResultArray($this->getPropertyValues($qt,$pr->getTitle(), NULL, $pr->getOutputFormat()), $pr);
790750 break;
791751 }
@@ -802,7 +762,7 @@
803763 $this->reportProgress("Setting up standard database configuration for SMW ...\n\n",$verbose);
804764 $db =& wfGetDB( DB_MASTER );
805765
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') );
807767
808768 // create relation table
809769 $this->setupTable($smw_relations,
@@ -835,6 +795,36 @@
836796 'value_blob' => 'MEDIUMBLOB'), $db, $verbose);
837797 $this->setupIndex($smw_longstrings, array('subject_id','attribute_title'), $db);
838798
 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+
839829 // create table for special properties
840830 $this->setupTable($smw_specialprops,
841831 array('subject_id' => 'INT(8) UNSIGNED NOT NULL',
@@ -847,9 +837,8 @@
848838 // create table for subproperty relationships
849839 $this->setupTable($smw_subprops,
850840 array('subject_title' => 'VARCHAR(255) NOT NULL',
851 - 'namespace' => 'INT(11) NOT NULL', // will be obsolete when collapsing attribs+rels
852841 '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);
854843
855844 $this->reportProgress("Database initialised successfully.\n",$verbose);
856845 return true;
@@ -940,8 +929,9 @@
941930 }
942931 $res = $db->select($db->tableName('redirect'), 'rd_namespace, rd_title', 'rd_from=' . $id, 'SMW::getRedirectTarget', $options);
943932 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()) {
946936 return $result;
947937 }
948938 }
@@ -1178,9 +1168,8 @@
11791169 * @param &$where The string of computed WHERE conditions, appended to supplied string.
11801170 * @param $db The database object
11811171 * @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.
11831173 *
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).
11851174 * @TODO: Maybe there need to be optimisations in certain cases (atomic implementation for common nestings of descriptions?)
11861175 */
11871176 protected function createSQLQuery(SMWDescription $description, &$from, &$where, &$db, &$curtables, $sort = false) {
@@ -1202,59 +1191,57 @@
12031192 if ($this->addJoin('PAGE', $from, $db, $curtables)) {
12041193 $where .= $curtables['PAGE'] . '.page_namespace=' . $db->addQuotes($description->getNamespace());
12051194 }
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 - }
12321195 } elseif ($description instanceof SMWValueDescription) {
12331196 switch ($description->getDatavalue()->getTypeID()) {
12341197 case '_txt': // actually this should not happen; we cannot do anything here
12351198 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;
12361226 default:
12371227 if ( $this->addJoin('ATTS', $from, $db, $curtables) ) {
12381228 switch ($description->getComparator()) {
1239 - case SMW_CMP_EQ: $op = '='; break;
12401229 case SMW_CMP_LEQ: $op = '<='; break;
12411230 case SMW_CMP_GEQ: $op = '>='; break;
12421231 case SMW_CMP_NEQ: $op = '!='; break;
1243 - case SMW_CMP_ANY: default: $op = NULL; break;
 1232+ case SMW_CMP_EQ: default: $op = '='; break;
12441233 }
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();
12581240 }
 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+ }
12591246 }
12601247 }
12611248 } elseif ($description instanceof SMWConjunction) {
@@ -1289,46 +1276,42 @@
12901277 $subwhere = '';
12911278 }
12921279 }
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());
13121282 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;
13131288 case '_txt':
13141289 $table = 'TEXT';
 1290+ $pcolumn = 'attribute_title';
13151291 $sub = false; //no recursion: we do not support further conditions on text-type values
13161292 break;
13171293 default:
13181294 $table = 'ATTS';
 1295+ $pcolumn = 'attribute_title';
13191296 $sub = true;
13201297 }
13211298 if ($this->addJoin($table, $from, $db, $curtables)) {
13221299 global $smwgQSubpropertyDepth;
13231300 if ($smwgQSubpropertyDepth > 0) {
1324 - $pt = $this->getPropertyTable($description->getAttribute()->getDBKey(), $db);
 1301+ $pt = $this->getPropertyTable($description->getProperty()->getDBKey(), $db);
13251302 $from = '`' . $pt . '`, ' . $from;
1326 - $where = "$pt.title=" . $curtables[$table] . '.attribute_title';
 1303+ $where = "$pt.title=" . $curtables[$table] . '.' . $pcolumn;
13271304 } else {
1328 - $where .= $curtables[$table] . '.attribute_title=' .
1329 - $db->addQuotes($description->getAttribute()->getDBKey());
 1305+ $where .= $curtables[$table] . '.' . $pcolumn . '=' .
 1306+ $db->addQuotes($description->getProperty()->getDBKey());
13301307 }
13311308 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()) );
13331316 if ( $subwhere != '') {
13341317 $where .= ' AND (' . $subwhere . ')';
13351318 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_WikiPage.php
@@ -152,10 +152,10 @@
153153 /**
154154 * Get MediaWiki's ID for this value, if any.
155155 */
156 - public function getID() {
 156+ public function getArticleID() {
157157 if ($this->m_id === false) {
158158 if ($this->getTitle() !== NULL) {
159 - $this->m_id = $this->m_title->getID();
 159+ $this->m_id = $this->m_title->getArticleID();
160160 } else {
161161 $this->m_id = -1;
162162 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -3,7 +3,7 @@
44 * Global functions and constants for Semantic MediaWiki.
55 */
66
7 -define('SMW_VERSION','0.7');
 7+define('SMW_VERSION','1.0prealpha');
88
99 // constants for special properties, used for datatype assignment and storage
1010 define('SMW_SP_HAS_TYPE',1);
@@ -74,7 +74,7 @@
7575
7676 ///// register specials /////
7777
78 - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchTriple.php');
 78+ //require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchTriple.php'); // no longer supported
7979 require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php');
8080 require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php');
8181 require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php');
@@ -227,8 +227,7 @@
228228
229229 // Support subpages only for talk pages by default
230230 $wgNamespacesWithSubpages = $wgNamespacesWithSubpages + array(
231 - SMW_NS_RELATION_TALK => true,
232 - SMW_NS_ATTRIBUTE_TALK => true,
 231+ SMW_NS_PROPERTY_TALK => true,
233232 SMW_NS_TYPE_TALK => true
234233 );
235234
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryPrinters.php
@@ -362,7 +362,7 @@
363363
364364 if ( !$eventline && ($this->m_tlstart == '') ) { // seek defaults
365365 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') ) {
367367 if ( ($this->m_tlend == '') && ($this->m_tlstart != '') &&
368368 ($this->m_tlstart != $pr->getTitle()->getText()) ) {
369369 $this->m_tlend = $pr->getTitle()->getText();
@@ -423,7 +423,7 @@
424424 $header = $pr->getHTMLText($this->mLinker) . ' ';
425425 }
426426 // is this a start date?
427 - if ( ($pr->getMode() == SMW_PRINT_ATTS) &&
 427+ if ( ($pr->getMode() == SMW_PRINT_PROP) &&
428428 ($pr->getTitle()->getText() == $this->m_tlstart) ) {
429429 //FIXME: Timeline scripts should support XSD format explicitly. They
430430 //currently seem to implement iso8601 which deviates from XSD in cases.
@@ -433,7 +433,7 @@
434434 $hastime = true;
435435 }
436436 // is this the end date?
437 - if ( ($pr->getMode() == SMW_PRINT_ATTS) &&
 437+ if ( ($pr->getMode() == SMW_PRINT_PROP) &&
438438 ($pr->getTitle()->getText() == $this->m_tlend) ) {
439439 //NOTE: We can assume $object to be an SMWDataValue in this case.
440440 $curmeta .= '<span class="smwtlend">' . $object->getXSDValue() . '</span>';
@@ -456,7 +456,7 @@
457457 $curdata .= $header . $objectlabel;
458458 $output = true;
459459 }
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) ) {
461461 $events[] = array($object->getXSDValue(), $pr->getLabel(), $object->getNumericValue());
462462 }
463463 $first_value = false;
@@ -644,8 +644,7 @@
645645 while ( $row = $res->getNext() ) {
646646 $first_col = true;
647647 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
650649 while ( ($object = $field->getNextObject()) !== false ) {
651650 $result .= $embstart;
652651 // create text version (this will improve with the unified datavalue framework) ...
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -196,6 +196,20 @@
197197 }
198198
199199 /**
 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+ /**
200214 * Create a value from a user-supplied string for which a type handler is known
201215 * If no value is given, an empty container is created, the value of which
202216 * can be set later on.
@@ -226,6 +240,7 @@
227241 return SMWDataValueFactory::newPropertyObjectValue($property, $value, $caption);
228242 }
229243
 244+
230245 /**
231246 * Register a new SMWDataValue class for dealing with some type. Will be included and
232247 * instantiated dynamically if needed.
@@ -239,6 +254,7 @@
240255 /// NOTE: the type constants are registered to translated labels in SMW_TypeValue.php.
241256 /// However, types that are not available to users can also have ids for being registered here, but
242257 /// these ids should start with two underscores.
 258+SMWDataValueFactory::registerDataValueClass('_txt','String','SMWStringValue');
243259 SMWDataValueFactory::registerDataValueClass('_str','String','SMWStringValue');
244260 // SMWDataValueFactory::registerDataValueClass('ema','URI','SMWURIValue');
245261 // SMWDataValueFactory::registerDataValueClass('uri','URI','SMWURIValue');
@@ -248,3 +264,4 @@
249265
250266 SMWDataValueFactory::registerDataValueClass('__typ','Types','SMWTypesValue');
251267 SMWDataValueFactory::registerDataValueClass('__nry','NAry','SMWNAryValue');
 268+SMWDataValueFactory::registerDataValueClass('__err','Error','SMWErrorValue');
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -12,21 +12,18 @@
1313 private $m_xsdvalue = '';
1414
1515 protected function parseUserValue($value) {
16 - if ($this->m_caption === false) {
17 - $this->m_caption = $value;
18 - }
1916 if ($value!='') {
2017 $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">[&hellip;]</span> ' . mb_substr($value, mb_strlen($this->m_xsdvalue) - 42)));
2720 }
 21+ $this->m_value = $this->m_xsdvalue;
2822 } else {
2923 $this->addError(wfMsgForContent('smw_emptystring'));
3024 }
 25+ if ($this->m_caption === false) {
 26+ $this->m_caption = $this->m_value;
 27+ }
3128 return true;
3229 }
3330
@@ -45,14 +42,14 @@
4643 }
4744
4845 public function getShortHTMLText($linker = NULL) {
49 - return htmlspecialchars($this->getShortWikiText($linker));
 46+ return $this->getShortWikiText($linker); // should be save (based on xsdvalue)
5047 }
5148
5249 public function getLongWikiText($linked = NULL) {
5350 if (!$this->isValid()) {
5451 return $this->getErrorText();
5552 } else {
56 - return $this->m_value;
 53+ return $this->getAbbValue($linked);
5754 }
5855 }
5956
@@ -60,7 +57,7 @@
6158 if (!$this->isValid()) {
6259 return $this->getErrorText();
6360 } else {
64 - return htmlspecialchars($this->m_value);
 61+ return $this->getAbbValue($linker); // should be save (based on xsdvalue)
6562 }
6663 }
6764
@@ -88,8 +85,32 @@
8986 return false;
9087 }
9188
 89+ public function getInfolinks() {
 90+ if ($this->m_typeid !== '_txt') {
 91+ return SMWDataValue::getInfolinks();
 92+ }
 93+ return $this->m_infolinks;
 94+ }
 95+
9296 public function exportToRDF($QName, ExportRDF $exporter) {
9397 return "\t\t<$QName rdf:datatype=\"http://www.w3.org/2001/XMLSchema#string\">$this->m_xsdvalue</$QName>\n";
9498 }
9599
 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">&hellip;</span> ' . mb_substr($this->m_value, $len - 42);
 108+ } else {
 109+ return mb_substr($this->m_value, 0, 42) . ' <span class="smwttpersist"> &hellip; <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+
96117 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Settings.php
@@ -119,10 +119,8 @@
120120 NS_HELP_TALK => false,
121121 NS_CATEGORY => true,
122122 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,
127125 SMW_NS_TYPE => true,
128126 SMW_NS_TYPE_TALK => false
129127 );

Status & tagging log