5 * @subpackage SpecialPage
11 function wfSpecialImagelist() {
12 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest, $wgMiserMode;
14 $sort = $wgRequest->getVal( 'sort' );
15 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
16 $dbr =& wfGetDB( DB_SLAVE
);
17 $image = $dbr->tableName( 'image' );
18 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
19 "img_description,img_timestamp FROM $image";
21 if ( !$wgMiserMode && !empty( $wpIlMatch ) ) {
22 $nt = Title
::newFromUrl( $wpIlMatch );
24 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
25 $m = str_replace( "%", "\\%", $m );
26 $m = str_replace( "_", "\\_", $m );
27 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
31 if ( "bysize" == $sort ) {
32 $sql .= " ORDER BY img_size DESC";
33 } else if ( "byname" == $sort ) {
34 $sql .= " ORDER BY img_name";
37 $sql .= " ORDER BY img_timestamp DESC";
40 list( $limit, $offset ) = wfCheckLimits( 50 );
41 $lt = $wgLang->formatNum( "${limit}" );
42 $sql .= " LIMIT {$limit}";
44 $wgOut->addWikiText( wfMsg( 'imglegend' ) );
45 $wgOut->addHTML( wfMsgExt( 'imagelisttext', array('parse'), $lt, wfMsg( $sort ) ) );
47 $sk = $wgUser->getSkin();
48 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Imagelist" );
49 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
51 if ( !$wgMiserMode ) {
52 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
58 'name' => 'wpIlMatch',
59 'value' => $wpIlMatch, )) .
63 'name' => 'wpIlSubmit',
64 'value' => wfMsg( 'ilsubmit'), )) .
68 $here = Title
::makeTitle( NS_SPECIAL
, 'Imagelist' );
70 foreach ( array( 'byname', 'bysize', 'bydate') as $sorttype ) {
72 foreach ( array( 50, 100, 250, 500 ) as $num ) {
73 $urls[] = $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
74 "sort={$sorttype}&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
76 $sortlinks[] = wfMsgExt(
78 array( 'parseinline', 'replaceafter' ),
79 implode($urls, ' | '),
80 wfMsgExt( $sorttype, array('escape') )
83 $wgOut->addHTML( implode( $sortlinks, "<br />\n") . "\n\n<hr />" );
86 $wgOut->addHTML( '<p>' );
87 $res = $dbr->query( $sql, "wfSpecialImagelist" );
89 while ( $s = $dbr->fetchObject( $res ) ) {
91 $ut = $s->img_user_text
;
92 if ( 0 == $s->img_user
) {
95 $ul = $sk->makeLinkObj( Title
::makeTitle( NS_USER
, $ut ), $ut );
98 $dirmark = $wgContLang->getDirMark(); // to keep text in correct direction
100 $ilink = "<a href=\"" . htmlspecialchars( Image
::imageUrl( $name ) ) .
101 "\">" . strtr(htmlspecialchars( $name ), '_', ' ') . "</a>";
103 $nb = wfMsgExt( 'nbytes', array( 'parsemag', 'escape'),
104 $wgLang->formatNum( $s->img_size
) );
106 $desc = $sk->makeKnownLinkObj( Title
::makeTitle( NS_IMAGE
, $name ),
107 wfMsg( 'imgdesc' ) );
109 $date = $wgLang->timeanddate( $s->img_timestamp
, true );
110 $comment = $sk->commentBlock( $s->img_description
);
112 $l = "({$desc}) {$dirmark}{$ilink} . . {$dirmark}{$nb} . . {$dirmark}{$ul}".
113 " . . {$dirmark}{$date} . . {$dirmark}{$comment}<br />\n";
114 $wgOut->addHTML( $l );
117 $dbr->freeResult( $res );
118 $wgOut->addHTML( '</p>' );