Migrate doubleredirect and brokenredirect subpages from SpecialMaintenance.php to...
[lhc/web/wiklou.git] / includes / SpecialUnusedimages.php
index fb94bcc..48961cf 100644 (file)
@@ -1,17 +1,17 @@
 <?php
 
-function wfSpecialUnusedimages()
-{
+function wfSpecialUnusedimages() {
        global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $limit, $offset; # From query string
        $fname = "wfSpecialUnusedimages";
 
        list( $limit, $offset ) = wfCheckLimits();
+       $dbr =& wfGetDB( DB_SLAVE );
+       extract( $dbr->tableNames( 'image','imagelinks' ) );
 
        $sql = "SELECT img_name,img_user,img_user_text,img_timestamp,img_description " .
-         "FROM image LEFT JOIN imagelinks ON img_name=il_to WHERE il_to IS NULL " .
-         "ORDER BY img_timestamp LIMIT {$offset}, {$limit}";
-       $res = wfQuery( $sql, DB_READ, $fname );
+         "FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL " .
+         "ORDER BY img_timestamp ".$dbr->limitResult($limit,$offset);
+       $res = $dbr->query( $sql, $fname );
 
        $sk = $wgUser->getSkin();
 
@@ -21,14 +21,14 @@ function wfSpecialUnusedimages()
 
        $sl = wfViewPrevNext( $offset, $limit,
          $wgLang->specialPage( "Unusedimages" ) );
-       $wgOut->addHTML( "<br>{$sl}\n" );
+       $wgOut->addHTML( "<br />{$sl}</p>\n" );
 
        $ins = $wgLang->getNsText ( 6 ) ;
-       $s = "<ol start=" . ( $offset + 1 ) . ">";
-       while ( $obj = wfFetchObject( $res ) ) {
+       $s = "<ol start='" . ( $offset + 1 ) . "'>";
+       while ( $obj = $dbr->fetchObject( $res ) ) {
                $name = $obj->img_name;
                $dlink = $sk->makeKnownLink( "{$ins}:{$name}", wfMsg( "imgdesc" ) );
-               $ilink = "<a href=\"" . wfImageUrl( $name ) . "\">{$name}</a>";
+               $ilink = "<a href=\"" . Image::wfImageUrl( $name ) . "\">{$name}</a>";
 
                $d = $wgLang->timeanddate( $obj->img_timestamp, true );
                $u = $obj->img_user;
@@ -43,10 +43,10 @@ function wfSpecialUnusedimages()
                if ( "" != $c && "*" != $c ) { $s .= " <em>({$c})</em>"; }
                $s .= "</li>\n";
        }
-       wfFreeResult( $res );
-       $s .= "</ol>";
+       $dbr->freeResult( $res );
+       $s .= "</ol>\n\n";
        $wgOut->addHTML( $s );
-       $wgOut->addHTML( "<p>{$sl}\n" );
+       $wgOut->addHTML( "<p>{$sl}</p>\n" );
 }
 
 ?>