4 * @addtogroup SpecialPage
10 function wfSpecialImagelist() {
13 $pager = new ImageListPager
;
15 $limit = $pager->getForm();
16 $body = $pager->getBody();
17 $nav = $pager->getNavigationBar();
27 * @addtogroup SpecialPage
30 class ImageListPager
extends TablePager
{
31 var $mFieldNames = null;
32 var $mMessages = array();
33 var $mQueryConds = array();
35 function __construct() {
36 global $wgRequest, $wgMiserMode;
37 if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
38 $this->mDefaultDirection
= true;
40 $this->mDefaultDirection
= false;
42 $search = $wgRequest->getText( 'ilsearch' );
43 if ( $search != '' && !$wgMiserMode ) {
44 $nt = Title
::newFromUrl( $search );
46 $dbr = wfGetDB( DB_SLAVE
);
47 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
48 $m = str_replace( "%", "\\%", $m );
49 $m = str_replace( "_", "\\_", $m );
50 $this->mQueryConds
= array( "LOWER(img_name) LIKE '%{$m}%'" );
54 parent
::__construct();
57 function getFieldNames() {
58 if ( !$this->mFieldNames
) {
59 $this->mFieldNames
= array(
61 'img_timestamp' => wfMsg( 'imagelist_date' ),
62 'img_name' => wfMsg( 'imagelist_name' ),
63 'img_user_text' => wfMsg( 'imagelist_user' ),
64 'img_size' => wfMsg( 'imagelist_size' ),
65 'img_description' => wfMsg( 'imagelist_description' ),
68 return $this->mFieldNames
;
71 function isFieldSortable( $field ) {
72 static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
73 return in_array( $field, $sortable );
76 function getQueryInfo() {
77 $fields = $this->getFieldNames();
78 unset( $fields['links'] );
79 $fields = array_keys( $fields );
80 $fields[] = 'img_user';
84 'conds' => $this->mQueryConds
88 function getDefaultSort() {
89 return 'img_timestamp';
92 function getStartBody() {
93 # Do a link batch query for user pages
94 if ( $this->mResult
->numRows() ) {
96 $this->mResult
->seek( 0 );
97 while ( $row = $this->mResult
->fetchObject() ) {
98 if ( $row->img_user
) {
99 $lb->add( NS_USER
, str_replace( ' ', '_', $row->img_user_text
) );
105 # Cache messages used in each row
106 $this->mMessages
['imgdesc'] = wfMsgHtml( 'imgdesc' );
107 $this->mMessages
['imgfile'] = wfMsgHtml( 'imgfile' );
109 return parent
::getStartBody();
112 function formatValue( $field, $value ) {
116 $name = $this->mCurrentRow
->img_name
;
117 $ilink = "<a href=\"" . htmlspecialchars( Image
::imageUrl( $name ) ) .
118 "\">" . $this->mMessages
['imgfile'] . "</a>";
119 $desc = $this->getSkin()->makeKnownLinkObj( Title
::makeTitle( NS_IMAGE
, $name ),
120 $this->mMessages
['imgdesc'] );
121 return "$desc | $ilink";
122 case 'img_timestamp':
123 return $wgLang->timeanddate( $value, true );
125 return htmlspecialchars( $value );
126 case 'img_user_text':
127 if ( $this->mCurrentRow
->img_user
) {
128 $link = $this->getSkin()->makeLinkObj( Title
::makeTitle( NS_USER
, $value ),
129 htmlspecialchars( $value ) );
131 $link = htmlspecialchars( $value );
135 return $wgLang->formatNum( $value );
136 case 'img_description':
137 return $this->getSkin()->commentBlock( $value );
142 global $wgRequest, $wgMiserMode;
143 $url = $this->getTitle()->escapeLocalURL();
144 $search = $wgRequest->getText( 'ilsearch' );
145 $s = "<form method=\"get\" action=\"$url\">\n" .
146 wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() );
147 if ( !$wgMiserMode ) {
149 Xml
::inputLabel( wfMsg( 'imagelist_search_for' ), 'ilsearch', 'mw-ilsearch', 20, $search );
151 $s .= " " . Xml
::submitButton( wfMsg( 'table_pager_limit_submit' ) ) ." \n" .
152 $this->getHiddenFields( array( 'limit', 'ilsearch' ) ) .
157 function getTableClass() {
158 return 'imagelist ' . parent
::getTableClass();
161 function getNavClass() {
162 return 'imagelist_nav ' . parent
::getNavClass();
165 function getSortHeaderClass() {
166 return 'imagelist_sort ' . parent
::getSortHeaderClass();