5 * @subpackage SpecialPage
8 require_once ( "SpecialFilelist.php" ) ;
10 function wfSpecialNewimages( $par, $specialPage ) {
11 wfSpecialFilelist ( $par , $specialPage , true ) ;
14 # _____________________________________________
15 # The rest of this file is obsolete
16 # _____________________________________________
20 require_once( 'ImageGallery.php' );
25 function OLD_wfSpecialNewimages( $par, $specialPage ) {
26 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest,
29 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
30 $dbr =& wfGetDB( DB_SLAVE
);
31 $sk = $wgUser->getSkin();
32 $shownav = !$specialPage->including();
33 $hidebots = $wgRequest->getBool('hidebots',1);
37 /** Make a list of group names which have the 'bot' flag
41 foreach ($wgGroupPermissions as $groupname=>$perms) {
42 if(array_key_exists('bot',$perms) && $perms['bot']) {
43 $botconds[]="ug_group='$groupname'";
46 $isbotmember=$dbr->makeList($botconds, LIST_OR
);
48 /** This join, in conjunction with WHERE ug_group
49 IS NULL, returns only those rows from IMAGE
50 where the uploading user is not a member of
51 a group which has the 'bot' permission set.
53 $ug = $dbr->tableName('user_groups');
54 $joinsql=" LEFT OUTER JOIN $ug ON img_user=ug_user AND ("
58 $image = $dbr->tableName('image');
60 $sql="SELECT img_timestamp from $image";
62 $sql.=$joinsql.' WHERE ug_group IS NULL';
64 $sql.=' ORDER BY img_timestamp DESC LIMIT 1';
65 $res = $dbr->query($sql, 'wfSpecialNewImages');
66 $row = $dbr->fetchRow($res);
72 $dbr->freeResult($res);
75 /** If we were clever, we'd use this to cache. */
76 $latestTimestamp = wfTimestamp( TS_MW
, $ts);
78 /** Hardcode this for now. */
81 if ( $parval = intval( $par ) )
82 if ( $parval <= $limit && $parval > 0 )
87 if ( $wpIlMatch != '' ) {
88 $nt = Title
::newFromUrl( $wpIlMatch );
90 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
91 $m = str_replace( '%', "\\%", $m );
92 $m = str_replace( '_', "\\_", $m );
93 $where[] = "LCASE(img_name) LIKE '%{$m}%'";
94 $searchpar = '&wpIlMatch=' . urlencode( $wpIlMatch );
99 if( $until = $wgRequest->getVal( 'until' ) ) {
100 $where[] = 'img_timestamp < ' . $dbr->timestamp( $until );
102 if( $from = $wgRequest->getVal( 'from' ) ) {
103 $where[] = 'img_timestamp >= ' . $dbr->timestamp( $from );
106 $sql='SELECT img_size, img_name, img_user, img_user_text,'.
107 "img_description,img_timestamp FROM $image";
111 $where[]='ug_group IS NULL';
114 $sql.=' WHERE '.$dbr->makeList($where, LIST_AND
);
116 $sql.=' ORDER BY img_timestamp '. ( $invertSort ?
'' : ' DESC' );
117 $sql.=' LIMIT '.($limit+
1);
118 $res = $dbr->query($sql, 'wfSpecialNewImages');
121 * We have to flip things around to get the last N after a certain date
124 while ( $s = $dbr->fetchObject( $res ) ) {
126 array_unshift( $images, $s );
128 array_push( $images, $s );
131 $dbr->freeResult( $res );
133 $gallery = new ImageGallery();
134 $firstTimestamp = null;
135 $lastTimestamp = null;
137 foreach( $images as $s ) {
138 if( ++
$shownImages > $limit ) {
139 # One extra just to test for whether to show a page link;
140 # don't actually show it.
144 $name = $s->img_name
;
145 $ut = $s->img_user_text
;
147 $nt = Title
::newFromText( $name, NS_IMAGE
);
148 $img = Image
::newFromTitle( $nt );
149 $ul = $sk->makeLinkObj( Title
::makeTitle( NS_USER
, $ut ), $ut );
151 $gallery->add( $img, "$ul<br />\n<i>".$wgLang->timeanddate( $s->img_timestamp
, true )."</i><br />\n" );
153 $timestamp = wfTimestamp( TS_MW
, $s->img_timestamp
);
154 if( empty( $firstTimestamp ) ) {
155 $firstTimestamp = $timestamp;
157 $lastTimestamp = $timestamp;
160 $bydate = wfMsg( 'bydate' );
161 $lt = $wgLang->formatNum( min( $shownImages, $limit ) );
163 $text = wfMsg( 'imagelisttext', "<strong>{$lt}</strong>", "<strong>{$bydate}</strong>" );
164 $wgOut->addHTML( "<p>{$text}\n</p>" );
167 $sub = wfMsg( 'ilsubmit' );
168 $titleObj = Title
::makeTitle( NS_SPECIAL
, 'Newimages' );
169 $action = $titleObj->escapeLocalURL();
171 $action.='&hidebots=0';
174 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
176 "<input type='text' size='20' name=\"wpIlMatch\" value=\"" .
177 htmlspecialchars( $wpIlMatch ) . "\" /> " .
178 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
180 $here = $wgContLang->specialPage( 'Newimages' );
186 # If we change bot visibility, this needs to be carried along.
188 $botpar='&hidebots=0';
192 $now = wfTimestampNow();
193 $date = $wgLang->timeanddate( $now );
194 $dateLink = $sk->makeKnownLinkObj( $titleObj, wfMsg( 'rclistfrom', $date ), 'from='.$now.$botpar.$searchpar );
196 $botLink = $sk->makeKnownLinkObj($titleObj, wfMsg( 'showhidebots', ($hidebots ?
wfMsg('show') : wfMsg('hide'))),'hidebots='.($hidebots ?
'0' : '1').$searchpar);
198 $prevLink = wfMsg( 'prevn', $wgLang->formatNum( $limit ) );
199 if( $firstTimestamp && $firstTimestamp != $latestTimestamp ) {
200 $prevLink = $sk->makeKnownLinkObj( $titleObj, $prevLink, 'from=' . $firstTimestamp . $botpar . $searchpar );
203 $nextLink = wfMsg( 'nextn', $wgLang->formatNum( $limit ) );
204 if( $shownImages > $limit && $lastTimestamp ) {
205 $nextLink = $sk->makeKnownLinkObj( $titleObj, $nextLink, 'until=' . $lastTimestamp.$botpar.$searchpar );
208 $prevnext = '<p>' . $botLink . ' '. wfMsg( 'viewprevnext', $prevLink, $nextLink, $dateLink ) .'</p>';
211 $wgOut->addHTML( $prevnext );
213 if( count( $images ) ) {
214 $wgOut->addHTML( $gallery->toHTML() );
216 $wgOut->addHTML( $prevnext );
218 $wgOut->addWikiText( wfMsg( 'noimages' ) );