28use OOUI\ButtonGroupWidget;
56 $this->mSort = $this->
getRequest()->getText(
'sort' );
57 if ( !array_key_exists( $this->mSort, $this->
getFieldNames() )
64 } elseif ( $this->
getRequest()->getBool(
'desc' ) ) {
69 parent::__construct(
null, $linkRenderer );
82 $body = parent::getBody();
100 $body = parent::getBody();
103 $pout->
setRawText( $navigation . $body . $navigation );
119 foreach ( $fields as $field => $name ) {
120 if ( strval( $name ) ==
'' ) {
121 $s .= Html::rawElement(
'th', [],
"\u{00A0}" ) .
"\n";
127 if ( $this->mSort == $field ) {
132 $class =
"$sortClass mw-datatable-is-sorted mw-datatable-is-descending";
137 $class =
"$sortClass mw-datatable-is-sorted mw-datatable-is-ascending";
139 $query[
'desc'] =
'1';
143 $link = $this->
makeLink( htmlspecialchars( $name ), $query, $linkType );
144 $s .= Html::rawElement(
'th', [
'class' => $class ], $link ) .
"\n";
150 $ret = Html::openElement(
'table', [
153 $ret .= Html::rawElement(
'thead', [], Html::rawElement(
'tr', [],
"\n" . $s .
"\n" ) );
154 $ret .= Html::openElement(
'tbody' ) .
"\n";
164 return "</tbody></table>\n";
172 $msgEmpty = $this->
msg(
'table_pager_empty' )->text();
173 return Html::rawElement(
'tr', [],
174 Html::element(
'td', [
'colspan' => $colspan ], $msgEmpty ) );
183 $this->mCurrentRow = $row;
184 $s = Html::openElement(
'tr', $this->
getRowAttrs( $row ) ) .
"\n";
187 foreach ( $fieldNames as $field => $name ) {
188 $value = $row->$field ??
null;
189 $formatted = strval( $this->
formatValue( $field, $value ) );
191 if ( $formatted ==
'' ) {
192 $formatted =
"\u{00A0}";
195 $s .= Html::rawElement(
'td', $this->
getCellAttrs( $field, $value ), $formatted ) .
"\n";
198 $s .= Html::closeElement(
'tr' ) .
"\n";
246 return [
'class' =>
'TablePager_col_' . $field ];
264 return 'mw-datatable';
272 return 'TablePager_nav';
280 return 'TablePager_sort';
296 $types = [
'first',
'prev',
'next',
'last' ];
304 foreach ( $types as $type ) {
305 $buttons[] =
new ButtonWidget( [
311 'classes' => [
'TablePager-button-' . $type ],
312 'flags' => [
'progressive' ],
314 'label' => $this->
msg(
'table_pager_' . $type )->text(),
315 'href' => $queries[ $type ] ?
316 $title->getLinkURL( $queries[ $type ] + $this->getDefaultQuery() ) :
318 'icon' => $type ===
'prev' ?
'previous' : $type,
319 'disabled' => $queries[ $type ] === false
322 return new ButtonGroupWidget( [
333 parent::getModuleStyles(), [
'oojs-ui.styles.icons-movement' ]
344 $select = new
XmlSelect(
'limit', false, $this->mLimit );
346 foreach ( $attribs as $name => $value ) {
347 $select->setAttribute( $name, $value );
349 return $select->getHTML();
360 # Add the current limit from the query string
361 # to avoid that the limit is lost after clicking Go next time
362 if ( !in_array( $this->mLimit, $this->mLimitsShown ) ) {
363 $this->mLimitsShown[] = $this->mLimit;
364 sort( $this->mLimitsShown );
367 foreach ( $this->mLimitsShown as $key => $value ) {
368 # The pair is either $index => $limit, in which case the $value
369 # will be numeric, or $limit => $text, in which case the $value
371 if ( is_int( $value ) ) {
373 $text = $this->getLanguage()->formatNum( $limit );
378 $ret[$text] = $limit;
393 $noResubmit = (array)$noResubmit;
394 $query = $this->getRequest()->getQueryValues();
395 foreach ( $noResubmit as $name ) {
396 unset( $query[$name] );
399 foreach ( $query as $name => $value ) {
400 if ( is_array( $value ) ) {
404 $s .= Html::hidden( $name, $value ) .
"\n";
415 return Html::rawElement(
421 "\n" . $this->getLimitDropdown()
430 private function getLimitDropdown() {
431 # Make the select with some explanatory text
432 $msgSubmit = $this->msg(
'table_pager_limit_submit' )->escaped();
434 return $this->msg(
'table_pager_limit' )
435 ->rawParams( $this->getLimitSelect() )->escaped() .
436 "\n<input type=\"submit\" value=\"$msgSubmit\"/>\n" .
437 $this->getHiddenFields( [
'limit' ] );
484class_alias( TablePager::class,
'TablePager' );
wfScript( $script='index')
Get the URL path to a MediaWiki entry point.
setContext(IContextSource $context)
msg( $key,... $params)
Get a Message object with context set Parameters are the same as wfMessage()
Interface for objects which can provide a MediaWiki context on request.