X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FSpecialImagelist.php;h=1688fe7c61ef73336a8b3c0145d96001ea720917;hb=cd56a97356138520c706067c9e3b9ee89344583f;hp=a4e6bf5983275726ccffdabc48d9390619f168a2;hpb=4dac4d85c61f5163bfd703b6252e620f546e652f;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/SpecialImagelist.php b/includes/SpecialImagelist.php
index a4e6bf5983..1688fe7c61 100644
--- a/includes/SpecialImagelist.php
+++ b/includes/SpecialImagelist.php
@@ -1,112 +1,166 @@
getForm();
+ $body = $pager->getBody();
+ $nav = $pager->getNavigationBar();
+ $wgOut->addHTML(
+ $limit
+ . '
'
+ . $body
+ . '
'
+ . $nav );
+}
-function wfSpecialImagelist()
-{
- global $wgUser, $wgOut, $wgLang, $sort;
- global $wpIlMatch, $wpIlSubmit;
-
- $fields = array( 'wpIlMatch' );
- wfCleanFormFields( $fields );
-
- $sql = "SELECT img_size,img_name,img_user,img_user_text," .
- "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() ) );
- $m = str_replace( "%", "\\%", $m );
- $m = str_replace( "_", "\\_", $m );
- $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
+/**
+ * @addtogroup SpecialPage
+ * @addtogroup Pager
+ */
+class ImageListPager extends TablePager {
+ var $mFieldNames = null;
+ var $mMessages = array();
+ var $mQueryConds = array();
+
+ function __construct() {
+ global $wgRequest, $wgMiserMode;
+ if ( $wgRequest->getText( 'sort', 'img_date' ) == 'img_date' ) {
+ $this->mDefaultDirection = true;
+ } else {
+ $this->mDefaultDirection = false;
+ }
+ $search = $wgRequest->getText( 'ilsearch' );
+ if ( $search != '' && !$wgMiserMode ) {
+ $nt = Title::newFromUrl( $search );
+ if( $nt ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
+ $m = str_replace( "%", "\\%", $m );
+ $m = str_replace( "_", "\\_", $m );
+ $this->mQueryConds = array( "LOWER(img_name) LIKE '%{$m}%'" );
+ }
}
- $sql .= " ORDER BY img_name";
- $st = $byname;
- } else {
- $sql .= " ORDER BY img_timestamp DESC";
- $st = $bydate;
+
+ parent::__construct();
}
- list( $limit, $offset ) = wfCheckLimits( 50 );
- if ( 0 == $limit ) {
- $lt = wfMsg( "all" );
- } else {
- $lt = $wgLang->formatNum( "${limit}" );
- $sql .= " LIMIT {$limit}";
+
+ function getFieldNames() {
+ if ( !$this->mFieldNames ) {
+ $this->mFieldNames = array(
+ 'img_timestamp' => wfMsg( 'imagelist_date' ),
+ 'img_name' => wfMsg( 'imagelist_name' ),
+ 'img_user_text' => wfMsg( 'imagelist_user' ),
+ 'img_size' => wfMsg( 'imagelist_size' ),
+ 'img_description' => wfMsg( 'imagelist_description' ),
+ );
+ }
+ return $this->mFieldNames;
}
- $wgOut->addHTML( "
" . wfMsg( "imglegend" ) . "\n" ); - - $text = wfMsg( "imagelisttext", - "{$lt}", "{$st}" ); - $wgOut->addHTML( "
{$text}\n
" ); - - $sk = $wgUser->getSkin(); - $cap = wfMsg( "ilshowmatch" ); - $sub = wfMsg( "ilsubmit" ); - $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" ); - $action = $titleObj->getURL( "sort=byname&limit={$limit}", true ); - - $wgOut->addHTML( "
" ); - - $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=bysize&limit={$num}" ); + + function isFieldSortable( $field ) { + static $sortable = array( 'img_timestamp', 'img_name', 'img_size' ); + return in_array( $field, $sortable ); } - $text = wfMsg( "showlast", $fill, $bysize ); - $wgOut->addHTML( "{$text}" ); - - $res = wfQuery( $sql, DB_READ, "wfSpecialImagelist" ); - while ( $s = wfFetchObject( $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 ); } - - $ilink = "{$name}"; - - $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) ); - $l = "(" . - $sk->makeKnownLink( $wgLang->getNsText( - Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) . - ") {$ilink} . . {$nb} . . {$ul} . . " . - $wgLang->timeanddate( $s->img_timestamp, true ); - - if ( "" != $s->img_description ) { - $l .= " ({$s->img_description})"; + + function getForm() { + global $wgRequest, $wgMiserMode; + $url = $this->getTitle()->escapeLocalURL(); + $search = $wgRequest->getText( 'ilsearch' ); + $s = "
\n"; + return $s; + } + + function getTableClass() { + return 'imagelist ' . parent::getTableClass(); + } + + function getNavClass() { + return 'imagelist_nav ' . parent::getNavClass(); + } + + function getSortHeaderClass() { + return 'imagelist_sort ' . parent::getSortHeaderClass(); } - wfFreeResult( $res ); } -?> +