Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php |
— | — | @@ -35,7 +35,7 @@ |
36 | 36 | if ( $type && $wgRecordAdminUseNamespaces ) { |
37 | 37 | if ( $wpTitle && !ereg( "^$type:.+$", $wpTitle ) ) $wpTitle = "$type:$wpTitle"; |
38 | 38 | } |
39 | | - if (version_compare(substr($wgVersion, 0, 4), '1.13') > 0) { |
| 39 | + if ( version_compare( substr( $wgVersion, 0, 4 ), '1.13' ) > 0 ) { |
40 | 40 | $wgOut->addHTML( $wgLang->pipeList( array( |
41 | 41 | "<div class='center'><a href='" . $title->getLocalURL() . "/$type'>" . wfMsg( 'recordadmin-newsearch', $type ) . "</a>", |
42 | 42 | "<a href='" . $title->getLocalURL() . "'>" . wfMsg( 'recordadmin-newrecord' ) . "</a></div><br />\n" |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | . "<a href='" . $title->getLocalURL() . "'>" . wfMsg( 'recordadmin-newrecord' ) . "</a><br />\n" |
48 | 48 | ); |
49 | 49 | } |
50 | | - |
| 50 | + |
51 | 51 | # Get posted form values if any |
52 | 52 | $posted = array(); |
53 | 53 | foreach ( $_POST as $k => $v ) if ( ereg( '^ra_(.+)$', $k, $m ) ) $posted[$m[1]] = $v; |
— | — | @@ -80,7 +80,7 @@ |
81 | 81 | while ( $row = $dbr->fetchRow( $res ) ) $options .= '<option>' . Title::newFromID( $row[0] )->getText() . '</option>'; |
82 | 82 | |
83 | 83 | # Render type select list |
84 | | - if ($options) $wgOut->addHTML( |
| 84 | + if ( $options ) $wgOut->addHTML( |
85 | 85 | "<select name='wpType'>$options</select> " |
86 | 86 | . Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'recordadmin-submit' ) ) ) |
87 | 87 | ); |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | |
119 | 119 | # Attempt to create the article |
120 | 120 | $article = new Article( $t ); |
121 | | - $summary = "[[Special:RecordAdmin/$type|".wfMsgForContent( 'recordadmin' )."]]: " . wfMsg( 'recordadmin-summary-typecreated', $type ); |
| 121 | + $summary = "[[Special:RecordAdmin/$type|" . wfMsgForContent( 'recordadmin' ) . "]]: " . wfMsg( 'recordadmin-summary-typecreated', $type ); |
122 | 122 | $text = ''; |
123 | 123 | foreach ( $posted as $k => $v ) if ( $v ) { |
124 | 124 | if ( $this->types[$k] == 'bool' ) $v = 'yes'; |
— | — | @@ -139,7 +139,7 @@ |
140 | 140 | |
141 | 141 | # Render the form |
142 | 142 | $wgOut->addHTML( |
143 | | - Xml::element( 'form', array( 'class' => strtolower($type).'-record recordadmin', 'action' => $title->getLocalURL( 'action=submit' ), 'method' => 'post' ), null ) |
| 143 | + Xml::element( 'form', array( 'class' => strtolower( $type ) . '-record recordadmin', 'action' => $title->getLocalURL( 'action=submit' ), 'method' => 'post' ), null ) |
144 | 144 | . '<b>' . wfMsg( 'recordadmin-recordid' ) . '</b> ' . Xml::element( 'input', array( 'name' => 'wpTitle', 'size' => 30, 'value' => $wpTitle ) ) |
145 | 145 | . ' ' . Xml::element( 'input', array( 'name' => 'wpInvert', 'type' => 'checkbox' ) ) . ' ' . wfMsg( 'recordadmin-invert' ) |
146 | 146 | . "\n<br><br><hr><br>\n{$this->form}" |
— | — | @@ -159,7 +159,7 @@ |
160 | 160 | $records = $this->getRecords( $type, $posted, $wpTitle, $invert ); |
161 | 161 | |
162 | 162 | # Render resulting records |
163 | | - $wgOut->addHTML( $this->renderRecords($records) ); |
| 163 | + $wgOut->addHTML( $this->renderRecords( $records ) ); |
164 | 164 | |
165 | 165 | } |
166 | 166 | } |
— | — | @@ -172,7 +172,7 @@ |
173 | 173 | $text = $article->fetchContent(); |
174 | 174 | |
175 | 175 | # Update article if form posted |
176 | | - if ( count( $posted ) && $rtitle->userCan('edit', false)) { |
| 176 | + if ( count( $posted ) && $rtitle->userCan( 'edit', false ) ) { |
177 | 177 | |
178 | 178 | # Get the location and length of the record braces to replace |
179 | 179 | foreach ( $this->examineBraces( $text ) as $brace ) if ( $brace['NAME'] == $type ) $braces = $brace; |
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | # Extract current values from article |
199 | 199 | $braces = false; |
200 | 200 | foreach ( $this->examineBraces( $text ) as $brace ) if ( $brace['NAME'] == $type ) $braces = $brace; |
201 | | - if ($braces) { |
| 201 | + if ( $braces ) { |
202 | 202 | |
203 | 203 | # Fill in current values |
204 | 204 | $this->populateForm( substr( $text, $braces['OFFSET'], $braces['LENGTH'] ) ); |
— | — | @@ -213,16 +213,16 @@ |
214 | 214 | . '</tr></table></form>' |
215 | 215 | ); |
216 | 216 | } |
217 | | - |
| 217 | + |
218 | 218 | # No instance of the template found, just display the article content |
219 | | - else $wgOut->addWikiText($text); |
| 219 | + else $wgOut->addWikiText( $text ); |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Return an array of records given type and other criteria |
225 | 225 | */ |
226 | | - function getRecords($type, $posted, $wpTitle = '', $invert = false, $orderby = 'created desc') { |
| 226 | + function getRecords( $type, $posted, $wpTitle = '', $invert = false, $orderby = 'created desc' ) { |
227 | 227 | $records = array(); |
228 | 228 | $dbr = wfGetDB( DB_SLAVE ); |
229 | 229 | $tbl = $dbr->tableName( 'templatelinks' ); |
— | — | @@ -246,7 +246,7 @@ |
247 | 247 | } |
248 | 248 | } |
249 | 249 | $dbr->freeResult( $res ); |
250 | | - |
| 250 | + |
251 | 251 | # Add the creation date column to the records |
252 | 252 | foreach ( $records as $i => $r ) { |
253 | 253 | $t = $r[0]; |
— | — | @@ -263,19 +263,19 @@ |
264 | 264 | } |
265 | 265 | |
266 | 266 | # Sort the records according to "orderby" parameter |
267 | | - if ($this->desc = eregi(' +desc *$', $orderby)) $orderby = eregi_replace(' +desc *$', '', $orderby); |
| 267 | + if ( $this->desc = eregi( ' +desc *$', $orderby ) ) $orderby = eregi_replace( ' +desc *$', '', $orderby ); |
268 | 268 | $this->orderby = $orderby; |
269 | | - usort($records, array($this, 'sortCallback')); |
| 269 | + usort( $records, array( $this, 'sortCallback' ) ); |
270 | 270 | |
271 | 271 | return $records; |
272 | 272 | } |
273 | | - |
| 273 | + |
274 | 274 | /** |
275 | 275 | * Compares to arrays by column |
276 | 276 | */ |
277 | | - function sortCallback($row1, $row2) { |
278 | | - if (!isset($row1[$this->orderby]) || !isset($row1[$this->orderby])) return 0; |
279 | | - if ($row1[$this->orderby] == $row2[$this->orderby]) return 0; |
| 277 | + function sortCallback( $row1, $row2 ) { |
| 278 | + if ( !isset( $row1[$this->orderby] ) || !isset( $row1[$this->orderby] ) ) return 0; |
| 279 | + if ( $row1[$this->orderby] == $row2[$this->orderby] ) return 0; |
280 | 280 | $cmp = $row1[$this->orderby] > $row2[$this->orderby] ? 1 : -1; |
281 | 281 | return $this->desc ? -$cmp : $cmp; |
282 | 282 | } |
— | — | @@ -283,16 +283,16 @@ |
284 | 284 | /** |
285 | 285 | * Render a set of records returned by getRecords() as an HTML table |
286 | 286 | */ |
287 | | - function renderRecords($records, $cols = false, $sortable = true) { |
| 287 | + function renderRecords( $records, $cols = false, $sortable = true ) { |
288 | 288 | global $wgUser; |
289 | | - if (count($records) < 1) return wfMsg( 'recordadmin-nomatch' ); |
| 289 | + if ( count( $records ) < 1 ) return wfMsg( 'recordadmin-nomatch' ); |
290 | 290 | |
291 | 291 | $special = Title::makeTitle( NS_SPECIAL, 'RecordAdmin' ); |
292 | 292 | $type = $this->type; |
293 | 293 | $sortable = $sortable ? ' sortable' : ''; |
294 | 294 | $br = $sortable ? '<br />' : ''; |
295 | 295 | $parser = new Parser; |
296 | | - $options = ParserOptions::newFromUser($wgUser); |
| 296 | + $options = ParserOptions::newFromUser( $wgUser ); |
297 | 297 | |
298 | 298 | # Table header |
299 | 299 | $table = "<table class='recordadmin$sortable $type-record'>\n<tr>"; |
— | — | @@ -301,11 +301,11 @@ |
302 | 302 | 'actions' => "<th class='col1'>" . wfMsg( 'recordadmin-actions' ) . "$br</th>", |
303 | 303 | 'created' => "<th class='col2'>" . wfMsg( 'recordadmin-created' ) . "$br</th>" |
304 | 304 | ); |
305 | | - foreach ( array_keys($this->types) as $col ) { |
306 | | - $class = 'col'.preg_replace('|\W|', '-', $col); |
| 305 | + foreach ( array_keys( $this->types ) as $col ) { |
| 306 | + $class = 'col' . preg_replace( '|\W|', '-', $col ); |
307 | 307 | $th[$col] = "<th class='$class'>$col$br</th>"; |
308 | 308 | } |
309 | | - foreach ( $cols ? $cols : array_keys($th) as $col ) $table .= $th[$col]."\n"; |
| 309 | + foreach ( $cols ? $cols : array_keys( $th ) as $col ) $table .= $th[$col] . "\n"; |
310 | 310 | $table .= "</tr>\n"; |
311 | 311 | |
312 | 312 | $stripe = ''; |
— | — | @@ -318,17 +318,17 @@ |
319 | 319 | $table .= "<tr$stripe>"; |
320 | 320 | $row = array( |
321 | 321 | 'title' => "<td class='col0'><a href='$u'>$col</a></td>", |
322 | | - 'actions' => "<td class='col1'>(<a href='$u'>" . wfMsg( 'recordadmin-viewlink' ) . "</a>)". |
| 322 | + 'actions' => "<td class='col1'>(<a href='$u'>" . wfMsg( 'recordadmin-viewlink' ) . "</a>)" . |
323 | 323 | "(<a href='" . $special->getLocalURL( "wpType=$type&wpRecord=$col" ) . "'>" . wfMsg( 'recordadmin-editlink' ) . "</a>)</td>", |
324 | 324 | 'created' => "<td class='col2'>$ts</td>\n" |
325 | 325 | ); |
326 | 326 | foreach ( array_keys( $this->types ) as $col ) { |
327 | 327 | $v = isset( $r[$col] ) ? $parser->parse( $r[$col], $special, $options, true, true )->getText() : ' '; |
328 | | - $class = 'col'.preg_replace('|\W|', '-', $col); |
| 328 | + $class = 'col' . preg_replace( '|\W|', '-', $col ); |
329 | 329 | $row[$col] = "<td class='$class'>$v</td>"; |
330 | 330 | } |
331 | | - foreach ($cols ? $cols : array_keys($th) as $col) $table .= $row[$col]."\n"; |
332 | | - |
| 331 | + foreach ( $cols ? $cols : array_keys( $th ) as $col ) $table .= $row[$col] . "\n"; |
| 332 | + |
333 | 333 | $table .= "</tr>\n"; |
334 | 334 | } |
335 | 335 | $table .= "</table>\n"; |
— | — | @@ -512,7 +512,7 @@ |
513 | 513 | $rtype = wfMsg( 'recordadmin-recordtype' ) . " ($newtype)"; |
514 | 514 | $ttitle = Title::newFromtext( $newtype, NS_TEMPLATE ); |
515 | 515 | $ftitle = Title::newFromtext( $newtype, NS_FORM ); |
516 | | - if ( !is_object($ttitle) || !is_object($ftitle) ) { |
| 516 | + if ( !is_object( $ttitle ) || !is_object( $ftitle ) ) { |
517 | 517 | $wgOut->addHTML( "<div class='errorbox'>" . wfMsg( 'recordadmin-createerror', $rtype ) . "</div>\n" ); |
518 | 518 | } |
519 | 519 | $tttext = $ttitle->getPrefixedText(); |
— | — | @@ -530,27 +530,27 @@ |
531 | 531 | |
532 | 532 | # Attempt to create the template and form |
533 | 533 | else { |
534 | | - $summary = "[[Special:RecordAdmin/$newtype|".wfMsgForContent( 'recordadmin' )."]]: " . wfMsg( 'recordadmin-summary-typecreated', $rtype ); |
| 534 | + $summary = "[[Special:RecordAdmin/$newtype|" . wfMsgForContent( 'recordadmin' ) . "]]: " . wfMsg( 'recordadmin-summary-typecreated', $rtype ); |
535 | 535 | |
536 | 536 | # Compose the content of the new template |
537 | 537 | $cat = Title::newFromText( $wgRecordAdminCategory, NS_CATEGORY )->getPrefixedText(); |
538 | | - $link = "[{{fullurl:$tttext|action=edit}} ".wfMsg('recordadmin-needscontent')."]"; |
| 538 | + $link = "[{{fullurl:$tttext|action=edit}} " . wfMsg( 'recordadmin-needscontent' ) . "]"; |
539 | 539 | $text = "<noinclude>[[$cat]]</noinclude>\n{| class=recordadmin-template\n\n$link\n\n|}<includeonly>[[Category:{$newtype}s]]</includeonly>"; |
540 | 540 | $article = new Article( $ttitle ); |
541 | 541 | $success = $article->doEdit( $text, $summary, EDIT_NEW ); |
542 | | - if (!$success) { |
| 542 | + if ( !$success ) { |
543 | 543 | $wgOut->addHTML( "<div class='errorbox'>" . wfMsg( 'recordadmin-createerror', $tttext ) . "</div>\n" ); |
544 | 544 | } |
545 | 545 | else { |
546 | 546 | |
547 | 547 | # Compose the content of the new form |
548 | 548 | $cat = Title::newFromText( $wgRecordAdminCategory, NS_CATEGORY )->getPrefixedText(); |
549 | | - $url = $ftitle->getLocalUrl('action=edit'); |
550 | | - $link = "<a href=\"$url\">".wfMsg('recordadmin-needscontent')."</a>"; |
| 549 | + $url = $ftitle->getLocalUrl( 'action=edit' ); |
| 550 | + $link = "<a href=\"$url\">" . wfMsg( 'recordadmin-needscontent' ) . "</a>"; |
551 | 551 | $text = "<html>\n\t<form>\n\t\t<table>\n\t\t$link\n\t\t</table>\n\t</form>\n</html>"; |
552 | 552 | $article = new Article( $ftitle ); |
553 | 553 | $success = $article->doEdit( $text, $summary, EDIT_NEW ); |
554 | | - if (!$success) { |
| 554 | + if ( !$success ) { |
555 | 555 | $wgOut->addHTML( "<div class='errorbox'>" . wfMsg( 'recordadmin-createerror', $fttext ) . "</div>\n" ); |
556 | 556 | } |
557 | 557 | } |
— | — | @@ -563,7 +563,7 @@ |
564 | 564 | /** |
565 | 565 | * Render a record search in a parser-function |
566 | 566 | */ |
567 | | - function expandMagic(&$parser, $type) { |
| 567 | + function expandMagic( &$parser, $type ) { |
568 | 568 | $parser->mOutput->mCacheTime = -1; |
569 | 569 | $filter = array(); |
570 | 570 | $title = ''; |
— | — | @@ -571,27 +571,27 @@ |
572 | 572 | $orderby = 'created desc'; |
573 | 573 | $cols = false; |
574 | 574 | $sortable = true; |
575 | | - foreach (func_get_args() as $arg) if (!is_object($arg)) { |
576 | | - if (preg_match("/^(.+?)\\s*=\\s*(.+)$/", $arg, $match)) { |
577 | | - list(, $k, $v) = $match; |
578 | | - if ($k == 'title') $title = $v; |
579 | | - elseif ($k == 'invert') $invert = $v; |
580 | | - elseif ($k == 'orderby') $orderby = $v; |
581 | | - elseif ($k == 'cols') $cols = preg_split('/\s*,\s*/', $v); |
582 | | - elseif ($k == 'sortable') $sortable = eregi('1|yes|true|on', $v); |
| 575 | + foreach ( func_get_args() as $arg ) if ( !is_object( $arg ) ) { |
| 576 | + if ( preg_match( "/^(.+?)\\s*=\\s*(.+)$/", $arg, $match ) ) { |
| 577 | + list( , $k, $v ) = $match; |
| 578 | + if ( $k == 'title' ) $title = $v; |
| 579 | + elseif ( $k == 'invert' ) $invert = $v; |
| 580 | + elseif ( $k == 'orderby' ) $orderby = $v; |
| 581 | + elseif ( $k == 'cols' ) $cols = preg_split( '/\s*,\s*/', $v ); |
| 582 | + elseif ( $k == 'sortable' ) $sortable = eregi( '1|yes|true|on', $v ); |
583 | 583 | else $filter[$match[1]] = $match[2]; |
584 | 584 | } |
585 | 585 | } |
586 | | - $this->preProcessForm($type); |
| 586 | + $this->preProcessForm( $type ); |
587 | 587 | $this->examineForm(); |
588 | | - $records = $this->getRecords($type, $filter, $title, $invert, $orderby); |
589 | | - $table = $this->renderRecords($records, $cols, $sortable); |
| 588 | + $records = $this->getRecords( $type, $filter, $title, $invert, $orderby ); |
| 589 | + $table = $this->renderRecords( $records, $cols, $sortable ); |
590 | 590 | return array( |
591 | 591 | $table, |
592 | 592 | 'noparse' => true, |
593 | 593 | 'isHTML' => true |
594 | 594 | ); |
595 | | - |
| 595 | + |
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
Index: trunk/extensions/RecordAdmin/RecordAdmin.i18n.php |
— | — | @@ -49,7 +49,7 @@ |
50 | 50 | 'recordadmin-title' => '$1', |
51 | 51 | 'recordadmin-created' => 'Created', |
52 | 52 | 'recordadmin-actions' => 'Actions', |
53 | | - 'recordadmin-needscontent' => 'Content needed, click here to add it...', |
| 53 | + 'recordadmin-needscontent' => 'Add content...', |
54 | 54 | 'right-recordadmin' => 'Find and edit record pages', |
55 | 55 | ); |
56 | 56 | |
Index: trunk/extensions/RecordAdmin/RecordAdmin.php |
— | — | @@ -64,8 +64,8 @@ |
65 | 65 | /** |
66 | 66 | * Setup parser-function magic |
67 | 67 | */ |
68 | | -function wfRecordAdminLanguageGetMagic(&$magicWords, $langCode = 0) { |
| 68 | +function wfRecordAdminLanguageGetMagic( &$magicWords, $langCode = 0 ) { |
69 | 69 | global $wgRecordAdminMagic; |
70 | | - $magicWords[$wgRecordAdminMagic] = array($langCode, $wgRecordAdminMagic); |
| 70 | + $magicWords[$wgRecordAdminMagic] = array( $langCode, $wgRecordAdminMagic ); |
71 | 71 | return true; |
72 | 72 | } |