4 * @addtogroup SpecialPage
10 function wfSpecialImagelist() {
13 $pager = new ImageListPager
;
15 $limit = $pager->getForm();
16 $body = $pager->getBody();
17 $nav = $pager->getNavigationBar();
26 class ImageListPager
extends TablePager
{
27 var $mFieldNames = null;
28 var $mMessages = array();
29 var $mQueryConds = array();
31 function __construct() {
32 global $wgRequest, $wgMiserMode;
33 if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
34 $this->mDefaultDirection
= true;
36 $this->mDefaultDirection
= false;
38 $search = $wgRequest->getText( 'ilsearch' );
39 if ( $search != '' && !$wgMiserMode ) {
40 $nt = Title
::newFromUrl( $search );
42 $dbr = wfGetDB( DB_SLAVE
);
43 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
44 $m = str_replace( "%", "\\%", $m );
45 $m = str_replace( "_", "\\_", $m );
46 $this->mQueryConds
= array( "LOWER(img_name) LIKE '%{$m}%'" );
50 parent
::__construct();
53 function getFieldNames() {
54 if ( !$this->mFieldNames
) {
55 $this->mFieldNames
= array(
57 'img_timestamp' => wfMsg( 'imagelist_date' ),
58 'img_name' => wfMsg( 'imagelist_name' ),
59 'img_user_text' => wfMsg( 'imagelist_user' ),
60 'img_size' => wfMsg( 'imagelist_size' ),
61 'img_description' => wfMsg( 'imagelist_description' ),
64 return $this->mFieldNames
;
67 function isFieldSortable( $field ) {
68 static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
69 return in_array( $field, $sortable );
72 function getQueryInfo() {
73 $fields = $this->getFieldNames();
74 unset( $fields['links'] );
75 $fields = array_keys( $fields );
76 $fields[] = 'img_user';
80 'conds' => $this->mQueryConds
84 function getDefaultSort() {
85 return 'img_timestamp';
88 function getStartBody() {
89 # Do a link batch query for user pages
90 if ( $this->mResult
->numRows() ) {
92 $this->mResult
->seek( 0 );
93 while ( $row = $this->mResult
->fetchObject() ) {
94 if ( $row->img_user
) {
95 $lb->add( NS_USER
, str_replace( ' ', '_', $row->img_user_text
) );
101 # Cache messages used in each row
102 $this->mMessages
['imgdesc'] = wfMsgHtml( 'imgdesc' );
103 $this->mMessages
['imgfile'] = wfMsgHtml( 'imgfile' );
105 return parent
::getStartBody();
108 function formatValue( $field, $value ) {
112 $name = $this->mCurrentRow
->img_name
;
113 $ilink = "<a href=\"" . htmlspecialchars( Image
::imageUrl( $name ) ) .
114 "\">" . $this->mMessages
['imgfile'] . "</a>";
115 $desc = $this->getSkin()->makeKnownLinkObj( Title
::makeTitle( NS_IMAGE
, $name ),
116 $this->mMessages
['imgdesc'] );
117 return "$desc | $ilink";
118 case 'img_timestamp':
119 return $wgLang->timeanddate( $value, true );
121 return htmlspecialchars( $value );
122 case 'img_user_text':
123 if ( $this->mCurrentRow
->img_user
) {
124 $link = $this->getSkin()->makeLinkObj( Title
::makeTitle( NS_USER
, $value ),
125 htmlspecialchars( $value ) );
127 $link = htmlspecialchars( $value );
131 return $wgLang->formatNum( $value );
132 case 'img_description':
133 return $this->getSkin()->commentBlock( $value );
138 global $wgRequest, $wgMiserMode;
139 $url = $this->getTitle()->escapeLocalURL();
140 $search = $wgRequest->getText( 'ilsearch' );
141 $s = "<form method=\"get\" action=\"$url\">\n" .
142 wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() );
143 if ( !$wgMiserMode ) {
145 Xml
::inputLabel( wfMsg( 'imagelist_search_for' ), 'ilsearch', 'mw-ilsearch', 20, $search );
147 $s .= " " . Xml
::submitButton( wfMsg( 'table_pager_limit_submit' ) ) ." \n" .
148 $this->getHiddenFields( array( 'limit', 'ilsearch' ) ) .
153 function getTableClass() {
154 return 'imagelist ' . parent
::getTableClass();
157 function getNavClass() {
158 return 'imagelist_nav ' . parent
::getNavClass();
161 function getSortHeaderClass() {
162 return 'imagelist_sort ' . parent
::getSortHeaderClass();