r46063 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r46062‎ | r46063 | r46064 >
Date:05:51, 23 January 2009
Author:nad
Status:deferred
Tags:
Comment:
implement sortable parameter
Modified paths:
  • /trunk/extensions/RecordAdmin/RecordAdmin_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/RecordAdmin/RecordAdmin_body.php
@@ -232,20 +232,22 @@
233233 /**
234234 * Render a set of records returned by getRecords() as an HTML table
235235 */
236 - function renderRecords($records, $orderby = false, $cols = false) {
 236+ function renderRecords($records, $orderby = false, $cols = false, $sortable = true) {
237237 if (count($records) < 1) return wfMsg( 'recordadmin-nomatch' );
238238
239239 $special = Title::makeTitle( NS_SPECIAL, 'RecordAdmin' );
240240 $type = $this->type;
 241+ $sortable = $sortable ? ' sortable' : '';
 242+ $br = $sortable ? '<br />' : '';
241243
242244 # Table header
243 - $table = "<table class='sortable recordadmin $type-record'>\n<tr>";
 245+ $table = "<table class='recordadmin$sortable $type-record'>\n<tr>";
244246 $th = array(
245 - 'title' => "<th class='col0'>" . wfMsg( 'recordadmin-title', $type ) . "<br></th>",
246 - 'actions' => "<th class='col1'>" . wfMsg( 'recordadmin-actions' ) . "<br></th>",
247 - 'created' => "<th class='col2'>" . wfMsg( 'recordadmin-created' ) . "<br></th>"
 247+ 'title' => "<th class='col0'>" . wfMsg( 'recordadmin-title', $type ) . "$br</th>",
 248+ 'actions' => "<th class='col1'>" . wfMsg( 'recordadmin-actions' ) . "$br</th>",
 249+ 'created' => "<th class='col2'>" . wfMsg( 'recordadmin-created' ) . "$br</th>"
248250 );
249 - foreach ( array_keys($this->types) as $col ) $th[$col] = "<th class='col$col'>$col<br></th>";
 251+ foreach ( array_keys($this->types) as $col ) $th[$col] = "<th class='col$col'>$col$br</th>";
250252 foreach ( $cols ? $cols : array_keys($th) as $col ) $table .= $th[$col]."\n";
251253 $table .= "</tr>\n";
252254
@@ -448,25 +450,27 @@
449451 */
450452 function expandMagic(&$parser, $type) {
451453 $parser->mOutput->mCacheTime = -1;
452 - $filter = array();
453 - $title = '';
454 - $invert = false;
455 - $orderby = false;
456 - $cols = false;
 454+ $filter = array();
 455+ $title = '';
 456+ $invert = false;
 457+ $orderby = false;
 458+ $cols = false;
 459+ $sortable = true;
457460 foreach (func_get_args() as $arg) if (!is_object($arg)) {
458461 if (preg_match("/^(.+?)\\s*=\\s*(.+)$/", $arg, $match)) {
459462 list(, $k, $v) = $match;
460463 if ($k == 'title') $title = $v;
461 - elseif ($k == 'invert') $invert = $v;
462 - elseif ($k == 'orderby') $orderby = $v;
463 - elseif ($k == 'cols') $cols = preg_split('/\s*,\s*/', $v);
 464+ elseif ($k == 'invert') $invert = $v;
 465+ elseif ($k == 'orderby') $orderby = $v;
 466+ elseif ($k == 'cols') $cols = preg_split('/\s*,\s*/', $v);
 467+ elseif ($k == 'sortable') $sortabke = $v;
464468 else $filter[$match[1]] = $match[2];
465469 }
466470 }
467471 $this->preProcessForm($type);
468472 $this->examineForm();
469473 $records = $this->getRecords($type, $filter, $title, $invert);
470 - $table = $this->renderRecords($records, $orderby, $cols);
 474+ $table = $this->renderRecords($records, $orderby, $cols, $sortable);
471475 return array(
472476 $table,
473477 'noparse' => true,

Status & tagging log