use of $wgRequest
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
index fa86e3a..afe39ce 100644 (file)
@@ -1,16 +1,15 @@
-<?
+<?php
 include_once( "SpecialRecentchanges.php" );
 
 function wfSpecialRecentchangeslinked( $par = NULL )
 {
-       global $wgUser, $wgOut, $wgLang, $wgTitle;
-       global $days, $target, $hideminor; # From query string
-       $days      = $_REQUEST["days"];
-       $hideminor = $_REQUEST["hideminor"];
-       $from      = $_REQUEST["from"];
-
+       global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest;
        $fname = "wfSpecialRecentchangeslinked";
 
+       $days = $wgRequest->getInt( 'days' );
+       $target = $wgRequest->getText( 'target' );
+       $hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
+       
        $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
        $sk = $wgUser->getSkin();
 
@@ -22,6 +21,12 @@ function wfSpecialRecentchangeslinked( $par = NULL )
                return;
        }
        $nt = Title::newFromURL( $target );
+       if( !$nt ) {
+               $wgOut->errorpage( "notargettitle", "notargettext" );
+               return;
+       }
+       $id = $nt->getArticleId();
+       
        $wgOut->setSubtitle( wfMsg( "rclsub", $nt->getPrefixedText() ) );
 
        if ( ! $days ) {
@@ -32,9 +37,7 @@ function wfSpecialRecentchangeslinked( $par = NULL )
        list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
        $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
 
-       if ( ! isset( $hideminor ) ) {
-               $hideminor = $wgUser->getOption( "hideminor" );
-       }
+       $hideminor = ($hideminor ? 1 : 0);
        if ( $hideminor ) {
                $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
                  WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
@@ -50,16 +53,17 @@ function wfSpecialRecentchangeslinked( $par = NULL )
 
        $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
          "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
-         "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
-      wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
-         "ORDER BY inverse_timestamp LIMIT {$limit}";
+         "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
+      "GROUP BY cur_id ORDER BY inverse_timestamp LIMIT {$limit}";
        $res = wfQuery( $sql, DB_READ, $fname );
 
        $note = wfMsg( "rcnote", $limit, $days );
        $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
 
-       $tu = "target=" . $nt->getPrefixedURL();
-       $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked", $tu );
+       $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
+                                 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
+                                 false, $mlink );
+
        $wgOut->addHTML( "{$note}\n" );
 
        $s = $sk->beginRecentChangesList();
@@ -70,16 +74,8 @@ function wfSpecialRecentchangeslinked( $par = NULL )
                $obj = wfFetchObject( $res );
                --$count;
 
-               $ts = $obj->cur_timestamp;
-               $u = $obj->cur_user;
-               $ut = $obj->cur_user_text;
-               $ns = $obj->cur_namespace;
-               $ttl = $obj->cur_title;
-               $com = $obj->cur_comment;
-               $me = ( $obj->cur_minor_edit > 0 );
-               $new = ( $obj->cur_is_new > 0 );
-
-               $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
+               $rc = RecentChange::newFromCurRow( $obj );
+               $s .= $sk->recentChangesLine( $rc );
                --$limit;
        }
        $s .= $sk->endRecentChangesList();