r24118 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24117‎ | r24118 | r24119 >
Date:11:58, 15 July 2007
Author:mkroetzsch
Status:old
Tags:
Comment:
Started transition from Attribute/Relation to Property. Some things will fail temporarily.
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Text.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.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_Datatype.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_OldDataValue.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByAttribute.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialBrowse.php
@@ -23,7 +23,7 @@
2424 * A class to encapsulate the special page that allows browsing through
2525 * the knowledge structure of a Semantic MediaWiki.
2626 */
27 -class SMW_SpecialBrowse {
 27+class SMW_SpecialBrowse {
2828
2929 static function execute($query = '') {
3030 global $wgRequest, $wgOut, $wgUser,$wgContLang;
@@ -33,7 +33,7 @@
3434 $articletext = $wgRequest->getVal( 'article' );
3535 // no GET parameters? Then try the URL
3636 if ('' == $articletext) { $articletext = $query; }
37 - $article = Title::newFromText( $articletext );
 37+ $article = SMWDataValueFactory::newTypeIDValue('_wpg', $articletext);
3838 $limit = $wgRequest->getVal( 'limit' );
3939 if ('' == $limit) $limit = 10;
4040 $offset = $wgRequest->getVal( 'offset' );
@@ -44,22 +44,21 @@
4545
4646 $vsep = '<div class="smwhr"><hr /></div>';
4747
48 - if ((NULL !== $article) && ('' !== $articletext)) { // legal article given
 48+ if (($article->isValid()) && ('' !== $articletext)) { // legal article given
4949 $options = new SMWRequestOptions();
50 - $outrel = &smwfGetStore()->getOutRelations($article, $options);
51 - $atts = &smwfGetStore()->getAttributes($article, $options);
52 - $cats = &smwfGetStore()->getSpecialValues($article, SMW_SP_HAS_CATEGORY, $options);
53 - $redout = &smwfGetStore()->getSpecialValues($article, SMW_SP_REDIRECTS_TO, $options);
54 - $redin = &smwfGetStore()->getSpecialSubjects(SMW_SP_REDIRECTS_TO, $article, $options);
 50+ $atts = &smwfGetStore()->getProperties($article->getTitle(), $options);
 51+ $cats = &smwfGetStore()->getSpecialValues($article->getTitle(), SMW_SP_HAS_CATEGORY, $options);
 52+ $redout = &smwfGetStore()->getSpecialValues($article->getTitle(), SMW_SP_REDIRECTS_TO, $options);
 53+ $redin = &smwfGetStore()->getSpecialSubjects(SMW_SP_REDIRECTS_TO, $article->getTitle(), $options);
5554 $options->limit = $innerlimit;
56 - $instances = &smwfGetStore()->getSpecialSubjects(SMW_SP_HAS_CATEGORY, $article, $options);
 55+ $instances = &smwfGetStore()->getSpecialSubjects(SMW_SP_HAS_CATEGORY, $article->getTitle(), $options);
5756 $options->limit = $limit+1;
5857 $options->offset = $offset;
5958 $options->sort = TRUE;
6059 // get results (get one more, to see if we have to add a link to more)
61 - $inrel = &smwfGetStore()->getInRelations($article, $options);
 60+ $inprop = &smwfGetStore()->getInProperties($article, $options);
6261
63 - $wgOut->setPagetitle($article->getFullText());
 62+ $wgOut->setPagetitle($article->getLongHTMLText(NULL));
6463
6564 $html .= '<table width="100%"><tr>';
6665 // left column (incoming links)
@@ -73,18 +72,18 @@
7473
7574 $navigation .= '&nbsp;&nbsp;&nbsp;&nbsp;'; // The following shows the numbers of the result.
7675 // Is this better, or not? TODO
77 - // <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '&ndash; ' . ($offset + min(count($inrel), $limit)) . '</b>&nbsp;&nbsp;&nbsp;&nbsp;';
 76+ // <b>' . wfMsg('smw_result_results') . ' ' . ($offset+1) . '&ndash; ' . ($offset + min(count($inprop), $limit)) . '</b>&nbsp;&nbsp;&nbsp;&nbsp;';
7877
79 - if (count($inrel)==($limit+1))
 78+ if (count($inprop)==($limit+1))
8079 $navigation .= ' <a href="' . htmlspecialchars($skin->makeSpecialUrl('Browse', 'offset=' . ($offset+$limit) . '&article=' . urlencode($articletext) )) . '">' . wfMsg('smw_result_next') . '</a>';
8180 else
8281 $navigation .= wfMsg('smw_result_next');
8382
84 - if ((count($inrel) == 0) && (count($instances) == 0) && (count($redin)==0)) {
 83+ if ((count($inprop) == 0) && (count($instances) == 0) && (count($redin)==0)) {
8584 $html .= '&nbsp;';
8685 } else {
8786 // no need to show the navigation bars when there is not enough to navigate
88 - if (($offset>0) || (count($inrel)>$limit)) $html .= $navigation;
 87+ if (($offset>0) || (count($inprop)>$limit)) $html .= $navigation;
8988 $html .= $vsep . "\n";
9089 if ((0==$offset) && (count($instances) > 0)) {
9190 $count = 0;
@@ -95,7 +94,7 @@
9695 $html .= $skin->makeKnownLinkObj( $instance ) . '&nbsp;' . $browselink->getHTML($skin);
9796 if ($count < count( $instances )) $html .= ', ';
9897 } else {
99 - $html .= $skin->makeKnownLinkObj( $article, wfMsg('smw_browse_more') );
 98+ $html .= $skin->makeKnownLinkObj( $article->getTitle(), wfMsg('smw_browse_more') );
10099 }
101100 }
102101 $html .= ' &nbsp;<strong>' . $skin->specialLink( 'Categories' ) . '</strong>';
@@ -112,21 +111,21 @@
113112 $html .= ' &nbsp;<strong>' . $skin->specialLink( 'Listredirects', 'isredirect' ) . '</strong>';
114113 $html .= $vsep . "\n";
115114 }
116 - foreach ($inrel as $result) {
 115+ foreach ($inprop as $result) {
117116 $subjectoptions = new SMWRequestOptions();
118117 $subjectoptions->limit = $innerlimit;
119 - $subjects = &smwfGetStore()->getRelationSubjects($result, $article, $subjectoptions);
 118+ $subjects = &smwfGetStore()->getPropertySubjects($result, $article, $subjectoptions);
120119 $subjectcount = count($subjects);
121120 $more = ($subjectcount == $innerlimit);
122121 $innercount = 0;
123122 foreach ($subjects as $subject) {
124123 $innercount += 1;
125124 if (($innercount < $innerlimit) || !$more) {
126 - $subjectlink = SMWInfolink::newBrowsingLink('+',$subject->getFullText());
 125+ $subjectlink = SMWInfolink::newBrowsingLink('+',$subject->getPrefixedText());
127126 $html .= $skin->makeKnownLinkObj($subject, smwfT($subject, TRUE)) . '&nbsp;' . $subjectlink->getHTML($skin);
128127 if ($innercount<$subjectcount) $html .= ", \n";
129128 } else {
130 - $html .= '<a href="' . $skin->makeSpecialUrl('SearchByRelation', 'type=' . urlencode($result->getFullText()) . '&target=' . urlencode($article->getFullText())) . '">' . wfMsg("smw_browse_more") . "</a>\n";
 129+ $html .= '<a href="' . $skin->makeSpecialUrl('SearchByRelation', 'type=' . urlencode($result->getPrefixedText()) . '&target=' . urlencode($article->getPrefixedText())) . '">' . wfMsg("smw_browse_more") . "</a>\n";
131130 }
132131 }
133132 // replace the last two whitespaces in the relation name with
@@ -135,44 +134,48 @@
136135 // That's why nbsp is written backward.
137136 $html .= ' &nbsp;<strong>' . $skin->makeKnownLinkObj($result, strrev(preg_replace('/[\s]/', ';psbn&', strrev(smwfT($result)), 2) )) . '</strong>' . $vsep . "\n"; // TODO makeLinkObj or makeKnownLinkObj?
138137 }
139 - if (($offset>0) || (count($inrel)>$limit)) $html .= $navigation;
 138+ if (($offset>0) || (count($inprop)>$limit)) $html .= $navigation;
140139 }
141140
142 - $html .= '</td><td style="vertical-align:middle; text-align:center;" width="18%">' . $skin->makeLinkObj($article, smwfT($article, TRUE)) . '</td><td style="vertical-align:middle; text-align:left;" width="40%">';
 141+ $html .= '</td><td style="vertical-align:middle; text-align:center;" width="18%">' . $skin->makeLinkObj($article->getTitle(), smwfT($article->getTitle(), TRUE)) . '</td><td style="vertical-align:middle; text-align:left;" width="40%">';
143142
144 - if ((count($outrel) == 0) && (count($atts) == 0) && (count($cats) == 0) && (count($redout) == 0)) {
 143+ if ((count($atts) == 0) && (count($cats) == 0) && (count($redout) == 0)) {
145144 $html .= '&nbsp;';
146145 } else {
147146 $html .= $vsep . "\n";
148 - foreach ($outrel as $result) {
149 - $objectoptions = new SMWRequestOptions();
150 - $objectoptions->limit = $innerlimit;
151 - $html .= '<strong>' . $skin->makeKnownLinkObj($result, preg_replace('/[\s]/', '&nbsp;', smwfT($result), 2)) . "</strong>&nbsp; \n";// TODO makeLinkObj or makeKnownLinkObj?
152 - $objects = &smwfGetStore()->getRelationObjects($article, $result, $objectoptions);
153 - $objectcount = count($objects);
154 - $count = 0;
155 - foreach ($objects as $object) {
156 - $count += 1;
157 - if ($count == 4) {
158 - $querylink = SMWInfolink::newInverseRelationSearchLink( wfMsg("smw_browse_more"), $article->getPrefixedText(), $result->getText() );
159 - $html .= $querylink->getHTML($skin);
160 - } else {
161 - $searchlink = SMWInfolink::newBrowsingLink('+',$object->getFullText());
162 - $html .= $skin->makeLinkObj($object, smwfT($object, TRUE)) . '&nbsp;' . $searchlink->getHTML($skin);
163 - }
164 - if ($count<$objectcount) $html .= ", ";
165 - }
166 - $html .= $vsep."\n";
167 - }
 147+// foreach ($outrel as $result) {
 148+// $objectoptions = new SMWRequestOptions();
 149+// $objectoptions->limit = $innerlimit;
 150+// $html .= '<strong>' . $skin->makeKnownLinkObj($result, preg_replace('/[\s]/', '&nbsp;', smwfT($result), 2)) . "</strong>&nbsp; \n";// TODO makeLinkObj or makeKnownLinkObj?
 151+// $objects = &smwfGetStore()->getRelationObjects($article, $result, $objectoptions);
 152+// $objectcount = count($objects);
 153+// $count = 0;
 154+// foreach ($objects as $object) {
 155+// $count += 1;
 156+// if ($count == 4) {
 157+// $querylink = SMWInfolink::newInverseRelationSearchLink( wfMsg("smw_browse_more"), $article->getPrefixedText(), $result->getText() );
 158+// $html .= $querylink->getHTML($skin);
 159+// } else {
 160+// $searchlink = SMWInfolink::newBrowsingLink('+',$object->getFullText());
 161+// $html .= $skin->makeLinkObj($object, smwfT($object, TRUE)) . '&nbsp;' . $searchlink->getHTML($skin);
 162+// }
 163+// if ($count<$objectcount) $html .= ", ";
 164+// }
 165+// $html .= $vsep."\n";
 166+// }
168167 foreach ($atts as $att) {
169168 $objectoptions = new SMWRequestOptions();
170169 $html .= '<strong>' . $skin->makeKnownLinkObj($att, preg_replace('/[\s]/', '&nbsp;', smwfT($att), 2)) . "</strong>&nbsp; \n";
171 - $objects = &smwfGetStore()->getAttributeValues($article, $att, $objectoptions);
 170+ $objects = &smwfGetStore()->getPropertyValues($article->getTitle(), $att, $objectoptions);
172171 $objectcount = count($objects);
173172 $count = 0;
174173 foreach ($objects as $object) {
175174 $count += 1;
176175 $html .= $object->getLongHTMLText($skin);
 176+ if ($object->getTypeID() == '_wpg') {
 177+ $searchlink = SMWInfolink::newBrowsingLink('+',$object->getPrefixedText());
 178+ $html .= '&nbsp;' . $searchlink->getHTML($skin);
 179+ }
177180 if ($count<$objectcount) $html .= ", ";
178181 }
179182 $html .= $vsep."\n";
@@ -209,7 +212,7 @@
210213 $html .= '<form name="smwbrowse" action="' . $spectitle->escapeLocalURL() . '" method="get">' . "\n";
211214 $html .= '<input type="hidden" name="title" value="' . $spectitle->getPrefixedText() . '"/>' ;
212215 $html .= wfMsg('smw_browse_article') . "<br />\n";
213 - if (NULL == $article) { $boxtext = $articletext; } else { $boxtext = $article->getFullText(); }
 216+ if (!$article->isValid()) { $boxtext = $articletext; } else { $boxtext = $article->getWikiValue(); }
214217 $html .= '<input type="text" name="article" value="' . htmlspecialchars($boxtext) . '" />' . "\n";
215218 $html .= '<input type="submit" value="' . wfMsg('smw_browse_go') . "\"/>\n</form>\n";
216219
Index: trunk/extensions/SemanticMediaWiki/specials/SearchTriple/SMW_SpecialSearchByAttribute.php
@@ -53,7 +53,7 @@
5454 $html .= wfMsg('smw_sbv_docu') . "\n";
5555 } else {
5656 // Now that we have an attribute, let's figure out the datavalue
57 - $value = SMWDataValueFactory::newAttributeObjectValue( $attribute, $valuestring );
 57+ $value = SMWDataValueFactory::newPropertyObjectValue( $attribute, $valuestring );
5858 if ( $value->isValid() == FALSE ) { // no value understood
5959 $html .= wfMSG('smw_sbv_novalue', $skin->makeLinkObj($attribute, $attribute->getText()));
6060 $valuestring = '';
@@ -65,7 +65,7 @@
6666 $options->limit = $limit+1;
6767 $options->offset = $offset;
6868
69 - $res = &smwfGetStore()->getAttributeSubjects( $attribute, $value, $options );
 69+ $res = &smwfGetStore()->getPropertySubjects( $attribute, $value, $options );
7070 $count = count($res);
7171
7272
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -72,26 +72,20 @@
7373 smwfInitStore();
7474 smwfInitMessages();
7575
76 - /**********************************************/
77 - /***** register specials *****/
78 - /**********************************************/
 76+ ///// register specials /////
7977
80 - //require_once($smwgIP . '/specials/SearchSemantic/SMW_SpecialSearchSemantic.php'); //really not longer functional!
8178 require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchTriple.php');
82 - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByAttribute.php');
83 - require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByRelation.php');
 79+ require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialSearchByProperty.php');
8480 require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialPageProperty.php');
8581 require_once($smwgIP . '/specials/SearchTriple/SMW_SpecialBrowse.php');
8682
8783 require_once($smwgIP . '/specials/URIResolver/SMW_SpecialURIResolver.php');
88 - require_once($smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php'); // coming soon
 84+ require_once($smwgIP . '/specials/ExportRDF/SMW_SpecialExportRDF.php');
8985 require_once($smwgIP . '/specials/SMWAdmin/SMW_SpecialSMWAdmin.php');
9086 //require_once($smwgIP . '/specials/OntologyImport/SMW_SpecialOntologyImport.php'); // broken, TODO: fix or delete
9187 require_once($smwgIP . '/specials/AskSpecial/SMW_SpecialAsk.php');
9288 require_once($smwgIP . '/specials/ExtendedStatistics/SMW_SpecialExtendedStatistics.php');
9389
94 - include_once($smwgIP . '/includes/SMW_QueryProcessor.php');
95 -
9690 require_once($smwgIP . '/specials/Relations/SMW_SpecialRelations.php');
9791 require_once($smwgIP . '/specials/Relations/SMW_SpecialUnusedRelations.php');
9892 require_once($smwgIP . '/specials/Relations/SMW_SpecialWantedRelations.php');
@@ -99,12 +93,11 @@
10094 require_once($smwgIP . '/specials/Relations/SMW_SpecialUnusedAttributes.php');
10195 require_once($smwgIP . '/specials/Relations/SMW_SpecialTypes.php');
10296
103 - /**********************************************/
104 - /***** register hooks *****/
105 - /**********************************************/
 97+ ///// register hooks /////
10698
10799 require_once($smwgIP . '/includes/SMW_Hooks.php');
108100 require_once($smwgIP . '/includes/SMW_RefreshTab.php');
 101+ require_once($smwgIP . '/includes/SMW_QueryProcessor.php');
109102
110103 if ($smwgEnableTemplateSupport===true) {
111104 $wgHooks['InternalParseBeforeLinks'][] = 'smwfParserHook'; //patch required;
@@ -119,9 +112,7 @@
120113 $wgHooks['ParserBeforeStrip'][] = 'smwfRegisterInlineQueries'; // a hook for registering the <ask> parser hook
121114 $wgHooks['ArticleFromTitle'][] = 'smwfShowListPage';
122115
123 - /**********************************************/
124 - /***** credits (see "Special:Version") *****/
125 - /**********************************************/
 116+ ///// credits (see "Special:Version") /////
126117 $wgExtensionCredits['parserhook'][]= array('name'=>'Semantic&nbsp;MediaWiki', 'version'=>SMW_VERSION, 'author'=>"Klaus&nbsp;Lassleben, Markus&nbsp;Kr&ouml;tzsch, Denny&nbsp;Vrandecic, S&nbsp;Page, and others. Maintained by [http://www.aifb.uni-karlsruhe.de/Forschungsgruppen/WBS/english AIFB Karlsruhe].", 'url'=>'http://ontoworld.org/wiki/Semantic_MediaWiki', 'description' => 'Making your wiki more accessible&nbsp;&ndash; for machines \'\'and\'\' humans. [http://ontoworld.org/wiki/Help:Semantics View online documentation.]');
127118
128119 return true;
@@ -219,13 +210,17 @@
220211
221212 smwfInitContentLanguage($wgLanguageCode);
222213
223 - define('SMW_NS_RELATION', $smwgNamespaceIndex);
224 - define('SMW_NS_RELATION_TALK', $smwgNamespaceIndex+1);
225 - define('SMW_NS_ATTRIBUTE', $smwgNamespaceIndex+2);
226 - define('SMW_NS_ATTRIBUTE_TALK', $smwgNamespaceIndex+3);
 214+ define('SMW_NS_PROPERTY', $smwgNamespaceIndex+2);
 215+ define('SMW_NS_PROPERTY_TALK', $smwgNamespaceIndex+3);
227216 define('SMW_NS_TYPE', $smwgNamespaceIndex+4);
228217 define('SMW_NS_TYPE_TALK', $smwgNamespaceIndex+5);
229218
 219+ /// @DEPRECATED
 220+ define('SMW_NS_ATTRIBUTE', $smwgNamespaceIndex+2);
 221+ define('SMW_NS_ATTRIBUTE_TALK', $smwgNamespaceIndex+3);
 222+ define('SMW_NS_RELATION', $smwgNamespaceIndex);
 223+ define('SMW_NS_RELATION_TALK', $smwgNamespaceIndex+1);
 224+
230225 // Register namespace identifiers
231226 if (!is_array($wgExtraNamespaces)) { $wgExtraNamespaces=array(); }
232227 $wgExtraNamespaces = $wgExtraNamespaces + $smwgContLang->getNamespaceArray();
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_SemanticData.php
@@ -45,147 +45,62 @@
4646 $specprops = Array();
4747 }
4848
49 -//// Attributes
 49+//// Properties
5050
5151 /**
52 - * Get the array of all attributes that have stored values.
 52+ * Get the array of all properties that have stored values.
5353 */
54 - public function getAttributes() {
 54+ public function getProperties() {
5555 ksort($this->attribtitles,SORT_STRING);
5656 return $this->attribtitles;
5757 }
5858
5959 /**
60 - * Get the array of all stored values for some attribute.
 60+ * Get the array of all stored values for some property.
6161 */
62 - public function getAttributeValues(Title $attribute) {
63 - if (array_key_exists($attribute->getText(), $this->attribvals)) {
64 - return $this->attribvals[$attribute->getText()];
 62+ public function getPropertyValues(Title $property) {
 63+ if (array_key_exists($property->getText(), $this->attribvals)) {
 64+ return $this->attribvals[$property->getText()];
6565 } else {
66 - return Array();
 66+ return array();
6767 }
6868 }
6969
7070 /**
71 - * Return true if there are any attributes.
 71+ * Return true if there are any properties.
7272 */
73 - public function hasAttributes() {
 73+ public function hasProperties() {
7474 return (count($this->attribtitles) != 0);
7575 }
7676
7777 /**
78 - * Store a value for an attribute identified by its title object. Duplicate
 78+ * Store a value for an property identified by its title object. Duplicate
7979 * value entries are ignored.
8080 */
81 - public function addAttributeValue(Title $attribute, SMWDataValue $value) {
82 - if (!array_key_exists($attribute->getText(), $this->attribvals)) {
83 - $this->attribvals[$attribute->getText()] = Array();
84 - $this->attribtitles[$attribute->getText()] = $attribute;
 81+ public function addPropertyObjectValue(Title $property, SMWDataValue $value) {
 82+ if (!array_key_exists($property->getText(), $this->attribvals)) {
 83+ $this->attribvals[$property->getText()] = Array();
 84+ $this->attribtitles[$property->getText()] = $property;
8585 }
86 - $this->attribvals[$attribute->getText()][$value->getHash()] = $value;
 86+ $this->attribvals[$property->getText()][$value->getHash()] = $value;
8787 }
8888
8989 /**
90 - * Store a value for a given attribute identified by its text label (without
 90+ * Store a value for a given property identified by its text label (without
9191 * namespace prefix). Duplicate value entries are ignored.
9292 */
93 - public function addAttributeTextValue($attributetext, SMWDataValue $value) {
94 - if (array_key_exists($attributetext, $this->attribtitles)) {
95 - $attribute = $this->attribtitles[$attributetext];
 93+ public function addPropertyValue($propertyname, SMWDataValue $value) {
 94+ if (array_key_exists($propertyname, $this->attribtitles)) {
 95+ $property = $this->attribtitles[$propertyname];
9696 } else {
97 - $attribute = Title::newFromText($attributetext, SMW_NS_ATTRIBUTE);
98 - if ($attribute === NULL) { // error, maybe illegal title text
 97+ $property = Title::newFromText($propertyname, SMW_NS_PROPERTY);
 98+ if ($property === NULL) { // error, maybe illegal title text
9999 return;
100100 }
101101 }
102 - $this->addAttributeValue($attribute, $value);
 102+ $this->addPropertyObjectValue($property, $value);
103103 }
104104
105 -//// Relations
106 -
107 - /**
108 - * Get the array of all relations that have stored values.
109 - */
110 - public function getRelations() {
111 - ksort($this->reltitles,SORT_STRING);
112 - return $this->reltitles;
113 - }
114 -
115 - /**
116 - * Get the array of all stored objects for some relation.
117 - */
118 - public function getRelationValues(Title $relation) {
119 - if (array_key_exists($relation->getText(), $this->relobjs)) {
120 - return $this->relobjs[$relation->getText()];
121 - } else {
122 - return array();
123 - }
124 - }
125 -
126 - /**
127 - * Return true if there are any relations.
128 - */
129 - public function hasRelations() {
130 - return (count($this->reltitles) != 0);
131 - }
132 -
133 - /**
134 - * Store a value for a relation identified by its title. Duplicate
135 - * object entries are ignored.
136 - */
137 - public function addRelationValue(Title $relation, SMWDataValue $value) {
138 - if (!array_key_exists($relation->getText(), $this->relobjs)) {
139 - $this->relobjs[$relation->getText()] = Array();
140 - $this->reltitles[$relation->getText()] = $relation;
141 - }
142 - $this->relobjs[$relation->getText()][$value->getHash()] = $value;
143 - }
144 -
145 - /**
146 - * Store a value for a given relation identified by its text label (without
147 - * namespace prefix). Duplicate value entries are ignored.
148 - */
149 - public function addRelationTextvalue($relationtext, SMWDataValue $value) {
150 - if (array_key_exists($relationtext, $this->reltitles)) {
151 - $relation = $this->reltitles[$relationtext];
152 - } else {
153 - $relation = Title::newFromText($relationtext, SMW_NS_RELATION);
154 - if ($relation === NULL) { // error, maybe illegal title text
155 - return;
156 - }
157 - }
158 - $this->addRelationValue($relation, $value);
159 - }
160 -
161 -
162 - /**
163 - * Store an object for a relation identified by its title. Duplicate
164 - * object entries are ignored.
165 - */
166 - public function addRelationObject(Title $relation, Title $object) {
167 - if (!array_key_exists($relation->getText(), $this->relobjs)) {
168 - $this->relobjs[$relation->getText()] = Array();
169 - $this->reltitles[$relation->getText()] = $relation;
170 - }
171 - $this->relobjs[$relation->getText()][$object->getPrefixedText()] = $object;
172 - }
173 -
174 - /**
175 - * Store an object for a given relation identified by its text label (without
176 - * namespace prefix). Duplicate value entries are ignored.
177 - */
178 - public function addRelationTextObject($relationtext, Title $object) {
179 - if (array_key_exists($relationtext, $this->reltitles)) {
180 - $relation = $this->reltitles[$relationtext];
181 - } else {
182 - $relation = Title::newFromText($relationtext, SMW_NS_RELATION);
183 - if ($relation === NULL) { // error, maybe illegal title text
184 - return;
185 - }
186 - }
187 - $this->addRelationObject($relation, $object);
188 - }
189 -
190105 //// Special properties
191106
192107 /**
@@ -233,5 +148,58 @@
234149 }
235150 }
236151
 152+
 153+//// Attributes (deprecated)
 154+
 155+ /**
 156+ * Get the array of all attributes that have stored values.
 157+ */
 158+ public function getAttributes() {
 159+ trigger_error("Function getAttributes is deprecated. Use new property methods.", E_USER_NOTICE);
 160+ return $this->getProperties();
 161+ }
 162+
 163+ /**
 164+ * Get the array of all stored values for some attribute.
 165+ */
 166+ public function getAttributeValues(Title $attribute) {
 167+ trigger_error("Function getAttributeValues is deprecated. Use new property methods.", E_USER_NOTICE);
 168+ return $this->getAttributeValues($attribute);
 169+ }
 170+
 171+ /**
 172+ * Return true if there are any attributes.
 173+ */
 174+ public function hasAttributes() {
 175+ trigger_error("Function hasAttributes is deprecated. Use new property methods.", E_USER_NOTICE);
 176+ return $this->hasProperties();
 177+ }
 178+
 179+//// Relations (deprecated)
 180+
 181+ /**
 182+ * Get the array of all relations that have stored values.
 183+ */
 184+ public function getRelations() {
 185+ trigger_error("Function getRelations is deprecated. Use new property methods.", E_USER_NOTICE);
 186+ return array();
 187+ }
 188+
 189+ /**
 190+ * Get the array of all stored objects for some relation.
 191+ */
 192+ public function getRelationValues(Title $relation) {
 193+ trigger_error("Function getRelationValues is deprecated. Use new property methods.", E_USER_NOTICE);
 194+ return array();
 195+ }
 196+
 197+ /**
 198+ * Return true if there are any relations.
 199+ */
 200+ public function hasRelations() {
 201+ trigger_error("Function hasRelations is deprecated. Use new property methods.", E_USER_NOTICE);
 202+ return false;
 203+ }
 204+
237205 }
238206
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValueFactory.php
@@ -6,16 +6,16 @@
77 require_once($smwgIP . '/includes/SMW_OldDataValue.php');
88
99 /**
10 - * Factory class for creating SMWDataValue objects for supplied types or attributes
 10+ * Factory class for creating SMWDataValue objects for supplied types or properties
1111 * and data values.
1212 *
1313 * The class has two main entry points:
1414 * - newTypeObjectValue
1515 * - newTypeIDValue
16 - * These create new DV objects, possibly with preset user values, captions and attribute names.
17 - * Further methods are used to conveniently create DVs for attributes and special properties:
18 - * - newAttributeValue
19 - * - newAttributeObjectValue
 16+ * These create new DV objects, possibly with preset user values, captions and property names.
 17+ * Further methods are used to conveniently create DVs for properties and special properties:
 18+ * - newPropertyValue
 19+ * - newPropertyObjectValue
2020 * - newSpecialValue
2121 */
2222 class SMWDataValueFactory {
@@ -29,52 +29,52 @@
3030 static private $m_valueclasses = array();
3131
3232 /**
33 - * Cache for type specifications (type datavalues), indexed by attribute name (both without namespace prefix).
 33+ * Cache for type specifications (type datavalues), indexed by property name (both without namespace prefix).
3434 */
3535 static private $m_typelabels = array();
3636
3737 /**
38 - * Create a value from a string supplied by a user for a given attribute.
 38+ * Create a value from a string supplied by a user for a given property.
3939 * If no value is given, an empty container is created, the value of which
4040 * can be set later on.
4141 */
42 - static public function newAttributeValue($attstring, $value=false, $caption=false) {
43 - if(array_key_exists($attstring,SMWDataValueFactory::$m_typelabels)) { // use cache
44 - return SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$attstring], $value, $caption, $attstring);
45 - } // else: find type for attribute:
 42+ static public function newPropertyValue($propertyname, $value=false, $caption=false) {
 43+ if(array_key_exists($propertyname,SMWDataValueFactory::$m_typelabels)) { // use cache
 44+ return SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$propertyname], $value, $caption, $propertyname);
 45+ } // else: find type for property:
4646
47 - $atitle = Title::newFromText($attstring, SMW_NS_ATTRIBUTE);
48 - if ($atitle !== NULL) {
49 - return SMWDataValueFactory::newAttributeObjectValue($atitle,$value,$caption);
 47+ $ptitle = Title::newFromText($propertyname, SMW_NS_PROPERTY);
 48+ if ($ptitle !== NULL) {
 49+ return SMWDataValueFactory::newPropertyObjectValue($ptitle,$value,$caption);
5050 } else {
5151 $type = SMWDataValueFactory::newTypeIDValue('__typ');
5252 $type->setXSDValue('_wpg');
53 - SMWDataValueFactory::$m_typelabels[$attstring] = $type;
54 - return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$attstring);
 53+ SMWDataValueFactory::$m_typelabels[$propertyname] = $type;
 54+ return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$propertyname);
5555 }
5656 }
5757
5858 /**
59 - * Create a value from a string supplied by a user for a given attribute title.
 59+ * Create a value from a string supplied by a user for a given property title.
6060 * If no value is given, an empty container is created, the value of which
6161 * can be set later on.
6262 */
63 - static public function newAttributeObjectValue(Title $att, $value=false, $caption=false) {
64 - $attstring = $att->getText();
65 - if(array_key_exists($attstring,SMWDataValueFactory::$m_typelabels)) { // use cache
66 - return SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$attstring], $value, $caption, $attstring);
67 - } // else: find type for attribute:
 63+ static public function newPropertyObjectValue(Title $property, $value=false, $caption=false) {
 64+ $propertyname = $property->getText();
 65+ if(array_key_exists($propertyname,SMWDataValueFactory::$m_typelabels)) { // use cache
 66+ return SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$propertyname], $value, $caption, $propertyname);
 67+ } // else: find type for property:
6868
69 - $typearray = smwfGetStore()->getSpecialValues($att,SMW_SP_HAS_TYPE);
 69+ $typearray = smwfGetStore()->getSpecialValues($property,SMW_SP_HAS_TYPE);
7070 if (count($typearray)==1) {
71 - SMWDataValueFactory::$m_typelabels[$attstring] = $typearray[0];
72 - $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$attstring], $value, $caption, $attstring);
 71+ SMWDataValueFactory::$m_typelabels[$propertyname] = $typearray[0];
 72+ $result = SMWDataValueFactory::newTypeObjectValue(SMWDataValueFactory::$m_typelabels[$propertyname], $value, $caption, $propertyname);
7373 return $result;
7474 } elseif (count($typearray)==0) {
7575 $type = SMWDataValueFactory::newTypeIDValue('__typ');
7676 $type->setXSDValue('_wpg');
77 - SMWDataValueFactory::$m_typelabels[$attstring] = $type;
78 - return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$attstring);
 77+ SMWDataValueFactory::$m_typelabels[$propertyname] = $type;
 78+ return SMWDataValueFactory::newTypeIDValue('_wpg',$value,$caption,$propertyname);
7979 } else {
8080 return new SMWErrorValue(wfMsgForContent('smw_manytypes'), $value, $caption);
8181 }
@@ -118,11 +118,11 @@
119119 * @param $typevalue datavalue representing the type of the object
120120 * @param $value user value string, or false if unknown
121121 * @param $caption user-defined caption or false if none given
122 - * @param $attstring text name of according attribute, or false (may be relevant for getting further parameters)
 122+ * @param $propertyname text name of according property, or false (may be relevant for getting further parameters)
123123 */
124 - static public function newTypeObjectValue(SMWDataValue $typevalue, $value=false, $caption=false, $attstring=false) {
 124+ static public function newTypeObjectValue(SMWDataValue $typevalue, $value=false, $caption=false, $propertyname=false) {
125125 if (array_key_exists($typevalue->getXSDValue(), SMWDataValueFactory::$m_valueclasses)) {
126 - return SMWDataValueFactory::newTypeIDValue($typevalue->getXSDValue(), $value, $caption, $attstring);
 126+ return SMWDataValueFactory::newTypeIDValue($typevalue->getXSDValue(), $value, $caption, $propertyname);
127127 } else {
128128 if (!$typevalue->isUnary()) { // n-ary type?
129129 $result = SMWDataValueFactory::newTypeIDValue('__nry');
@@ -133,8 +133,8 @@
134134 }
135135 }
136136
137 - if ($attstring != false) {
138 - $result->setAttribute($attstring);
 137+ if ($propertyname != false) {
 138+ $result->setProperty($propertyname);
139139 }
140140 if ($value !== false) {
141141 $result->setUserValue($value,$caption);
@@ -149,9 +149,9 @@
150150 * @param $typeid id string for the given type
151151 * @param $value user value string, or false if unknown
152152 * @param $caption user-defined caption or false if none given
153 - * @param $attstring text name of according attribute, or false (may be relevant for getting further parameters)
 153+ * @param $propertyname text name of according property, or false (may be relevant for getting further parameters)
154154 */
155 - static public function newTypeIDValue($typeid, $value=false, $caption=false, $attstring=false) {
 155+ static public function newTypeIDValue($typeid, $value=false, $caption=false, $propertyname=false) {
156156 if (array_key_exists($typeid, SMWDataValueFactory::$m_valueclasses)) {
157157 $vc = SMWDataValueFactory::$m_valueclasses[$typeid];
158158 // check if class file was already included for this class
@@ -168,11 +168,11 @@
169169 } else {
170170 $typevalue = SMWDataValueFactory::newTypeIDValue('__typ');
171171 $typevalue->setXSDValue($typeid);
172 - return SMWDataValueFactory::newTypeObjectValue($typevalue, $value, $caption, $attstring);
 172+ return SMWDataValueFactory::newTypeObjectValue($typevalue, $value, $caption, $propertyname);
173173 }
174174
175 - if ($attstring != false) {
176 - $result->setAttribute($attstring);
 175+ if ($propertyname != false) {
 176+ $result->setProperty($propertyname);
177177 }
178178 if ($value !== false) {
179179 $result->setUserValue($value,$caption);
@@ -181,14 +181,14 @@
182182 }
183183
184184 /**
185 - * Quickly get the type id of some attribute without necessarily making another datavalue.
 185+ * Quickly get the type id of some property without necessarily making another datavalue.
186186 */
187 - static public function getAttributeObjectTypeID(Title $att) {
188 - $attstring = $att->getText();
189 - if (array_key_exists($attstring, SMWDataValueFactory::$m_typelabels)) {
190 - return SMWDataValueFactory::$m_typelabels[$attstring]->getXSDValue();
 187+ static public function getPropertyObjectTypeID(Title $property) {
 188+ $propertyname = $property->getText();
 189+ if (array_key_exists($propertyname, SMWDataValueFactory::$m_typelabels)) {
 190+ return SMWDataValueFactory::$m_typelabels[$propertyname]->getXSDValue();
191191 } else {
192 - return SMWDataValueFactory::newAttributeObjectValue($att)->getTypeID(); // this also triggers caching
 192+ return SMWDataValueFactory::newPropertyObjectValue($property)->getTypeID(); // this also triggers caching
193193 }
194194 }
195195
@@ -208,6 +208,22 @@
209209 }
210210
211211 /**
 212+ * @DEPRECATED
 213+ */
 214+ static public function newAttributeValue($property, $value=false, $caption=false) {
 215+ trigger_error("Function newAttributeValue is deprecated. Use new property methods.", E_USER_NOTICE);
 216+ return SMWDataValueFactory::newPropertyValue($property, $value, $caption);
 217+ }
 218+
 219+ /**
 220+ * @DEPRECATED
 221+ */
 222+ static public function newAttributeObjectValue(Title $property, $value=false, $caption=false) {
 223+ trigger_error("Function newAttributeObjectValue is deprecated. Use new property methods.", E_USER_NOTICE);
 224+ return SMWDataValueFactory::newPropertyObjectValue($property, $value, $caption);
 225+ }
 226+
 227+ /**
212228 * Register a new SMWDataValue class for dealing with some type. Will be included and
213229 * instantiated dynamically if needed.
214230 */
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_String.php
@@ -23,7 +23,6 @@
2424 $this->m_value = $this->m_xsdvalue;
2525 } else {
2626 $this->m_value = $this->m_xsdvalue;
27 - //$this->m_infolinks[] = SMWInfolink::newAttributeSearchLink('+', $this->m_attribute, $this->m_value);
2827 }
2928 } else {
3029 $this->addError(wfMsgForContent('smw_emptystring'));
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_NAry.php
@@ -69,7 +69,6 @@
7070 $this->m_values[$i] = SMWDataValueFactory::newTypeObjectValue($types[$i], false);
7171 }
7272 }
73 - //$this->m_infolinks[] = SMWInfolink::newAttributeSearchLink('+', $this->m_attribute, $value);
7473 }
7574
7675 protected function parseXSDValue($value, $unit) {
@@ -102,6 +101,7 @@
103102 } else {
104103 // everything specified and passed correctly - set XSDValue of DV containers.
105104 for ($i = 0; $i < sizeof($types); $i++) {
 105+ $this->m_values[$i] = SMWDataValueFactory::newTypeObjectValue($types[$i]);
106106 $this->m_values[$i]->setXSDValue($values[$i], (is_array($unit)? $units[$i] : null));
107107 }
108108 }
@@ -228,10 +228,6 @@
229229 return $hash;
230230 }
231231
232 - public function isValid() {
233 - return $this->isValid;
234 - }
235 -
236232 public function isNumeric() {
237233 return false; // the n-ary is clearly non numeric (n-ary values cannot be ordered by numbers)
238234 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_OldDataValue.php
@@ -108,8 +108,6 @@
109109 // additional information about the value and the context in which it was given
110110 var $type_handler; //type handler for this object
111111 var $infolinks; // an array of additional links provided in long descriptions of the value
112 - var $attribute; // wiki name (without namespace) of the attribute that this value was
113 - // assigned to, or FALSE if no attribute was given.
114112 /**#@-*/
115113
116114 /**
@@ -121,7 +119,6 @@
122120 $this->clear();
123121
124122 $this->type_handler = $type;
125 - $this->attribute = false;
126123 $this->desiredUnits = $desiredUnits;
127124 $this->serviceLinks = false;
128125 }
@@ -196,7 +193,7 @@
197194 * E.g. it is not very user-friendly. -- mak
198195 */
199196 function addQuicksearchLink() {
200 - $this->infolinks[] = SMWInfolink::newAttributeSearchLink('+', $this->attribute, $this->vuser);
 197+ $this->infolinks[] = SMWInfolink::newPropertySearchLink('+', $this->m_property, $this->vuser);
201198 }
202199
203200 /**
@@ -242,14 +239,6 @@
243240 }
244241
245242 /**
246 - * Set the attribute to which this value refers. Used to generate search links.
247 - * The atriubte is given as a simple wiki text title, without namespace prefix.
248 - */
249 - function setAttribute($attribute) {
250 - $this->attribute = $attribute;
251 - }
252 -
253 - /**
254243 * Set an error message for the current datavalue. The message should be plain
255244 * text, possibly with light wiki/html markup. Global styling, especially spans
256245 * enclosing the whole message, are not needed.
@@ -506,8 +495,8 @@
507496 */
508497 function getDesiredUnits() {
509498 // If we don't have a value for this, get it from the attribute.
510 - if ($this->desiredUnits === false && $this->attribute != false) {
511 - $this->desiredUnits = SMWTypeHandlerFactory::getUnitsList($this->attribute);
 499+ if ($this->desiredUnits === false && $this->m_property != false) {
 500+ $this->desiredUnits = SMWTypeHandlerFactory::getUnitsList($this->m_property);
512501 }
513502 if ($this->desiredUnits === false) {
514503 return Array();
@@ -521,8 +510,8 @@
522511 */
523512 function getServiceLinks() {
524513 // If we don't have a value for this, get it from the attribute.
525 - if ($this->serviceLinks === false && $this->attribute != false) {
526 - $this->serviceLinks = SMWTypeHandlerFactory::getServiceLinks($this->attribute);
 514+ if ($this->serviceLinks === false && $this->m_property != false) {
 515+ $this->serviceLinks = SMWTypeHandlerFactory::getServiceLinks($this->m_property);
527516 }
528517 if ($this->serviceLinks === false) {
529518 return Array();
@@ -537,8 +526,8 @@
538527 */
539528 function getPossibleValues() {
540529 // If we don't have a value for this, get it from the attribute.
541 - if ( $this->attribute != false) {
542 - return SMWTypeHandlerFactory::getPossibleValues($this->attribute);
 530+ if ( $this->m_property != false) {
 531+ return SMWTypeHandlerFactory::getPossibleValues($this->m_property);
543532 } else {
544533 return Array();
545534 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_QueryProcessor.php
@@ -603,7 +603,7 @@
604604 }
605605 break;
606606 case '+': // wildcard
607 - $vd = new SMWValueDescription(SMWDataValueFactory::newAttributeObjectValue($att), SMW_CMP_ANY);
 607+ $vd = new SMWValueDescription(SMWDataValueFactory::newPropertyObjectValue($att), SMW_CMP_ANY);
608608 break;
609609 default: // fixed value, possibly with comparator addons
610610 // for now, treat comparators only if placed before whole value:
@@ -627,7 +627,7 @@
628628 }
629629 }
630630 // TODO: needs extension for n-ary values
631 - $dv = SMWDataValueFactory::newAttributeObjectValue($att, $value);
 631+ $dv = SMWDataValueFactory::newPropertyObjectValue($att, $value);
632632 if (!$dv->isValid()) {
633633 $this->m_errors = $this->m_errors + $dv->getErrors();
634634 $vd = new SMWValueDescription($dv, SMW_CMP_ANY);
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DataValue.php
@@ -9,7 +9,7 @@
1010 */
1111 abstract class SMWDataValue {
1212
13 - protected $m_attribute = false; /// The text label of the respective attribute or false if none given
 13+ protected $m_property = false; /// The text label of the respective property or false if none given
1414 protected $m_caption = false; /// The text label to be used for output or false if none given
1515 protected $m_errors = array(); /// Array of error text messages
1616 protected $m_isset = false; /// True if a value was set.
@@ -55,12 +55,12 @@
5656 }
5757
5858 /**
59 - * Set the attribute to which this value refers. Used to generate search links and
60 - * to find custom settings that relate to the attribute.
61 - * The attribute is given as a simple wiki text title, without namespace prefix.
 59+ * Set the property to which this value refers. Used to generate search links and
 60+ * to find custom settings that relate to the property.
 61+ * The property is given as a simple wiki text title, without namespace prefix.
6262 */
63 - public function setAttribute($attstring) {
64 - $this->m_attribute = $attstring;
 63+ public function setProperty($propertyname) {
 64+ $this->m_property = $propertyname;
6565 }
6666
6767 public function addInfoLink(SMWInfoLink $link) {
@@ -196,9 +196,9 @@
197197 * text, but no more. Result might have no entries but is always an array.
198198 */
199199 public function getInfolinks() {
200 - if (!$this->m_hasssearchlink && $this->isValid() && $this->m_attribute) {
 200+ if (!$this->m_hasssearchlink && $this->isValid() && $this->m_property) {
201201 $this->m_hasssearchlink = true;
202 - $this->m_infolinks[] = SMWInfolink::newAttributeSearchLink('+', $this->m_attribute, $this->getWikiValue());
 202+ $this->m_infolinks[] = SMWInfolink::newPropertySearchLink('+', $this->m_property, $this->getWikiValue());
203203 }
204204 return $this->m_infolinks;
205205 }
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Datatype.php
@@ -286,12 +286,9 @@
287287 global $wgContLang;
288288
289289 SMWTypeHandlerFactory::$possibleValuesByAttribute[$attribute] = Array();
290 - $atitle = Title::newFromText($wgContLang->getNsText(SMW_NS_ATTRIBUTE) . ':' . $attribute);
 290+ $atitle = Title::newFromText($wgContLang->getNsText(SMW_NS_PROPERTY) . ':' . $attribute);
291291 if ($atitle !== NULL) {
292 - // get special property for possible values. Assume only one such property per attribute.
293292 $apvprops = smwfGetStore()->getSpecialValues($atitle, SMW_SP_POSSIBLE_VALUE);
294 - // OBSOLETE: Possible values are separated by commas.
295 - // SMWTypeHandlerFactory::$possibleValuesByAttribute[$attribute] = preg_split('/[,][\s]*/',$apvprops[0]);
296293 foreach ($apvprops as $prop ) {
297294 SMWTypeHandlerFactory::$possibleValuesByAttribute[$attribute][] = $prop;
298295 }
@@ -373,138 +370,7 @@
374371 // Booleans can (and more problematic: will) be modelled by two-valued enums; too much choice yields confusion (note that Categories are also addressing a simliar modelling problem already -- let's not introduce three ways of encoding this)
375372 //SMWTypeHandlerFactory::announceTypeHandler($smwgContLang->getDatatypeLabel('smw_bool'),'bool','Boolean','SMWBooleanTypeHandler');
376373
377 -
378 -
379374 /*********************************************************************/
380 -/* Helper classes for storing output of type handlers */
381 -/*********************************************************************/
382 -
383 -/**
384 - * This class mainly is a container to store URLs for the factbox in a
385 - * clean way. The class provides methods for creating source code for
386 - * realising them in wiki or html contexts.
387 - */
388 -class SMWInfolink {
389 - private $target; // the actual link target
390 - private $caption; // the label for the link
391 - private $style; // CSS class of a span to embedd the link into, or
392 - // false if no extra style is required
393 - private $internal; // indicates whether $target is a page name (true) or URL (false)
394 -
395 - /**
396 - * Create a new link to an internal page $target. All parameters are mere strings
397 - * as used by wiki users
398 - */
399 - static function newInternalLink($caption, $target, $style=false) {
400 - return new SMWInfolink(true,$caption,$target,$style);
401 - }
402 -
403 - /**
404 - * Create a new link to an external location $url.
405 - */
406 - static function newExternalLink($caption, $url, $style=false) {
407 - return new SMWInfolink(false,$caption,$url,$style);
408 - }
409 -
410 - /**
411 - * Static function to construct links to attribute searches.
412 - */
413 - static function newAttributeSearchLink($caption,$attribute,$value,$style = 'smwsearch') {
414 - global $wgContLang;
415 - return new SMWInfolink(true,$caption,$wgContLang->getNsText(NS_SPECIAL) . ':SearchByAttribute/' . $attribute . ':=' . $value, $style);
416 - }
417 -
418 - /**
419 - * Static function to construct links to relation searches.
420 - */
421 - static function newRelationSearchLink($caption,$relation,$object,$style = 'smwsearch') {
422 - global $wgContLang;
423 - return new SMWInfolink(true,$caption,$wgContLang->getNsText(NS_SPECIAL) . ':SearchByRelation/' . $relation . '::' . $object, $style);
424 - }
425 -
426 - /**
427 - * Static function to construct links to inverse relation searches.
428 - */
429 - static function newInverseRelationSearchLink($caption,$subject,$relation,$style = false) {
430 - global $wgContLang;
431 - return new SMWInfolink(true,$caption,$wgContLang->getNsText(NS_SPECIAL) . ':PageProperty/' . $subject . '::' . $relation, $style);
432 - }
433 -
434 - /**
435 - * Static function to construct links to inverse attribute searches.
436 - */
437 - static function newInverseAttributeSearchLink($caption,$subject,$attribute,$style = false) {
438 - global $wgContLang;
439 - return new SMWInfolink(true,$caption,$wgContLang->getNsText(NS_SPECIAL) . ':PageProperty/' . $subject . '::' . $attribute, $style);
440 - }
441 -
442 - /**
443 - * Static function to construct links to the browsing special.
444 - */
445 - static function newBrowsingLink($caption,$titletext,$style = 'smwbrowse') {
446 - global $wgContLang;
447 - return new SMWInfolink(true,$caption,$wgContLang->getNsText(NS_SPECIAL) . ':Browse/' . $titletext, $style);
448 - }
449 -
450 - /**
451 - * Create a new link to some internal page or to some external URL.
452 - */
453 - function SMWInfolink($internal, $caption, $target, $style=false) {
454 - $this->internal = $internal;
455 - $this->caption = $caption;
456 - $this->target = $target;
457 - $this->style = $style;
458 - }
459 -
460 - /**
461 - * Return hyperlink for this infolink in HTML format.
462 - * @access public
463 - */
464 - function getHTML($skin) {
465 - if ($this->style !== false) {
466 - $start = "<span class=\"$this->style\">";
467 - $end = '</span>';
468 - } else {
469 - $start = '';
470 - $end = '';
471 - }
472 - if ($this->internal) {
473 - $title = Title::newFromText($this->target);
474 - if ($title !== NULL) {
475 - return $start . $skin->makeKnownLinkObj(Title::newFromText($this->target), $this->caption) . $end;
476 - } else {
477 - return '';
478 - }
479 - } else {
480 - return $start . "<a href=\"$this->target\">$this->caption</a>" . $end;
481 - }
482 - }
483 -
484 - /**
485 - * Return hyperlink for this infolink in wiki format.
486 - * @access public
487 - */
488 - function getWikiText() {
489 - if ($this->style !== false) {
490 - $start = "<span class=\"$this->style\">";
491 - $end = '</span>';
492 - } else {
493 - $start = '';
494 - $end = '';
495 - }
496 - if ($this->internal) {
497 - if (preg_match('/(.*)(\[|\]|<|>|&gt;|&lt;|{|})(.*)/', $this->target) != 0 ) {
498 - return ''; // give up if illegal characters occur,
499 - // TODO: we would need a skin to provide an ext URL in this case
500 - }
501 - return $start . "[[$this->target|$this->caption]]" . $end;
502 - } else {
503 - return $start . "[$this->target $this->caption]" . $end;
504 - }
505 - }
506 -}
507 -
508 -/*********************************************************************/
509375 /* Basic typehandler classes */
510376 /*********************************************************************/
511377
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DT_Text.php
@@ -13,7 +13,7 @@
1414 class SMWTextTypeHandler implements SMWTypeHandler {
1515
1616 function getID() {
17 - return 'text';
 17+ return '_txt';
1818 }
1919
2020 function getXSDType() {
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Factbox.php
@@ -6,7 +6,9 @@
77 * @author Markus Krötzsch
88 */
99
10 -require_once('SMW_SemanticData.php');
 10+global $smwgIP;
 11+require_once($smwgIP . '/includes/SMW_SemanticData.php');
 12+require_once($smwgIP . '/includes/SMW_Infolink.php');
1113
1214 /**
1315 * Static class for representing semantic data, which accepts user
@@ -60,9 +62,9 @@
6163
6264 switch ($special) {
6365 case false: // normal attribute
64 - $result = SMWDataValueFactory::newAttributeValue($attribute,$value,$caption);
 66+ $result = SMWDataValueFactory::newPropertyValue($attribute,$value,$caption);
6567 if ($smwgStoreActive) {
66 - SMWFactbox::$semdata->addAttributeTextValue($attribute,$result);
 68+ SMWFactbox::$semdata->addPropertyValue($attribute,$result);
6769 }
6870 return $result;
6971 case SMW_SP_IMPORTED_FROM: // this requires special handling
@@ -109,7 +111,7 @@
110112 SMWFactbox::$semdata->addSpecialValue($special, $value);
111113 }
112114 } else {
113 - SMWFactbox::$semdata->addRelationTextValue($relation, $value);
 115+ SMWFactbox::$semdata->addPropertyValue($relation, $value);
114116 }
115117 }
116118
@@ -235,7 +237,7 @@
236238 switch ($smwgShowFactbox) {
237239 case SMW_FACTBOX_HIDDEN: return true;
238240 case SMW_FACTBOX_NONEMPTY:
239 - if ( (!SMWFactbox::$semdata->hasRelations()) && (!SMWFactbox::$semdata->hasAttributes()) && (!SMWFactbox::$semdata->hasSpecialProperties()) ) {
 241+ if ( (!SMWFactbox::$semdata->hasProperties()) && (!SMWFactbox::$semdata->hasSpecialProperties()) ) {
240242 return;
241243 }
242244 }
@@ -251,8 +253,7 @@
252254 '<span class="smwfactboxhead">' . wfMsgForContent('smw_factbox_head', $browselink->getWikiText() ) . '</span>' .
253255 '<span class="smwrdflink">' . $rdflink->getWikiText() . '</span>' .
254256 '<table class="smwfacttable">' . "\n";
255 - SMWFactbox::printRelations($text);
256 - SMWFactbox::printAttributes($text);
 257+ SMWFactbox::printProperties($text);
257258 SMWFactbox::printSpecialProperties($text);
258259 $text .= '</table></div>';
259260 }
@@ -260,15 +261,15 @@
261262 /**
262263 * This method prints attribute values at the bottom of an article.
263264 */
264 - static protected function printAttributes(&$text) {
265 - if (!SMWFactbox::$semdata->hasAttributes()) {
 265+ static protected function printProperties(&$text) {
 266+ if (!SMWFactbox::$semdata->hasProperties()) {
266267 return;
267268 }
268269
269270 //$text .= ' <tr><th class="atthead"></th><th class="atthead">' . wfMsgForContent('smw_att_head') . "</th></tr>\n";
270271
271 - foreach(SMWFactbox::$semdata->getAttributes() as $attribute) {
272 - $attributeValueArray = SMWFactbox::$semdata->getAttributeValues($attribute);
 272+ foreach(SMWFactbox::$semdata->getProperties() as $attribute) {
 273+ $attributeValueArray = SMWFactbox::$semdata->getPropertyValues($attribute);
273274 $text .= '<tr><td class="smwattname">';
274275 $text .= ' [[' . $attribute->getPrefixedText() . '|' . preg_replace('/[\s]/','&nbsp;',$attribute->getText(),2) . ']] </td><td class="smwatts">';
275276 // TODO: the preg_replace is a kind of hack to ensure that the left column does not get too narrow; maybe we can find something nicer later
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php
@@ -1,6 +1,6 @@
22 <?php
33 /**
4 - * Special handling for relation/attribute description pages.
 4+ * Special handling for property description pages.
55 * Some code based on CategoryPage.php
66 *
77 * @author: Markus Krötzsch
@@ -13,9 +13,8 @@
1414
1515 /**
1616 * Implementation of MediaWiki's Article that shows additional information on
17 - * property pages (Relation: and Attribute:). Very simliar to CategoryPage, but
18 - * with different printout that also displays values for each subject with the
19 - * given property.
 17+ * property pages. Very simliar to CategoryPage, but with different printout
 18+ * that also displays values for each subject with the given property.
2019 */
2120 class SMWPropertyPage extends SMWOrderedListPage {
2221
@@ -57,11 +56,7 @@
5857 $options->include_boundary = false;
5958 $reverse = true;
6059 }
61 - if ( $this->mTitle->getNamespace()== SMW_NS_RELATION ) {
62 - $this->articles = $store->getAllRelationSubjects($this->mTitle, $options);
63 - } else {
64 - $this->articles = $store->getAllAttributeSubjects($this->mTitle, $options);
65 - }
 60+ $this->articles = $store->getAllPropertySubjects($this->mTitle, $options);
6661 if ($reverse) {
6762 $this->articles = array_reverse($this->articles);
6863 }
@@ -79,16 +74,8 @@
8075 $ti = htmlspecialchars( $this->mTitle->getText() );
8176 $nav = $this->getNavigationLinks();
8277 $r = '<a name="SMWResults"></a>' . $nav . "<div id=\"mw-pages\">\n";
83 - switch ( $this->mTitle->getNamespace() ) {
84 - case SMW_NS_RELATION:
85 - $r .= '<h2>' . wfMsg('smw_relation_header',$ti) . "</h2>\n";
86 - $r .= wfMsg('smw_relationarticlecount', min($this->limit, count($this->articles))) . "\n";
87 - break;
88 - case SMW_NS_ATTRIBUTE:
89 - $r .= '<h2>' . wfMsg('smw_attribute_header',$ti) . "</h2>\n";
90 - $r .= wfMsg('smw_relationarticlecount', min($this->limit, count($this->articles))) . "\n";
91 - break;
92 - }
 78+ $r .= '<h2>' . wfMsg('smw_attribute_header',$ti) . "</h2>\n";
 79+ $r .= wfMsg('smw_relationarticlecount', min($this->limit, count($this->articles))) . "\n";
9380 $r .= $this->shortList( $this->articles, $this->articles_start_char ) . "\n</div>" . $nav;
9481 return $r;
9582 }
@@ -121,50 +108,32 @@
122109 $r .= '<tr><th class="smwattname"><h3>' . htmlspecialchars( $this->articles_start_char[$index] ) . "</h3></th><th></th></tr>\n";
123110 $prevchar = $this->articles_start_char[$index];
124111 }
125 - // Attribute/relation name
 112+ // Property name
126113 $searchlink = SMWInfolink::newBrowsingLink('+',$this->articles[$index]->getPrefixedText());
127114 $r .= '<tr><td class="smwattname">' . $this->getSkin()->makeKnownLinkObj( $this->articles[$index],
128115 $wgContLang->convert( $this->articles[$index]->getPrefixedText() ) ) .
129116 '&nbsp;' . $searchlink->getHTML($this->getSkin()) .
130117 '</td><td class="smwatts">';
131 - // Attribute/relation values
 118+ // Property values
132119 $ropts = new SMWRequestOptions();
133120 $ropts->limit = 4;
134 - if ($this->mTitle->getNamespace() == SMW_NS_RELATION) {
135 - $objects = $store->getRelationObjects($this->articles[$index], $this->mTitle,$ropts);
136 - $i=0;
137 - foreach ($objects as $object) {
138 - if ($i != 0) {
139 - $r .= ', ';
140 - }
141 - $i++;
142 - if ($i < 4) {
143 - $searchlink = SMWInfolink::newRelationSearchLink('+',$this->mTitle->getText(),$object->getPrefixedText());
144 - $r .= $this->getSkin()->makeLinkObj($object, $wgContLang->convert( $object->getText() )) . '&nbsp;&nbsp;' . $searchlink->getHTML($this->getSkin());
145 - } else {
146 - $searchlink = SMWInfolink::newInverseRelationSearchLink('&hellip;', $this->articles[$index]->getPrefixedText(), $this->mTitle->getText());
147 - $r .= $searchlink->getHTML($this->getSkin());
148 - }
 121+ $values = $store->getPropertyValues($this->articles[$index], $this->mTitle, $ropts);
 122+ $i=0;
 123+ foreach ($values as $value) {
 124+ if ($i != 0) {
 125+ $r .= ', ';
149126 }
150 - } elseif ($this->mTitle->getNamespace() == SMW_NS_ATTRIBUTE) {
151 - $values = $store->getAttributeValues($this->articles[$index], $this->mTitle, $ropts);
152 - $i=0;
153 - foreach ($values as $value) {
154 - if ($i != 0) {
155 - $r .= ', ';
 127+ $i++;
 128+ if ($i < 4) {
 129+ $r .= $value->getLongHTMLText($this->getSkin());
 130+ $sep = '&nbsp;&nbsp;';
 131+ foreach ($value->getInfolinks() as $link) {
 132+ $r .= $sep . $link->getHTML($this->getSkin());
 133+ $sep = ' &nbsp;&nbsp;'; // allow breaking for longer lists of infolinks
156134 }
157 - $i++;
158 - if ($i < 4) {
159 - $r .= $value->getLongHTMLText($this->getSkin());
160 - $sep = '&nbsp;&nbsp;';
161 - foreach ($value->getInfolinks() as $link) {
162 - $r .= $sep . $link->getHTML($this->getSkin());
163 - $sep = ' &nbsp;&nbsp;'; // allow breaking for longer lists of infolinks
164 - }
165 - } else {
166 - $searchlink = SMWInfolink::newInverseAttributeSearchLink('&hellip;', $this->articles[$index]->getPrefixedText(), $this->mTitle->getText());
167 - $r .= $searchlink->getHTML($this->getSkin());
168 - }
 135+ } else {
 136+ $searchlink = SMWInfolink::newInversePropertySearchLink('&hellip;', $this->articles[$index]->getPrefixedText(), $this->mTitle->getText());
 137+ $r .= $searchlink->getHTML($this->getSkin());
169138 }
170139 }
171140 $r .= "</td></tr>\n";
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Description.php
@@ -98,7 +98,7 @@
9999
100100 public function getTypeID() {
101101 if ($this->m_typeid === false) {
102 - $dv = SMWDataValueFactory::newAttributeObjectValue($this->m_title);
 102+ $dv = SMWDataValueFactory::newPropertyObjectValue($this->m_title);
103103 $this->m_typeid = $dv->getTypeID();
104104 }
105105 return $this->m_typeid;
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore.php
@@ -172,13 +172,10 @@
173173
174174 $sql = 'property_id=' . $db->addQuotes($specialprop) .
175175 ' AND value_string=' . $db->addQuotes($stringvalue) .
176 - $this->getSQLConditions($requestoptions,'subject_title','subject_title');
177 -
 176+ $this->getSQLConditions($requestoptions,'subject_title','subject_title');
178177 $res = $db->select( 'smw_specialprops',
179178 'DISTINCT subject_id',
180179 $sql, 'SMW::getSpecialSubjects', $this->getSQLOptions($requestoptions,'subject_title') );
181 -
182 - // rewrite result as array
183180 while($row = $db->fetchObject($res)) {
184181 $result[] = Title::newFromID($row->subject_id);
185182 }
@@ -189,25 +186,23 @@
190187 }
191188
192189
193 - function getAttributeValues(Title $subject, Title $attribute, $requestoptions = NULL, $outputformat = '') {
 190+ function getPropertyValues(Title $subject, Title $property, $requestoptions = NULL, $outputformat = '') {
194191 $db =& wfGetDB( DB_SLAVE );
195192 $result = array();
196193
197 - $id = SMWDataValueFactory::getAttributeObjectTypeID($attribute);
 194+ $id = SMWDataValueFactory::getPropertyObjectTypeID($property);
198195 switch ($id) {
199196 case '_txt': // long text attribute
200197 $res = $db->select( $db->tableName('smw_longstrings'),
201198 'value_blob',
202199 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
203 - ' AND attribute_title=' . $db->addQuotes($attribute->getDBkey()),
204 - 'SMW::getAttributeValues', $this->getSQLOptions($requestoptions) );
205 - if($db->numRows( $res ) > 0) {
206 - while($row = $db->fetchObject($res)) {
207 - $dv = SMWDataValueFactory::newAttributeObjectValue($attribute);
208 - $dv->setOutputFormat($outputformat);
209 - $dv->setXSDValue($row->value_blob, '');
210 - $result[] = $dv;
211 - }
 200+ ' AND attribute_title=' . $db->addQuotes($property->getDBkey()),
 201+ 'SMW::getPropertyValues', $this->getSQLOptions($requestoptions) );
 202+ while($row = $db->fetchObject($res)) {
 203+ $dv = SMWDataValueFactory::newPropertyObjectValue($property);
 204+ $dv->setOutputFormat($outputformat);
 205+ $dv->setXSDValue($row->value_blob, '');
 206+ $result[] = $dv;
212207 }
213208 $db->freeResult($res);
214209 break;
@@ -215,16 +210,14 @@
216211 $res = $db->select( $db->tableName('smw_relations'),
217212 'object_title, object_namespace',
218213 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
219 - ' AND relation_title=' . $db->addQuotes($attribute->getDBkey()) .
 214+ ' AND relation_title=' . $db->addQuotes($property->getDBkey()) .
220215 $this->getSQLConditions($requestoptions,'object_title','object_title'),
221 - 'SMW::getAttributeValues', $this->getSQLOptions($requestoptions,'object_title') );
222 - if($db->numRows( $res ) > 0) {
223 - while($row = $db->fetchObject($res)) {
224 - $dv = SMWDataValueFactory::newTypeIDValue('_wpg');
225 - $dv->setOutputFormat($outputformat);
226 - $dv->setValues($row->object_title, $row->object_namespace);
227 - $result[] = $dv;
228 - }
 216+ 'SMW::getPropertyValues', $this->getSQLOptions($requestoptions,'object_title') );
 217+ while($row = $db->fetchObject($res)) {
 218+ $dv = SMWDataValueFactory::newPropertyObjectValue($property);
 219+ $dv->setOutputFormat($outputformat);
 220+ $dv->setValues($row->object_title, $row->object_namespace);
 221+ $result[] = $dv;
229222 }
230223 $db->freeResult($res);
231224 break;
@@ -236,57 +229,72 @@
237230 $value_column = 'value_xsd';
238231 }
239232 $sql = 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
240 - ' AND attribute_title=' . $db->addQuotes($attribute->getDBkey()) .
 233+ ' AND attribute_title=' . $db->addQuotes($property->getDBkey()) .
241234 $this->getSQLConditions($requestoptions,$value_column,'value_xsd');
242235 $res = $db->select( $db->tableName('smw_attributes'),
243236 'value_unit, value_xsd',
244 - $sql, 'SMW::getAttributeValues', $this->getSQLOptions($requestoptions,$value_column) );
245 - if($db->numRows( $res ) > 0) {
246 - while($row = $db->fetchObject($res)) {
247 - $dv = SMWDataValueFactory::newAttributeObjectValue($attribute);
248 - $dv->setOutputFormat($outputformat);
249 - $dv->setXSDValue($row->value_xsd, $row->value_unit);
250 - $result[] = $dv;
251 - }
 237+ $sql, 'SMW::getPropertyValues', $this->getSQLOptions($requestoptions,$value_column) );
 238+ while($row = $db->fetchObject($res)) {
 239+ $dv = SMWDataValueFactory::newPropertyObjectValue($property);
 240+ $dv->setOutputFormat($outputformat);
 241+ $dv->setXSDValue($row->value_xsd, $row->value_unit);
 242+ $result[] = $dv;
252243 }
253244 $db->freeResult($res);
254245 }
255246 return $result;
256247 }
257248
258 - function getAttributeSubjects(Title $attribute, SMWDataValue $value, $requestoptions = NULL) {
 249+ function getPropertySubjects(Title $property, SMWDataValue $value, $requestoptions = NULL) {
259250 if ( !$value->isValid() ) {
260251 return array();
261252 }
262 -
 253+ $result = array();
263254 $db =& wfGetDB( DB_SLAVE );
264 - $sql = 'value_xsd=' . $db->addQuotes($value->getXSDValue()) .
265 - ' AND value_unit=' . $db->addQuotes($value->getUnit()) .
266 - ' AND attribute_title=' . $db->addQuotes($attribute->getDBKey()) .
267 - $this->getSQLConditions($requestoptions,'subject_title','subject_title');
268255
269 - $result = array();
270 - $res = $db->select( $db->tableName('smw_attributes'),
 256+ switch ($value->getTypeID()) {
 257+ case '_txt': // not supported
 258+ break;
 259+ case '_wpg': // wikipage
 260+ $sql = 'object_namespace=' . $db->addQuotes($value->getNamespace()) .
 261+ ' AND object_title=' . $db->addQuotes($value->getDBKey()) .
 262+ ' AND relation_title=' . $db->addQuotes($property->getDBKey()) .
 263+ $this->getSQLConditions($requestoptions,'subject_title','subject_title');
 264+
 265+ $res = $db->select( $db->tableName('smw_relations'),
 266+ 'DISTINCT subject_id',
 267+ $sql, 'SMW::getPropertySubjects',
 268+ $this->getSQLOptions($requestoptions,'subject_title') );
 269+ while($row = $db->fetchObject($res)) {
 270+ $result[] = Title::newFromID($row->subject_id);
 271+ }
 272+ $db->freeResult($res);
 273+ break;
 274+ default:
 275+ $sql = 'value_xsd=' . $db->addQuotes($value->getXSDValue()) .
 276+ ' AND value_unit=' . $db->addQuotes($value->getUnit()) .
 277+ ' AND attribute_title=' . $db->addQuotes($property->getDBKey()) .
 278+ $this->getSQLConditions($requestoptions,'subject_title','subject_title');
 279+ $res = $db->select( $db->tableName('smw_attributes'),
271280 'DISTINCT subject_id',
272 - $sql, 'SMW::getAttributeSubjects', $this->getSQLOptions($requestoptions,'subject_title') );
273 - if($db->numRows( $res ) > 0) {
 281+ $sql, 'SMW::getPropertySubjects',
 282+ $this->getSQLOptions($requestoptions,'subject_title') );
274283 while($row = $db->fetchObject($res)) {
275284 $result[] = Title::newFromID($row->subject_id);
276285 }
 286+ $db->freeResult($res);
 287+ break;
277288 }
278 - $db->freeResult($res);
279 - // long strings not supported for this operation
280 -
281289 return $result;
282290 }
283291
284 - function getAllAttributeSubjects(Title $attribute, $requestoptions = NULL) {
 292+ function getAllPropertySubjects(Title $property, $requestoptions = NULL) {
285293 $db =& wfGetDB( DB_SLAVE );
286 - $sql = 'attribute_title=' . $db->addQuotes($attribute->getDBkey()) .
 294+ $sql = 'attribute_title=' . $db->addQuotes($property->getDBkey()) .
287295 $this->getSQLConditions($requestoptions,'subject_title','subject_title');
288296
289297 $result = array();
290 - $id = SMWDataValueFactory::getAttributeObjectTypeID($attribute);
 298+ $id = SMWDataValueFactory::getPropertyObjectTypeID($property);
291299 switch ($id) {
292300 case '_txt':
293301 $res = $db->select( $db->tableName('smw_longstrings'),
@@ -300,10 +308,22 @@
301309 }
302310 $db->freeResult($res);
303311 break;
 312+ case '_wpg':
 313+ $sql = 'relation_title=' . $db->addQuotes($property->getDBkey()) .
 314+ $this->getSQLConditions($requestoptions,'subject_title','subject_title');
 315+ $res = $db->select( $db->tableName('smw_relations'),
 316+ 'DISTINCT subject_id',
 317+ $sql, 'SMW::getAllAttributeSubjects',
 318+ $this->getSQLOptions($requestoptions,'subject_title') );
 319+ while($row = $db->fetchObject($res)) {
 320+ $result[] = Title::newFromId($row->subject_id);
 321+ }
 322+ $db->freeResult($res);
 323+ break;
304324 default:
305325 $res = $db->select( $db->tableName('smw_attributes'),
306326 'DISTINCT subject_id',
307 - $sql, 'SMW::getAllAttributeSubjects',
 327+ $sql, 'SMW::getAllAttributeSubjects',
308328 $this->getSQLOptions($requestoptions,'subject_title') );
309329 if($db->numRows( $res ) > 0) {
310330 while($row = $db->fetchObject($res)) {
@@ -315,14 +335,14 @@
316336 return $result;
317337 }
318338
319 - function getAttributes(Title $subject, $requestoptions = NULL) {
 339+ function getProperties(Title $subject, $requestoptions = NULL) {
320340 $db =& wfGetDB( DB_SLAVE );
321341 $sql = 'subject_id=' . $db->addQuotes($subject->getArticleID()) . $this->getSQLConditions($requestoptions,'attribute_title','attribute_title');
322342
323343 $result = array();
324344 $res = $db->select( $db->tableName('smw_attributes'),
325345 'DISTINCT attribute_title',
326 - $sql, 'SMW::getAttributes', $this->getSQLOptions($requestoptions,'attribute_title') );
 346+ $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'attribute_title') );
327347 if ($db->numRows( $res ) > 0) {
328348 while($row = $db->fetchObject($res)) {
329349 $result[] = Title::newFromText($row->attribute_title, SMW_NS_ATTRIBUTE);
@@ -331,7 +351,7 @@
332352 $db->freeResult($res);
333353 $res = $db->select( $db->tableName('smw_longstrings'),
334354 'DISTINCT attribute_title',
335 - $sql, 'SMW::getAttributes', $this->getSQLOptions($requestoptions,'attribute_title') );
 355+ $sql, 'SMW::getProperties', $this->getSQLOptions($requestoptions,'attribute_title') );
336356 if ($db->numRows( $res ) > 0) {
337357 while($row = $db->fetchObject($res)) {
338358 $result[] = Title::newFromText($row->attribute_title, SMW_NS_ATTRIBUTE);
@@ -339,23 +359,14 @@
340360 }
341361 $db->freeResult($res);
342362
343 - return $result;
344 - }
345 -
346 - function getRelationObjects(Title $subject, Title $relation, $requestoptions = NULL) {
347 - $db =& wfGetDB( DB_SLAVE );
348363 $sql = 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
349 - ' AND relation_title=' . $db->addQuotes($relation->getDBKey()) .
350 - $this->getSQLConditions($requestoptions,'object_title','object_title');
351 -
 364+ $this->getSQLConditions($requestoptions,'relation_title','relation_title');
352365 $res = $db->select( $db->tableName('smw_relations'),
353 - 'object_title, object_namespace',
354 - $sql, 'SMW::getRelationObjects', $this->getSQLOptions($requestoptions,'object_title') );
355 - // rewrite result as array
356 - $result = array();
 366+ 'DISTINCT relation_title',
 367+ $sql, 'SMW::getOutRelations', $this->getSQLOptions($requestoptions,'relation_title') );
357368 if($db->numRows( $res ) > 0) {
358369 while($row = $db->fetchObject($res)) {
359 - $result[] = Title::newFromText($row->object_title, $row->object_namespace);
 370+ $result[] = Title::newFromText($row->relation_title, SMW_NS_ATTRIBUTE);
360371 }
361372 }
362373 $db->freeResult($res);
@@ -363,89 +374,129 @@
364375 return $result;
365376 }
366377
367 - function getRelationSubjects(Title $relation, Title $object, $requestoptions = NULL) {
 378+ function getInProperties(SMWDataValue $value, $requestoptions = NULL) {
368379 $db =& wfGetDB( DB_SLAVE );
369 - $sql = 'object_namespace=' . $db->addQuotes($object->getNamespace()) .
370 - ' AND object_title=' . $db->addQuotes($object->getDBKey()) .
371 - ' AND relation_title=' . $db->addQuotes($relation->getDBKey()) .
372 - $this->getSQLConditions($requestoptions,'subject_title','subject_title');
373 -
374 - $res = $db->select( $db->tableName('smw_relations'),
375 - 'DISTINCT subject_id',
376 - $sql, 'SMW::getRelationSubjects', $this->getSQLOptions($requestoptions,'subject_title') );
377 - // rewrite result as array
378380 $result = array();
379 - if($db->numRows( $res ) > 0) {
 381+ if ($value->getTypeID() == '_wpg') {
 382+ $sql = 'object_namespace=' . $db->addQuotes($value->getNamespace()) .
 383+ ' AND object_title=' . $db->addQuotes($value->getDBKey()) .
 384+ $this->getSQLConditions($requestoptions,'relation_title','relation_title');
 385+
 386+ $res = $db->select( $db->tableName('smw_relations'),
 387+ 'DISTINCT relation_title',
 388+ $sql, 'SMW::getInRelations', $this->getSQLOptions($requestoptions,'relation_title') );
380389 while($row = $db->fetchObject($res)) {
381 - $result[] = Title::newFromID($row->subject_id);
 390+ $result[] = Title::newFromText($row->relation_title, SMW_NS_RELATION);
382391 }
 392+ $db->freeResult($res);
383393 }
384 - $db->freeResult($res);
385 -
386394 return $result;
387395 }
388396
389 - function getAllRelationSubjects(Title $relation, $requestoptions = NULL) {
390 - $db =& wfGetDB( DB_SLAVE );
391 - $sql = 'relation_title=' . $db->addQuotes($relation->getDBkey()) .
392 - $this->getSQLConditions($requestoptions,'subject_title','subject_title');
 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+// }
393417
394 - $res = $db->select( $db->tableName('smw_relations'),
395 - 'DISTINCT subject_id',
396 - $sql, 'SMW::getAllRelationSubjects', $this->getSQLOptions($requestoptions,'subject_title') );
397 - // rewrite result as array
398 - $result = array();
399 - if($db->numRows( $res ) > 0) {
400 - while($row = $db->fetchObject($res)) {
401 - $result[] = Title::newFromId($row->subject_id);
402 - }
403 - }
404 - $db->freeResult($res);
 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+// }
405439
406 - return $result;
407 - }
 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+// }
408459
409 - function getOutRelations(Title $subject, $requestoptions = NULL) {
410 - $db =& wfGetDB( DB_SLAVE );
411 - $sql = 'subject_id=' . $db->addQuotes($subject->getArticleID()) .
412 - $this->getSQLConditions($requestoptions,'relation_title','relation_title');
 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+// }
413479
414 - $res = $db->select( $db->tableName('smw_relations'),
415 - 'DISTINCT relation_title',
416 - $sql, 'SMW::getOutRelations', $this->getSQLOptions($requestoptions,'relation_title') );
417 - // rewrite result as array
418 - $result = array();
419 - if($db->numRows( $res ) > 0) {
420 - while($row = $db->fetchObject($res)) {
421 - $result[] = Title::newFromText($row->relation_title, SMW_NS_RELATION);
422 - }
423 - }
424 - $db->freeResult($res);
 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+// }
425500
426 - return $result;
427 - }
428 -
429 - function getInRelations(Title $object, $requestoptions = NULL) {
430 - $db =& wfGetDB( DB_SLAVE );
431 - $sql = 'object_namespace=' . $db->addQuotes($object->getNamespace()) .
432 - ' AND object_title=' . $db->addQuotes($object->getDBKey()) .
433 - $this->getSQLConditions($requestoptions,'relation_title','relation_title');
434 -
435 - $res = $db->select( $db->tableName('smw_relations'),
436 - 'DISTINCT relation_title',
437 - $sql, 'SMW::getInRelations', $this->getSQLOptions($requestoptions,'relation_title') );
438 - // rewrite result as array
439 - $result = array();
440 - if($db->numRows( $res ) > 0) {
441 - while($row = $db->fetchObject($res)) {
442 - $result[] = Title::newFromText($row->relation_title, SMW_NS_RELATION);
443 - }
444 - }
445 - $db->freeResult($res);
446 -
447 - return $result;
448 - }
449 -
450501 ///// Writing methods /////
451502
452503 function deleteSubject(Title $subject) {
@@ -481,49 +532,36 @@
482533 $up_specials = array();
483534 $up_subprops = array();
484535
485 - // relations
486 - foreach($data->getRelations() as $relation) {
487 - foreach($data->getRelationObjects($relation) as $object) {
488 - $up_relations[] =
489 - array( 'subject_id' => $subject->getArticleID(),
490 - 'subject_namespace' => $subject->getNamespace(),
491 - 'subject_title' => $subject->getDBkey(),
492 - 'relation_title' => $relation->getDBkey(),
493 - 'object_namespace' => $object->getNamespace(),
494 - 'object_title' => $object->getDBkey() );
495 - }
496 - }
497 -
498 - //attributes
499 - foreach($data->getAttributes() as $attribute) {
500 - $attributeValueArray = $data->getAttributeValues($attribute);
501 - foreach($attributeValueArray as $value) {
 536+ //properties
 537+ foreach($data->getProperties() as $property) {
 538+ $propertyValueArray = $data->getPropertyValues($property);
 539+ foreach($propertyValueArray as $value) {
502540 if ($value->isValid()) {
503 - if ($value->getTypeID() !== '_txt') {
 541+ if ($value->getTypeID() == '_txt') {
 542+ $up_longstrings[] =
 543+ array( 'subject_id' => $subject->getArticleID(),
 544+ 'subject_namespace' => $subject->getNamespace(),
 545+ 'subject_title' => $subject->getDBkey(),
 546+ 'attribute_title' => $property->getDBkey(),
 547+ 'value_blob' => $value->getXSDValue() );
 548+ } elseif ($value->getTypeID() == '_wpg') { // f.k.a. "Relation"
 549+ $up_relations[] =
 550+ array( 'subject_id' => $subject->getArticleID(),
 551+ 'subject_namespace' => $subject->getNamespace(),
 552+ 'subject_title' => $subject->getDBkey(),
 553+ 'relation_title' => $property->getDBkey(),
 554+ 'object_namespace' => $value->getNamespace(),
 555+ 'object_title' => $value->getDBkey() );
 556+ } else {
504557 $up_attributes[] =
505558 array( 'subject_id' => $subject->getArticleID(),
506559 'subject_namespace' => $subject->getNamespace(),
507560 'subject_title' => $subject->getDBkey(),
508 - 'attribute_title' => $attribute->getDBkey(),
 561+ 'attribute_title' => $property->getDBkey(),
509562 'value_unit' => $value->getUnit(),
510563 'value_datatype' => $value->getTypeID(),
511564 'value_xsd' => $value->getXSDValue(),
512565 'value_num' => $value->getNumericValue() );
513 - } elseif ($value->getTypeID() !== '_wpg') { // f.k.a. "Relation"
514 - $up_relations[] =
515 - array( 'subject_id' => $subject->getArticleID(),
516 - 'subject_namespace' => $subject->getNamespace(),
517 - 'subject_title' => $subject->getDBkey(),
518 - 'relation_title' => $attribute->getDBkey(),
519 - 'object_namespace' => $value->getNamespace(),
520 - 'object_title' => $value->getDBkey() );
521 - } else {
522 - $up_longstrings[] =
523 - array( 'subject_id' => $subject->getArticleID(),
524 - 'subject_namespace' => $subject->getNamespace(),
525 - 'subject_title' => $subject->getDBkey(),
526 - 'attribute_title' => $attribute->getDBkey(),
527 - 'value_blob' => $value->getXSDValue() );
528566 }
529567 }
530568 }
@@ -747,7 +785,7 @@
748786 $row[] = new SMWResultArray($this->getSpecialValues($qt,SMW_SP_HAS_CATEGORY), $pr);
749787 break;
750788 case SMW_PRINT_ATTS:
751 - $row[] = new SMWResultArray($this->getAttributeValues($qt,$pr->getTitle(), NULL, $pr->getOutputFormat()), $pr);
 789+ $row[] = new SMWResultArray($this->getPropertyValues($qt,$pr->getTitle(), NULL, $pr->getOutputFormat()), $pr);
752790 break;
753791 }
754792 }
@@ -1269,7 +1307,7 @@
12701308 }
12711309 }
12721310 } elseif ($description instanceof SMWSomeAttribute) {
1273 - $id = SMWDataValueFactory::getAttributeObjectTypeID($description->getAttribute());
 1311+ $id = SMWDataValueFactory::getPropertyObjectTypeID($description->getAttribute());
12741312 switch ($id) {
12751313 case '_txt':
12761314 $table = 'TEXT';
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php
@@ -129,60 +129,144 @@
130130 abstract function getSpecialSubjects($specialprop, $value, $requestoptions = NULL);
131131
132132 /**
 133+ * Get an array of all property values stored for the given subject and property. The result
 134+ * is an array of SMWDataValue objects. The provided outputformat is a string identifier that
 135+ * may be used by the datavalues to modify their output behaviour, e.g. when interpreted as a
 136+ * desired unit to convert the output to.
 137+ */
 138+ abstract function getPropertyValues(Title $subject, Title $property, $requestoptions = NULL, $outputformat = '');
 139+
 140+ /**
 141+ * Get an array of all subjects that have the given value for the given property. The
 142+ * result is an array of Title objects.
 143+ */
 144+ abstract function getPropertySubjects(Title $property, SMWDataValue $value, $requestoptions = NULL);
 145+
 146+ /**
 147+ * Get an array of all subjects that have some value for the given property. The
 148+ * result is an array of Title objects.
 149+ */
 150+ abstract function getAllPropertySubjects(Title $property, $requestoptions = NULL);
 151+
 152+ /**
 153+ * Get an array of all properties for which the given subject has some value. The result is an
 154+ * array of Title objects.
 155+ */
 156+ abstract function getProperties(Title $subject, $requestoptions = NULL);
 157+
 158+ /**
 159+ * Get an array of all properties for which there is some subject that relates to the given value.
 160+ * The result is an array of Title objects.
 161+ * This function might be implemented partially so that only values of type Page (_wpg) are supported.
 162+ */
 163+ abstract function getInProperties(SMWDataValue $object, $requestoptions = NULL);
 164+
 165+
 166+
 167+////// Transition methods (deprecated)
 168+
 169+ /**
133170 * Get an array of all attribute values stored for the given subject and atttribute. The result
134171 * is an array of SMWDataValue objects. The provided outputformat is a string identifier that
135172 * may be used by the datavalues to modify their output behaviour, e.g. when interpreted as a
136173 * desierd unit to convert the output to.
 174+ * @DEPRECATED
137175 */
138 - abstract function getAttributeValues(Title $subject, Title $attribute, $requestoptions = NULL, $outputformat = '');
 176+ function getAttributeValues(Title $subject, Title $attribute, $requestoptions = NULL, $outputformat = '') {
 177+ trigger_error("Function getAttributeValues is deprecated. Use new property methods.", E_USER_NOTICE);
 178+ return $this->getPropertyValues($subject, $attribute, $requestoptions, $outputformat);
 179+ }
139180
140181 /**
141182 * Get an array of all subjects that have the given value for the given attribute. The
142183 * result is an array of Title objects.
 184+ * @DEPRECATED
143185 */
144 - abstract function getAttributeSubjects(Title $relation, SMWDataValue $value, $requestoptions = NULL);
 186+ function getAttributeSubjects(Title $attribute, SMWDataValue $value, $requestoptions = NULL) {
 187+ trigger_error("Function getAttributeSubjects is deprecated. Use new property methods.", E_USER_NOTICE);
 188+ return $this->getPropertySubjects($attribute,$value,$requestoptions);
 189+ }
145190
146191 /**
147192 * Get an array of all subjects that have some value for the given attribute. The
148193 * result is an array of Title objects.
 194+ * @DEPRECATED
149195 */
150 - abstract function getAllAttributeSubjects(Title $attribute, $requestoptions = NULL);
 196+ function getAllAttributeSubjects(Title $attribute, $requestoptions = NULL) {
 197+ trigger_error("Function getAllAttributeSubjects is deprecated. Use new property methods.", E_USER_NOTICE);
 198+ return $this->getAllPropertySubjects($attribute,$requestoptions);
 199+ }
151200
152201 /**
153202 * Get an array of all attributes for which the given subject has some value. The result is an
154203 * array of Title objects.
 204+ * @DEPRECATED
155205 */
156 - abstract function getAttributes(Title $subject, $requestoptions = NULL);
 206+ function getAttributes(Title $subject, $requestoptions = NULL) {
 207+ trigger_error("Function getAttributes is deprecated. Use new property methods.", E_USER_NOTICE);
 208+ return $this->getProperties($subject, $requestoptions);
 209+ }
157210
158211 /**
159212 * Get an array of all objects that a given subject relates to via the given relation. The
160213 * result is an array of Title objects.
 214+ * @DEPRECATED
161215 */
162 - abstract function getRelationObjects(Title $subject, Title $relation, $requestoptions = NULL);
 216+ function getRelationObjects(Title $subject, Title $relation, $requestoptions = NULL) {
 217+ trigger_error("Function getRelationObjects is deprecated. Use new property methods.", E_USER_NOTICE);
 218+ $dvs = $this->getPropertyValues($subject, $relation, $requestoptions);
 219+ $result = array();
 220+ foreach ($dvs as $dv) {
 221+ if ($dv->getTypeID() == '_wpg') {
 222+ $result[] = $dv->getTitle();
 223+ }
 224+ }
 225+ return $result;
 226+ }
163227
164228 /**
165229 * Get an array of all subjects that are related to a given object via the given relation. The
166230 * result is an array of Title objects.
 231+ * @DEPRECATED
167232 */
168 - abstract function getRelationSubjects(Title $relation, Title $object, $requestoptions = NULL);
 233+ function getRelationSubjects(Title $relation, Title $object, $requestoptions = NULL) {
 234+ trigger_error("Function getRelationSubjects is deprecated. Use new property methods.", E_USER_NOTICE);
 235+ $value = SMWDataValueFactory::newTypeIDValue('_wpg');
 236+ $value->setValues($object->getDBKey(), $object->getNamespace());
 237+ return $this->getPropertySubjects($relation, $value, $requestoptions);
 238+ }
169239
170240 /**
171241 * Get an array of all subjects that relate to some object via the given relation. The
172242 * result is an array of Title objects.
 243+ * @DEPRECATED
173244 */
174 - abstract function getAllRelationSubjects(Title $relation, $requestoptions = NULL);
 245+ function getAllRelationSubjects(Title $relation, $requestoptions = NULL) {
 246+ trigger_error("Function getAllPropertySubjects is deprecated. Use new property methods.", E_USER_NOTICE);
 247+ return $this->getAllPropertySubjects($relation, $requestoptions);
 248+ }
175249
176250 /**
177251 * Get an array of all relations via which the given subject relates to some object. The result is an
178252 * array of Title objects.
 253+ * @DEPRECATED
179254 */
180 - abstract function getOutRelations(Title $subject, $requestoptions = NULL);
 255+ function getOutRelations(Title $subject, $requestoptions = NULL) {
 256+ trigger_error("Function getOutRelations is deprecated. Use new property methods.", E_USER_NOTICE);
 257+ return $this->getProperties($subject, $requestoptions);
 258+ }
181259
182260 /**
183261 * Get an array of all relations for which there is some subject that relates to the given object.
184262 * The result is an array of Title objects.
 263+ * @DEPRECATED
185264 */
186 - abstract function getInRelations(Title $object, $requestoptions = NULL);
 265+ function getInRelations(Title $object, $requestoptions = NULL) {
 266+ trigger_error("Function getInRelations is deprecated. Use new property methods.", E_USER_NOTICE);
 267+ $value = SMWDataValueFactory::newTypeIDValue('_wpg');
 268+ $value->setValues($object->getDBKey(), $object->getNamespace());
 269+ return $this->getInProperties($value,$requestoptions);
 270+ }
187271
188272 ///// Writing methods /////
189273
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_DV_URI.php
@@ -62,7 +62,6 @@
6363 break;
6464 }
6565 $this->m_value = str_replace(array('&','<',' '),array('&amp;','&lt;','_'),$value); // TODO: spaces are just not allowed and should lead to an error
66 - $this->m_infolinks[] = SMWInfolink::newAttributeSearchLink('+', $this->m_attribute, $this->m_value);
6766 } else {
6867 $this->addError(wfMsgForContent('smw_emptystring'));
6968 }
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageRu.php
@@ -147,22 +147,13 @@
148148 'smw_ask_ascorder' => 'По возрастанию',
149149 'smw_ask_descorder' => 'По убыванию',
150150 'smw_ask_submit' => 'Найти',
151 - // Messages for search by relation Special
152 - 'searchbyrelation' => 'Искать по отношению',
153 - 'smw_tb_docu' => '<p>Искать все страницы, которые содержат указанное отношение к заданной странице.</p>',
154 - 'smw_tb_notype' => '<p>Укажите отношение или <a href="$2">просмотрите все ссылки на $1.</a></p>',
155 - 'smw_tb_notarget' => '<p>Укажите страницу или просмотрите все отношения $1.</p>',
156 - 'smw_tb_displayresult' => 'Список всех страниц, которые содержат отношение $1 к странице $2.',
157 - 'smw_tb_linktype' => 'Отношение',
158 - 'smw_tb_linktarget' => 'к',
159 - 'smw_tb_submit' => 'Найти',
160 - // Messages for the search by attribute special
161 - 'searchbyattribute' => 'Искать по атрибуту',
 151+ // Messages for the search by property special
 152+ 'searchbyproperty' => 'Искать по атрибуту',
162153 'smw_sbv_docu' => '<p>Искать все страницы, которые содержат указанный атрибут и значение.</p>',
163 - 'smw_sbv_noattribute' => '<p>Укажите атрибут.</p>',
 154+ 'smw_sbv_noproperty' => '<p>Укажите атрибут.</p>',
164155 'smw_sbv_novalue' => '<p>Укажите значение или просмотрите все значения атрибута $1.</p>',
165156 'smw_sbv_displayresult' => 'Список всех страниц, которые содержат атрибут $1 со значением $2.',
166 - 'smw_sbv_attribute' => 'Атрибут',
 157+ 'smw_sbv_property' => 'Атрибут',
167158 'smw_sbv_value' => 'значение',
168159 'smw_sbv_submit' => 'Найти',
169160 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEs.php
@@ -156,22 +156,13 @@
157157 'smw_ask_ascorder' => 'Ascendente',
158158 'smw_ask_descorder' => 'Descendente',
159159 'smw_ask_submit' => 'Buscar resultados',
160 - // Messages for search by relation Special
161 - 'searchbyrelation' => 'Buscar por relacion',
162 - 'smw_tb_docu' => '<p>Buscar para todas las páginas que tenga una cierta relación con la página objetivo dada.</p>',
163 - 'smw_tb_notype' => '<p>Por favor introduzca una relación, o <a href="$2">ver todos los enlaces a $1.</a></p>',
164 - 'smw_tb_notarget' => '<p>Por favor introduzca una página objetivo, o ver todas las $1 relaciones.</p>',
165 - 'smw_tb_displayresult' => 'Un listado de páginas que tienen una relación $1 a la página $2.',
166 - 'smw_tb_linktype' => 'Relación',
167 - 'smw_tb_linktarget' => 'A',
168 - 'smw_tb_submit' => 'Buscar resultados',
169 - // Messages for the search by attribute special
170 - 'searchbyattribute' => 'Buscar por atributo',
 160+ // Messages for the search by property special
 161+ 'searchbyproperty' => 'Buscar por atributo',
171162 'smw_sbv_docu' => '<p>Buscar por todas las páginas que tiene un atributo y valor dado.</p>',
172 - 'smw_sbv_noattribute' => '<p>Por favor introduzca un atributo.</p>',
 163+ 'smw_sbv_noproperty' => '<p>Por favor introduzca un atributo.</p>',
173164 'smw_sbv_novalue' => '<p>Por favor introduzca un valor, o ver todos los valores de atributo para $1.</p>',
174165 'smw_sbv_displayresult' => 'Una lista de todas las páginas que tienen un atributo $1 con el valor $2.',
175 - 'smw_sbv_attribute' => 'Atributo',
 166+ 'smw_sbv_property' => 'Atributo',
176167 'smw_sbv_value' => 'Valor',
177168 'smw_sbv_submit' => 'Buscar resultados',
178169 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageFr.php
@@ -157,22 +157,13 @@
158158 'smw_ask_ascorder' => 'Croissant',
159159 'smw_ask_descorder' => 'Décroissant',
160160 'smw_ask_submit' => 'Trouver des résultats',
161 - // Messages for search by relation Special
162 - 'searchbyrelation' => 'Rechercher par relation',
163 - 'smw_tb_docu' => '<p>Rechercher toutes les pages qui ont une certaine relation à la page cible.</p>',
164 - 'smw_tb_notype' => '<p>Veuillez entrer une relation, ou <a href="$2">voir tous les liens vers $1.</a></p>',
165 - 'smw_tb_notarget' => '<p>Veuillez entrer une page cible, ou voir toutes les relations à $1.</p>',
166 - 'smw_tb_displayresult' => 'Liste de toutes les pages qui ont une relation $1 à la page $2.',
167 - 'smw_tb_linktype' => 'Relation',
168 - 'smw_tb_linktarget' => 'À',
169 - 'smw_tb_submit' => 'Trouver des résultats',
170 - // Messages for the search by attribute special
171 - 'searchbyattribute' => 'Rechercher par attribut',
 161+ // Messages for the search by property special
 162+ 'searchbyproperty' => 'Rechercher par attribut',
172163 'smw_sbv_docu' => '<p>Rechercher toutes les pages qui ont un attribut donné avec un certaine valeur.</p>',
173 - 'smw_sbv_noattribute' => '<p>Veuillez entrer un attribut.</p>',
 164+ 'smw_sbv_noproperty' => '<p>Veuillez entrer un attribut.</p>',
174165 'smw_sbv_novalue' => '<p>Veuillez entrer une valeur ou consulter toutes les valeurs des attributs pour $1.</p>',
175166 'smw_sbv_displayresult' => 'Liste de toutes les pages qui ont un attribut $1 avec la valeur $2.',
176 - 'smw_sbv_attribute' => 'Attribut',
 167+ 'smw_sbv_property' => 'Attribut',
177168 'smw_sbv_value' => 'Valeur',
178169 'smw_sbv_submit' => 'Trouver des résultats',
179170 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageDe.php
@@ -157,22 +157,13 @@
158158 'smw_ask_ascorder' => 'Aufsteigend',
159159 'smw_ask_descorder' => 'Absteigend',
160160 'smw_ask_submit' => 'Finde Ergebnisse',
161 - // Messages for search by relation Special
162 - 'searchbyrelation' => 'Suche mittels Relation',
163 - 'smw_tb_docu' => '<p>Diese Spezialseite findet alle Seiten, die eine bestimmte Relation zur angegebenen Zielseite haben.</p>',
164 - 'smw_tb_notype' => '<p>Bitte den Namen einer Relation eingeben oder <a href="$2">alle Links zur Seite $1 ansehen.</a></p>',
165 - 'smw_tb_notarget' => '<p>Bitte den Namen der Zeilseite eingeben oder alle Verwendungen der Relation $1 ansehen.</p>',
166 - 'smw_tb_displayresult' => 'Eine Liste aller Seiten mit der Relation $1 zur Seite $2.',
167 - 'smw_tb_linktype' => 'Relation',
168 - 'smw_tb_linktarget' => 'Zu',
169 - 'smw_tb_submit' => 'Finde Ergebnisse',
170 - // Messages for the search by attribute special
171 - 'searchbyattribute' => 'Suche mittels Attribut',
172 - 'smw_sbv_docu' => '<p>Diese Spezialseite findet alle Seiten, die einen bestimmten Wert für das angegebene Attribut haben.</p>',
173 - 'smw_sbv_noattribute' => '<p>Bitte den Namen eines Attributs eingeben</p>',
174 - 'smw_sbv_novalue' => '<p>Bitte den gewünschten Wert eingeben oder alle Werte für das Attribut $1 ansehen.</p>',
175 - 'smw_sbv_displayresult' => 'Eine Liste aller Seiten, die ein Attribut $1 mit dem Wert $2 haben.',
176 - 'smw_sbv_attribute' => 'Attribut',
 161+ // Messages for the search by property special
 162+ 'searchbyproperty' => 'Suche mittels Eigenschaft',
 163+ 'smw_sbv_docu' => '<p>Diese Spezialseite findet alle Seiten, die einen bestimmten Wert für die angegebene Eigenschaft haben.</p>',
 164+ 'smw_sbv_noproperty' => '<p>Bitte den Namen einer Eigenschaft eingeben</p>',
 165+ 'smw_sbv_novalue' => '<p>Bitte den gewünschten Wert eingeben oder alle Werte für die Eingenschaft $1 ansehen.</p>',
 166+ 'smw_sbv_displayresult' => 'Eine Liste aller Seiten, die eine Eigenschaft $1 mit dem Wert $2 haben.',
 167+ 'smw_sbv_property' => 'Eigenschaft',
177168 'smw_sbv_value' => 'Wert',
178169 'smw_sbv_submit' => 'Finde Ergebnisse',
179170 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguagePl.php
@@ -187,22 +187,13 @@
188188 'smw_ask_ascorder' => 'Rosnąco',
189189 'smw_ask_descorder' => 'Malejąco',
190190 'smw_ask_submit' => 'Szukaj wyników',
191 - // Messages for search by relation Special
192 - 'searchbyrelation' => 'Szukaj po relacji',
193 - 'smw_tb_docu' => '<p>Szukanie wszystkich stron, które są w pewnej relacji do danej strony docelowej.</p>',
194 - 'smw_tb_notype' => '<p>Wpisz relację, lub <a href="$2">zobacz wszystkie linki do $1.</a></p>',
195 - 'smw_tb_notarget' => '<p>Wpisz stronę docelową, lub zobacz wszystkie relacje $1.</p>',
196 - 'smw_tb_displayresult' => 'Lista wszystkich stron, które są w relacji $1 do strony $2.',
197 - 'smw_tb_linktype' => 'Relacja',
198 - 'smw_tb_linktarget' => 'Do',
199 - 'smw_tb_submit' => 'Znajdź wyniki',
200 - // Messages for the search by attribute special
201 - 'searchbyattribute' => 'Szukaj po atrybucie',
 191+ // Messages for the search by property special
 192+ 'searchbyproperty' => 'Szukaj po atrybucie',
202193 'smw_sbv_docu' => '<p>Szukanie wszystkich stron, które mają dany atrybut i wartość.</p>',
203 - 'smw_sbv_noattribute' => '<p>Wpisz atrybut.</p>',
 194+ 'smw_sbv_noproperty' => '<p>Wpisz atrybut.</p>',
204195 'smw_sbv_novalue' => '<p>Wpisz wartość, lub zobacz wszystkie wartości atrybutów dla $1.</p>',
205196 'smw_sbv_displayresult' => 'Lista wszystkich stron, które mają atrybut $1 z wartością $2.',
206 - 'smw_sbv_attribute' => 'Atrybut',
 197+ 'smw_sbv_property' => 'Atrybut',
207198 'smw_sbv_value' => 'Wartość',
208199 'smw_sbv_submit' => 'Znajdź wyniki',
209200 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageHe.php
@@ -165,22 +165,13 @@
166166 'smw_ask_ascorder' => 'בסדר עולה',
167167 'smw_ask_descorder' => 'בסדר יורד',
168168 'smw_ask_submit' => 'חפש תוצאות',
169 - // Messages for search by relation Special
170 - 'searchbyrelation' => 'Search by relation', //TODO: translate
171 - 'smw_tb_docu' => '<p>Search for all pages that have a certain relation to the given target page.</p>', //TODO: translate
172 - 'smw_tb_notype' => '<p>Please enter a relation, or <a href="$2">view all links to $1.</a></p>', //TODO: translate
173 - 'smw_tb_notarget' => '<p>Please enter a target page, or view all $1 relations.</p>', //TODO: translate
174 - 'smw_tb_displayresult' => 'A list of all pages that have a relation $1 to the page $2.', //TODO: translate
175 - 'smw_tb_linktype' => 'Relation', //TODO: translate
176 - 'smw_tb_linktarget' => 'To', //TODO: translate
177 - 'smw_tb_submit' => 'Find results', //TODO: translate
178 - // Messages for the search by attribute special
179 - 'searchbyattribute' => 'Search by attribute', //TODO: translate
180 - 'smw_sbv_docu' => '<p>Search for all pages that have a given attribute and value.</p>', //TODO: translate
181 - 'smw_sbv_noattribute' => '<p>Please enter an attribute.</p>', //TODO: translate
182 - 'smw_sbv_novalue' => '<p>Please enter a value, or view all attributes values for $1.</p>', //TODO: translate
183 - 'smw_sbv_displayresult' => 'A list of all pages that have an attribute $1 with value $2.', //TODO: translate
184 - 'smw_sbv_attribute' => 'Attribute', //TODO: translate
 169+ // Messages for the search by property special TODO: translate
 170+ 'searchbyproperty' => 'Search by property', //TODO: translate
 171+ 'smw_sbv_docu' => '<p>Search for all pages that have a given property and value.</p>', //TODO: translate
 172+ 'smw_sbv_noproperty' => '<p>Please enter a property.</p>', //TODO: translate
 173+ 'smw_sbv_novalue' => '<p>Please enter a valid value for the property, or view all property values for “$1.”</p>', //TODO: translate
 174+ 'smw_sbv_displayresult' => 'A list of all pages that have property “$1” with value “$2”', //TODO: translate
 175+ 'smw_sbv_property' => 'Property', //TODO: translate
185176 'smw_sbv_value' => 'Value', //TODO: translate
186177 'smw_sbv_submit' => 'Find results', //TODO: translate
187178 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageSk.php
@@ -167,22 +167,13 @@
168168 'smw_ask_ascorder' => 'Vzostupne',
169169 'smw_ask_descorder' => 'Zostupne',
170170 'smw_ask_submit' => 'Nájdi výsledky',
171 - // Messages for typed backlink Special // TODO: consider re-translation (look at new English version)
172 - 'searchbyrelation' => 'Typové spätné odkazy',
173 - 'smw_tb_docu' => '<p>Vyhľadávať na wiki akýkoľvek článok s istým typom odkazu na zadaný cieľ.</p>',
174 - 'smw_tb_notype' => '<p>Nebol poskytnutý typ odkazu. Prosím, poskytnite ho vo formulári alebo <a href="$2">kliknite sem pre zobrazenie všetkých odkazov na $1</a></p>',
175 - 'smw_tb_notarget' => '<p>Nebola poskytnutá cieľová stránka pre spätné odkazy. Prosím, poskytnite ju vo formulári alebo zobrazte všetky odkazy typu $1</p>',
176 - 'smw_tb_displayresult' => 'Zoznam všetkých článkov, ktoré majú vzťah $1 $2.',
177 - 'smw_tb_linktype' => 'Typ odkazu:',
178 - 'smw_tb_linktarget' => 'Cieľ odkazu:',
179 - 'smw_tb_submit' => 'Hľadať výsledky',
180171 // Messages for the search by value special // TODO: consider re-translation (look at new English version)
181 - 'searchbyattribute' => 'Hľadať podľa hodnoty atribútu',
 172+ 'searchbyproperty' => 'Hľadať podľa hodnoty atribútu',
182173 'smw_sbv_docu' => '<p>Hľadať na wiki článok, ktorý má atribút s istou hodnotou.</p>',
183 - 'smw_sbv_noattribute' => '<p>Nebol poskytnutý atribút. Prosím, poskytnite ho vo formulári.</p>',
 174+ 'smw_sbv_noproperty' => '<p>Nebol poskytnutý atribút. Prosím, poskytnite ho vo formulári.</p>',
184175 'smw_sbv_novalue' => '<p>Nebola poskytnutá hodnota. Prosím, poskytnite ju vo formulári alebo zobrazte všetky atribúty typu $1</p>',
185176 'smw_sbv_displayresult' => 'Zoznam všetkých článkov, ktoré majú atribút $1 $2.',
186 - 'smw_sbv_attribute' => 'Atribút:',
 177+ 'smw_sbv_property' => 'Atribút:',
187178 'smw_sbv_value' => 'Hodnota:',
188179 'smw_sbv_submit' => 'Hľadať výsledky',
189180 // Messages for the browsing system
Index: trunk/extensions/SemanticMediaWiki/languages/SMW_LanguageEn.php
@@ -166,22 +166,13 @@
167167 'smw_ask_ascorder' => 'Ascending',
168168 'smw_ask_descorder' => 'Descending',
169169 'smw_ask_submit' => 'Find results',
170 - // Messages for search by relation Special
171 - 'searchbyrelation' => 'Search by relation',
172 - 'smw_tb_docu' => '<p>Search for all pages that have a certain relation to the given target page.</p>',
173 - 'smw_tb_notype' => '<p>Please enter a relation, or <a href="$2">view all links to “$1.”</a></p>',
174 - 'smw_tb_notarget' => '<p>Please enter a target page, or view all “$1” relations.</p>',
175 - 'smw_tb_displayresult' => 'A list of all pages that have a relation “$1” to the page “$2”',
176 - 'smw_tb_linktype' => 'Relation',
177 - 'smw_tb_linktarget' => 'To',
178 - 'smw_tb_submit' => 'Find results',
179 - // Messages for the search by attribute special
180 - 'searchbyattribute' => 'Search by attribute',
181 - 'smw_sbv_docu' => '<p>Search for all pages that have a given attribute and value.</p>',
182 - 'smw_sbv_noattribute' => '<p>Please enter an attribute.</p>',
183 - 'smw_sbv_novalue' => '<p>Please enter a valid value for the attribute, or view all attributes values for “$1.”</p>',
184 - 'smw_sbv_displayresult' => 'A list of all pages that have an attribute “$1” with value “$2”',
185 - 'smw_sbv_attribute' => 'Attribute',
 170+ // Messages for the search by property special
 171+ 'searchbyproperty' => 'Search by property',
 172+ 'smw_sbv_docu' => '<p>Search for all pages that have a given property and value.</p>',
 173+ 'smw_sbv_noproperty' => '<p>Please enter a property.</p>',
 174+ 'smw_sbv_novalue' => '<p>Please enter a valid value for the property, or view all property values for “$1.”</p>',
 175+ 'smw_sbv_displayresult' => 'A list of all pages that have property “$1” with value “$2”',
 176+ 'smw_sbv_property' => 'Property',
186177 'smw_sbv_value' => 'Value',
187178 'smw_sbv_submit' => 'Find results',
188179 // Messages for the browsing special

Status & tagging log