Index: trunk/extensions/SemanticMediaWiki/includes/datavalues/SMW_DV_WikiPage.php |
— | — | @@ -51,6 +51,8 @@ |
52 | 52 | /** |
53 | 53 | * Static function for creating a new wikipage object from a |
54 | 54 | * MediaWiki Title object. |
| 55 | + * |
| 56 | + * @return SMWWikiPageValue |
55 | 57 | */ |
56 | 58 | static public function makePageFromTitle( $titleobject ) { |
57 | 59 | $page = new SMWWikiPageValue( '_wpg' ); |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_OrderedListPage.php |
— | — | @@ -1,40 +1,67 @@ |
2 | 2 | <?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 | | - */ |
12 | 3 | |
13 | 4 | /** |
14 | 5 | * Abstract subclass of MediaWiki's Article that handles the common tasks of |
15 | 6 | * article pages for Types and Properties. Mostly, it implements general processing |
16 | 7 | * and the generation of suitable navigation links from results sets and HTTP |
17 | 8 | * parameters. |
18 | | - * |
| 9 | + * |
19 | 10 | * Some code adapted from CategoryPage.php |
| 11 | + * |
| 12 | + * @file SMW_OrderedListPage.php |
20 | 13 | * @ingroup SMW |
| 14 | + * |
| 15 | + * @author Nikolas Iwan |
| 16 | + * @author Markus Krötzsch |
| 17 | + * @author Jeroen De Dauw |
21 | 18 | */ |
22 | 19 | abstract class SMWOrderedListPage extends Article { |
23 | 20 | |
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; |
29 | 27 | |
30 | 28 | /** |
| 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 | + /** |
31 | 57 | * Overwrite view() from Article.php to add additional html to the output. |
32 | 58 | */ |
33 | 59 | public function view() { |
34 | 60 | global $wgRequest, $wgUser; |
35 | 61 | |
36 | | - // copied from CategoryPage ... |
| 62 | + // Copied from CategoryPage |
37 | 63 | $diff = $wgRequest->getVal( 'diff' ); |
38 | 64 | $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
| 65 | + |
39 | 66 | if ( isset( $diff ) && $diffOnly ) { |
40 | 67 | return Article::view(); |
41 | 68 | } |
— | — | @@ -48,13 +75,17 @@ |
49 | 76 | */ |
50 | 77 | protected function showList() { |
51 | 78 | wfProfileIn( __METHOD__ . ' (SMW)' ); |
| 79 | + |
52 | 80 | global $wgOut, $wgRequest; |
| 81 | + |
53 | 82 | $this->from = $wgRequest->getVal( 'from' ); |
54 | 83 | $this->until = $wgRequest->getVal( 'until' ); |
| 84 | + |
55 | 85 | if ( $this->initParameters() ) { |
56 | 86 | $wgOut->addHTML( $this->getHTML() ); |
57 | 87 | SMWOutputs::commitToOutputPage( $wgOut ); // Flush required CSS to output |
58 | 88 | } |
| 89 | + |
59 | 90 | wfProfileOut( __METHOD__ . ' (SMW)' ); |
60 | 91 | } |
61 | 92 | |
— | — | @@ -63,6 +94,8 @@ |
64 | 95 | * (e.g. $limit). Method can be overwritten in this case. |
65 | 96 | * If the method returns false, nothing will be printed besides |
66 | 97 | * the original article. |
| 98 | + * |
| 99 | + * @return true |
67 | 100 | */ |
68 | 101 | protected function initParameters() { |
69 | 102 | $this->limit = 20; |
— | — | @@ -71,12 +104,16 @@ |
72 | 105 | |
73 | 106 | /** |
74 | 107 | * Returns HTML which is added to wgOut. |
| 108 | + * |
| 109 | + * @return string |
75 | 110 | */ |
76 | 111 | protected function getHTML() { |
77 | 112 | global $wgOut; |
| 113 | + |
78 | 114 | $this->clearPageState(); |
79 | 115 | $this->doQuery(); |
80 | 116 | $r = "<br id=\"smwfootbr\"/>\n" . $this->getPages(); |
| 117 | + |
81 | 118 | return $r; |
82 | 119 | } |
83 | 120 | |
— | — | @@ -104,19 +141,23 @@ |
105 | 142 | */ |
106 | 143 | protected function getNavigationLinks( $query = array() ) { |
107 | 144 | global $wgUser, $wgLang; |
| 145 | + |
108 | 146 | $sk = $this->getSkin(); |
109 | 147 | $limitText = $wgLang->formatNum( $this->limit ); |
110 | 148 | |
111 | 149 | $ac = count( $this->articles ); |
| 150 | + |
112 | 151 | if ( $this->until != '' ) { |
113 | 152 | if ( $ac > $this->limit ) { // (we assume that limit is at least 1) |
114 | 153 | $first = $this->articles[1]->getSortkey(); |
115 | 154 | } else { |
116 | 155 | $first = ''; |
117 | 156 | } |
| 157 | + |
118 | 158 | $last = $this->until; |
119 | 159 | } elseif ( ( $ac > $this->limit ) || ( $this->from != '' ) ) { |
120 | 160 | $first = $this->from; |
| 161 | + |
121 | 162 | if ( $ac > $this->limit ) { |
122 | 163 | $last = $this->articles[$ac - 1]->getSortkey(); |
123 | 164 | } else { |
— | — | @@ -127,32 +168,40 @@ |
128 | 169 | } |
129 | 170 | |
130 | 171 | $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 | + |
132 | 174 | if ( $first != '' ) { |
133 | 175 | $prevLink = $sk->makeLinkObj( $this->mTitle, $prevLink, |
134 | 176 | wfArrayToCGI( $query + array( 'until' => $first ) ) ); |
135 | 177 | } |
136 | 178 | $nextLink = htmlspecialchars( wfMsg( 'nextn', $limitText ) ); |
| 179 | + |
137 | 180 | if ( $last != '' ) { |
138 | 181 | $nextLink = $sk->makeLinkObj( $this->mTitle, $nextLink, |
139 | 182 | wfArrayToCGI( $query + array( 'from' => $last ) ) ); |
140 | 183 | } |
| 184 | + |
141 | 185 | return "($prevLink) ($nextLink)"; |
142 | 186 | } |
143 | 187 | |
144 | 188 | /** |
145 | 189 | * Fetch and return the relevant skin object. |
| 190 | + * |
| 191 | + * @return Skin |
146 | 192 | */ |
147 | 193 | protected function getSkin() { |
148 | 194 | if ( !$this->skin ) { |
149 | 195 | global $wgUser; |
150 | 196 | $this->skin = $wgUser->getSkin(); |
151 | 197 | } |
| 198 | + |
152 | 199 | return $this->skin; |
153 | 200 | } |
154 | 201 | |
155 | 202 | /** |
156 | 203 | * Like Article's getTitle(), but returning a suitable SMWWikiPageValue |
| 204 | + * |
| 205 | + * @return SMWWikiPageValue |
157 | 206 | */ |
158 | 207 | protected function getDataValue() { |
159 | 208 | return SMWWikiPageValue::makePageFromTitle( $this->getTitle() ); |
— | — | @@ -161,18 +210,25 @@ |
162 | 211 | /** |
163 | 212 | * Format a list of SMWWikipageValues chunked by letter in a three-column |
164 | 213 | * list, ordered vertically. |
| 214 | + * |
| 215 | + * @param integer $start |
| 216 | + * @param integer $end |
| 217 | + * @param array $elements |
| 218 | + * |
| 219 | + * @return string |
165 | 220 | */ |
166 | 221 | protected function columnList( $start, $end, $elements ) { |
167 | 222 | global $wgContLang; |
168 | | - // divide list into three equal chunks |
| 223 | + |
| 224 | + // Divide list into three equal chunks. |
169 | 225 | $chunk = (int) ( ( $end - $start + 1 ) / 3 ); |
170 | 226 | |
171 | | - // get and display header |
| 227 | + // Get and display header. |
172 | 228 | $r = '<table width="100%"><tr valign="top">'; |
173 | 229 | |
174 | 230 | $prev_start_char = 'none'; |
175 | 231 | |
176 | | - // loop through the chunks |
| 232 | + // Loop through the chunks. |
177 | 233 | for ( $startChunk = $start, $endChunk = $chunk, $chunkIndex = 0; |
178 | 234 | $chunkIndex < 3; |
179 | 235 | $chunkIndex++, $startChunk = $endChunk, $endChunk += $chunk + 1 ) { |
— | — | @@ -180,11 +236,10 @@ |
181 | 237 | $atColumnTop = true; |
182 | 238 | |
183 | 239 | // output all articles |
184 | | - for ( $index = $startChunk ; |
185 | | - $index < $endChunk && $index < $end; |
186 | | - $index++ ) { |
| 240 | + for ( $index = $startChunk ; $index < $endChunk && $index < $end; $index++ ) { |
187 | 241 | // check for change of starting letter or begining of chunk |
188 | 242 | $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$index]->getSortkey() ) ); |
| 243 | + |
189 | 244 | if ( ( $index == $startChunk ) || |
190 | 245 | ( $start_char != $prev_start_char ) ) { |
191 | 246 | if ( $atColumnTop ) { |
— | — | @@ -192,46 +247,63 @@ |
193 | 248 | } else { |
194 | 249 | $r .= "</ul>\n"; |
195 | 250 | } |
| 251 | + |
196 | 252 | $cont_msg = ""; |
| 253 | + |
197 | 254 | if ( $start_char == $prev_start_char ) { |
198 | 255 | $cont_msg = wfMsgHtml( 'listingcontinuesabbrev' ); |
199 | 256 | } |
| 257 | + |
200 | 258 | $r .= "<h3>" . htmlspecialchars( $start_char ) . " $cont_msg</h3>\n<ul>"; |
201 | 259 | $prev_start_char = $start_char; |
202 | 260 | } |
| 261 | + |
203 | 262 | $r .= "<li>" . $elements[$index]->getLongHTMLText( $this->getSkin() ) . "</li>\n"; |
204 | 263 | } |
| 264 | + |
205 | 265 | if ( !$atColumnTop ) { |
206 | 266 | $r .= "</ul>\n"; |
207 | 267 | } |
| 268 | + |
208 | 269 | $r .= "</td>\n"; |
209 | 270 | } |
| 271 | + |
210 | 272 | $r .= '</tr></table>'; |
| 273 | + |
211 | 274 | return $r; |
212 | 275 | } |
213 | 276 | |
214 | 277 | /** |
215 | 278 | * 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 |
216 | 285 | */ |
217 | | - protected function shortList( $start, $end, $elements ) { |
| 286 | + protected function shortList( $start, $end, array $elements ) { |
218 | 287 | global $wgContLang; |
| 288 | + |
219 | 289 | $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$start]->getSortkey() ) ); |
220 | 290 | $prev_start_char = $start_char; |
221 | 291 | $r = '<h3>' . htmlspecialchars( $start_char ) . "</h3>\n"; |
222 | 292 | $r .= '<ul><li>' . $elements[$start]->getLongHTMLText( $this->getSkin() ) . '</li>'; |
| 293 | + |
223 | 294 | for ( $index = $start + 1; $index < $end; $index++ ) { |
224 | 295 | $start_char = $wgContLang->convert( $wgContLang->firstChar( $elements[$index]->getSortkey() ) ); |
| 296 | + |
225 | 297 | if ( $start_char != $prev_start_char ) { |
226 | 298 | $r .= "</ul><h3>" . htmlspecialchars( $start_char ) . "</h3>\n<ul>"; |
227 | 299 | $prev_start_char = $start_char; |
228 | 300 | } |
| 301 | + |
229 | 302 | $r .= '<li>' . $elements[$index]->getLongHTMLText( $this->getSkin() ) . '</li>'; |
230 | 303 | } |
| 304 | + |
231 | 305 | $r .= '</ul>'; |
| 306 | + |
232 | 307 | return $r; |
233 | 308 | } |
234 | 309 | |
235 | | -} |
236 | | - |
237 | | - |
238 | | - |
| 310 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/articlepages/SMW_PropertyPage.php |
— | — | @@ -1,18 +1,16 @@ |
2 | 2 | <?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 | | - */ |
11 | 3 | |
12 | 4 | /** |
13 | 5 | * Implementation of MediaWiki's Article that shows additional information on |
14 | 6 | * property pages. Very similar to CategoryPage, but with different printout |
15 | 7 | * 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 |
16 | 12 | * @ingroup SMW |
| 13 | + * |
| 14 | + * @author: Markus Krötzsch |
17 | 15 | */ |
18 | 16 | class SMWPropertyPage extends SMWOrderedListPage { |
19 | 17 | |
— | — | @@ -24,9 +22,11 @@ |
25 | 23 | */ |
26 | 24 | protected function initParameters() { |
27 | 25 | global $smwgContLang, $smwgPropertyPagingLimit; |
| 26 | + |
28 | 27 | $this->limit = $smwgPropertyPagingLimit; |
29 | 28 | $this->mProperty = SMWPropertyValue::makeProperty( $this->mTitle->getDBkey() ); |
30 | 29 | $this->mProperty->setInverse( false ); |
| 30 | + |
31 | 31 | return true; |
32 | 32 | } |
33 | 33 | |
— | — | @@ -41,11 +41,13 @@ |
42 | 42 | */ |
43 | 43 | protected function doQuery() { |
44 | 44 | $store = smwfGetStore(); |
| 45 | + |
45 | 46 | if ( $this->limit > 0 ) { // for limit==0 there is no paging, and no query |
46 | 47 | $options = new SMWRequestOptions(); |
47 | 48 | $options->limit = $this->limit + 1; |
48 | 49 | $options->sort = true; |
49 | 50 | $reverse = false; |
| 51 | + |
50 | 52 | if ( $this->from != '' ) { |
51 | 53 | $options->boundary = $this->from; |
52 | 54 | $options->ascending = true; |
— | — | @@ -56,7 +58,9 @@ |
57 | 59 | $options->include_boundary = false; |
58 | 60 | $reverse = true; |
59 | 61 | } |
| 62 | + |
60 | 63 | $this->articles = $store->getAllPropertySubjects( $this->mProperty, $options ); |
| 64 | + |
61 | 65 | if ( $reverse ) { |
62 | 66 | $this->articles = array_reverse( $this->articles ); |
63 | 67 | } |
— | — | @@ -80,28 +84,38 @@ |
81 | 85 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
82 | 86 | $r = ''; |
83 | 87 | $ti = htmlspecialchars( $this->mTitle->getText() ); |
| 88 | + |
84 | 89 | if ( count( $this->subproperties ) > 0 ) { |
85 | 90 | $r .= "<div id=\"mw-subcategories\">\n<h2>" . wfMsg( 'smw_subproperty_header', $ti ) . "</h2>\n<p>"; |
| 91 | + |
86 | 92 | if ( !$this->mProperty->isUserDefined() ) { |
87 | 93 | $r .= wfMsg( 'smw_isspecprop' ) . ' '; |
88 | 94 | } |
| 95 | + |
89 | 96 | $r .= wfMsgExt( 'smw_subpropertyarticlecount', array( 'parsemag' ), count( $this->subproperties ) ) . "</p>\n"; |
90 | 97 | $r .= ( count( $this->subproperties ) < 6 ) ? |
91 | 98 | $this->shortList( 0, count( $this->subproperties ), $this->subproperties ): |
92 | 99 | $this->columnList( 0, count( $this->subproperties ), $this->subproperties ); |
| 100 | + |
93 | 101 | $r .= "\n</div>"; |
94 | 102 | } |
| 103 | + |
95 | 104 | if ( count( $this->articles ) > 0 ) { |
96 | 105 | $nav = $this->getNavigationLinks(); |
| 106 | + |
97 | 107 | $r .= '<a name="SMWResults"></a>' . $nav . "<div id=\"mw-pages\">\n" . |
98 | 108 | '<h2>' . wfMsg( 'smw_attribute_header', $ti ) . "</h2>\n<p>"; |
| 109 | + |
99 | 110 | if ( !$this->mProperty->isUserDefined() ) { |
100 | 111 | $r .= wfMsg( 'smw_isspecprop' ) . ' '; |
101 | 112 | } |
| 113 | + |
102 | 114 | $r .= wfMsgExt( 'smw_attributearticlecount', array( 'parsemag' ), min( $this->limit, count( $this->articles ) ) ) . "</p>\n" . |
103 | 115 | $this->subjectObjectList() . "\n</div>" . $nav; |
104 | 116 | } |
| 117 | + |
105 | 118 | wfProfileOut( __METHOD__ . ' (SMW)' ); |
| 119 | + |
106 | 120 | return $r; |
107 | 121 | } |
108 | 122 | |
— | — | @@ -114,6 +128,7 @@ |
115 | 129 | $store = smwfGetStore(); |
116 | 130 | |
117 | 131 | $ac = count( $this->articles ); |
| 132 | + |
118 | 133 | if ( $ac > $this->limit ) { |
119 | 134 | if ( $this->until != '' ) { |
120 | 135 | $start = 1; |
— | — | @@ -127,27 +142,34 @@ |
128 | 143 | |
129 | 144 | $r = '<table style="width: 100%; ">'; |
130 | 145 | $prev_start_char = 'None'; |
| 146 | + |
131 | 147 | for ( $index = $start; $index < $ac; $index++ ) { |
132 | 148 | $start_char = $wgContLang->convert( $wgContLang->firstChar( $this->articles[$index]->getSortkey() ) ); |
| 149 | + |
133 | 150 | // Header for index letters |
134 | 151 | if ( $start_char != $prev_start_char ) { |
135 | 152 | $r .= '<tr><th class="smwpropname"><h3>' . htmlspecialchars( $start_char ) . "</h3></th><th></th></tr>\n"; |
136 | 153 | $prev_start_char = $start_char; |
137 | 154 | } |
| 155 | + |
138 | 156 | // Property name |
139 | 157 | $searchlink = SMWInfolink::newBrowsingLink( '+', $this->articles[$index]->getShortHTMLText() ); |
140 | 158 | $r .= '<tr><td class="smwpropname">' . $this->articles[$index]->getLongHTMLText( $this->getSkin() ) . |
141 | 159 | ' ' . $searchlink->getHTML( $this->getSkin() ) . '</td><td class="smwprops">'; |
| 160 | + |
142 | 161 | // Property values |
143 | 162 | $ropts = new SMWRequestOptions(); |
144 | 163 | $ropts->limit = $smwgMaxPropertyValues + 1; |
145 | 164 | $values = $store->getPropertyValues( $this->articles[$index], $this->mProperty, $ropts ); |
146 | 165 | $i = 0; |
| 166 | + |
147 | 167 | foreach ( $values as $value ) { |
148 | 168 | if ( $i != 0 ) { |
149 | 169 | $r .= ', '; |
150 | 170 | } |
| 171 | + |
151 | 172 | $i++; |
| 173 | + |
152 | 174 | if ( $i < $smwgMaxPropertyValues + 1 ) { |
153 | 175 | $r .= $value->getLongHTMLText( $this->getSkin() ) . $value->getInfolinkText( SMW_OUTPUT_HTML, $this->getSkin() ); |
154 | 176 | } else { |
— | — | @@ -155,11 +177,13 @@ |
156 | 178 | $r .= $searchlink->getHTML( $this->getSkin() ); |
157 | 179 | } |
158 | 180 | } |
| 181 | + |
159 | 182 | $r .= "</td></tr>\n"; |
160 | 183 | } |
| 184 | + |
161 | 185 | $r .= '</table>'; |
| 186 | + |
162 | 187 | return $r; |
163 | 188 | } |
164 | | -} |
165 | 189 | |
166 | | - |
| 190 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_QueryResult.php |
— | — | @@ -70,7 +70,7 @@ |
71 | 71 | * @param SMWStore $store |
72 | 72 | * @param boolean $furtherRes |
73 | 73 | */ |
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 ) { |
75 | 75 | $this->mResults = $results; |
76 | 76 | reset( $this->mResults ); |
77 | 77 | $this->mPrintRequests = $printRequests; |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2Table.php |
— | — | @@ -1,24 +1,20 @@ |
2 | 2 | <?php |
3 | 3 | |
4 | 4 | /** |
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 | | -/** |
15 | 5 | * Simple data container for storing information about property tables. A |
16 | 6 | * property table is a DB table that is used to store subject-property-value |
17 | 7 | * records about data in SMW. Tables mostly differ in the composition of the |
18 | 8 | * value, but also in whether the property is explicitly named (or fixed), |
19 | 9 | * and in the way subject pages are referred to. |
| 10 | + * |
| 11 | + * @file SMW_SQLStore2Table.php |
20 | 12 | * @ingroup SMWStore |
| 13 | + * |
| 14 | + * @author Markus Krötzsch |
| 15 | + * @author Jeroen De Dauw |
21 | 16 | */ |
22 | 17 | class SMWSQLStore2Table { |
| 18 | + |
23 | 19 | /** |
24 | 20 | * Name of the table in the DB. |
25 | 21 | * |
— | — | @@ -79,14 +75,14 @@ |
80 | 76 | * Constructor. |
81 | 77 | * |
82 | 78 | * @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 |
85 | 81 | * @param mixed $fixedProperty string or false |
86 | 82 | */ |
87 | | - public function __construct( $name, array $objectFields, array $indexes = array(), $fixedProperty = false ) { |
| 83 | + public function __construct( $name, $objectFields, $indexes = array(), $fixedProperty = false ) { |
88 | 84 | $this->name = $name; |
89 | | - $this->objectfields = $objectFields; |
90 | | - $this->fixedproperty = $fixedProperty; |
| 85 | + $this->objectfields = (array)$objectFields; |
| 86 | + $this->fixedproperty = (array)$fixedProperty; |
91 | 87 | $this->indexes = $indexes; |
92 | 88 | } |
93 | 89 | |
— | — | @@ -94,7 +90,7 @@ |
95 | 91 | * @return string |
96 | 92 | */ |
97 | 93 | public function getFieldSignature() { |
98 | | - // TODO: this was implode( $this->objectfields, '' ), which might indicate some error where this method is called. |
99 | 94 | return implode( '', $this->objectfields ); |
100 | 95 | } |
| 96 | + |
101 | 97 | } |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2_Queries.php |
— | — | @@ -87,8 +87,10 @@ |
88 | 88 | * Refresh the concept cache for the given concept. |
89 | 89 | * |
90 | 90 | * @param $concept Title |
| 91 | + * |
| 92 | + * @return array |
91 | 93 | */ |
92 | | - public function refreshConceptCache( $concept ) { |
| 94 | + public function refreshConceptCache( Title $concept ) { |
93 | 95 | global $smwgQMaxLimit, $smwgQConceptFeatures, $wgDBtype; |
94 | 96 | |
95 | 97 | $cid = $this->m_store->getSMWPageID( $concept->getDBkey(), SMW_NS_CONCEPT, '' ); |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_Store.php |
— | — | @@ -1,8 +1,10 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | 4 | * Basic abstract classes for SMW's storage abstraction layer. |
| 5 | + * |
5 | 6 | * @file |
6 | 7 | * @ingroup SMWStore |
| 8 | + * |
7 | 9 | * @author Markus Krötzsch |
8 | 10 | */ |
9 | 11 | |
— | — | @@ -10,6 +12,7 @@ |
11 | 13 | * This group contains all parts of SMW that relate to storing and retrieving |
12 | 14 | * semantic data. SMW components that relate to semantic querying only have their |
13 | 15 | * own group. |
| 16 | + * |
14 | 17 | * @defgroup SMWStore SMWStore |
15 | 18 | * @ingroup SMW |
16 | 19 | */ |
— | — | @@ -18,16 +21,21 @@ |
19 | 22 | * Small data container class for describing filtering conditions on the string |
20 | 23 | * label of some entity. States that a given string should either be prefix, postfix, |
21 | 24 | * or some arbitrary part of labels. |
| 25 | + * |
22 | 26 | * @ingroup SMWStore |
| 27 | + * |
| 28 | + * @author Markus Krötzsch |
23 | 29 | */ |
24 | 30 | class SMWStringCondition { |
25 | 31 | const STRCOND_PRE = 0; |
26 | 32 | const STRCOND_POST = 1; |
27 | 33 | const STRCOND_MID = 2; |
| 34 | + |
28 | 35 | /** |
29 | 36 | * String to match. |
30 | 37 | */ |
31 | 38 | public $string; |
| 39 | + |
32 | 40 | /** |
33 | 41 | * Condition. One of STRCOND_PRE (string matches prefix), |
34 | 42 | * STRCOND_POST (string matches postfix), STRCOND_MID |
— | — | @@ -35,7 +43,7 @@ |
36 | 44 | */ |
37 | 45 | public $condition; |
38 | 46 | |
39 | | - public function SMWStringCondition( $string, $condition ) { |
| 47 | + public function __construct( $string, $condition ) { |
40 | 48 | $this->string = $string; |
41 | 49 | $this->condition = $condition; |
42 | 50 | } |
— | — | @@ -48,19 +56,25 @@ |
49 | 57 | * to their more complex structure. |
50 | 58 | * Options that should not be used or where default values should be used |
51 | 59 | * can be left as initialised. |
| 60 | + * |
52 | 61 | * @ingroup SMWStore |
| 62 | + * |
| 63 | + * @author Markus Krötzsch |
53 | 64 | */ |
54 | 65 | class SMWRequestOptions { |
| 66 | + |
55 | 67 | /** |
56 | 68 | * The maximum number of results that should be returned. |
57 | 69 | */ |
58 | | - public $limit = - 1; |
| 70 | + public $limit = -1; |
| 71 | + |
59 | 72 | /** |
60 | 73 | * A numerical offset. The first $offset results are skipped. |
61 | 74 | * Note that this does not imply a defined order of results |
62 | 75 | * (see SMWRequestOptions->$sort below). |
63 | 76 | */ |
64 | 77 | public $offset = 0; |
| 78 | + |
65 | 79 | /** |
66 | 80 | * Should the result be ordered? The employed order is defined |
67 | 81 | * by the type of result that are requested: Title objects and |
— | — | @@ -69,22 +83,26 @@ |
70 | 84 | * Usually, the order should be fairly "natural". |
71 | 85 | */ |
72 | 86 | public $sort = false; |
| 87 | + |
73 | 88 | /** |
74 | 89 | * If SMWRequestOptions->$sort is true, this parameter defines whether |
75 | 90 | * the results are ordered in ascending or descending order. |
76 | 91 | */ |
77 | 92 | public $ascending = true; |
| 93 | + |
78 | 94 | /** |
79 | 95 | * Specifies a lower or upper bound for the values returned by the query. |
80 | 96 | * Whether it is lower or upper is specified by the parameter "ascending" |
81 | 97 | * (true->lower, false->upper). |
82 | 98 | */ |
83 | 99 | public $boundary = null; |
| 100 | + |
84 | 101 | /** |
85 | 102 | * Specifies whether or not the requested boundary should be returned |
86 | 103 | * as a result. |
87 | 104 | */ |
88 | 105 | public $include_boundary = true; |
| 106 | + |
89 | 107 | /** |
90 | 108 | * An array of string conditions that are applied if the result has a string |
91 | 109 | * label that can be subject to those patterns. |
— | — | @@ -93,6 +111,7 @@ |
94 | 112 | |
95 | 113 | /** |
96 | 114 | * Set a new string condition applied to labels of results (if available). |
| 115 | + * |
97 | 116 | * @param $string the string to match |
98 | 117 | * @param $condition type of condition, one of STRCOND_PRE, STRCOND_POST, STRCOND_MID |
99 | 118 | */ |
— | — | @@ -106,6 +125,7 @@ |
107 | 126 | public function getStringConditions() { |
108 | 127 | return $this->stringcond; |
109 | 128 | } |
| 129 | + |
110 | 130 | } |
111 | 131 | |
112 | 132 | |
— | — | @@ -114,7 +134,10 @@ |
115 | 135 | * semantic store. Besides the relevant interface, this class provides default |
116 | 136 | * implementations for some optional methods, which inform the caller that |
117 | 137 | * these methods are not implemented. |
| 138 | + * |
118 | 139 | * @ingroup SMWStore |
| 140 | + * |
| 141 | + * @author Markus Krötzsch |
119 | 142 | */ |
120 | 143 | abstract class SMWStore { |
121 | 144 | |
— | — | @@ -132,7 +155,7 @@ |
133 | 156 | * than requested when a filter is used. Filtering just ensures that |
134 | 157 | * only necessary requests are made, i.e. it improves performance. |
135 | 158 | */ |
136 | | - abstract function getSemanticData( $subject, $filter = false ); |
| 159 | + public abstract function getSemanticData( $subject, $filter = false ); |
137 | 160 | |
138 | 161 | /** |
139 | 162 | * Get an array of all property values stored for the given subject and property. The result |
— | — | @@ -142,28 +165,29 @@ |
143 | 166 | * |
144 | 167 | * If called with $subject == NULL, all values for the given property are returned. |
145 | 168 | */ |
146 | | - abstract function getPropertyValues( $subject, SMWPropertyValue $property, $requestoptions = null, $outputformat = '' ); |
| 169 | + public abstract function getPropertyValues( $subject, SMWPropertyValue $property, $requestoptions = null, $outputformat = '' ); |
147 | 170 | |
148 | 171 | /** |
149 | 172 | * Get an array of all subjects that have the given value for the given property. The |
150 | 173 | * result is an array of SMWWikiPageValue objects. If NULL is given as a value, all subjects having |
151 | 174 | * that property are returned. |
152 | 175 | */ |
153 | | - abstract function getPropertySubjects( SMWPropertyValue $property, $value, $requestoptions = null ); |
| 176 | + public abstract function getPropertySubjects( SMWPropertyValue $property, $value, $requestoptions = null ); |
154 | 177 | |
155 | 178 | /** |
156 | 179 | * Get an array of all subjects that have some value for the given property. The |
157 | 180 | * result is an array of SMWWikiPageValue objects. |
158 | 181 | */ |
159 | | - abstract function getAllPropertySubjects( SMWPropertyValue $property, $requestoptions = null ); |
| 182 | + public abstract function getAllPropertySubjects( SMWPropertyValue $property, $requestoptions = null ); |
160 | 183 | |
161 | 184 | /** |
162 | 185 | * Get an array of all properties for which the given subject has some value. The result is an |
163 | 186 | * array of SMWPropertyValue objects. |
| 187 | + * |
164 | 188 | * @param $subject Title or SMWWikiPageValue denoting the subject |
165 | 189 | * @param $requestoptions SMWRequestOptions optionally defining further options |
166 | 190 | */ |
167 | | - abstract function getProperties( $subject, $requestoptions = null ); |
| 191 | + public abstract function getProperties( $subject, $requestoptions = null ); |
168 | 192 | |
169 | 193 | /** |
170 | 194 | * Get an array of all properties for which there is some subject that relates to the given value. |
— | — | @@ -171,7 +195,7 @@ |
172 | 196 | * @note In some stores, this function might be implemented partially so that only values of type Page |
173 | 197 | * (_wpg) are supported. |
174 | 198 | */ |
175 | | - abstract function getInProperties( SMWDataValue $object, $requestoptions = null ); |
| 199 | + public abstract function getInProperties( SMWDataValue $object, $requestoptions = null ); |
176 | 200 | |
177 | 201 | ///// Writing methods ///// |
178 | 202 | |
— | — | @@ -181,19 +205,19 @@ |
182 | 206 | * delete the respective text from the wiki, but only clears the stored |
183 | 207 | * data. |
184 | 208 | */ |
185 | | - abstract function deleteSubject( Title $subject ); |
| 209 | + public abstract function deleteSubject( Title $subject ); |
186 | 210 | |
187 | 211 | /** |
188 | 212 | * Update the semantic data stored for some individual. The data is given |
189 | 213 | * as a SMWSemanticData object, which contains all semantic data for one particular |
190 | 214 | * subject. |
191 | 215 | */ |
192 | | - abstract function updateData( SMWSemanticData $data ); |
| 216 | + public abstract function updateData( SMWSemanticData $data ); |
193 | 217 | |
194 | 218 | /** |
195 | 219 | * Clear all semantic data specified for some page. |
196 | 220 | */ |
197 | | - function clearData( Title $subject ) { |
| 221 | + public function clearData( Title $subject ) { |
198 | 222 | $emptydata = new SMWSemanticData( SMWWikiPageValue::makePageFromTitle( $subject ) ); |
199 | 223 | $this->updateData( $emptydata ); |
200 | 224 | } |
— | — | @@ -206,7 +230,7 @@ |
207 | 231 | * $pageid, and the ID of the newly created redirect, if any, is given by $redirid. If no new |
208 | 232 | * page was created, $redirid will be 0. |
209 | 233 | */ |
210 | | - abstract function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ); |
| 234 | + public abstract function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ); |
211 | 235 | |
212 | 236 | ///// Query answering ///// |
213 | 237 | |
— | — | @@ -218,7 +242,7 @@ |
219 | 243 | * |
220 | 244 | * @return SMWQueryResult |
221 | 245 | */ |
222 | | - abstract function getQueryResult( SMWQuery $query ); |
| 246 | + public abstract function getQueryResult( SMWQuery $query ); |
223 | 247 | |
224 | 248 | ///// Special page functions ///// |
225 | 249 | |
— | — | @@ -226,24 +250,36 @@ |
227 | 251 | * Return all properties that have been used on pages in the wiki. The result is an array |
228 | 252 | * of arrays, each containing a property title and a count. The expected order is |
229 | 253 | * alphabetical w.r.t. to property title texts. |
| 254 | + * |
| 255 | + * @param SMWRequestOptions $requestoptions |
| 256 | + * |
| 257 | + * @return array |
230 | 258 | */ |
231 | | - abstract function getPropertiesSpecial( $requestoptions = null ); |
| 259 | + public abstract function getPropertiesSpecial( $requestoptions = null ); |
232 | 260 | |
233 | 261 | /** |
234 | 262 | * Return all properties that have been declared in the wiki but that |
235 | 263 | * are not used on any page. Stores might restrict here to those properties |
236 | 264 | * that have been given a type if they have no efficient means of accessing |
237 | 265 | * the set of all pages in the property namespace. |
| 266 | + * |
| 267 | + * @param SMWRequestOptions $requestoptions |
| 268 | + * |
| 269 | + * @return array |
238 | 270 | */ |
239 | | - abstract function getUnusedPropertiesSpecial( $requestoptions = null ); |
| 271 | + public abstract function getUnusedPropertiesSpecial( $requestoptions = null ); |
240 | 272 | |
241 | 273 | /** |
242 | 274 | * Return all properties that are used on some page but that do not have any |
243 | 275 | * page describing them. Stores that have no efficient way of accessing the |
244 | 276 | * set of all existing pages can extend this list to all properties that are |
245 | 277 | * used but do not have a type assigned to them. |
| 278 | + * |
| 279 | + * @param SMWRequestOptions $requestoptions |
| 280 | + * |
| 281 | + * @return array |
246 | 282 | */ |
247 | | - abstract function getWantedPropertiesSpecial( $requestoptions = null ); |
| 283 | + public abstract function getWantedPropertiesSpecial( $requestoptions = null ); |
248 | 284 | |
249 | 285 | /** |
250 | 286 | * Return statistical information as an associative array with the following |
— | — | @@ -251,8 +287,10 @@ |
252 | 288 | * - 'PROPUSES': Number of property instances (value assignments) in the datatbase |
253 | 289 | * - 'USEDPROPS': Number of properties that are used with at least one value |
254 | 290 | * - 'DECLPROPS': Number of properties that have been declared (i.e. assigned a type) |
| 291 | + * |
| 292 | + * @return array |
255 | 293 | */ |
256 | | - abstract function getStatistics(); |
| 294 | + public abstract function getStatistics(); |
257 | 295 | |
258 | 296 | ///// Setup store ///// |
259 | 297 | |
— | — | @@ -266,14 +304,18 @@ |
267 | 305 | * This is doen by just using print and possibly ob_flush/flush. This is also relevant for preventing |
268 | 306 | * timeouts during long operations. All output must be valid XHTML, but should preferrably be plain |
269 | 307 | * text, possibly with some linebreaks and weak markup. |
| 308 | + * |
| 309 | + * @param boolean $verbose |
270 | 310 | */ |
271 | | - abstract function setup( $verbose = true ); |
| 311 | + public abstract function setup( $verbose = true ); |
272 | 312 | |
273 | 313 | /** |
274 | 314 | * Drop (delete) all storage structures created by setup(). This will delete all semantic data and |
275 | 315 | * possibly leave the wiki uninitialised. |
| 316 | + * |
| 317 | + * @param boolean $verbose |
276 | 318 | */ |
277 | | - abstract function drop( $verbose = true ); |
| 319 | + public abstract function drop( $verbose = true ); |
278 | 320 | |
279 | 321 | /** |
280 | 322 | * Refresh some objects in the store, addressed by numerical ids. The meaning of the ids is |
— | — | @@ -289,7 +331,14 @@ |
290 | 332 | * |
291 | 333 | * The optional parameter $usejobs indicates whether updates should be processed later using |
292 | 334 | * 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 |
293 | 342 | */ |
294 | | - abstract function refreshData( &$index, $count, $namespaces = false, $usejobs = true ); |
| 343 | + public abstract function refreshData( &$index, $count, $namespaces = false, $usejobs = true ); |
295 | 344 | |
296 | | -} |
| 345 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLStore2.php |
— | — | @@ -44,12 +44,12 @@ |
45 | 45 | |
46 | 46 | /// Array for keeping property table table data, indexed by table id. |
47 | 47 | /// Access this only by calling getPropertyTables(). |
48 | | - private static $prop_tables = array(); |
| 48 | + protected static $prop_tables = array(); |
49 | 49 | /// Array to cache "propkey => propid" associations. Built only when needed. |
50 | | - private static $fixed_prop_tables = null; |
| 50 | + protected static $fixed_prop_tables = null; |
51 | 51 | |
52 | 52 | /// 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( |
54 | 54 | '_TYPE' => 1, |
55 | 55 | '_URI' => 2, |
56 | 56 | '_INST' => 4, |
— | — | @@ -75,7 +75,7 @@ |
76 | 76 | |
77 | 77 | /// Array to cache ids of tables for storing known built-in types. Having |
78 | 78 | /// this data here shortcuts the search in findTypeTableID() below. |
79 | | - private static $property_table_ids = array( |
| 79 | + protected static $property_table_ids = array( |
80 | 80 | '_txt' => 'smw_text2', // Text type |
81 | 81 | '_cod' => 'smw_text2', // Code type |
82 | 82 | '_str' => 'smw_atts2', // String type |
— | — | @@ -109,7 +109,7 @@ |
110 | 110 | |
111 | 111 | /// Array to cache signatures of known built-in types. Having this data |
112 | 112 | /// here safes us from creating datavalue instances in getTypeSignature(). |
113 | | - private static $type_signatures = array( |
| 113 | + protected static $type_signatures = array( |
114 | 114 | '_txt' => array( 'l', -1, -1 ), // Text type |
115 | 115 | '_cod' => array( 'l', -1, -1 ), // Code type |
116 | 116 | '_str' => array( 't', 0, 0 ), // String type |
— | — | @@ -214,6 +214,7 @@ |
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
| 218 | + * @see SMWStore::getPropertyValues |
218 | 219 | * |
219 | 220 | * @param $subject |
220 | 221 | * @param SMWPropertyValue $property |
— | — | @@ -435,7 +436,7 @@ |
436 | 437 | } |
437 | 438 | |
438 | 439 | /** |
439 | | - * returns an array of SMWWikiPageValue. |
| 440 | + * @see SMWStore::getPropertySubjects |
440 | 441 | * |
441 | 442 | * @param SMWPropertyValue $property |
442 | 443 | * @param $value |
— | — | @@ -578,6 +579,8 @@ |
579 | 580 | } |
580 | 581 | |
581 | 582 | /** |
| 583 | + * @see SMWStore::getAllPropertySubjects |
| 584 | + * |
582 | 585 | * @param SMWPropertyValue $property |
583 | 586 | * @param SMWRequestOptions $requestoptions |
584 | 587 | * |
— | — | @@ -592,7 +595,9 @@ |
593 | 596 | } |
594 | 597 | |
595 | 598 | /** |
596 | | - * @todo Restrict this function to SMWWikiPageValue subjects. |
| 599 | + * @see SMWStore::getProperties |
| 600 | + * |
| 601 | + * TODO: Restrict this function to SMWWikiPageValue subjects. |
597 | 602 | * |
598 | 603 | * @param $subject |
599 | 604 | * @param SMWRequestOptions $requestoptions |
— | — | @@ -657,7 +662,10 @@ |
658 | 663 | /** |
659 | 664 | * Implementation of SMWStore::getInProperties(). This function is meant to |
660 | 665 | * 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 |
662 | 670 | * properties since it selects results by comparing the stored information |
663 | 671 | * (DB keys) only, while not currently comparing the type of the returned |
664 | 672 | * property to the type of the queried data. So values with the same DB keys |
— | — | @@ -666,6 +674,8 @@ |
667 | 675 | * |
668 | 676 | * @param SMWDataValue $value |
669 | 677 | * @param SMWRequestOptions $requestoptions |
| 678 | + * |
| 679 | + * @return array of SMWWikiPageValue |
670 | 680 | */ |
671 | 681 | public function getInProperties( SMWDataValue $value, $requestoptions = null ) { |
672 | 682 | wfProfileIn( "SMWSQLStore2::getInProperties (SMW)" ); |
— | — | @@ -718,6 +728,11 @@ |
719 | 729 | |
720 | 730 | ///// Writing methods ///// |
721 | 731 | |
| 732 | + /** |
| 733 | + * @see SMWStore::deleteSubject |
| 734 | + * |
| 735 | + * @param Title $subject |
| 736 | + */ |
722 | 737 | public function deleteSubject( Title $subject ) { |
723 | 738 | wfProfileIn( 'SMWSQLStore2::deleteSubject (SMW)' ); |
724 | 739 | wfRunHooks( 'SMWSQLStore2::deleteSubjectBefore', array( $this, $subject ) ); |
— | — | @@ -740,6 +755,11 @@ |
741 | 756 | wfProfileOut( 'SMWSQLStore2::deleteSubject (SMW)' ); |
742 | 757 | } |
743 | 758 | |
| 759 | + /** |
| 760 | + * @see SMWStore::updateData |
| 761 | + * |
| 762 | + * @param SMWSemanticData $data |
| 763 | + */ |
744 | 764 | public function updateData( SMWSemanticData $data ) { |
745 | 765 | wfProfileIn( "SMWSQLStore2::updateData (SMW)" ); |
746 | 766 | wfRunHooks( 'SMWSQLStore2::updateDataBefore', array( $this, $data ) ); |
— | — | @@ -752,12 +772,12 @@ |
753 | 773 | $redirect = end( $redirects ); // at most one redirect per page |
754 | 774 | $this->updateRedirects( $subject->getDBkey(), $subject->getNamespace(), $redirect->getDBkey(), $redirect->getNameSpace() ); |
755 | 775 | 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! |
757 | 777 | } else { |
758 | 778 | $this->updateRedirects( $subject->getDBkey(), $subject->getNamespace() ); |
759 | 779 | } |
760 | 780 | |
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!): |
762 | 782 | $sid = $this->makeSMWPageID( $subject->getDBkey(), $subject->getNamespace(), '', true, $subject->getSortkey() ); |
763 | 783 | $updates = array(); // collect data for bulk updates; format: tableid => updatearray |
764 | 784 | $this->prepareDBUpdates( $updates, $data, $sid ); |
— | — | @@ -808,8 +828,11 @@ |
809 | 829 | |
810 | 830 | // Finally update caches (may be important if jobs are directly following this call) |
811 | 831 | $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 | + |
813 | 835 | wfRunHooks( 'SMWSQLStore2::updateDataAfter', array( $this, $data ) ); |
| 836 | + |
814 | 837 | wfProfileOut( "SMWSQLStore2::updateData (SMW)" ); |
815 | 838 | } |
816 | 839 | |
— | — | @@ -848,8 +871,9 @@ |
849 | 872 | |
850 | 873 | foreach ( $data->getPropertyValues( $property ) as $dv ) { |
851 | 874 | 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 |
854 | 878 | ///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 |
855 | 879 | $uvals = ( $proptable->idsubject ) ? array( 's_id' => $sid ): |
856 | 880 | array( 's_title' => $subject->getDBkey(), 's_namespace' => $subject->getNamespace() ); |
— | — | @@ -888,6 +912,7 @@ |
889 | 913 | $updates[$proptable->name][] = $uvals; |
890 | 914 | } |
891 | 915 | } |
| 916 | + |
892 | 917 | return $sid; |
893 | 918 | } |
894 | 919 | |
— | — | @@ -909,15 +934,15 @@ |
910 | 935 | * store has its own ID management. Also, the function requires that both |
911 | 936 | * titles are local, i.e. have empty interwiki prefix. |
912 | 937 | * |
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 |
914 | 939 | * not possible to move it reliably in all cases: we cannot distinguish an |
915 | 940 | * unset sortkey from one that was set to the name of oldtitle. Maybe use |
916 | 941 | * update jobs right away? |
917 | 942 | * |
918 | 943 | * @param Title $oldtitle |
919 | 944 | * @param Title $newtitle |
920 | | - * @param $pageid |
921 | | - * @param $redirid |
| 945 | + * @param integer $pageid |
| 946 | + * @param integer $redirid |
922 | 947 | */ |
923 | 948 | public function changeTitle( Title $oldtitle, Title $newtitle, $pageid, $redirid = 0 ) { |
924 | 949 | global $smwgQEqualitySupport; |
— | — | @@ -941,10 +966,10 @@ |
942 | 967 | $this->makeSMWPageID( $oldtitle->getDBkey(), $oldtitle->getNamespace(), SMW_SQL2_SMWREDIIW ); // make redirect id for oldtitle |
943 | 968 | $db->insert( 'smw_redi2', array( 's_title' => $oldtitle->getDBkey(), 's_namespace' => $oldtitle->getNamespace(), 'o_id' => $sid ), |
944 | 969 | 'SMWSQLStore2::changeTitle' ); |
945 | | - $this->m_ids[" " . $oldtitle->getNamespace() . " " . $oldtitle->getDBkey() . " C"] = $sid; |
| 970 | + $this->m_ids[" " . $oldtitle->getNamespace() . ' ' . $oldtitle->getDBkey() . ' C'] = $sid; |
946 | 971 | // $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; |
949 | 974 | /// NOTE: there is the (bad) case that the moved page is a redirect. As chains of |
950 | 975 | /// redirects are not supported by MW or SMW, the above is maximally correct in this case too. |
951 | 976 | /// NOTE: this temporarily leaves existing redirects to oldtitle point to newtitle as well, which |
— | — | @@ -971,11 +996,13 @@ |
972 | 997 | ///// Query answering ///// |
973 | 998 | |
974 | 999 | /** |
| 1000 | + * @see SMWStore::getQueryResult |
| 1001 | + * |
975 | 1002 | * @param $query SMWQuery |
976 | 1003 | * |
977 | 1004 | * @return mixed: depends on $query->querymode |
978 | 1005 | */ |
979 | | - function getQueryResult( SMWQuery $query ) { |
| 1006 | + public function getQueryResult( SMWQuery $query ) { |
980 | 1007 | wfProfileIn( 'SMWSQLStore2::getQueryResult (SMW)' ); |
981 | 1008 | global $smwgIP; |
982 | 1009 | include_once( "$smwgIP/includes/storage/SMW_SQLStore2_Queries.php" ); |
— | — | @@ -1450,23 +1477,34 @@ |
1451 | 1478 | return true; |
1452 | 1479 | } |
1453 | 1480 | |
| 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 | + */ |
1454 | 1491 | public function refreshData( &$index, $count, $namespaces = false, $usejobs = true ) { |
1455 | 1492 | $updatejobs = array(); |
1456 | 1493 | $emptyrange = true; // was nothing found in this run? |
1457 | 1494 | |
1458 | | - // update by MediaWiki page id --> make sure we get all pages |
| 1495 | + // Update by MediaWiki page id --> make sure we get all pages. |
1459 | 1496 | $tids = array(); |
1460 | 1497 | |
1461 | | - for ( $i = $index; $i < $index + $count; $i++ ) { // array of ids |
| 1498 | + // Array of ids |
| 1499 | + for ( $i = $index; $i < $index + $count; $i++ ) { |
1462 | 1500 | $tids[] = $i; |
1463 | 1501 | } |
1464 | 1502 | |
1465 | 1503 | $titles = Title::newFromIDs( $tids ); |
1466 | 1504 | |
1467 | 1505 | foreach ( $titles as $title ) { |
1468 | | - // set $wgTitle, in case semantic data is set based |
| 1506 | + // Set $wgTitle, in case semantic data is set based |
1469 | 1507 | // on values not originating from the page (such as |
1470 | | - // via the External Data extension) |
| 1508 | + // via the External Data extension). |
1471 | 1509 | global $wgTitle; |
1472 | 1510 | $wgTitle = $title; |
1473 | 1511 | |
— | — | @@ -1531,8 +1569,10 @@ |
1532 | 1570 | * Refresh the concept cache for the given concept. |
1533 | 1571 | * |
1534 | 1572 | * @param $concept Title |
| 1573 | + * |
| 1574 | + * @return array |
1535 | 1575 | */ |
1536 | | - public function refreshConceptCache( $concept ) { |
| 1576 | + public function refreshConceptCache( Title $concept ) { |
1537 | 1577 | wfProfileIn( 'SMWSQLStore2::refreshConceptCache (SMW)' ); |
1538 | 1578 | global $smwgIP; |
1539 | 1579 | |
— | — | @@ -2033,11 +2073,11 @@ |
2034 | 2074 | * predefined properties from the ids for the current pages (which may, |
2035 | 2075 | * e.g. be moved, while the predefined object is not movable). |
2036 | 2076 | */ |
2037 | | - private function getPropertyInterwiki( SMWPropertyValue $property ) { |
| 2077 | + protected function getPropertyInterwiki( SMWPropertyValue $property ) { |
2038 | 2078 | if ( $property->isUserDefined() ) { |
2039 | 2079 | return ''; |
2040 | 2080 | } else { |
2041 | | - return $property->isVisible() ? SMW_SQL2_SMWPREDEFIW:SMW_SQL2_SMWINTDEFIW; |
| 2081 | + return $property->isVisible() ? SMW_SQL2_SMWPREDEFIW : SMW_SQL2_SMWINTDEFIW; |
2042 | 2082 | } |
2043 | 2083 | } |
2044 | 2084 | |
— | — | @@ -2217,11 +2257,15 @@ |
2218 | 2258 | |
2219 | 2259 | // Update bnode references that use namespace field to store ids: |
2220 | 2260 | 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 | + ); |
2223 | 2267 | } |
2224 | 2268 | |
2225 | | - // change all id entries in property tables: |
| 2269 | + // Change all id entries in property tables: |
2226 | 2270 | foreach ( self::getPropertyTables() as $proptable ) { |
2227 | 2271 | if ( $sdata && $proptable->idsubject ) { |
2228 | 2272 | $db->update( $proptable->name, array( 's_id' => $newid ), array( 's_id' => $oldid ), $fname ); |
— | — | @@ -2243,7 +2287,8 @@ |
2244 | 2288 | } |
2245 | 2289 | } |
2246 | 2290 | } |
2247 | | - // change id entries in concept-related tables: |
| 2291 | + |
| 2292 | + // Change id entries in concept-related tables: |
2248 | 2293 | if ( $sdata && ( ( $oldnamespace == -1 ) || ( $oldnamespace == SMW_NS_CONCEPT ) ) ) { |
2249 | 2294 | if ( ( $newnamespace == -1 ) || ( $newnamespace == SMW_NS_CONCEPT ) ) { |
2250 | 2295 | $db->update( 'smw_conc2', array( 's_id' => $newid ), array( 's_id' => $oldid ), $fname ); |
— | — | @@ -2253,6 +2298,7 @@ |
2254 | 2299 | $db->delete( 'smw_conccache', array( 's_id' => $oldid ), $fname ); |
2255 | 2300 | } |
2256 | 2301 | } |
| 2302 | + |
2257 | 2303 | if ( $podata ) { |
2258 | 2304 | $db->update( 'smw_conccache', array( 'o_id' => $newid ), array( 'o_id' => $oldid ), $fname ); |
2259 | 2305 | } |
— | — | @@ -2261,6 +2307,8 @@ |
2262 | 2308 | /** |
2263 | 2309 | * Delete all semantic data stored for the given subject. Used for update |
2264 | 2310 | * purposes. |
| 2311 | + * |
| 2312 | + * @param SMWWikiPageValue $subject |
2265 | 2313 | */ |
2266 | 2314 | protected function deleteSemanticData( SMWWikiPageValue $subject ) { |
2267 | 2315 | $db = wfGetDB( DB_MASTER ); |
— | — | @@ -2384,6 +2432,7 @@ |
2385 | 2433 | } |
2386 | 2434 | } |
2387 | 2435 | } |
| 2436 | + |
2388 | 2437 | /// NOTE: we do not update the concept cache here; this remains an offline task |
2389 | 2438 | Job::batchInsert( $jobs ); ///NOTE: this only happens if $smwgEnableUpdateJobs was true above |
2390 | 2439 | } |
— | — | @@ -2446,36 +2495,59 @@ |
2447 | 2496 | * @return array of SMWSQLStore2Table |
2448 | 2497 | */ |
2449 | 2498 | 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. |
2451 | 2500 | |
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 | + ); |
2463 | 2523 | 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 | + ); |
2480 | 2552 | self::$prop_tables['smw_redi2']->idsubject = false; |
2481 | 2553 | |
2482 | 2554 | wfRunHooks( 'SMWPropertyTables', array( &self::$prop_tables ) ); |
— | — | @@ -2483,4 +2555,4 @@ |
2484 | 2556 | return self::$prop_tables; |
2485 | 2557 | } |
2486 | 2558 | |
2487 | | -} |
| 2559 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_RAPStore2.php |
— | — | @@ -38,12 +38,11 @@ |
39 | 39 | /** |
40 | 40 | * @todo Maybe find a better nomenclature for the model. |
41 | 41 | */ |
42 | | - public function SMWRAPStore2() { |
| 42 | + public function __construct() { |
43 | 43 | global $smwgRAPPath, $wgServer; |
44 | 44 | |
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' ); |
48 | 47 | } |
49 | 48 | |
50 | 49 | ///// Writing methods ///// |
— | — | @@ -293,5 +292,4 @@ |
294 | 293 | |
295 | 294 | return $uri; // still requires expandURI() |
296 | 295 | } |
297 | | -} |
298 | | - |
| 296 | +} |
\ No newline at end of file |
Index: trunk/extensions/SemanticMediaWiki/includes/storage/SMW_SQLHelpers.php |
— | — | @@ -1,4 +1,5 @@ |
2 | 2 | <?php |
| 3 | + |
3 | 4 | /** |
4 | 5 | * Some static helper functions that SMW uses for setting up |
5 | 6 | * SQL databases. |
— | — | @@ -7,16 +8,9 @@ |
8 | 9 | * @author Marcel Gsteiger |
9 | 10 | * @author Jeroen De Dauw |
10 | 11 | * |
11 | | - * @file |
| 12 | + * @file SMW_SQLHelpers.php |
12 | 13 | * @ingroup SMWStore |
13 | 14 | */ |
14 | | - |
15 | | -/** |
16 | | - * Static class to collect some helper functions that SMW uses |
17 | | - * for settnig up SQL databases. |
18 | | - * |
19 | | - * @ingroup SMWStore |
20 | | - */ |
21 | 15 | class SMWSQLHelpers { |
22 | 16 | |
23 | 17 | /** |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_GlobalFunctions.php |
— | — | @@ -9,18 +9,18 @@ |
10 | 10 | * @ingroup SMW |
11 | 11 | */ |
12 | 12 | |
13 | | -// constants for displaying the factbox |
| 13 | +// Constants for displaying the factbox. |
14 | 14 | define( 'SMW_FACTBOX_HIDDEN', 1 ); |
15 | 15 | define( 'SMW_FACTBOX_SPECIAL', 2 ); |
16 | 16 | define( 'SMW_FACTBOX_NONEMPTY', 3 ); |
17 | 17 | define( 'SMW_FACTBOX_SHOWN', 5 ); |
18 | 18 | |
19 | | -// constants for regulating equality reasoning |
| 19 | +// Constants for regulating equality reasoning. |
20 | 20 | define( 'SMW_EQ_NONE', 0 ); |
21 | 21 | define( 'SMW_EQ_SOME', 1 ); |
22 | 22 | define( 'SMW_EQ_FULL', 2 ); |
23 | 23 | |
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. |
25 | 25 | define( 'SMW_PROPERTY_QUERY', 1 ); // [[some property::...]] |
26 | 26 | define( 'SMW_CATEGORY_QUERY', 2 ); // [[Category:...]] |
27 | 27 | define( 'SMW_CONCEPT_QUERY', 4 ); // [[Concept:...]] |
— | — | @@ -29,17 +29,17 @@ |
30 | 30 | define( 'SMW_DISJUNCTION_QUERY', 32 ); // any disjunctions (OR, ||) |
31 | 31 | define( 'SMW_ANY_QUERY', 0xFFFFFFFF ); // subsumes all other options |
32 | 32 | |
33 | | -// constants for defining which concepts to show only if cached |
| 33 | +// Constants for defining which concepts to show only if cached. |
34 | 34 | define( 'CONCEPT_CACHE_ALL', 4 ); // show concept elements anywhere only if cached |
35 | 35 | define( 'CONCEPT_CACHE_HARD', 1 ); // show without cache if concept is not harder than permitted inline queries |
36 | 36 | define( 'CONCEPT_CACHE_NONE', 0 ); // show all concepts even without any cache |
37 | 37 | |
38 | | -// constants for identifying javascripts as used in SMWOutputs |
| 38 | +// Constants for identifying javascripts as used in SMWOutputs. |
39 | 39 | define( 'SMW_HEADER_TOOLTIP', 2 ); |
40 | 40 | define( 'SMW_HEADER_SORTTABLE', 3 ); |
41 | 41 | define( 'SMW_HEADER_STYLE', 4 ); |
42 | 42 | |
43 | | -// constants for denoting output modes in many functions: HTML or Wiki? |
| 43 | +// Constants for denoting output modes in many functions: HTML or Wiki? |
44 | 44 | // "File" is for printing results into stand-alone files (e.g. building RSS) |
45 | 45 | // and should be treated like HTML when building single strings. Only query |
46 | 46 | // printers tend to have special handling for that. |
— | — | @@ -55,7 +55,7 @@ |
56 | 56 | define( 'SMW_CMP_LIKE', 5 ); // Matches only datavalues that are LIKE the given value. |
57 | 57 | define( 'SMW_CMP_NLKE', 6 ); // Matches only datavalues that are not LIKE the given value. |
58 | 58 | |
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). |
60 | 60 | define( 'SMW_MDY', 785 ); // Month-Day-Year |
61 | 61 | define( 'SMW_DMY', 673 ); // Day-Month-Year |
62 | 62 | define( 'SMW_YMD', 610 ); // Year-Month-Day |
— | — | @@ -85,20 +85,19 @@ |
86 | 86 | * reimplements most of the title normalization as done in Title.php in order |
87 | 87 | * to achieve conversion with less overhead. The official code could be called |
88 | 88 | * here if more advanced normalization is needed. |
| 89 | + * |
| 90 | + * @param string $text |
89 | 91 | */ |
90 | 92 | function smwfNormalTitleDBKey( $text ) { |
91 | 93 | global $wgCapitalLinks; |
| 94 | + |
92 | 95 | $text = trim( $text ); |
| 96 | + |
93 | 97 | if ( $wgCapitalLinks ) { |
94 | 98 | $text = ucfirst( $text ); |
95 | 99 | } |
| 100 | + |
96 | 101 | 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; |
103 | 102 | } |
104 | 103 | |
105 | 104 | /** |
— | — | @@ -106,25 +105,26 @@ |
107 | 106 | * reimplements the title normalization as done in Title.php in order to |
108 | 107 | * achieve conversion with less overhead. The official code could be called |
109 | 108 | * here if more advanced normalization is needed. |
| 109 | + * |
| 110 | + * @param string $text |
110 | 111 | */ |
111 | 112 | function smwfNormalTitleText( $text ) { |
112 | 113 | global $wgCapitalLinks; |
| 114 | + |
113 | 115 | $text = trim( $text ); |
| 116 | + |
114 | 117 | if ( $wgCapitalLinks ) { |
115 | 118 | $text = ucfirst( $text ); |
116 | 119 | } |
| 120 | + |
117 | 121 | 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; |
124 | 122 | } |
125 | 123 | |
126 | 124 | /** |
127 | 125 | * Escapes text in a way that allows it to be used as XML content (e.g. as a |
128 | 126 | * string value for some property). |
| 127 | + * |
| 128 | + * @param string $text |
129 | 129 | */ |
130 | 130 | function smwfXMLContentEncode( $text ) { |
131 | 131 | return str_replace( array( '&', '<', '>' ), array( '&', '<', '>' ), Sanitizer::decodeCharReferences( $text ) ); |
— | — | @@ -133,6 +133,8 @@ |
134 | 134 | /** |
135 | 135 | * Decodes character references and inserts Unicode characters instead, using |
136 | 136 | * the MediaWiki Sanitizer. |
| 137 | + * |
| 138 | + * @param string $text |
137 | 139 | */ |
138 | 140 | function smwfHTMLtoUTF8( $text ) { |
139 | 141 | return Sanitizer::decodeCharReferences( $text ); |
— | — | @@ -142,12 +144,14 @@ |
143 | 145 | * This method formats a float number value according to the given language and |
144 | 146 | * precision settings, with some intelligence to produce readable output. Used |
145 | 147 | * 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 |
148 | 151 | * the decimal point are shown |
149 | 152 | */ |
150 | 153 | function smwfNumberFormat( $value, $decplaces = 3 ) { |
151 | 154 | global $smwgMaxNonExpNumber; |
| 155 | + |
152 | 156 | smwfLoadExtensionMessages( 'SemanticMediaWiki' ); |
153 | 157 | $decseparator = wfMsgForContent( 'smw_decseparator' ); |
154 | 158 | |
— | — | @@ -157,6 +161,7 @@ |
158 | 162 | // using number_format. This may lead to 1.200, so then use trim to |
159 | 163 | // remove trailing zeroes. |
160 | 164 | $doScientific = false; |
| 165 | + |
161 | 166 | // @todo: Don't do all this magic for integers, since the formatting does not fit there |
162 | 167 | // correctly. E.g. one would have integers formatted as 1234e6, not as 1.234e9, right? |
163 | 168 | // The "$value!=0" is relevant: we want to scientify numbers that are close to 0, but never 0! |
— | — | @@ -177,6 +182,7 @@ |
178 | 183 | } |
179 | 184 | } |
180 | 185 | } |
| 186 | + |
181 | 187 | if ( $doScientific ) { |
182 | 188 | // Should we use decimal places here? |
183 | 189 | $value = sprintf( "%1.6e", $value ); |
— | — | @@ -197,6 +203,7 @@ |
198 | 204 | // Assumes substr is faster than a regular expression replacement. |
199 | 205 | $end = $decseparator . str_repeat( '0', $decplaces ); |
200 | 206 | $lenEnd = strlen( $end ); |
| 207 | + |
201 | 208 | if ( substr( $value, - $lenEnd ) === $end ) { |
202 | 209 | $value = substr( $value, 0, - $lenEnd ); |
203 | 210 | } else { |
— | — | @@ -205,6 +212,7 @@ |
206 | 213 | $value = preg_replace( "/(\\$decseparator\\d+?)0*$/u", '$1', $value, 1 ); |
207 | 214 | } |
208 | 215 | } |
| 216 | + |
209 | 217 | return $value; |
210 | 218 | } |
211 | 219 | |
Index: trunk/extensions/SemanticMediaWiki/includes/SMW_Setup.php |
— | — | @@ -243,6 +243,7 @@ |
244 | 244 | $wgHooks['MonoBookTemplateToolboxEnd'][] = 'smwfShowBrowseLink'; |
245 | 245 | } |
246 | 246 | } |
| 247 | + |
247 | 248 | if ( version_compare( $wgVersion, '1.14alpha', '>=' ) ) { |
248 | 249 | $wgHooks['SkinAfterContent'][] = 'SMWFactbox::onSkinAfterContent'; // draw Factbox below categories |
249 | 250 | $smwgMW_1_14 = true; // assume latest 1.14 API |
— | — | @@ -479,11 +480,12 @@ |
480 | 481 | include_once( $smwgIP . 'languages/' . $smwContLangFile . '.php' ); |
481 | 482 | } |
482 | 483 | |
483 | | - // fallback if language not supported |
| 484 | + // Fallback if language not supported. |
484 | 485 | if ( !class_exists( $smwContLangClass ) ) { |
485 | 486 | include_once( $smwgIP . 'languages/SMW_LanguageEn.php' ); |
486 | 487 | $smwContLangClass = 'SMWLanguageEn'; |
487 | 488 | } |
| 489 | + |
488 | 490 | $smwgContLang = new $smwContLangClass(); |
489 | 491 | |
490 | 492 | wfProfileOut( 'smwfInitContentLanguage (SMW)' ); |