New Special page: Visual list of newly uploaded images Special:Newimages
This commit is contained in:
parent
de5516294c
commit
3d946b5c22
5 changed files with 198 additions and 3 deletions
|
|
@ -71,6 +71,11 @@ class Image
|
|||
return $this->name;
|
||||
}
|
||||
|
||||
function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
function getURL()
|
||||
{
|
||||
return $this->url;
|
||||
|
|
@ -117,7 +122,6 @@ class Image
|
|||
return wfUrlencode( $url );
|
||||
}
|
||||
|
||||
|
||||
function exists()
|
||||
{
|
||||
return $this->fileExists;
|
||||
|
|
@ -137,6 +141,24 @@ class Image
|
|||
return $width."px-".$this->name;
|
||||
}
|
||||
|
||||
function createThumb( $width, $height=-1 ) {
|
||||
if ( $height == -1 ) {
|
||||
return $this->renderThumb( $width );
|
||||
}
|
||||
if ( $width < $this->width ) {
|
||||
$thumbheight = $this->height * $width / $this->width;
|
||||
$thumbwidth = $width;
|
||||
} else {
|
||||
$thumbheight = $this->height;
|
||||
$thumbwidth = $this->width;
|
||||
}
|
||||
if ( $thumbheight > $height ) {
|
||||
$thumbwidth = $thumbwidth * $height / $thumbheight;
|
||||
$thumbheight = $height;
|
||||
}
|
||||
return $this->renderThumb( $thumbwidth );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a thumbnail of the image having the specified width.
|
||||
* The thumbnail will not be created if the width is larger than the
|
||||
|
|
@ -145,7 +167,7 @@ class Image
|
|||
* file does not exist OR if it is older than the image.
|
||||
* Returns the URL.
|
||||
*/
|
||||
function createThumb( $width ) {
|
||||
function /* private */ renderThumb( $width ) {
|
||||
global $wgUploadDirectory;
|
||||
global $wgImageMagickConvertCommand;
|
||||
global $wgUseImageMagick;
|
||||
|
|
|
|||
72
includes/ImageGallery.php
Normal file
72
includes/ImageGallery.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
|
||||
<?php
|
||||
/**
|
||||
* @package MediaWiki
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is not a valid entry point, perform no further processing unless MEDIAWIKI is defined
|
||||
*/
|
||||
if( defined( 'MEDIAWIKI' ) ) {
|
||||
|
||||
|
||||
/**
|
||||
* Image gallery
|
||||
* @package MediaWiki
|
||||
*/
|
||||
class ImageGallery
|
||||
{
|
||||
var $mImages;
|
||||
|
||||
function ImageGallery( ) {
|
||||
$this->mImages=array();
|
||||
}
|
||||
|
||||
function add( $image, $text='' ) {
|
||||
$this->mImages[] = array( &$image, $text );
|
||||
}
|
||||
|
||||
function toHTML() {
|
||||
global $wgLang, $wgUser;
|
||||
|
||||
$sk = $wgUser->getSkin();
|
||||
|
||||
$s = '<table style="border:solid 1px #DDDDDD; cellspacing:0; cellpadding:0; margin:1em;">';
|
||||
$i = 0;
|
||||
foreach ( $this->mImages as $pair ) {
|
||||
$img =& $pair[0];
|
||||
$text = $pair[1];
|
||||
|
||||
$name = $img->getName();
|
||||
$nt = $img->getTitle();
|
||||
|
||||
//TODO
|
||||
//$ul = $sk->makeLink( $wgLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
|
||||
|
||||
$ilink = '<a href="' . $img->getURL() . '">' . $nt->getText() . '</a>';
|
||||
$nb = wfMsg( "nbytes", $wgLang->formatNum( $img->getSize() ) );
|
||||
|
||||
$s .= ($i%4==0) ? '<tr>' : '';
|
||||
$s .= '<td valign="top" width="150px" style="background-color:#F0F0F0;">' .
|
||||
'<table width="100%" height="150px">'.
|
||||
'<tr><td align="center" valign="center" style="background-color:#F8F8F8;border:solid 1px #888888;">' .
|
||||
'<img src="'.$img->createThumb(120,120).'" alt=""></td></tr></table> ' .
|
||||
'(' . $sk->makeKnownLinkObj( $nt, wfMsg( "imgdesc" ) ) .
|
||||
") {$ilink}<br />{$text}{$nb}<br />" ;
|
||||
|
||||
$s .= '</td>' . (($i%4==3) ? '</tr>' : '');
|
||||
|
||||
$i++;
|
||||
}
|
||||
$s .= '</table>';
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
||||
} //class
|
||||
|
||||
|
||||
|
||||
|
||||
} // defined( 'MEDIAWIKI' )
|
||||
?>
|
||||
97
includes/SpecialNewimages.php
Normal file
97
includes/SpecialNewimages.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @package MediaWiki
|
||||
* @subpackage SpecialPage
|
||||
*/
|
||||
|
||||
require_once( 'ImageGallery.php' );
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function wfSpecialNewimages() {
|
||||
global $wgUser, $wgOut, $wgLang, $wgRequest;
|
||||
|
||||
$sort = $wgRequest->getVal( 'sort' );
|
||||
$wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
|
||||
$dbr =& wfGetDB( DB_SLAVE );
|
||||
$image = $dbr->tableName( 'image' );
|
||||
$sql = "SELECT img_size,img_name,img_user,img_user_text," .
|
||||
"img_description,img_timestamp FROM $image";
|
||||
|
||||
$bydate = wfMsg( "bydate" );
|
||||
|
||||
if ( !empty( $wpIlMatch ) ) {
|
||||
$nt = Title::newFromUrl( $wpIlMatch );
|
||||
if($nt ) {
|
||||
$m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
|
||||
$m = str_replace( "%", "\\%", $m );
|
||||
$m = str_replace( "_", "\\_", $m );
|
||||
$sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
|
||||
}
|
||||
}
|
||||
$sort = "bydate";
|
||||
$sql .= " ORDER BY img_timestamp DESC";
|
||||
$st = $bydate;
|
||||
|
||||
list( $limit, $offset ) = wfCheckLimits( 50 );
|
||||
if ( 0 == $limit ) {
|
||||
$lt = wfMsg( "all" );
|
||||
} else {
|
||||
$lt = $wgLang->formatNum( "${limit}" );
|
||||
$sql .= " LIMIT {$limit}";
|
||||
}
|
||||
$wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
|
||||
|
||||
$text = wfMsg( "imagelisttext",
|
||||
"<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
|
||||
$wgOut->addHTML( "<p>{$text}\n</p>" );
|
||||
|
||||
$sk = $wgUser->getSkin();
|
||||
$cap = wfMsg( "ilshowmatch" );
|
||||
$sub = wfMsg( "ilsubmit" );
|
||||
$titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" );
|
||||
$action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
|
||||
|
||||
$wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
|
||||
"{$action}\">" .
|
||||
"{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"" .
|
||||
htmlspecialchars( $wpIlMatch ) . "\" /> " .
|
||||
"<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
|
||||
$nums = array( 50, 100, 250, 500 );
|
||||
$here = $wgLang->specialPage( "Imagelist" );
|
||||
|
||||
$fill = "";
|
||||
$first = true;
|
||||
foreach ( $nums as $num ) {
|
||||
if ( ! $first ) { $fill .= " | "; }
|
||||
$first = false;
|
||||
|
||||
$fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
|
||||
"sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
|
||||
}
|
||||
$text = wfMsg( "showlast", $fill, $bydate );
|
||||
$wgOut->addHTML( "{$text}</p>\n" );
|
||||
|
||||
$i=0;
|
||||
$res = $dbr->query( $sql, "wfSpecialImagelist" );
|
||||
|
||||
$gallery = new ImageGallery();
|
||||
|
||||
while ( $s = $dbr->fetchObject( $res ) ) {
|
||||
$name = $s->img_name;
|
||||
$ut = $s->img_user_text;
|
||||
|
||||
$nt = Title::newFromText( $name, NS_IMAGE );
|
||||
$img = Image::newFromTitle( $nt );
|
||||
$ul = $sk->makeLink( $wgLang->getNsText( Namespace::getUser() ) . ":{$ut}", $ut );
|
||||
|
||||
$gallery->add( $img, $ul.'<br /><i>'.$wgLang->timeanddate( $s->img_timestamp, true ).'</i><br />' );
|
||||
$i++;
|
||||
}
|
||||
$wgOut->addHTML( $gallery->toHTML() );
|
||||
$dbr->freeResult( $res );
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -34,6 +34,7 @@ $wgSpecialPages = array(
|
|||
"Recentchanges" => new SpecialPage( "Recentchanges" ),
|
||||
"Upload" => new SpecialPage( "Upload" ),
|
||||
"Imagelist" => new SpecialPage( "Imagelist" ),
|
||||
"Newimages" => new SpecialPage( "Newimages" ),
|
||||
"Listusers" => new SpecialPage( "Listusers" ),
|
||||
"Listadmins" => new SpecialPage( "Listadmins" ),
|
||||
"Statistics" => new SpecialPage( "Statistics" ),
|
||||
|
|
@ -81,7 +82,8 @@ $wgSpecialPages = array_merge($wgSpecialPages, array (
|
|||
# "Import" => new SpecialPage( "Import", "sysop" ),
|
||||
|
||||
"Lockdb" => new SpecialPage( "Lockdb", "developer" ),
|
||||
"Unlockdb" => new SpecialPage( "Unlockdb", "developer" )
|
||||
"Unlockdb" => new SpecialPage( "Unlockdb", "developer" ),
|
||||
// "Sitesettings" => new SpecialPage( "Sitesettings" )
|
||||
));
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1539,6 +1539,8 @@ ta[\'ca-nstab-category\'] = new Array(\'c\',\'View the category page\');
|
|||
'imagemaxsize' => 'Limit images on image description pages to: ',
|
||||
'showbigimage' => 'Download high resolution version ($1x$2, $3 KB)',
|
||||
|
||||
'newimages' => 'New images gallery',
|
||||
|
||||
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue