5 * @subpackage SpecialPage
8 require_once( 'ImageGallery.php' );
13 function wfSpecialNewimages() {
14 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
16 $sort = $wgRequest->getVal( 'sort' );
17 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
18 $dbr =& wfGetDB( DB_SLAVE
);
19 $image = $dbr->tableName( 'image' );
20 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
21 "img_description,img_timestamp FROM $image";
23 $bydate = wfMsg( 'bydate' );
25 if ( !empty( $wpIlMatch ) ) {
26 $nt = Title
::newFromUrl( $wpIlMatch );
28 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
29 $m = str_replace( '%', "\\%", $m );
30 $m = str_replace( '_', "\\_", $m );
31 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
35 $sql .= ' ORDER BY img_timestamp DESC';
38 list( $limit, $offset ) = wfCheckLimits( 50 );
42 $lt = $wgLang->formatNum( "${limit}" );
43 $sql .= " LIMIT {$limit}";
45 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
47 $text = wfMsg( "imagelisttext",
48 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
49 $wgOut->addHTML( "<p>{$text}\n</p>" );
51 $sk = $wgUser->getSkin();
52 $cap = wfMsg( 'ilshowmatch' );
53 $sub = wfMsg( 'ilsubmit' );
54 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Newimages' );
55 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
57 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
59 "{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"" .
60 htmlspecialchars( $wpIlMatch ) . "\" /> " .
61 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
62 $nums = array( 50, 100, 250, 500 );
63 $here = $wgContLang->specialPage( 'Imagelist' );
67 foreach ( $nums as $num ) {
68 if ( ! $first ) { $fill .= ' | '; }
71 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
72 "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
74 $text = wfMsg( 'showlast', $fill, $bydate );
75 $wgOut->addHTML( $text."\n" );
78 $res = $dbr->query( $sql, 'wfSpecialImagelist' );
80 $gallery = new ImageGallery();
82 while ( $s = $dbr->fetchObject( $res ) ) {
84 $ut = $s->img_user_text
;
86 $nt = Title
::newFromText( $name, NS_IMAGE
);
87 $img = Image
::newFromTitle( $nt );
88 $ul = $sk->makeLink( $wgContLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
90 $gallery->add( $img, $ul.'<br /><i>'.$wgLang->timeanddate( $s->img_timestamp
, true ).'</i><br />' );
93 $wgOut->addHTML( $gallery->toHTML() );
94 $dbr->freeResult( $res );