X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialImagelist.php;h=277ed15a3cd9ec5528f8be26283e166669b61fb0;hb=8f0f91659d5db006f61ff8c3332f83928e546f5d;hp=d7fde56ba0b86c4ae2fe644b3aea00e8ac1582bc;hpb=13c17d0cc9cc901c74469ece3c7646f830ca9623;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php index d7fde56ba0..277ed15a3c 100644 --- a/includes/SpecialImagelist.php +++ b/includes/SpecialImagelist.php @@ -1,66 +1,73 @@ - - -function wfSpecialImagelist() -{ - global $wgUser, $wgOut, $wgLang, $sort; - global $wpIlMatch, $wpIlSubmit; - $sort = $_REQUEST['sort']; - $wpIlMatch = $_REQUEST["wpIlMatch"]; - $wpIlSubmit = $_REQUEST["wpIlSubmit"]; - - $fields = array( 'wpIlMatch' ); - wfCleanFormFields( $fields ); - +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"; + "img_description,img_timestamp FROM $image"; $byname = wfMsg( "byname" ); $bydate = wfMsg( "bydate" ); $bysize = wfMsg( "bysize" ); - if ( "bysize" == $sort ) { - $sql .= " ORDER BY img_size DESC"; - $st = $bysize; - } else if ( "byname" == $sort ) { - if ( $wpIlMatch ) { - $nt = Title::newFromUrl( $wpIlMatch ); - $m = wfStrencode( strtolower( $nt->getDBkey() ) ); + 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}%'"; } + } + if ( "bysize" == $sort ) { + $sql .= " ORDER BY img_size DESC"; + $st = $bysize; + } else if ( "byname" == $sort ) { $sql .= " ORDER BY img_name"; $st = $byname; } else { + $sort = "bydate"; $sql .= " ORDER BY img_timestamp DESC"; $st = $bydate; } list( $limit, $offset ) = wfCheckLimits( 50 ); if ( 0 == $limit ) { - $lt = wfMsg( "all" ); + $lt = wfMsg( 'imagelistall' ); } else { - $lt = "${limit}"; + $lt = $wgLang->formatNum( "${limit}" ); $sql .= " LIMIT {$limit}"; } - $wgOut->addHTML( "
" . wfMsg( "imglegend" ) . "\n" ); + $wgOut->addHTML( "
" . wfMsg( "imglegend" ) . "
\n" ); $text = wfMsg( "imagelisttext", "{$lt}", "{$st}" ); - $wgOut->addHTML( "{$text}\n
" ); + $wgOut->addHTML( "
{$text}\n
" ); $sk = $wgUser->getSkin(); $cap = wfMsg( "ilshowmatch" ); $sub = wfMsg( "ilsubmit" ); - $action = wfLocalUrlE( $wgLang->specialPage( "Imagelist" ), - "sort=byname&limit={$limit}" ); + $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" ); + $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" ); $wgOut->addHTML( "" ); - + "{$cap}: " . + "" ); $nums = array( 50, 100, 250, 500 ); - $here = $wgLang->specialPage( "Imagelist" ); + $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' ); $fill = ""; $first = true; @@ -68,11 +75,23 @@ function wfSpecialImagelist() if ( ! $first ) { $fill .= " | "; } $first = false; - $fill .= $sk->makeKnownLink( $here, "{$num}", - "sort=bysize&limit={$num}" ); + $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ), + "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) ); + } + $text = wfMsg( "showlast", $fill, $byname ); + $wgOut->addHTML( "{$text}
\n" );
+
+ $fill = "";
+ $first = true;
+ foreach ( $nums as $num ) {
+ if ( ! $first ) { $fill .= " | "; }
+ $first = false;
+
+ $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
+ "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
}
$text = wfMsg( "showlast", $fill, $bysize );
- $wgOut->addHTML( "{$text}
\n" );
+ $wgOut->addHTML( "{$text}
\n" );
$fill = "";
$first = true;
@@ -80,36 +99,37 @@ function wfSpecialImagelist()
if ( ! $first ) { $fill .= " | "; }
$first = false;
- $fill .= $sk->makeKnownLink( $here, $num,
- "sort=bydate&limit={$num}" );
+ $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
+ "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
}
$text = wfMsg( "showlast", $fill, $bydate );
- $wgOut->addHTML( "{$text}
\n
" ); + $wgOut->addHTML( "{$text}
\n" );
- $res = wfQuery( $sql, DB_READ, "wfSpecialImagelist" );
- while ( $s = wfFetchObject( $res ) ) {
+ $res = $dbr->query( $sql, "wfSpecialImagelist" );
+ while ( $s = $dbr->fetchObject( $res ) ) {
$name = $s->img_name;
$ut = $s->img_user_text;
- if ( 0 == $s->img_user ) { $ul = $ut; }
- else { $ul = $sk->makeLink( $wgLang->getNsText(
- Namespace::getUser() ) . ":{$ut}", $ut ); }
+ if ( 0 == $s->img_user ) {
+ $ul = $ut;
+ } else {
+ $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
+ }
- $ilink = "{$name}";
+ $ilink = "" . htmlspecialchars( $name ) . "";
- $nb = wfMsg( "nbytes", $s->img_size );
+ $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
$l = "(" .
- $sk->makeKnownLink( $wgLang->getNsText(
- Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
+ $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
+ wfMsg( "imgdesc" ) ) .
") {$ilink} . . {$nb} . . {$ul} . . " .
$wgLang->timeanddate( $s->img_timestamp, true );
- if ( "" != $s->img_description ) {
- $l .= " ({$s->img_description})";
- }
- $wgOut->addHTML( "{$l}
\n" );
+ $l .= $sk->commentBlock( $s->img_description );
+ $wgOut->addHTML( "{$l}
\n" );
}
- wfFreeResult( $res );
+ $wgOut->addHTML( "