Index: trunk/extensions/DPLforum/DPLforum_body.php |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | DPLforum v3.2 -- DynamicPageList-based forum extension |
5 | 5 | |
6 | 6 | Author: Ross McClure |
— | — | @@ -24,7 +24,8 @@ |
25 | 25 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
26 | 26 | http://www.gnu.org/copyleft/gpl.html |
27 | 27 | |
28 | | - * @addtogroup Extensions |
| 28 | + * @file |
| 29 | + * @ingroup Extensions |
29 | 30 | */ |
30 | 31 | |
31 | 32 | if ( !defined( 'MEDIAWIKI' ) ) { |
— | — | @@ -66,27 +67,32 @@ |
67 | 68 | foreach ( $matches[1] as $cat ) { |
68 | 69 | $title = Title::newFromText( $parser->replaceVariables( trim( $cat ) ) ); |
69 | 70 | if ( !is_null( $title ) ) |
70 | | - $cats[] = $title; |
| 71 | + $cats[] = $title; |
71 | 72 | } |
72 | 73 | } |
73 | 74 | return $cats; |
74 | 75 | } |
75 | 76 | |
76 | | - function get( $name, $value = NULL, $parser = NULL ) { |
| 77 | + function get( $name, $value = null, $parser = null ) { |
77 | 78 | if ( preg_match( "/^\s*$name\s*=\s*(.*)/mi", $this->sInput, $matches ) ) { |
78 | 79 | $arg = trim( $matches[1] ); |
79 | | - if ( is_int( $value ) ) return intval( $arg ); |
80 | | - else if ( is_null( $parser ) ) return htmlspecialchars( $arg ); |
81 | | - else return $parser->replaceVariables( $arg ); |
| 80 | + if ( is_int( $value ) ) |
| 81 | + return intval( $arg ); |
| 82 | + elseif ( is_null( $parser ) ) |
| 83 | + return htmlspecialchars( $arg ); |
| 84 | + else |
| 85 | + return $parser->replaceVariables( $arg ); |
82 | 86 | } |
83 | 87 | return $value; |
84 | 88 | } |
85 | 89 | |
86 | 90 | function link( &$parser, $count, $page = '', $text = '' ) { |
87 | 91 | $count = intval( $count ); |
88 | | - if ( $count < 1 ) return ''; |
| 92 | + if ( $count < 1 ) |
| 93 | + return ''; |
89 | 94 | |
90 | | - if ( $this->requireCache ) $offset = 0; |
| 95 | + if ( $this->requireCache ) |
| 96 | + $offset = 0; |
91 | 97 | else { |
92 | 98 | global $wgRequest; |
93 | 99 | $parser->disableCache(); |
— | — | @@ -94,15 +100,20 @@ |
95 | 101 | } |
96 | 102 | |
97 | 103 | $i = intval( $page ); |
98 | | - if ( ( $i != 0 ) && ctype_digit( $page[0] ) ) $i -= 1; |
99 | | - else $i += intval( $offset / $count ); |
100 | | - if ( $this->link_test( $i, $page ) ) return ''; |
| 104 | + if ( ( $i != 0 ) && ctype_digit( $page[0] ) ) |
| 105 | + $i -= 1; |
| 106 | + else |
| 107 | + $i += intval( $offset / $count ); |
| 108 | + if ( $this->link_test( $i, $page ) ) |
| 109 | + return ''; |
101 | 110 | |
102 | | - if ( $text === '' ) $text = ( $i + 1 ); |
| 111 | + if ( $text === '' ) |
| 112 | + $text = ( $i + 1 ); |
103 | 113 | $page = ( $count * $i ); |
104 | | - if ( $page == $offset ) return $text; |
| 114 | + if ( $page == $offset ) |
| 115 | + return $text; |
105 | 116 | |
106 | | - return '[{{fullurl:{{FULLPAGENAME}}|offset=' . $page . '}} ' . $text . ']'; |
| 117 | + return '[' . $parser->replaceVariables( '{{fullurl:{{FULLPAGENAME}}|offset=' . $page . '}} ' ) . $text . ']'; |
107 | 118 | } |
108 | 119 | |
109 | 120 | function link_test( $page, $cond ) { |
— | — | @@ -110,16 +121,20 @@ |
111 | 122 | $m[1] = strtr( $m[1], array( ( '&l' . 't;' ) => '<', ( '&g' . 't;' ) => '>' ) ); |
112 | 123 | $m[2] = intval( $m[2] ) - 1; |
113 | 124 | switch( $m[1] ) { |
114 | | - case '<': return ( $page >= $m[2] ); |
115 | | - case '>': return ( $page <= $m[2] ); |
116 | | - case '<=': return ( $page > $m[2] ); |
117 | | - case '>=': return ( $page < $m[2] ); |
| 125 | + case '<': |
| 126 | + return ( $page >= $m[2] ); |
| 127 | + case '>': |
| 128 | + return ( $page <= $m[2] ); |
| 129 | + case '<=': |
| 130 | + return ( $page > $m[2] ); |
| 131 | + case '>=': |
| 132 | + return ( $page < $m[2] ); |
118 | 133 | } |
119 | 134 | } |
120 | 135 | return ( $page < 0 ); |
121 | 136 | } |
122 | 137 | |
123 | | - function msg( $type, $error = NULL ) { |
| 138 | + function msg( $type, $error = null ) { |
124 | 139 | if ( $error && ( $this->get( 'suppresserrors' ) == 'true' ) ) |
125 | 140 | return ''; |
126 | 141 | |
— | — | @@ -140,18 +155,20 @@ |
141 | 156 | |
142 | 157 | switch( $this->get( 'historylink' ) ) { |
143 | 158 | case 'embed': |
144 | | - case 'true': $this->bEmbedHistory = true; |
| 159 | + case 'true': |
| 160 | + $this->bEmbedHistory = true; |
145 | 161 | case 'append': |
146 | | - case 'show': $this->bLinkHistory = true; |
| 162 | + case 'show': |
| 163 | + $this->bLinkHistory = true; |
147 | 164 | } |
148 | 165 | $sOrder = 'rev_timestamp'; |
149 | 166 | switch( $this->get( 'ordermethod' ) ) { |
150 | 167 | case 'categoryadd': |
151 | 168 | case 'created': |
152 | | - $sOrder = 'first_time'; |
| 169 | + $sOrder = 'first_time'; |
153 | 170 | break; |
154 | 171 | case 'pageid': |
155 | | - $sOrder = 'page_id'; |
| 172 | + $sOrder = 'page_id'; |
156 | 173 | } |
157 | 174 | |
158 | 175 | $arg = $this->get( 'compact' ); |
— | — | @@ -162,12 +179,15 @@ |
163 | 180 | $arg = $this->get( 'namespace', '', $parser ); |
164 | 181 | $iNamespace = $wgContLang->getNsIndex( $arg ); |
165 | 182 | if ( !$iNamespace ) { |
166 | | - if ( ( $arg ) || ( $arg === '0' ) ) $iNamespace = intval( $arg ); |
167 | | - else $iNamespace = - 1; |
| 183 | + if ( ( $arg ) || ( $arg === '0' ) ) |
| 184 | + $iNamespace = intval( $arg ); |
| 185 | + else |
| 186 | + $iNamespace = - 1; |
168 | 187 | } |
169 | 188 | if ( $iNamespace < 0 ) |
170 | 189 | $this->bShowNamespace = ( $this->get( 'shownamespace' ) != 'false' ); |
171 | | - else $this->bShowNamespace = ( $this->get( 'shownamespace' ) == 'true' ); |
| 190 | + else |
| 191 | + $this->bShowNamespace = ( $this->get( 'shownamespace' ) == 'true' ); |
172 | 192 | |
173 | 193 | $this->bTableMode = false; |
174 | 194 | $sStartItem = $sEndItem = ''; |
— | — | @@ -175,22 +195,22 @@ |
176 | 196 | $arg = $this->get( 'mode' ); |
177 | 197 | switch( $arg ) { |
178 | 198 | case 'none': |
179 | | - $sEndItem = '<br />'; |
| 199 | + $sEndItem = '<br />'; |
180 | 200 | break; |
181 | 201 | case 'count': |
182 | | - $bCountMode = true; |
| 202 | + $bCountMode = true; |
183 | 203 | break; |
184 | 204 | case 'list': |
185 | 205 | case 'ordered': |
186 | 206 | case 'unordered': |
187 | | - $sStartItem = '<li>'; |
188 | | - $sEndItem = '</li>'; |
| 207 | + $sStartItem = '<li>'; |
| 208 | + $sEndItem = '</li>'; |
189 | 209 | break; |
190 | 210 | case 'table': |
191 | 211 | default: |
192 | | - $this->bTableMode = true; |
193 | | - $sStartItem = '<tr>'; |
194 | | - $sEndItem = '</tr>'; |
| 212 | + $this->bTableMode = true; |
| 213 | + $sStartItem = '<tr>'; |
| 214 | + $sEndItem = '</tr>'; |
195 | 215 | } |
196 | 216 | $aCategories = $this->cat( $parser, 'category' ); |
197 | 217 | $aExcludeCategories = $this->cat( $parser, 'notcategory' ); |
— | — | @@ -200,14 +220,15 @@ |
201 | 221 | $output = ''; |
202 | 222 | |
203 | 223 | if ( $sPrefix === '' && ( ( $cats < 1 && $iNamespace < 0 ) || |
204 | | - ( $total < $this->minCategories ) ) ) return $this->msg( 'dplforum-toofew', 1 ); |
| 224 | + ( $total < $this->minCategories ) ) ) |
| 225 | + return $this->msg( 'dplforum-toofew', 1 ); |
205 | 226 | if ( ( $total > $this->maxCategories ) && ( !$this->unlimitedCategories ) ) |
206 | | - return $this->msg( 'dplforum-toomany', 1 ); |
| 227 | + return $this->msg( 'dplforum-toomany', 1 ); |
207 | 228 | |
208 | 229 | $count = 1; |
209 | 230 | $start = $this->get( 'start', 0 ); |
210 | 231 | $title = Title::newFromText( $parser->replaceVariables( |
211 | | - trim( $this->get( 'title' ) ) ) ); |
| 232 | + trim( $this->get( 'title' ) ) ) ); |
212 | 233 | if ( !( $bCountMode || $this->requireCache || $this->get( 'cache' ) == 'true' ) ) { |
213 | 234 | $parser->disableCache(); |
214 | 235 | |
— | — | @@ -216,22 +237,22 @@ |
217 | 238 | $start += intval( $wgRequest->getVal( 'offset' ) ); |
218 | 239 | } |
219 | 240 | } |
220 | | - if ( $start < 0 ) $start = 0; |
| 241 | + if ( $start < 0 ) |
| 242 | + $start = 0; |
221 | 243 | |
222 | 244 | if ( is_null( $title ) ) { |
223 | 245 | $count = $this->get( 'count', 0 ); |
224 | 246 | if ( $count > 0 ) { |
225 | 247 | if ( $count > $this->maxResultCount ) |
| 248 | + $count = $this->maxResultCount; |
| 249 | + } elseif ( $this->unlimitedResults ) |
| 250 | + $count = 0x7FFFFFFF; // maximum integer value |
| 251 | + else |
226 | 252 | $count = $this->maxResultCount; |
227 | | - } |
228 | | - else if ( $this->unlimitedResults ) |
229 | | - $count = 0x7FFFFFFF; // maximum integer value |
230 | | - else |
231 | | - $count = $this->maxResultCount; |
232 | 253 | } |
233 | 254 | |
234 | 255 | // build the SQL query |
235 | | - $dbr =& wfGetDB( DB_SLAVE ); |
| 256 | + $dbr = wfGetDB( DB_SLAVE ); |
236 | 257 | $sPageTable = $dbr->tableName( 'page' ); |
237 | 258 | $sRevTable = $dbr->tableName( 'revision' ); |
238 | 259 | $categorylinks = $dbr->tableName( 'categorylinks' ); |
— | — | @@ -242,8 +263,7 @@ |
243 | 264 | |
244 | 265 | if ( $bCountMode ) { |
245 | 266 | $sSqlSelectFrom = "SELECT COUNT(*) AS num_rows FROM $sPageTable"; |
246 | | - } |
247 | | - else if ( ( $this->bAddAuthor || $this->bAddCreationDate || |
| 267 | + } elseif ( ( $this->bAddAuthor || $this->bAddCreationDate || |
248 | 268 | ( $sOrder == 'first_time' ) ) && ( ( !$this->restrictNamespace ) || |
249 | 269 | ( $iNamespace >= 0 && !in_array( $iNamespace, $this->restrictNamespace ) ) ) ) { |
250 | 270 | $sSqlSelectFrom .= ", o.rev_user_text AS first_user, o.rev_timestamp AS" |
— | — | @@ -251,13 +271,14 @@ |
252 | 272 | . " ON o.rev_id =( SELECT MIN(q.rev_id) FROM $sRevTable" |
253 | 273 | . " AS q WHERE q.rev_page = page_id )"; |
254 | 274 | } else { |
255 | | - if ( $sOrder == 'first_time' ) $sOrder = 'page_id'; |
| 275 | + if ( $sOrder == 'first_time' ) |
| 276 | + $sOrder = 'page_id'; |
256 | 277 | $sSqlSelectFrom .= $arg; |
257 | 278 | } |
258 | 279 | |
259 | 280 | $sSqlWhere = ' WHERE 1=1'; |
260 | 281 | if ( $iNamespace >= 0 ) |
261 | | - $sSqlWhere = ' WHERE page_namespace=' . $iNamespace; |
| 282 | + $sSqlWhere = ' WHERE page_namespace=' . $iNamespace; |
262 | 283 | |
263 | 284 | if ( $sPrefix !== '' ) { |
264 | 285 | // Escape SQL special characters |
— | — | @@ -268,12 +289,12 @@ |
269 | 290 | |
270 | 291 | switch( $this->get( 'redirects' ) ) { |
271 | 292 | case 'only': |
272 | | - $sSqlWhere .= ' AND page_is_redirect = 1'; |
| 293 | + $sSqlWhere .= ' AND page_is_redirect = 1'; |
273 | 294 | case 'include': |
274 | 295 | break; |
275 | 296 | case 'exclude': |
276 | 297 | default: |
277 | | - $sSqlWhere .= ' AND page_is_redirect = 0'; |
| 298 | + $sSqlWhere .= ' AND page_is_redirect = 0'; |
278 | 299 | break; |
279 | 300 | } |
280 | 301 | |
— | — | @@ -307,10 +328,10 @@ |
308 | 329 | // $output .= 'QUERY: [' . $sSqlSelectFrom . $sSqlWhere . "]<br />"; |
309 | 330 | |
310 | 331 | // process the query |
311 | | - $res = $dbr->query( $sSqlSelectFrom . $sSqlWhere ); |
| 332 | + $res = $dbr->query( $sSqlSelectFrom . $sSqlWhere, __METHOD__ ); |
312 | 333 | |
313 | 334 | $this->vMarkNew = $dbr->timestamp( time() - |
314 | | - intval( $this->get( 'newdays', 7 ) * 86400 ) ); |
| 335 | + intval( $this->get( 'newdays', 7 ) * 86400 ) ); |
315 | 336 | |
316 | 337 | if ( $bCountMode ) { |
317 | 338 | if ( $row = $dbr->fetchObject( $res ) ) { |
— | — | @@ -318,8 +339,7 @@ |
319 | 340 | } else { |
320 | 341 | $output .= '0'; |
321 | 342 | } |
322 | | - } |
323 | | - else if ( is_null( $title ) ) { |
| 343 | + } elseif ( is_null( $title ) ) { |
324 | 344 | while ( $row = $dbr->fetchObject( $res ) ) { |
325 | 345 | if( isset( $row->first_time ) ) { |
326 | 346 | $first_time = $row->first_time; |
— | — | @@ -336,16 +356,16 @@ |
337 | 357 | $title = Title::makeTitle( $row->page_namespace, $row->page_title ); |
338 | 358 | $output .= $sStartItem; |
339 | 359 | $output .= $this->buildOutput( $title, $title, $row->rev_timestamp, |
340 | | - $row->rev_user_text, $first_user, $first_time ); |
| 360 | + $row->rev_user_text, $first_user, $first_time ); |
341 | 361 | $output .= $sEndItem . "\n"; |
342 | 362 | } |
343 | 363 | } else { |
344 | 364 | $output .= $sStartItem; |
345 | 365 | if ( $row = $dbr->fetchObject( $res ) ) { |
346 | 366 | $output .= $this->buildOutput( Title::makeTitle( $row->page_namespace, |
347 | | - $row->page_title ), $title, $row->rev_timestamp, $row->rev_user_text ); |
| 367 | + $row->page_title ), $title, $row->rev_timestamp, $row->rev_user_text ); |
348 | 368 | } else { |
349 | | - $output .= $this->buildOutput( NULL, $title, $this->msg( 'dplforum-never' ) ); |
| 369 | + $output .= $this->buildOutput( null, $title, $this->msg( 'dplforum-never' ) ); |
350 | 370 | } |
351 | 371 | $output .= $sEndItem . "\n"; |
352 | 372 | } |
— | — | @@ -356,7 +376,7 @@ |
357 | 377 | function buildOutput( $page, $title, $time, $user = '', $author = '', $made = '' ) { |
358 | 378 | global $wgLang, $wgUser; |
359 | 379 | |
360 | | - $sk =& $wgUser->getSkin(); |
| 380 | + $sk = $wgUser->getSkin(); |
361 | 381 | $tm =& $this->bTableMode; |
362 | 382 | $output = ''; |
363 | 383 | |
— | — | @@ -376,7 +396,7 @@ |
377 | 397 | |
378 | 398 | if ( $tm ) { |
379 | 399 | $output .= "<td class='forum_created'>$made</td>"; |
380 | | - } else if ( $made ) { |
| 400 | + } elseif ( $made ) { |
381 | 401 | $output = "{$made}: "; |
382 | 402 | } |
383 | 403 | } |
— | — | @@ -420,7 +440,7 @@ |
421 | 441 | if ( $tm ) { |
422 | 442 | if ( $this->bCompactAuthor ) { |
423 | 443 | if ( $author ) { |
424 | | - $byAuthor = wfMsg( 'word-separator') . wfMsgHTML( 'dplforum-by', $author ); |
| 444 | + $byAuthor = wfMsg( 'word-separator' ) . wfMsgHtml( 'dplforum-by', $author ); |
425 | 445 | $output .= " <span class='forum_author'>$byAuthor</span>"; |
426 | 446 | } else { |
427 | 447 | $output .= " <span class='forum_author'>&nb" . "sp;</span>"; |
— | — | @@ -428,8 +448,8 @@ |
429 | 449 | } else { |
430 | 450 | $output .= "</td><td class='forum_author'>$author"; |
431 | 451 | } |
432 | | - } else if ( $author ) { |
433 | | - $byAuthor = wfMsg( 'word-separator') . wfMsgHTML( 'dplforum-by', $author ); |
| 452 | + } elseif ( $author ) { |
| 453 | + $byAuthor = wfMsg( 'word-separator' ) . wfMsgHtml( 'dplforum-by', $author ); |
434 | 454 | $output .= $byAuthor; |
435 | 455 | } |
436 | 456 | } |
— | — | @@ -465,7 +485,7 @@ |
466 | 486 | if ( $tm ) { |
467 | 487 | if ( $this->bCompactEdit ) { |
468 | 488 | if ( $user ) { |
469 | | - $byUser = wfMsgHTML( 'dplforum-by', $user ); |
| 489 | + $byUser = wfMsgHtml( 'dplforum-by', $user ); |
470 | 490 | $output .= " <span class='forum_editor'>$byUser</span>"; |
471 | 491 | } else { |
472 | 492 | $output .= " <span class='forum_editor'>&nb" . "sp;</span>"; |
— | — | @@ -473,16 +493,15 @@ |
474 | 494 | } else { |
475 | 495 | $output .= "</td><td class='forum_editor'>$user"; |
476 | 496 | } |
477 | | - } |
478 | | - else if ( $user ) { |
479 | | - $byUser = wfMsgHTML( 'dplforum-by', $user ); |
| 497 | + } elseif ( $user ) { |
| 498 | + $byUser = wfMsgHtml( 'dplforum-by', $user ); |
480 | 499 | $text .= $byUser; |
481 | 500 | } |
482 | 501 | } |
483 | 502 | |
484 | 503 | if ( $tm ) { |
485 | | - $output .= "</td>"; |
486 | | - } else if ( $text ) { |
| 504 | + $output .= '</td>'; |
| 505 | + } elseif ( $text ) { |
487 | 506 | $output .= wfMsg( 'word-separator' ) . $this->msg( 'dplforum-edited' ) . " $text"; |
488 | 507 | } |
489 | 508 | |
Index: trunk/extensions/DPLforum/DPLforum.i18n.php |
— | — | @@ -1,8 +1,9 @@ |
2 | 2 | <?php |
3 | 3 | /** |
4 | | - * Internationalization file for DPLforum extension |
| 4 | + * Internationalization file for DPLforum extension. |
5 | 5 | * |
6 | | - * @addtogroup Extensions |
| 6 | + * @file |
| 7 | + * @ingroup Extensions |
7 | 8 | */ |
8 | 9 | |
9 | 10 | $messages = array(); |
— | — | @@ -11,11 +12,11 @@ |
12 | 13 | * @author Ross McClure |
13 | 14 | */ |
14 | 15 | $messages['en'] = array( |
15 | | - 'dplforum-desc' => 'DPL-based forum extension', |
16 | | - 'dplforum-by' => 'by $1', |
17 | | - 'dplforum-edited' => '- Last edited', |
18 | | - 'dplforum-never' => 'Never', |
19 | | - 'dplforum-toofew' => 'DPL Forum: Too few categories!', |
| 16 | + 'dplforum-desc' => 'DPL-based forum extension', |
| 17 | + 'dplforum-by' => 'by $1', |
| 18 | + 'dplforum-edited' => '- Last edited', |
| 19 | + 'dplforum-never' => 'Never', |
| 20 | + 'dplforum-toofew' => 'DPL Forum: Too few categories!', |
20 | 21 | 'dplforum-toomany' => 'DPL Forum: Too many categories!' |
21 | 22 | ); |
22 | 23 | |
Index: trunk/extensions/DPLforum/DPLforum.php |
— | — | @@ -1,7 +1,7 @@ |
2 | 2 | <?php |
3 | | -/* |
| 3 | +/** |
4 | 4 | |
5 | | - DPLforum v3.2 -- DynamicPageList-based forum extension |
| 5 | + DPLforum v3.3.1 -- DynamicPageList-based forum extension |
6 | 6 | |
7 | 7 | Author: Ross McClure |
8 | 8 | http://www.mediawiki.org/wiki/User:Algorithm |
— | — | @@ -38,13 +38,13 @@ |
39 | 39 | $wgExtensionFunctions[] = 'wfDPLforum'; |
40 | 40 | $wgHooks['LanguageGetMagic'][] = 'wfDPLmagic'; |
41 | 41 | $wgExtensionCredits['parserhook'][] = array( |
42 | | - 'path' => __FILE__, |
43 | | - 'name' => 'DPLforum', |
44 | | - 'url' => 'http://www.mediawiki.org/wiki/Extension:DPLforum', |
45 | | - 'description' => 'DPL-based forum extension', |
| 42 | + 'path' => __FILE__, |
| 43 | + 'name' => 'DPLforum', |
| 44 | + 'author' => 'Ross McClure', |
| 45 | + 'version' => '3.3.1', |
| 46 | + 'url' => 'http://www.mediawiki.org/wiki/Extension:DPLforum', |
| 47 | + 'description' => 'DPL-based forum extension', |
46 | 48 | 'descriptionmsg' => 'dplforum-desc', |
47 | | - 'author' => 'Ross McClure', |
48 | | - 'version' => '3.3' |
49 | 49 | ); |
50 | 50 | |
51 | 51 | $dir = dirname( __FILE__ ) . '/'; |
— | — | @@ -59,9 +59,10 @@ |
60 | 60 | $wgParser->setFunctionHook( 'forumlink', array( new DPLForum(), 'link' ) ); |
61 | 61 | } |
62 | 62 | |
63 | | -function wfDPLmagic( &$magicWords, $langCode = "en" ) { |
| 63 | +function wfDPLmagic( &$magicWords, $langCode = 'en' ) { |
64 | 64 | switch( $langCode ) { |
65 | | - default: $magicWords['forumlink'] = array ( 0, 'forumlink' ); |
| 65 | + default: |
| 66 | + $magicWords['forumlink'] = array( 0, 'forumlink' ); |
66 | 67 | } |
67 | 68 | return true; |
68 | 69 | } |