Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

SpecialImagelist.php

Go to the documentation of this file.
00001 <?php 00002 00003 function wfSpecialImagelist() 00004 { 00005 global $wgUser, $wgOut, $wgLang, $wgRequest; 00006 00007 $sort = $wgRequest->getVal( 'sort' ); 00008 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' ); 00009 00010 $sql = "SELECT img_size,img_name,img_user,img_user_text," . 00011 "img_description,img_timestamp FROM image"; 00012 00013 $byname = wfMsg( "byname" ); 00014 $bydate = wfMsg( "bydate" ); 00015 $bysize = wfMsg( "bysize" ); 00016 00017 if ( "bysize" == $sort ) { 00018 $sql .= " ORDER BY img_size DESC"; 00019 $st = $bysize; 00020 } else if ( "byname" == $sort ) { 00021 if ( $wpIlMatch ) { 00022 $nt = Title::newFromUrl( $wpIlMatch ); 00023 $m = wfStrencode( strtolower( $nt->getDBkey() ) ); 00024 $m = str_replace( "%", "\\%", $m ); 00025 $m = str_replace( "_", "\\_", $m ); 00026 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'"; 00027 } 00028 $sql .= " ORDER BY img_name"; 00029 $st = $byname; 00030 } else { 00031 $sql .= " ORDER BY img_timestamp DESC"; 00032 $st = $bydate; 00033 } 00034 list( $limit, $offset ) = wfCheckLimits( 50 ); 00035 if ( 0 == $limit ) { 00036 $lt = wfMsg( "all" ); 00037 } else { 00038 $lt = $wgLang->formatNum( "${limit}" ); 00039 $sql .= " LIMIT {$limit}"; 00040 } 00041 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" ); 00042 00043 $text = wfMsg( "imagelisttext", 00044 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" ); 00045 $wgOut->addHTML( "<p>{$text}\n</p>" ); 00046 00047 $sk = $wgUser->getSkin(); 00048 $cap = wfMsg( "ilshowmatch" ); 00049 $sub = wfMsg( "ilsubmit" ); 00050 $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" ); 00051 $action = $titleObj->escapeLocalURL( "sort=byname&limit={$limit}" ); 00052 00053 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" . 00054 "{$action}\">" . 00055 "{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"\" /> " . 00056 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" ); 00057 $nums = array( 50, 100, 250, 500 ); 00058 $here = $wgLang->specialPage( "Imagelist" ); 00059 00060 $fill = ""; 00061 $first = true; 00062 foreach ( $nums as $num ) { 00063 if ( ! $first ) { $fill .= " | "; } 00064 $first = false; 00065 00066 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), 00067 "sort=bysize&limit={$num}" ); 00068 } 00069 $text = wfMsg( "showlast", $fill, $bysize ); 00070 $wgOut->addHTML( "<p>{$text}<br />\n" ); 00071 00072 $fill = ""; 00073 $first = true; 00074 foreach ( $nums as $num ) { 00075 if ( ! $first ) { $fill .= " | "; } 00076 $first = false; 00077 00078 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ), 00079 "sort=bydate&limit={$num}" ); 00080 } 00081 $text = wfMsg( "showlast", $fill, $bydate ); 00082 $wgOut->addHTML( "{$text}</p>\n<p>" ); 00083 00084 $res = wfQuery( $sql, DB_READ, "wfSpecialImagelist" ); 00085 while ( $s = wfFetchObject( $res ) ) { 00086 $name = $s->img_name; 00087 $ut = $s->img_user_text; 00088 if ( 0 == $s->img_user ) { $ul = $ut; } 00089 else { $ul = $sk->makeLink( $wgLang->getNsText( 00090 Namespace::getUser() ) . ":{$ut}", $ut ); } 00091 00092 $ilink = "<a href=\"" . Image::wfImageUrl( $name ) . 00093 "\">{$name}</a>"; 00094 00095 $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) ); 00096 $l = "(" . 00097 $sk->makeKnownLink( $wgLang->getNsText( 00098 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) . 00099 ") {$ilink} . . {$nb} . . {$ul} . . " . 00100 $wgLang->timeanddate( $s->img_timestamp, true ); 00101 00102 if ( "" != $s->img_description ) { 00103 $l .= " <em>({$s->img_description})</em>"; 00104 } 00105 $wgOut->addHTML( "{$l}<br />\n" ); 00106 } 00107 $wgOut->addHTML( "</p>" ); 00108 wfFreeResult( $res ); 00109 } 00110 00111 ?>

Generated on Tue Jun 29 23:40:07 2004 for Mediawiki by doxygen 1.3.7