r73379 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73378‎ | r73379 | r73380 >
Date:14:33, 20 September 2010
Author:jeroendedauw
Status:deferred (Comments)
Tags:
Comment:
A bunch of small improvements
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_RAPStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2Table.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php (modified) (history)
  • /trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php
@@ -51,6 +51,8 @@
5252 /**
5353 * Static function for creating a new wikipage object from a
5454 * MediaWiki Title object.
 55+ *
 56+ * @return SMWWikiPageValue
5557 */
5658 static public function makePageFromTitle( $titleobject ) {
5759 $page = new SMWWikiPageValue( '_wpg' );
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php
@@ -1,40 +1,67 @@
22 <?php
3 -/**
4 - * Abstract class to encapsulate properties of OrderedListPages.
5 - * Some code adapted from CategoryPage.php
6 - *
7 - * @author Nikolas Iwan
8 - * @author Markus Krötzsch
9 - * @file
10 - * @ingroup SMW
11 - */
123
134 /**
145 * Abstract subclass of MediaWiki's Article that handles the common tasks of
156 * article pages for Types and Properties. Mostly, it implements general processing
167 * and the generation of suitable navigation links from results sets and HTTP
178 * parameters.
18 - *
 9+ *
1910 * Some code adapted from CategoryPage.php
 11+ *
 12+ * @file SMW_OrderedListPage.php
2013 * @ingroup SMW
 14+ *
 15+ * @author Nikolas Iwan
 16+ * @author Markus Krötzsch
 17+ * @author Jeroen De Dauw
2118 */
2219 abstract class SMWOrderedListPage extends Article {
2320
24 - protected $limit; // limit for results per page
25 - protected $from; // start string: print $limit results from here
26 - protected $until; // end string: print $limit results strictly before this article
27 - protected $articles; // array of articles for which information is printed (primary ordering method)
28 - protected $skin; // cache for the current skin, obtained from $wgUser
 21+ /**
 22+ * Limit for results per page.
 23+ *
 24+ * @var integer
 25+ */
 26+ protected $limit;
2927
3028 /**
 29+ * Start string: print $limit results from here.
 30+ *
 31+ * @var string
 32+ */
 33+ protected $from;
 34+
 35+ /**
 36+ * End string: print $limit results strictly before this article.
 37+ *
 38+ * @var string
 39+ */
 40+ protected $until;
 41+
 42+ /**
 43+ * Array of articles for which information is printed (primary ordering method).
 44+ *
 45+ * @var array
 46+ */
 47+ protected $articles;
 48+
 49+ /**
 50+ * Cache for the current skin, obtained from $wgUser.
 51+ *
 52+ * @var Skin
 53+ */
 54+ protected $skin;
 55+
 56+ /**
3157 * Overwrite view() from Article.php to add additional html to the output.
3258 */
3359 public function view() {
3460 global $wgRequest, $wgUser;
3561
36 - // copied from CategoryPage ...
 62+ // Copied from CategoryPage
3763 $diff = $wgRequest->getVal( 'diff' );
3864 $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );
 65+
3966 if ( isset( $diff ) && $diffOnly ) {
4067 return Article::view();
4168 }
@@ -48,13 +75,17 @@
4976 */
5077 protected function showList() {
5178 wfProfileIn( __METHOD__ . ' (SMW)' );
 79+
5280 global $wgOut, $wgRequest;
 81+
5382 $this->from = $wgRequest->getVal( 'from' );
5483 $this->until = $wgRequest->getVal( 'until' );
 84+
5585 if ( $this->initParameters() ) {
5686 $wgOut->addHTML( $this->getHTML() );
5787 SMWOutputs::commitToOutputPage( $wgOut ); // Flush required CSS to output
5888 }
 89+
5990 wfProfileOut( __METHOD__ . ' (SMW)' );
6091 }
6192
@@ -63,6 +94,8 @@
6495 * (e.g. $limit). Method can be overwritten in this case.
6596 * If the method returns false, nothing will be printed besides
6697 * the original article.
 98+ *
 99+ * @return true
67100 */
68101 protected function initParameters() {
69102 $this->limit = 20;
@@ -71,12 +104,16 @@
72105
73106 /**
74107 * Returns HTML which is added to wgOut.
 108+ *
 109+ * @return string
75110 */
76111 protected function getHTML() {
77112 global $wgOut;
 113+
78114 $this->clearPageState();
79115 $this->doQuery();
80116 $r = "<br id=\"smwfootbr\"/>\n" . $this->getPages();
 117+
81118 return $r;
82119 }
83120
@@ -104,19 +141,23 @@
105142 */
106143 protected function getNavigationLinks( $query = array() ) {
107144 global $wgUser, $wgLang;
 145+
108146 $sk = $this->getSkin();
109147 $limitText = $wgLang->formatNum( $this->limit );
110148
111149 $ac = count( $this->articles );
 150+
112151 if ( $this->until != '' ) {
113152 if ( $ac > $this->limit ) { // (we assume that limit is at least 1)
114153 $first = $this->articles[1]->getSortkey();
115154 } else {
116155 $first = '';
117156 }
 157+
118158 $last = $this->until;
119159 } elseif ( ( $ac > $this->limit ) || ( $this->from != '' ) ) {
120160 $first = $this->from;
 161+
121162 if ( $ac > $this->limit ) {
122163 $last = $this->articles[$ac - 1]->getSortkey();
123164 } else {
@@ -127,32 +168,40 @@
128169 }
129170
130171 $prevLink = htmlspecialchars( wfMsg( 'prevn', $limitText ) );
131 - $this->mTitle->setFragment( '#SMWResults' ); // make navigation point to the result list
 172+ $this->mTitle->setFragment( '#SMWResults' ); // Make navigation point to the result list.
 173+
132174 if ( $first != '' ) {
133175 $prevLink = $sk->makeLinkObj( $this->mTitle, $prevLink,
134176 wfArrayToCGI( $query + array( 'until' => $first ) ) );
135177 }
136178 $nextLink = htmlspecialchars( wfMsg( 'nextn', $limitText ) );
 179+
137180 if ( $last != '' ) {
138181 $nextLink = $sk->makeLinkObj( $this->mTitle, $nextLink,
139182 wfArrayToCGI( $query + array( 'from' => $last ) ) );
140183 }
 184+
141185 return "($prevLink) ($nextLink)";
142186 }
143187
144188 /**
145189 * Fetch and return the relevant skin object.
 190+ *
 191+ * @return Skin
146192 */
147193 protected function getSkin() {
148194 if ( !$this->skin ) {
149195 global $wgUser;
150196 $this->skin = $wgUser->getSkin();
151197 }
 198+
152199 return $this->skin;
153200 }
154201
155202 /**
156203 * Like Article's getTitle(), but returning a suitable SMWWikiPageValue
 204+ *
 205+ * @return SMWWikiPageValue
157206 */
158207 protected function getDataValue() {
159208 return SMWWikiPageValue::makePageFromTitle( $this->getTitle() );
@@ -161,18 +210,25 @@
162211 /**
163212 * Format a list of SMWWikipageValues chunked by letter in a three-column
164213 * list, ordered vertically.
 214+ *
 215+ * @param integer $start
 216+ * @param integer $end
 217+ * @param array $elements
 218+ *
 219+ * @return string
165220 */
166221 protected function columnList( $start, $end, $elements ) {
167222 global $wgContLang;
168 - // divide list into three equal chunks
 223+
 224+ // Divide list into three equal chunks.
169225 $chunk = (int) ( ( $end - $start + 1 ) / 3 );
170226
171 - // get and display header
 227+ // Get and display header.
172228 $r = '<table width="100%"><tr valign="top">';
173229
174230 $prev_start_char = 'none';
175231
176 - // loop through the chunks
 232+ // Loop through the chunks.
177233 for ( $startChunk = $start, $endChunk = $chunk, $chunkIndex = 0;
178234 $chunkIndex < 3;
179235 $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1 ) {
@@ -180,11 +236,10 @@
181237 $atColumnTop = true;
182238
183239 // output all articles
184 - for ( $index = $startChunk ;
185 - $index < $endChunk && $index < $end;
186 - $index++ ) {
 240+ for ( $index = $startChunk ; $index < $endChunk && $index < $end; $index++ ) {
187241 // check for change of starting letter or begining of chunk
188242 $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$index]->getSortkey() ) );
 243+
189244 if ( ( $index == $startChunk ) ||
190245 ( $start_char != $prev_start_char ) ) {
191246 if ( $atColumnTop ) {
@@ -192,46 +247,63 @@
193248 } else {
194249 $r .= "</ul>\n";
195250 }
 251+
196252 $cont_msg = "";
 253+
197254 if ( $start_char == $prev_start_char ) {
198255 $cont_msg = wfMsgHtml( 'listingcontinuesabbrev' );
199256 }
 257+
200258 $r .= "<h3>" . htmlspecialchars( $start_char ) . " $cont_msg</h3>\n<ul>";
201259 $prev_start_char = $start_char;
202260 }
 261+
203262 $r .= "<li>" . $elements[$index]->getLongHTMLText( $this->getSkin() ) . "</li>\n";
204263 }
 264+
205265 if ( !$atColumnTop ) {
206266 $r .= "</ul>\n";
207267 }
 268+
208269 $r .= "</td>\n";
209270 }
 271+
210272 $r .= '</tr></table>';
 273+
211274 return $r;
212275 }
213276
214277 /**
215278 * Format a list of articles chunked by letter in a bullet list.
 279+ *
 280+ * @param integer $start
 281+ * @param integer $end
 282+ * @param array $elements
 283+ *
 284+ * @return string
216285 */
217 - protected function shortList( $start, $end, $elements ) {
 286+ protected function shortList( $start, $end, array $elements ) {
218287 global $wgContLang;
 288+
219289 $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$start]->getSortkey() ) );
220290 $prev_start_char = $start_char;
221291 $r = '<h3>' . htmlspecialchars( $start_char ) . "</h3>\n";
222292 $r .= '<ul><li>' . $elements[$start]->getLongHTMLText( $this->getSkin() ) . '</li>';
 293+
223294 for ( $index = $start + 1; $index < $end; $index++ ) {
224295 $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$index]->getSortkey() ) );
 296+
225297 if ( $start_char != $prev_start_char ) {
226298 $r .= "</ul><h3>" . htmlspecialchars( $start_char ) . "</h3>\n<ul>";
227299 $prev_start_char = $start_char;
228300 }
 301+
229302 $r .= '<li>' . $elements[$index]->getLongHTMLText( $this->getSkin() ) . '</li>';
230303 }
 304+
231305 $r .= '</ul>';
 306+
232307 return $r;
233308 }
234309
235 -}
236 -
237 -
238 -
 310+}
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php
@@ -1,18 +1,16 @@
22 <?php
3 -/**
4 - * Special handling for property description pages.
5 - * Some code based on CategoryPage.php
6 - *
7 - * @author: Markus Krötzsch
8 - * @file
9 - * @ingroup SMW
10 - */
113
124 /**
135 * Implementation of MediaWiki's Article that shows additional information on
146 * property pages. Very similar to CategoryPage, but with different printout
157 * that also displays values for each subject with the given property.
 8+ *
 9+ * Some code based on CategoryPage.php
 10+ *
 11+ * @file SMW_PropertyPage.php
1612 * @ingroup SMW
 13+ *
 14+ * @author: Markus Krötzsch
1715 */
1816 class SMWPropertyPage extends SMWOrderedListPage {
1917
@@ -24,9 +22,11 @@
2523 */
2624 protected function initParameters() {
2725 global $smwgContLang, $smwgPropertyPagingLimit;
 26+
2827 $this->limit = $smwgPropertyPagingLimit;
2928 $this->mProperty = SMWPropertyValue::makeProperty( $this->mTitle->getDBkey() );
3029 $this->mProperty->setInverse( false );
 30+
3131 return true;
3232 }
3333
@@ -41,11 +41,13 @@
4242 */
4343 protected function doQuery() {
4444 $store = smwfGetStore();
 45+
4546 if ( $this->limit > 0 ) { // for limit==0 there is no paging, and no query
4647 $options = new SMWRequestOptions();
4748 $options->limit = $this->limit + 1;
4849 $options->sort = true;
4950 $reverse = false;
 51+
5052 if ( $this->from != '' ) {
5153 $options->boundary = $this->from;
5254 $options->ascending = true;
@@ -56,7 +58,9 @@
5759 $options->include_boundary = false;
5860 $reverse = true;
5961 }
 62+
6063 $this->articles = $store->getAllPropertySubjects( $this->mProperty, $options );
 64+
6165 if ( $reverse ) {
6266 $this->articles = array_reverse( $this->articles );
6367 }
@@ -80,28 +84,38 @@
8185 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
8286 $r = '';
8387 $ti = htmlspecialchars( $this->mTitle->getText() );
 88+
8489 if ( count( $this->subproperties ) > 0 ) {
8590 $r .= "<div id=\"mw-subcategories\">\n<h2>" . wfMsg( 'smw_subproperty_header', $ti ) . "</h2>\n<p>";
 91+
8692 if ( !$this->mProperty->isUserDefined() ) {
8793 $r .= wfMsg( 'smw_isspecprop' ) . ' ';
8894 }
 95+
8996 $r .= wfMsgExt( 'smw_subpropertyarticlecount', array( 'parsemag' ), count( $this->subproperties ) ) . "</p>\n";
9097 $r .= ( count( $this->subproperties ) < 6 ) ?
9198 $this->shortList( 0, count( $this->subproperties ), $this->subproperties ):
9299 $this->columnList( 0, count( $this->subproperties ), $this->subproperties );
 100+
93101 $r .= "\n</div>";
94102 }
 103+
95104 if ( count( $this->articles ) > 0 ) {
96105 $nav = $this->getNavigationLinks();
 106+
97107 $r .= '<a name="SMWResults"></a>' . $nav . "<div id=\"mw-pages\">\n" .
98108 '<h2>' . wfMsg( 'smw_attribute_header', $ti ) . "</h2>\n<p>";
 109+
99110 if ( !$this->mProperty->isUserDefined() ) {
100111 $r .= wfMsg( 'smw_isspecprop' ) . ' ';
101112 }
 113+
102114 $r .= wfMsgExt( 'smw_attributearticlecount', array( 'parsemag' ), min( $this->limit, count( $this->articles ) ) ) . "</p>\n" .
103115 $this->subjectObjectList() . "\n</div>" . $nav;
104116 }
 117+
105118 wfProfileOut( __METHOD__ . ' (SMW)' );
 119+
106120 return $r;
107121 }
108122
@@ -114,6 +128,7 @@
115129 $store = smwfGetStore();
116130
117131 $ac = count( $this->articles );
 132+
118133 if ( $ac > $this->limit ) {
119134 if ( $this->until != '' ) {
120135 $start = 1;
@@ -127,27 +142,34 @@
128143
129144 $r = '<table style="width: 100%; ">';
130145 $prev_start_char = 'None';
 146+
131147 for ( $index = $start; $index < $ac; $index++ ) {
132148 $start_char = $wgContLang->convert( $wgContLang->firstChar( $this->articles[$index]->getSortkey() ) );
 149+
133150 // Header for index letters
134151 if ( $start_char != $prev_start_char ) {
135152 $r .= '<tr><th class="smwpropname"><h3>' . htmlspecialchars( $start_char ) . "</h3></th><th></th></tr>\n";
136153 $prev_start_char = $start_char;
137154 }
 155+
138156 // Property name
139157 $searchlink = SMWInfolink::newBrowsingLink( '+', $this->articles[$index]->getShortHTMLText() );
140158 $r .= '<tr><td class="smwpropname">' . $this->articles[$index]->getLongHTMLText( $this->getSkin() ) .
141159 '&#160;' . $searchlink->getHTML( $this->getSkin() ) . '</td><td class="smwprops">';
 160+
142161 // Property values
143162 $ropts = new SMWRequestOptions();
144163 $ropts->limit = $smwgMaxPropertyValues + 1;
145164 $values = $store->getPropertyValues( $this->articles[$index], $this->mProperty, $ropts );
146165 $i = 0;
 166+
147167 foreach ( $values as $value ) {
148168 if ( $i != 0 ) {
149169 $r .= ', ';
150170 }
 171+
151172 $i++;
 173+
152174 if ( $i < $smwgMaxPropertyValues + 1 ) {
153175 $r .= $value->getLongHTMLText( $this->getSkin() ) . $value->getInfolinkText( SMW_OUTPUT_HTML, $this->getSkin() );
154176 } else {
@@ -155,11 +177,13 @@
156178 $r .= $searchlink->getHTML( $this->getSkin() );
157179 }
158180 }
 181+
159182 $r .= "</td></tr>\n";
160183 }
 184+
161185 $r .= '</table>';
 186+
162187 return $r;
163188 }
164 -}
165189
166 -
 190+}
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php
@@ -70,7 +70,7 @@
7171 * @param SMWStore $store
7272 * @param boolean $furtherRes
7373 */
74 - public function SMWQueryResult( array $printRequests, SMWQuery $query, array $results, SMWStore $store, $furtherRes = false ) {
 74+ public function __construct( array $printRequests, SMWQuery $query, array $results, SMWStore $store, $furtherRes = false ) {
7575 $this->mResults = $results;
7676 reset( $this->mResults );
7777 $this->mPrintRequests = $printRequests;
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2Table.php
@@ -1,24 +1,20 @@
22 <?php
33
44 /**
5 - * File holding the SMWSQLStore2Table class
6 - *
7 - * @author Markus Krötzsch
8 - * @author Jeroen De Dauw
9 - *
10 - * @file
11 - * @ingroup SMWStore
12 - */
13 -
14 -/**
155 * Simple data container for storing information about property tables. A
166 * property table is a DB table that is used to store subject-property-value
177 * records about data in SMW. Tables mostly differ in the composition of the
188 * value, but also in whether the property is explicitly named (or fixed),
199 * and in the way subject pages are referred to.
 10+ *
 11+ * @file SMW_SQLStore2Table.php
2012 * @ingroup SMWStore
 13+ *
 14+ * @author Markus Krötzsch
 15+ * @author Jeroen De Dauw
2116 */
2217 class SMWSQLStore2Table {
 18+
2319 /**
2420 * Name of the table in the DB.
2521 *
@@ -79,14 +75,14 @@
8076 * Constructor.
8177 *
8278 * @param string $name
83 - * @param array $objectFields
84 - * @param array $indexes
 79+ * @param mixed $objectFields Array of string or a single string
 80+ * @param mixed $indexes Array of string or a single string
8581 * @param mixed $fixedProperty string or false
8682 */
87 - public function __construct( $name, array $objectFields, array $indexes = array(), $fixedProperty = false ) {
 83+ public function __construct( $name, $objectFields, $indexes = array(), $fixedProperty = false ) {
8884 $this->name = $name;
89 - $this->objectfields = $objectFields;
90 - $this->fixedproperty = $fixedProperty;
 85+ $this->objectfields = (array)$objectFields;
 86+ $this->fixedproperty = (array)$fixedProperty;
9187 $this->indexes = $indexes;
9288 }
9389
@@ -94,7 +90,7 @@
9591 * @return string
9692 */
9793 public function getFieldSignature() {
98 - // TODO: this was implode( $this->objectfields, '' ), which might indicate some error where this method is called.
9994 return implode( '', $this->objectfields );
10095 }
 96+
10197 }
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php
@@ -87,8 +87,10 @@
8888 * Refresh the concept cache for the given concept.
8989 *
9090 * @param $concept Title
 91+ *
 92+ * @return array
9193 */
92 - public function refreshConceptCache( $concept ) {
 94+ public function refreshConceptCache( Title $concept ) {
9395 global $smwgQMaxLimit, $smwgQConceptFeatures, $wgDBtype;
9496
9597 $cid = $this->m_store->getSMWPageID( $concept->getDBkey(), SMW_NS_CONCEPT, '' );
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php
@@ -1,8 +1,10 @@
22 <?php
33 /**
44 * Basic abstract classes for SMW's storage abstraction layer.
 5+ *
56 * @file
67 * @ingroup SMWStore
 8+ *
79 * @author Markus Krötzsch
810 */
911
@@ -10,6 +12,7 @@
1113 * This group contains all parts of SMW that relate to storing and retrieving
1214 * semantic data. SMW components that relate to semantic querying only have their
1315 * own group.
 16+ *
1417 * @defgroup SMWStore SMWStore
1518 * @ingroup SMW
1619 */
@@ -18,16 +21,21 @@
1922 * Small data container class for describing filtering conditions on the string
2023 * label of some entity. States that a given string should either be prefix, postfix,
2124 * or some arbitrary part of labels.
 25+ *
2226 * @ingroup SMWStore
 27+ *
 28+ * @author Markus Krötzsch
2329 */
2430 class SMWStringCondition {
2531 const STRCOND_PRE = 0;
2632 const STRCOND_POST = 1;
2733 const STRCOND_MID = 2;
 34+
2835 /**
2936 * String to match.
3037 */
3138 public $string;
 39+
3240 /**
3341 * Condition. One of STRCOND_PRE (string matches prefix),
3442 * STRCOND_POST (string matches postfix), STRCOND_MID
@@ -35,7 +43,7 @@
3644 */
3745 public $condition;
3846
39 - public function SMWStringCondition( $string, $condition ) {
 47+ public function __construct( $string, $condition ) {
4048 $this->string = $string;
4149 $this->condition = $condition;
4250 }
@@ -48,19 +56,25 @@
4957 * to their more complex structure.
5058 * Options that should not be used or where default values should be used
5159 * can be left as initialised.
 60+ *
5261 * @ingroup SMWStore
 62+ *
 63+ * @author Markus Krötzsch
5364 */
5465 class SMWRequestOptions {
 66+
5567 /**
5668 * The maximum number of results that should be returned.
5769 */
58 - public $limit = - 1;
 70+ public $limit = -1;
 71+
5972 /**
6073 * A numerical offset. The first $offset results are skipped.
6174 * Note that this does not imply a defined order of results
6275 * (see SMWRequestOptions->$sort below).
6376 */
6477 public $offset = 0;
 78+
6579 /**
6680 * Should the result be ordered? The employed order is defined
6781 * by the type of result that are requested: Title objects and
@@ -69,22 +83,26 @@
7084 * Usually, the order should be fairly "natural".
7185 */
7286 public $sort = false;
 87+
7388 /**
7489 * If SMWRequestOptions->$sort is true, this parameter defines whether
7590 * the results are ordered in ascending or descending order.
7691 */
7792 public $ascending = true;
 93+
7894 /**
7995 * Specifies a lower or upper bound for the values returned by the query.
8096 * Whether it is lower or upper is specified by the parameter "ascending"
8197 * (true->lower, false->upper).
8298 */
8399 public $boundary = null;
 100+
84101 /**
85102 * Specifies whether or not the requested boundary should be returned
86103 * as a result.
87104 */
88105 public $include_boundary = true;
 106+
89107 /**
90108 * An array of string conditions that are applied if the result has a string
91109 * label that can be subject to those patterns.
@@ -93,6 +111,7 @@
94112
95113 /**
96114 * Set a new string condition applied to labels of results (if available).
 115+ *
97116 * @param $string the string to match
98117 * @param $condition type of condition, one of STRCOND_PRE, STRCOND_POST, STRCOND_MID
99118 */
@@ -106,6 +125,7 @@
107126 public function getStringConditions() {
108127 return $this->stringcond;
109128 }
 129+
110130 }
111131
112132
@@ -114,7 +134,10 @@
115135 * semantic store. Besides the relevant interface, this class provides default
116136 * implementations for some optional methods, which inform the caller that
117137 * these methods are not implemented.
 138+ *
118139 * @ingroup SMWStore
 140+ *
 141+ * @author Markus Krötzsch
119142 */
120143 abstract class SMWStore {
121144
@@ -132,7 +155,7 @@
133156 * than requested when a filter is used. Filtering just ensures that
134157 * only necessary requests are made, i.e. it improves performance.
135158 */
136 - abstract function getSemanticData( $subject, $filter = false );
 159+ public abstract function getSemanticData( $subject, $filter = false );
137160
138161 /**
139162 * Get an array of all property values stored for the given subject and property. The result
@@ -142,28 +165,29 @@
143166 *
144167 * If called with $subject == NULL, all values for the given property are returned.
145168 */
146 - abstract function getPropertyValues( $subject, SMWPropertyValue $property, $requestoptions = null, $outputformat = '' );
 169+ public abstract function getPropertyValues( $subject, SMWPropertyValue $property, $requestoptions = null, $outputformat = '' );
147170
148171 /**
149172 * Get an array of all subjects that have the given value for the given property. The
150173 * result is an array of SMWWikiPageValue objects. If NULL is given as a value, all subjects having
151174 * that property are returned.
152175 */
153 - abstract function getPropertySubjects( SMWPropertyValue $property, $value, $requestoptions = null );
 176+ public abstract function getPropertySubjects( SMWPropertyValue $property, $value, $requestoptions = null );
154177
155178 /**
156179 * Get an array of all subjects that have some value for the given property. The
157180 * result is an array of SMWWikiPageValue objects.
158181 */
159 - abstract function getAllPropertySubjects( SMWPropertyValue $property, $requestoptions = null );
 182+ public abstract function getAllPropertySubjects( SMWPropertyValue $property, $requestoptions = null );
160183
161184 /**
162185 * Get an array of all properties for which the given subject has some value. The result is an
163186 * array of SMWPropertyValue objects.
 187+ *
164188 * @param $subject Title or SMWWikiPageValue denoting the subject
165189 * @param $requestoptions SMWRequestOptions optionally defining further options
166190 */
167 - abstract function getProperties( $subject, $requestoptions = null );
 191+ public abstract function getProperties( $subject, $requestoptions = null );
168192
169193 /**
170194 * Get an array of all properties for which there is some subject that relates to the given value.
@@ -171,7 +195,7 @@
172196 * @note In some stores, this function might be implemented partially so that only values of type Page
173197 * (_wpg) are supported.
174198 */
175 - abstract function getInProperties( SMWDataValue $object, $requestoptions = null );
 199+ public abstract function getInProperties( SMWDataValue $object, $requestoptions = null );
176200
177201 ///// Writing methods /////
178202
@@ -181,19 +205,19 @@
182206 * delete the respective text from the wiki, but only clears the stored
183207 * data.
184208 */
185 - abstract function deleteSubject( Title $subject );
 209+ public abstract function deleteSubject( Title $subject );
186210
187211 /**
188212 * Update the semantic data stored for some individual. The data is given
189213 * as a SMWSemanticData object, which contains all semantic data for one particular
190214 * subject.
191215 */
192 - abstract function updateData( SMWSemanticData $data );
 216+ public abstract function updateData( SMWSemanticData $data );
193217
194218 /**
195219 * Clear all semantic data specified for some page.
196220 */
197 - function clearData( Title $subject ) {
 221+ public function clearData( Title $subject ) {
198222 $emptydata = new SMWSemanticData( SMWWikiPageValue::makePageFromTitle( $subject ) );
199223 $this->updateData( $emptydata );
200224 }
@@ -206,7 +230,7 @@
207231 * $pageid, and the ID of the newly created redirect, if any, is given by $redirid. If no new
208232 * page was created, $redirid will be 0.
209233 */
210 - abstract function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 );
 234+ public abstract function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 );
211235
212236 ///// Query answering /////
213237
@@ -218,7 +242,7 @@
219243 *
220244 * @return SMWQueryResult
221245 */
222 - abstract function getQueryResult( SMWQuery $query );
 246+ public abstract function getQueryResult( SMWQuery $query );
223247
224248 ///// Special page functions /////
225249
@@ -226,24 +250,36 @@
227251 * Return all properties that have been used on pages in the wiki. The result is an array
228252 * of arrays, each containing a property title and a count. The expected order is
229253 * alphabetical w.r.t. to property title texts.
 254+ *
 255+ * @param SMWRequestOptions $requestoptions
 256+ *
 257+ * @return array
230258 */
231 - abstract function getPropertiesSpecial( $requestoptions = null );
 259+ public abstract function getPropertiesSpecial( $requestoptions = null );
232260
233261 /**
234262 * Return all properties that have been declared in the wiki but that
235263 * are not used on any page. Stores might restrict here to those properties
236264 * that have been given a type if they have no efficient means of accessing
237265 * the set of all pages in the property namespace.
 266+ *
 267+ * @param SMWRequestOptions $requestoptions
 268+ *
 269+ * @return array
238270 */
239 - abstract function getUnusedPropertiesSpecial( $requestoptions = null );
 271+ public abstract function getUnusedPropertiesSpecial( $requestoptions = null );
240272
241273 /**
242274 * Return all properties that are used on some page but that do not have any
243275 * page describing them. Stores that have no efficient way of accessing the
244276 * set of all existing pages can extend this list to all properties that are
245277 * used but do not have a type assigned to them.
 278+ *
 279+ * @param SMWRequestOptions $requestoptions
 280+ *
 281+ * @return array
246282 */
247 - abstract function getWantedPropertiesSpecial( $requestoptions = null );
 283+ public abstract function getWantedPropertiesSpecial( $requestoptions = null );
248284
249285 /**
250286 * Return statistical information as an associative array with the following
@@ -251,8 +287,10 @@
252288 * - 'PROPUSES': Number of property instances (value assignments) in the datatbase
253289 * - 'USEDPROPS': Number of properties that are used with at least one value
254290 * - 'DECLPROPS': Number of properties that have been declared (i.e. assigned a type)
 291+ *
 292+ * @return array
255293 */
256 - abstract function getStatistics();
 294+ public abstract function getStatistics();
257295
258296 ///// Setup store /////
259297
@@ -266,14 +304,18 @@
267305 * This is doen by just using print and possibly ob_flush/flush. This is also relevant for preventing
268306 * timeouts during long operations. All output must be valid XHTML, but should preferrably be plain
269307 * text, possibly with some linebreaks and weak markup.
 308+ *
 309+ * @param boolean $verbose
270310 */
271 - abstract function setup( $verbose = true );
 311+ public abstract function setup( $verbose = true );
272312
273313 /**
274314 * Drop (delete) all storage structures created by setup(). This will delete all semantic data and
275315 * possibly leave the wiki uninitialised.
 316+ *
 317+ * @param boolean $verbose
276318 */
277 - abstract function drop( $verbose = true );
 319+ public abstract function drop( $verbose = true );
278320
279321 /**
280322 * Refresh some objects in the store, addressed by numerical ids. The meaning of the ids is
@@ -289,7 +331,14 @@
290332 *
291333 * The optional parameter $usejobs indicates whether updates should be processed later using
292334 * MediaWiki jobs, instead of doing all updates immediately. The default is TRUE.
 335+ *
 336+ * @param integer $index
 337+ * @param integer $count
 338+ * @param mixed $namespaces Array or false
 339+ * @param boolean $usejobs
 340+ *
 341+ * @return decimal between 0 and 1 to indicate the overall progress of the refreshing
293342 */
294 - abstract function refreshData( &$index, $count, $namespaces = false, $usejobs = true );
 343+ public abstract function refreshData( &$index, $count, $namespaces = false, $usejobs = true );
295344
296 -}
 345+}
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php
@@ -44,12 +44,12 @@
4545
4646 /// Array for keeping property table table data, indexed by table id.
4747 /// Access this only by calling getPropertyTables().
48 - private static $prop_tables = array();
 48+ protected static $prop_tables = array();
4949 /// Array to cache "propkey => propid" associations. Built only when needed.
50 - private static $fixed_prop_tables = null;
 50+ protected static $fixed_prop_tables = null;
5151
5252 /// Use pre-defined ids for Very Important Properties, avoiding frequent ID lookups for those
53 - private static $special_ids = array(
 53+ protected static $special_ids = array(
5454 '_TYPE' => 1,
5555 '_URI' => 2,
5656 '_INST' => 4,
@@ -75,7 +75,7 @@
7676
7777 /// Array to cache ids of tables for storing known built-in types. Having
7878 /// this data here shortcuts the search in findTypeTableID() below.
79 - private static $property_table_ids = array(
 79+ protected static $property_table_ids = array(
8080 '_txt' => 'smw_text2', // Text type
8181 '_cod' => 'smw_text2', // Code type
8282 '_str' => 'smw_atts2', // String type
@@ -109,7 +109,7 @@
110110
111111 /// Array to cache signatures of known built-in types. Having this data
112112 /// here safes us from creating datavalue instances in getTypeSignature().
113 - private static $type_signatures = array(
 113+ protected static $type_signatures = array(
114114 '_txt' => array( 'l', -1, -1 ), // Text type
115115 '_cod' => array( 'l', -1, -1 ), // Code type
116116 '_str' => array( 't', 0, 0 ), // String type
@@ -214,6 +214,7 @@
215215 }
216216
217217 /**
 218+ * @see SMWStore::getPropertyValues
218219 *
219220 * @param $subject
220221 * @param SMWPropertyValue $property
@@ -435,7 +436,7 @@
436437 }
437438
438439 /**
439 - * returns an array of SMWWikiPageValue.
 440+ * @see SMWStore::getPropertySubjects
440441 *
441442 * @param SMWPropertyValue $property
442443 * @param $value
@@ -578,6 +579,8 @@
579580 }
580581
581582 /**
 583+ * @see SMWStore::getAllPropertySubjects
 584+ *
582585 * @param SMWPropertyValue $property
583586 * @param SMWRequestOptions $requestoptions
584587 *
@@ -592,7 +595,9 @@
593596 }
594597
595598 /**
596 - * @todo Restrict this function to SMWWikiPageValue subjects.
 599+ * @see SMWStore::getProperties
 600+ *
 601+ * TODO: Restrict this function to SMWWikiPageValue subjects.
597602 *
598603 * @param $subject
599604 * @param SMWRequestOptions $requestoptions
@@ -657,7 +662,10 @@
658663 /**
659664 * Implementation of SMWStore::getInProperties(). This function is meant to
660665 * be used for finding properties that link to wiki pages.
661 - * @todo When used for other datatypes, the function may return too many
 666+ *
 667+ * @see SMWStore::getInProperties
 668+ *
 669+ * TODO: When used for other datatypes, the function may return too many
662670 * properties since it selects results by comparing the stored information
663671 * (DB keys) only, while not currently comparing the type of the returned
664672 * property to the type of the queried data. So values with the same DB keys
@@ -666,6 +674,8 @@
667675 *
668676 * @param SMWDataValue $value
669677 * @param SMWRequestOptions $requestoptions
 678+ *
 679+ * @return array of SMWWikiPageValue
670680 */
671681 public function getInProperties( SMWDataValue $value, $requestoptions = null ) {
672682 wfProfileIn( "SMWSQLStore2::getInProperties (SMW)" );
@@ -718,6 +728,11 @@
719729
720730 ///// Writing methods /////
721731
 732+ /**
 733+ * @see SMWStore::deleteSubject
 734+ *
 735+ * @param Title $subject
 736+ */
722737 public function deleteSubject( Title $subject ) {
723738 wfProfileIn( 'SMWSQLStore2::deleteSubject (SMW)' );
724739 wfRunHooks( 'SMWSQLStore2::deleteSubjectBefore', array( $this, $subject ) );
@@ -740,6 +755,11 @@
741756 wfProfileOut( 'SMWSQLStore2::deleteSubject (SMW)' );
742757 }
743758
 759+ /**
 760+ * @see SMWStore::updateData
 761+ *
 762+ * @param SMWSemanticData $data
 763+ */
744764 public function updateData( SMWSemanticData $data ) {
745765 wfProfileIn( "SMWSQLStore2::updateData (SMW)" );
746766 wfRunHooks( 'SMWSQLStore2::updateDataBefore', array( $this, $data ) );
@@ -752,12 +772,12 @@
753773 $redirect = end( $redirects ); // at most one redirect per page
754774 $this->updateRedirects( $subject->getDBkey(), $subject->getNamespace(), $redirect->getDBkey(), $redirect->getNameSpace() );
755775 wfProfileOut( "SMWSQLStore2::updateData (SMW)" );
756 - return; // stop here -- no support for annotations on redirect pages!
 776+ return; // Stop here -- no support for annotations on redirect pages!
757777 } else {
758778 $this->updateRedirects( $subject->getDBkey(), $subject->getNamespace() );
759779 }
760780
761 - // always make an ID (pages without ID cannot be in query results, not even in fixed value queries!):
 781+ // Always make an ID (pages without ID cannot be in query results, not even in fixed value queries!):
762782 $sid = $this->makeSMWPageID( $subject->getDBkey(), $subject->getNamespace(), '', true, $subject->getSortkey() );
763783 $updates = array(); // collect data for bulk updates; format: tableid => updatearray
764784 $this->prepareDBUpdates( $updates, $data, $sid );
@@ -808,8 +828,11 @@
809829
810830 // Finally update caches (may be important if jobs are directly following this call)
811831 $this->m_semdata[$sid] = clone $data;
812 - $this->m_sdstate[$sid] = array_keys( self::getPropertyTables() ); // everything that one can know
 832+ // Everything that one can know.
 833+ $this->m_sdstate[$sid] = array_keys( self::getPropertyTables() );
 834+
813835 wfRunHooks( 'SMWSQLStore2::updateDataAfter', array( $this, $data ) );
 836+
814837 wfProfileOut( "SMWSQLStore2::updateData (SMW)" );
815838 }
816839
@@ -848,8 +871,9 @@
849872
850873 foreach ( $data->getPropertyValues( $property ) as $dv ) {
851874 if ( !$dv->isValid() || ( $tableid == 'smw_redi2' ) ) continue;
852 - // errors are already recorded separately, no need to store them here;
853 - // redirects were treated above
 875+
 876+ // errors are already recorded separately, no need to store them here;
 877+ // redirects were treated above
854878 ///TODO check needed if subject is null (would happen if a user defined proptable with !idsubject was used on an internal object -- currently this is not possible
855879 $uvals = ( $proptable->idsubject ) ? array( 's_id' => $sid ):
856880 array( 's_title' => $subject->getDBkey(), 's_namespace' => $subject->getNamespace() );
@@ -888,6 +912,7 @@
889913 $updates[$proptable->name][] = $uvals;
890914 }
891915 }
 916+
892917 return $sid;
893918 }
894919
@@ -909,15 +934,15 @@
910935 * store has its own ID management. Also, the function requires that both
911936 * titles are local, i.e. have empty interwiki prefix.
912937 *
913 - * @todo Currently the sortkey is not moved with the remaining data. It is
 938+ * TODO: Currently the sortkey is not moved with the remaining data. It is
914939 * not possible to move it reliably in all cases: we cannot distinguish an
915940 * unset sortkey from one that was set to the name of oldtitle. Maybe use
916941 * update jobs right away?
917942 *
918943 * @param Title $oldtitle
919944 * @param Title $newtitle
920 - * @param $pageid
921 - * @param $redirid
 945+ * @param integer $pageid
 946+ * @param integer $redirid
922947 */
923948 public function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ) {
924949 global $smwgQEqualitySupport;
@@ -941,10 +966,10 @@
942967 $this->makeSMWPageID( $oldtitle->getDBkey(), $oldtitle->getNamespace(), SMW_SQL2_SMWREDIIW ); // make redirect id for oldtitle
943968 $db->insert( 'smw_redi2', array( 's_title' => $oldtitle->getDBkey(), 's_namespace' => $oldtitle->getNamespace(), 'o_id' => $sid ),
944969 'SMWSQLStore2::changeTitle' );
945 - $this->m_ids[" " . $oldtitle->getNamespace() . " " . $oldtitle->getDBkey() . " C"] = $sid;
 970+ $this->m_ids[" " . $oldtitle->getNamespace() . ' ' . $oldtitle->getDBkey() . ' C'] = $sid;
946971 // $this->m_ids[" " . $oldtitle->getNamespace() . " " . $oldtitle->getDBkey() . " -"] = Already OK after makeSMWPageID above
947 - $this->m_ids[" " . $newtitle->getNamespace() . " " . $newtitle->getDBkey() . " C"] = $sid;
948 - $this->m_ids[" " . $newtitle->getNamespace() . " " . $newtitle->getDBkey() . " -"] = $sid;
 972+ $this->m_ids[" " . $newtitle->getNamespace() . ' ' . $newtitle->getDBkey() . ' C'] = $sid;
 973+ $this->m_ids[" " . $newtitle->getNamespace() . ' ' . $newtitle->getDBkey() . ' -'] = $sid;
949974 /// NOTE: there is the (bad) case that the moved page is a redirect. As chains of
950975 /// redirects are not supported by MW or SMW, the above is maximally correct in this case too.
951976 /// NOTE: this temporarily leaves existing redirects to oldtitle point to newtitle as well, which
@@ -971,11 +996,13 @@
972997 ///// Query answering /////
973998
974999 /**
 1000+ * @see SMWStore::getQueryResult
 1001+ *
9751002 * @param $query SMWQuery
9761003 *
9771004 * @return mixed: depends on $query->querymode
9781005 */
979 - function getQueryResult( SMWQuery $query ) {
 1006+ public function getQueryResult( SMWQuery $query ) {
9801007 wfProfileIn( 'SMWSQLStore2::getQueryResult (SMW)' );
9811008 global $smwgIP;
9821009 include_once( "$smwgIP/includes/storage/SMW_SQLStore2_Queries.php" );
@@ -1450,23 +1477,34 @@
14511478 return true;
14521479 }
14531480
 1481+ /**
 1482+ * @see SMWStore::refreshData
 1483+ *
 1484+ * @param integer $index
 1485+ * @param integer $count
 1486+ * @param mixed $namespaces Array or false
 1487+ * @param boolean $usejobs
 1488+ *
 1489+ * @return decimal between 0 and 1 to indicate the overall progress of the refreshing
 1490+ */
14541491 public function refreshData( &$index, $count, $namespaces = false, $usejobs = true ) {
14551492 $updatejobs = array();
14561493 $emptyrange = true; // was nothing found in this run?
14571494
1458 - // update by MediaWiki page id --> make sure we get all pages
 1495+ // Update by MediaWiki page id --> make sure we get all pages.
14591496 $tids = array();
14601497
1461 - for ( $i = $index; $i < $index + $count; $i++ ) { // array of ids
 1498+ // Array of ids
 1499+ for ( $i = $index; $i < $index + $count; $i++ ) {
14621500 $tids[] = $i;
14631501 }
14641502
14651503 $titles = Title::newFromIDs( $tids );
14661504
14671505 foreach ( $titles as $title ) {
1468 - // set $wgTitle, in case semantic data is set based
 1506+ // Set $wgTitle, in case semantic data is set based
14691507 // on values not originating from the page (such as
1470 - // via the External Data extension)
 1508+ // via the External Data extension).
14711509 global $wgTitle;
14721510 $wgTitle = $title;
14731511
@@ -1531,8 +1569,10 @@
15321570 * Refresh the concept cache for the given concept.
15331571 *
15341572 * @param $concept Title
 1573+ *
 1574+ * @return array
15351575 */
1536 - public function refreshConceptCache( $concept ) {
 1576+ public function refreshConceptCache( Title $concept ) {
15371577 wfProfileIn( 'SMWSQLStore2::refreshConceptCache (SMW)' );
15381578 global $smwgIP;
15391579
@@ -2033,11 +2073,11 @@
20342074 * predefined properties from the ids for the current pages (which may,
20352075 * e.g. be moved, while the predefined object is not movable).
20362076 */
2037 - private function getPropertyInterwiki( SMWPropertyValue $property ) {
 2077+ protected function getPropertyInterwiki( SMWPropertyValue $property ) {
20382078 if ( $property->isUserDefined() ) {
20392079 return '';
20402080 } else {
2041 - return $property->isVisible() ? SMW_SQL2_SMWPREDEFIW:SMW_SQL2_SMWINTDEFIW;
 2081+ return $property->isVisible() ? SMW_SQL2_SMWPREDEFIW : SMW_SQL2_SMWINTDEFIW;
20422082 }
20432083 }
20442084
@@ -2217,11 +2257,15 @@
22182258
22192259 // Update bnode references that use namespace field to store ids:
22202260 if ( $sdata ) { // bnodes are part of the data of a subject
2221 - $db->update( 'smw_ids', array( 'smw_namespace' => $newid ),
2222 - array( 'smw_title' => '', 'smw_namespace' => $oldid, 'smw_iw' => SMW_SQL2_SMWIW ), $fname );
 2261+ $db->update(
 2262+ 'smw_ids',
 2263+ array( 'smw_namespace' => $newid ),
 2264+ array( 'smw_title' => '', 'smw_namespace' => $oldid, 'smw_iw' => SMW_SQL2_SMWIW ),
 2265+ $fname
 2266+ );
22232267 }
22242268
2225 - // change all id entries in property tables:
 2269+ // Change all id entries in property tables:
22262270 foreach ( self::getPropertyTables() as $proptable ) {
22272271 if ( $sdata && $proptable->idsubject ) {
22282272 $db->update( $proptable->name, array( 's_id' => $newid ), array( 's_id' => $oldid ), $fname );
@@ -2243,7 +2287,8 @@
22442288 }
22452289 }
22462290 }
2247 - // change id entries in concept-related tables:
 2291+
 2292+ // Change id entries in concept-related tables:
22482293 if ( $sdata && ( ( $oldnamespace == -1 ) || ( $oldnamespace == SMW_NS_CONCEPT ) ) ) {
22492294 if ( ( $newnamespace == -1 ) || ( $newnamespace == SMW_NS_CONCEPT ) ) {
22502295 $db->update( 'smw_conc2', array( 's_id' => $newid ), array( 's_id' => $oldid ), $fname );
@@ -2253,6 +2298,7 @@
22542299 $db->delete( 'smw_conccache', array( 's_id' => $oldid ), $fname );
22552300 }
22562301 }
 2302+
22572303 if ( $podata ) {
22582304 $db->update( 'smw_conccache', array( 'o_id' => $newid ), array( 'o_id' => $oldid ), $fname );
22592305 }
@@ -2261,6 +2307,8 @@
22622308 /**
22632309 * Delete all semantic data stored for the given subject. Used for update
22642310 * purposes.
 2311+ *
 2312+ * @param SMWWikiPageValue $subject
22652313 */
22662314 protected function deleteSemanticData( SMWWikiPageValue $subject ) {
22672315 $db = wfGetDB( DB_MASTER );
@@ -2384,6 +2432,7 @@
23852433 }
23862434 }
23872435 }
 2436+
23882437 /// NOTE: we do not update the concept cache here; this remains an offline task
23892438 Job::batchInsert( $jobs ); ///NOTE: this only happens if $smwgEnableUpdateJobs was true above
23902439 }
@@ -2446,36 +2495,59 @@
24472496 * @return array of SMWSQLStore2Table
24482497 */
24492498 public static function getPropertyTables() {
2450 - if ( count( self::$prop_tables ) > 0 ) return self::$prop_tables; // don't initialise twice
 2499+ if ( count( self::$prop_tables ) > 0 ) return self::$prop_tables; // Don't initialise twice.
24512500
2452 - self::$prop_tables['smw_rels2'] = new SMWSQLStore2Table( 'smw_rels2',
2453 - array( 'o_id' => 'p' ),
2454 - array( 'o_id' ) );
2455 - self::$prop_tables['smw_atts2'] = new SMWSQLStore2Table( 'smw_atts2',
2456 - array( 'value_xsd' => 't', 'value_num' => 'f', 'value_unit' => 'u' ),
2457 - array( 'value_num', 'value_xsd' ) );
2458 - self::$prop_tables['smw_text2'] = new SMWSQLStore2Table( 'smw_text2',
2459 - array( 'value_blob' => 'l' ) );
2460 - self::$prop_tables['smw_spec2'] = new SMWSQLStore2Table( 'smw_spec2',
2461 - array( 'value_string' => 't' ),
2462 - array( 's_id,p_id' ) );
 2501+ self::$prop_tables['smw_rels2'] = new SMWSQLStore2Table(
 2502+ 'smw_rels2',
 2503+ array( 'o_id' => 'p' ),
 2504+ array( 'o_id' )
 2505+ );
 2506+
 2507+ self::$prop_tables['smw_atts2'] = new SMWSQLStore2Table(
 2508+ 'smw_atts2',
 2509+ array( 'value_xsd' => 't', 'value_num' => 'f', 'value_unit' => 'u' ),
 2510+ array( 'value_num', 'value_xsd' )
 2511+ );
 2512+
 2513+ self::$prop_tables['smw_text2'] = new SMWSQLStore2Table(
 2514+ 'smw_text2',
 2515+ array( 'value_blob' => 'l' )
 2516+ );
 2517+
 2518+ self::$prop_tables['smw_spec2'] = new SMWSQLStore2Table(
 2519+ 'smw_spec2',
 2520+ array( 'value_string' => 't' ),
 2521+ array( 's_id,p_id' )
 2522+ );
24632523 self::$prop_tables['smw_spec2']->specpropsonly = true;
2464 - self::$prop_tables['smw_subs2'] = new SMWSQLStore2Table( 'smw_subs2',
2465 - array( 'o_id' => 'p' ),
2466 - array( 'o_id' ),
2467 - '_SUBC' );
2468 - self::$prop_tables['smw_subp2'] = new SMWSQLStore2Table( 'smw_subp2',
2469 - array( 'o_id' => 'p' ),
2470 - array( 'o_id' ),
2471 - '_SUBP' );
2472 - self::$prop_tables['smw_inst2'] = new SMWSQLStore2Table( 'smw_inst2',
2473 - array( 'o_id' => 'p' ),
2474 - array( 'o_id' ),
2475 - '_INST' );
2476 - self::$prop_tables['smw_redi2'] = new SMWSQLStore2Table( 'smw_redi2',
2477 - array( 'o_id' => 'p' ),
2478 - array( 'o_id' ),
2479 - '_REDI' );
 2524+
 2525+ self::$prop_tables['smw_subs2'] = new SMWSQLStore2Table(
 2526+ 'smw_subs2',
 2527+ array( 'o_id' => 'p' ),
 2528+ array( 'o_id' ),
 2529+ '_SUBC'
 2530+ );
 2531+
 2532+ self::$prop_tables['smw_subp2'] = new SMWSQLStore2Table(
 2533+ 'smw_subp2',
 2534+ array( 'o_id' => 'p' ),
 2535+ array( 'o_id' ),
 2536+ '_SUBP'
 2537+ );
 2538+
 2539+ self::$prop_tables['smw_inst2'] = new SMWSQLStore2Table(
 2540+ 'smw_inst2',
 2541+ array( 'o_id' => 'p' ),
 2542+ array( 'o_id' ),
 2543+ '_INST'
 2544+ );
 2545+
 2546+ self::$prop_tables['smw_redi2'] = new SMWSQLStore2Table(
 2547+ 'smw_redi2',
 2548+ array( 'o_id' => 'p' ),
 2549+ array( 'o_id' ),
 2550+ '_REDI'
 2551+ );
24802552 self::$prop_tables['smw_redi2']->idsubject = false;
24812553
24822554 wfRunHooks( 'SMWPropertyTables', array( &self::$prop_tables ) );
@@ -2483,4 +2555,4 @@
24842556 return self::$prop_tables;
24852557 }
24862558
2487 -}
 2559+}
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_RAPStore2.php
@@ -38,12 +38,11 @@
3939 /**
4040 * @todo Maybe find a better nomenclature for the model.
4141 */
42 - public function SMWRAPStore2() {
 42+ public function __construct() {
4343 global $smwgRAPPath, $wgServer;
4444
45 -
46 - $this->modeluri = SMWExporter::expandURI( $wgServer . "/model" );
47 - $this->baseuri = SMWExporter::expandURI( $wgServer . "/id" );
 45+ $this->modeluri = SMWExporter::expandURI( $wgServer . '/model' );
 46+ $this->baseuri = SMWExporter::expandURI( $wgServer . '/id' );
4847 }
4948
5049 ///// Writing methods /////
@@ -293,5 +292,4 @@
294293
295294 return $uri; // still requires expandURI()
296295 }
297 -}
298 -
 296+}
\ No newline at end of file
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php
@@ -1,4 +1,5 @@
22 <?php
 3+
34 /**
45 * Some static helper functions that SMW uses for setting up
56 * SQL databases.
@@ -7,16 +8,9 @@
89 * @author Marcel Gsteiger
910 * @author Jeroen De Dauw
1011 *
11 - * @file
 12+ * @file SMW_SQLHelpers.php
1213 * @ingroup SMWStore
1314 */
14 -
15 -/**
16 - * Static class to collect some helper functions that SMW uses
17 - * for settnig up SQL databases.
18 - *
19 - * @ingroup SMWStore
20 - */
2115 class SMWSQLHelpers {
2216
2317 /**
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php
@@ -9,18 +9,18 @@
1010 * @ingroup SMW
1111 */
1212
13 -// constants for displaying the factbox
 13+// Constants for displaying the factbox.
1414 define( 'SMW_FACTBOX_HIDDEN', 1 );
1515 define( 'SMW_FACTBOX_SPECIAL', 2 );
1616 define( 'SMW_FACTBOX_NONEMPTY', 3 );
1717 define( 'SMW_FACTBOX_SHOWN', 5 );
1818
19 -// constants for regulating equality reasoning
 19+// Constants for regulating equality reasoning.
2020 define( 'SMW_EQ_NONE', 0 );
2121 define( 'SMW_EQ_SOME', 1 );
2222 define( 'SMW_EQ_FULL', 2 );
2323
24 -// flags to classify available query descriptions, used to enable/disable certain features
 24+// Flags to classify available query descriptions, used to enable/disable certain features.
2525 define( 'SMW_PROPERTY_QUERY', 1 ); // [[some property::...]]
2626 define( 'SMW_CATEGORY_QUERY', 2 ); // [[Category:...]]
2727 define( 'SMW_CONCEPT_QUERY', 4 ); // [[Concept:...]]
@@ -29,17 +29,17 @@
3030 define( 'SMW_DISJUNCTION_QUERY', 32 ); // any disjunctions (OR, ||)
3131 define( 'SMW_ANY_QUERY', 0xFFFFFFFF ); // subsumes all other options
3232
33 -// constants for defining which concepts to show only if cached
 33+// Constants for defining which concepts to show only if cached.
3434 define( 'CONCEPT_CACHE_ALL', 4 ); // show concept elements anywhere only if cached
3535 define( 'CONCEPT_CACHE_HARD', 1 ); // show without cache if concept is not harder than permitted inline queries
3636 define( 'CONCEPT_CACHE_NONE', 0 ); // show all concepts even without any cache
3737
38 -// constants for identifying javascripts as used in SMWOutputs
 38+// Constants for identifying javascripts as used in SMWOutputs.
3939 define( 'SMW_HEADER_TOOLTIP', 2 );
4040 define( 'SMW_HEADER_SORTTABLE', 3 );
4141 define( 'SMW_HEADER_STYLE', 4 );
4242
43 -// constants for denoting output modes in many functions: HTML or Wiki?
 43+// Constants for denoting output modes in many functions: HTML or Wiki?
4444 // "File" is for printing results into stand-alone files (e.g. building RSS)
4545 // and should be treated like HTML when building single strings. Only query
4646 // printers tend to have special handling for that.
@@ -55,7 +55,7 @@
5656 define( 'SMW_CMP_LIKE', 5 ); // Matches only datavalues that are LIKE the given value.
5757 define( 'SMW_CMP_NLKE', 6 ); // Matches only datavalues that are not LIKE the given value.
5858
59 -// constants for date formats (using binary encoding of nine bits: 3 positions x 3 interpretations)
 59+// Constants for date formats (using binary encoding of nine bits: 3 positions x 3 interpretations).
6060 define( 'SMW_MDY', 785 ); // Month-Day-Year
6161 define( 'SMW_DMY', 673 ); // Day-Month-Year
6262 define( 'SMW_YMD', 610 ); // Year-Month-Day
@@ -85,20 +85,19 @@
8686 * reimplements most of the title normalization as done in Title.php in order
8787 * to achieve conversion with less overhead. The official code could be called
8888 * here if more advanced normalization is needed.
 89+ *
 90+ * @param string $text
8991 */
9092 function smwfNormalTitleDBKey( $text ) {
9193 global $wgCapitalLinks;
 94+
9295 $text = trim( $text );
 96+
9397 if ( $wgCapitalLinks ) {
9498 $text = ucfirst( $text );
9599 }
 100+
96101 return str_replace( ' ', '_', $text );
97 - ///// The long and secure way. Use if problems occur.
98 - // $t = Title::newFromText( $text );
99 - // if ($t != null) {
100 - // return $t->getDBkey();
101 - // }
102 - // return $text;
103102 }
104103
105104 /**
@@ -106,25 +105,26 @@
107106 * reimplements the title normalization as done in Title.php in order to
108107 * achieve conversion with less overhead. The official code could be called
109108 * here if more advanced normalization is needed.
 109+ *
 110+ * @param string $text
110111 */
111112 function smwfNormalTitleText( $text ) {
112113 global $wgCapitalLinks;
 114+
113115 $text = trim( $text );
 116+
114117 if ( $wgCapitalLinks ) {
115118 $text = ucfirst( $text );
116119 }
 120+
117121 return str_replace( '_', ' ', $text );
118 - ///// The long and secure way. Use if problems occur.
119 - // $t = Title::newFromText( $text );
120 - // if ($t != null) {
121 - // return $t->getText();
122 - // }
123 - // return $text;
124122 }
125123
126124 /**
127125 * Escapes text in a way that allows it to be used as XML content (e.g. as a
128126 * string value for some property).
 127+ *
 128+ * @param string $text
129129 */
130130 function smwfXMLContentEncode( $text ) {
131131 return str_replace( array( '&', '<', '>' ), array( '&amp;', '&lt;', '&gt;' ), Sanitizer::decodeCharReferences( $text ) );
@@ -133,6 +133,8 @@
134134 /**
135135 * Decodes character references and inserts Unicode characters instead, using
136136 * the MediaWiki Sanitizer.
 137+ *
 138+ * @param string $text
137139 */
138140 function smwfHTMLtoUTF8( $text ) {
139141 return Sanitizer::decodeCharReferences( $text );
@@ -142,12 +144,14 @@
143145 * This method formats a float number value according to the given language and
144146 * precision settings, with some intelligence to produce readable output. Used
145147 * to format a number that was not hand-formatted by a user.
146 -* @param $value input number
147 -* @param $decplaces optional positive integer, controls how many digits after
 148+*
 149+* @param mixed $value input number
 150+* @param integer $decplaces optional positive integer, controls how many digits after
148151 * the decimal point are shown
149152 */
150153 function smwfNumberFormat( $value, $decplaces = 3 ) {
151154 global $smwgMaxNonExpNumber;
 155+
152156 smwfLoadExtensionMessages( 'SemanticMediaWiki' );
153157 $decseparator = wfMsgForContent( 'smw_decseparator' );
154158
@@ -157,6 +161,7 @@
158162 // using number_format. This may lead to 1.200, so then use trim to
159163 // remove trailing zeroes.
160164 $doScientific = false;
 165+
161166 // @todo: Don't do all this magic for integers, since the formatting does not fit there
162167 // correctly. E.g. one would have integers formatted as 1234e6, not as 1.234e9, right?
163168 // The "$value!=0" is relevant: we want to scientify numbers that are close to 0, but never 0!
@@ -177,6 +182,7 @@
178183 }
179184 }
180185 }
 186+
181187 if ( $doScientific ) {
182188 // Should we use decimal places here?
183189 $value = sprintf( "%1.6e", $value );
@@ -197,6 +203,7 @@
198204 // Assumes substr is faster than a regular expression replacement.
199205 $end = $decseparator . str_repeat( '0', $decplaces );
200206 $lenEnd = strlen( $end );
 207+
201208 if ( substr( $value, - $lenEnd ) === $end ) {
202209 $value = substr( $value, 0, - $lenEnd );
203210 } else {
@@ -205,6 +212,7 @@
206213 $value = preg_replace( "/(\\$decseparator\\d+?)0*$/u", '$1', $value, 1 );
207214 }
208215 }
 216+
209217 return $value;
210218 }
211219
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php
@@ -243,6 +243,7 @@
244244 $wgHooks['MonoBookTemplateToolboxEnd'][] = 'smwfShowBrowseLink';
245245 }
246246 }
 247+
247248 if ( version_compare( $wgVersion, '1.14alpha', '>=' ) ) {
248249 $wgHooks['SkinAfterContent'][] = 'SMWFactbox::onSkinAfterContent'; // draw Factbox below categories
249250 $smwgMW_1_14 = true; // assume latest 1.14 API
@@ -479,11 +480,12 @@
480481 include_once( $smwgIP . 'languages/' . $smwContLangFile . '.php' );
481482 }
482483
483 - // fallback if language not supported
 484+ // Fallback if language not supported.
484485 if ( !class_exists( $smwContLangClass ) ) {
485486 include_once( $smwgIP . 'languages/SMW_LanguageEn.php' );
486487 $smwContLangClass = 'SMWLanguageEn';
487488 }
 489+
488490 $smwgContLang = new $smwContLangClass();
489491
490492 wfProfileOut( 'smwfInitContentLanguage (SMW)' );

Follow-up revisions

RevisionCommit summaryAuthorDate
r73387Fixed fail from r73379jeroendedauw17:35, 20 September 2010
r73457Follow up to r73379jeroendedauw12:08, 21 September 2010

Comments

#Comment by Jeroen De Dauw (talk | contribs)   17:24, 20 September 2010

Issue with the fixedproperty field in SMWSQLStore2Table

Status & tagging log