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(
60 'img_timestamp' => wfMsg( 'imagelist_date' ),
61 'img_name' => wfMsg( 'imagelist_name' ),
62 'img_user_text' => wfMsg( 'imagelist_user' ),
63 'img_size' => wfMsg( 'imagelist_size' ),
64 'img_description' => wfMsg( 'imagelist_description' ),
67 return $this->mFieldNames
;
70 function isFieldSortable( $field ) {
71 static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
72 return in_array( $field, $sortable );
75 function getQueryInfo() {
76 $fields = $this->getFieldNames();
77 $fields = array_keys( $fields );
78 $fields[] = 'img_user';
82 'conds' => $this->mQueryConds
86 function getDefaultSort() {
87 return 'img_timestamp';
90 function getStartBody() {
91 # Do a link batch query for user pages
92 if ( $this->mResult
->numRows() ) {
94 $this->mResult
->seek( 0 );
95 while ( $row = $this->mResult
->fetchObject() ) {
96 if ( $row->img_user
) {
97 $lb->add( NS_USER
, str_replace( ' ', '_', $row->img_user_text
) );
103 # Cache messages used in each row
104 $this->mMessages
['imgdesc'] = wfMsgHtml( 'imgdesc' );
105 $this->mMessages
['imgfile'] = wfMsgHtml( 'imgfile' );
107 return parent
::getStartBody();
110 function formatValue( $field, $value ) {
113 case 'img_timestamp':
114 return $wgLang->timeanddate( $value, true );
116 $name = $this->mCurrentRow
->img_name
;
117 $link = $this->getSkin()->makeKnownLinkObj( Title
::makeTitle( NS_IMAGE
, $name ), $value );
118 $download = Xml
::element('a', array( "href" => Image
::imageUrl( $name ) ), $this->mMessages
['imgfile'] );
119 return "$link ($download)";
120 case 'img_user_text':
121 if ( $this->mCurrentRow
->img_user
) {
122 $link = $this->getSkin()->makeLinkObj( Title
::makeTitle( NS_USER
, $value ),
123 htmlspecialchars( $value ) );
125 $link = htmlspecialchars( $value );
129 return $this->getSkin()->formatSize( $value );
130 case 'img_description':
131 return $this->getSkin()->commentBlock( $value );
136 global $wgRequest, $wgMiserMode;
137 $url = $this->getTitle()->escapeLocalURL();
138 $search = $wgRequest->getText( 'ilsearch' );
139 $s = "<form method=\"get\" action=\"$url\">\n" .
140 wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() );
141 if ( !$wgMiserMode ) {
143 Xml
::inputLabel( wfMsg( 'imagelist_search_for' ), 'ilsearch', 'mw-ilsearch', 20, $search );
145 $s .= " " . Xml
::submitButton( wfMsg( 'table_pager_limit_submit' ) ) ." \n" .
146 $this->getHiddenFields( array( 'limit', 'ilsearch' ) ) .
151 function getTableClass() {
152 return 'imagelist ' . parent
::getTableClass();
155 function getNavClass() {
156 return 'imagelist_nav ' . parent
::getNavClass();
159 function getSortHeaderClass() {
160 return 'imagelist_sort ' . parent
::getSortHeaderClass();