5ecbe8a627b6e041e432832630f4b3bc796fd2f2
5 * @subpackage SpecialPage
11 function wfSpecialImagelist() {
14 $pager = new ImageListPager
;
16 $limit = $pager->getForm();
17 $body = $pager->getBody();
18 $nav = $pager->getNavigationBar();
27 class ImageListPager
extends TablePager
{
28 var $mFieldNames = null;
29 var $mMessages = array();
30 var $mQueryConds = array();
32 function __construct() {
33 global $wgRequest, $wgMiserMode;
34 if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
35 $this->mDefaultDirection
= true;
37 $this->mDefaultDirection
= false;
39 $search = $wgRequest->getText( 'ilsearch' );
40 if ( $search != '' && !$wgMiserMode ) {
41 $nt = Title
::newFromUrl( $search );
43 $dbr =& wfGetDB( DB_SLAVE
);
44 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
45 $m = str_replace( "%", "\\%", $m );
46 $m = str_replace( "_", "\\_", $m );
47 $this->mQueryConds
= array( "LCASE(img_name) LIKE '%{$m}%'" );
51 parent
::__construct();
54 function getFieldNames() {
55 if ( !$this->mFieldNames
) {
56 $this->mFieldNames
= array(
58 'img_timestamp' => wfMsg( 'imagelist_date' ),
59 'img_name' => wfMsg( 'imagelist_name' ),
60 'img_user_text' => wfMsg( 'imagelist_user' ),
61 'img_size' => wfMsg( 'imagelist_size' ),
62 'img_description' => wfMsg( 'imagelist_description' ),
65 return $this->mFieldNames
;
68 function isFieldSortable( $field ) {
69 static $sortable = array( 'img_timestamp', 'img_name', 'img_size' );
70 return in_array( $field, $sortable );
73 function getQueryInfo() {
74 $fields = $this->getFieldNames();
75 unset( $fields['links'] );
76 $fields = array_keys( $fields );
77 $fields[] = 'img_user';
81 'conds' => $this->mQueryConds
85 function getDefaultSort() {
86 return 'img_timestamp';
89 function getStartBody() {
90 # Do a link batch query for user pages
91 if ( $this->mResult
->numRows() ) {
93 $this->mResult
->seek( 0 );
94 while ( $row = $this->mResult
->fetchObject() ) {
95 if ( $row->img_user
) {
96 $lb->add( NS_USER
, str_replace( ' ', '_', $row->img_user_text
) );
102 # Cache messages used in each row
103 $this->mMessages
['imgdesc'] = wfMsgHtml( 'imgdesc' );
104 $this->mMessages
['imgfile'] = wfMsgHtml( 'imgfile' );
106 return parent
::getStartBody();
109 function formatValue( $field, $value ) {
113 $name = $this->mCurrentRow
->img_name
;
114 $ilink = "<a href=\"" . htmlspecialchars( Image
::imageUrl( $name ) ) .
115 "\">" . $this->mMessages
['imgfile'] . "</a>";
116 $desc = $this->getSkin()->makeKnownLinkObj( Title
::makeTitle( NS_IMAGE
, $name ),
117 $this->mMessages
['imgdesc'] );
118 return "$desc | $ilink";
119 case 'img_timestamp':
120 return $wgLang->timeanddate( $value, true );
122 return htmlspecialchars( $value );
123 case 'img_user_text':
124 if ( $this->mCurrentRow
->img_user
) {
125 $link = $this->getSkin()->makeLinkObj( Title
::makeTitle( NS_USER
, $value ),
126 htmlspecialchars( $value ) );
128 $link = htmlspecialchars( $value );
132 return $wgLang->formatNum( $value );
133 case 'img_description':
134 return $this->getSkin()->commentBlock( $value );
139 global $wgRequest, $wgMiserMode;
140 $url = $this->getTitle()->escapeLocalURL();
141 $msgSubmit = wfMsgHtml( 'table_pager_limit_submit' );
142 $msgSearch = wfMsgHtml( 'imagelist_search_for' );
143 $search = $wgRequest->getText( 'ilsearch' );
144 $encSearch = htmlspecialchars( $search );
145 $s = "<form method=\"get\" action=\"$url\">\n" .
146 wfMsgHtml( 'table_pager_limit', $this->getLimitSelect() );
147 if ( !$wgMiserMode ) {
148 $s .= "<br/>\n" . $msgSearch .
149 " <input type=\"text\" size=\"20\" name=\"ilsearch\" value=\"$encSearch\"/><br/>\n";
151 $s .= " <input type=\"submit\" value=\"$msgSubmit\"/>\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();