10 function wfSpecialImagelist() {
13 $pager = new ImageListPager
;
15 $limit = $pager->getForm();
16 $body = $pager->getBody();
17 $nav = $pager->getNavigationBar();
18 $wgOut->addHTML( "$limit<br />\n$body<br />\n$nav" );
22 * @ingroup SpecialPage Pager
24 class ImageListPager
extends TablePager
{
25 var $mFieldNames = null;
26 var $mQueryConds = array();
28 function __construct() {
29 global $wgRequest, $wgMiserMode;
30 if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
31 $this->mDefaultDirection
= true;
33 $this->mDefaultDirection
= false;
35 $search = $wgRequest->getText( 'ilsearch' );
36 if ( $search != '' && !$wgMiserMode ) {
37 $nt = Title
::newFromUrl( $search );
39 $dbr = wfGetDB( DB_SLAVE
);
40 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
41 $m = str_replace( "%", "\\%", $m );
42 $m = str_replace( "_", "\\_", $m );
43 $this->mQueryConds
= array( "LOWER(img_name) LIKE '%{$m}%'" );
47 parent
::__construct();
50 function getFieldNames() {
51 if ( !$this->mFieldNames
) {
52 $this->mFieldNames
= array(
53 'img_timestamp' => wfMsg( 'imagelist_date' ),
54 'img_name' => wfMsg( 'imagelist_name' ),
55 'img_user_text' => wfMsg( 'imagelist_user' ),
56 'img_size' => wfMsg( 'imagelist_size' ),
57 'img_description' => wfMsg( 'imagelist_description' ),
60 return $this->mFieldNames
;
63 function isFieldSortable( $field ) {
64 static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
65 return in_array( $field, $sortable );
68 function getQueryInfo() {
69 $fields = $this->getFieldNames();
70 $fields = array_keys( $fields );
71 $fields[] = 'img_user';
75 'conds' => $this->mQueryConds
79 function getDefaultSort() {
80 return 'img_timestamp';
83 function getStartBody() {
84 # Do a link batch query for user pages
85 if ( $this->mResult
->numRows() ) {
87 $this->mResult
->seek( 0 );
88 while ( $row = $this->mResult
->fetchObject() ) {
89 if ( $row->img_user
) {
90 $lb->add( NS_USER
, str_replace( ' ', '_', $row->img_user_text
) );
96 return parent
::getStartBody();
99 function formatValue( $field, $value ) {
102 case 'img_timestamp':
103 return $wgLang->timeanddate( $value, true );
105 static $imgfile = null;
106 if ( $imgfile === null ) $imgfile = wfMsg( 'imgfile' );
108 $name = $this->mCurrentRow
->img_name
;
109 $link = $this->getSkin()->makeKnownLinkObj( Title
::makeTitle( NS_IMAGE
, $name ), $value );
110 $image = wfLocalFile( $value );
111 $url = $image->getURL();
112 $download = Xml
::element('a', array( 'href' => $url ), $imgfile );
113 return "$link ($download)";
114 case 'img_user_text':
115 if ( $this->mCurrentRow
->img_user
) {
116 $link = $this->getSkin()->makeLinkObj( Title
::makeTitle( NS_USER
, $value ),
117 htmlspecialchars( $value ) );
119 $link = htmlspecialchars( $value );
123 return $this->getSkin()->formatSize( $value );
124 case 'img_description':
125 return $this->getSkin()->commentBlock( $value );
130 global $wgRequest, $wgMiserMode;
131 $search = $wgRequest->getText( 'ilsearch' );
133 $s = Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $this->getTitle()->getLocalURL(), 'id' => 'mw-imagelist-form' ) ) .
134 Xml
::openElement( 'fieldset' ) .
135 Xml
::element( 'legend', null, wfMsg( 'imagelist' ) ) .
136 Xml
::tags( 'label', null, wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() ) );
138 if ( !$wgMiserMode ) {
140 Xml
::inputLabel( wfMsg( 'imagelist_search_for' ), 'ilsearch', 'mw-ilsearch', 20, $search );
143 Xml
::submitButton( wfMsg( 'table_pager_limit_submit' ) ) ."\n" .
144 $this->getHiddenFields( array( 'limit', 'ilsearch' ) ) .
145 Xml
::closeElement( 'fieldset' ) .
146 Xml
::closeElement( 'form' ) . "\n";
150 function getTableClass() {
151 return 'imagelist ' . parent
::getTableClass();
154 function getNavClass() {
155 return 'imagelist_nav ' . parent
::getNavClass();
158 function getSortHeaderClass() {
159 return 'imagelist_sort ' . parent
::getSortHeaderClass();