Adding/updating Persian translations
[lhc/web/wiklou.git] / includes / SpecialRecentchanges.php
index bd9c853..60a04e0 100644 (file)
@@ -172,13 +172,9 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
        while( $row = $dbr->fetchObject( $res ) ){
                $rows[] = $row;
                if ( !$feedFormat ) {
-                       // User page link
-                       $title = Title::makeTitleSafe( NS_USER, $row->rc_user_text );
-                       $batch->addObj( $title );
-
-                       // User talk
-                       $title = Title::makeTitleSafe( NS_USER_TALK, $row->rc_user_text );
-                       $batch->addObj( $title );
+                       // User page and talk links
+                       $batch->add( NS_USER, $row->rc_user_text  );
+                       $batch->add( NS_USER_TALK, $row->rc_user_text  );
                }
 
        }
@@ -220,6 +216,8 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
                }
 
                // And now for the content
+               $wgOut->setSyndicated( true );
+               
                $list = ChangesList::newFromUser( $wgUser );
                
                if ( $wgAllowCategorizedRecentChanges ) {
@@ -231,6 +229,10 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
 
                $s = $list->beginRecentChangesList();
                $counter = 1;
+
+               $showWatcherCount = $wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' );
+               $watcherCache = array();
+
                foreach( $rows as $obj ){
                        if( $limit == 0) {
                                break;
@@ -249,13 +251,19 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
                                        $rc->notificationtimestamp = false;
                                }
 
-                               if ($wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' )) {
-                                       $sql3 = "SELECT COUNT(*) AS n FROM $watchlist WHERE wl_title='" . $dbr->strencode($obj->rc_title) ."' AND wl_namespace=$obj->rc_namespace" ;
-                                       $res3 = $dbr->query( $sql3, 'wfSpecialRecentChanges');
-                                       $x = $dbr->fetchObject( $res3 );
-                                       $rc->numberofWatchingusers = $x->n;
-                               } else {
-                                       $rc->numberofWatchingusers = 0;
+                               $rc->numberofWatchingusers = 0; // Default
+                               if ($showWatcherCount && $obj->rc_namespace >= 0) {
+                                       if (!isset($watcherCache[$obj->rc_namespace][$obj->rc_title])) {
+                                               $watcherCache[$obj->rc_namespace][$obj->rc_title] =
+                                                       $dbr->selectField( 'watchlist',
+                                                               'COUNT(*)',
+                                                               array(
+                                                                       'wl_namespace' => $obj->rc_namespace,
+                                                                       'wl_title' => $obj->rc_title,
+                                                               ),
+                                                               __METHOD__ . '-watchers' );
+                                       }
+                                       $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
                                }
                                $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ) );
                                --$limit;
@@ -267,6 +275,10 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
 }
 
 function rcFilterByCategories ( &$rows , $categories , $any ) {
+       if( empty( $categories ) ) {
+               return;
+       }
+       
        # Filter categories
        $cats = array () ;
        foreach ( $categories AS $cat ) {
@@ -279,7 +291,7 @@ function rcFilterByCategories ( &$rows , $categories , $any ) {
        $articles = array () ;
        $a2r = array () ;
        foreach ( $rows AS $k => $r ) {
-               $nt = Title::newFromText ( $r->rc_title , $r->rc_namespace ) ;
+               $nt = Title::makeTitle( $r->rc_title , $r->rc_namespace );
                $id = $nt->getArticleID() ;
                if ( $id == 0 ) continue ; # Page might have been deleted...
                if ( !in_array ( $id , $articles ) ) {
@@ -379,9 +391,12 @@ function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
        return true;
 }
 
+/**
+ * @todo document
+ * @param $rows Database resource with recentchanges rows
+ */
 function rcDoOutputFeed( $rows, &$feed ) {
-       $fname = 'rcDoOutputFeed';
-       wfProfileIn( $fname );
+       wfProfileIn( __METHOD__ );
 
        $feed->outHeader();
 
@@ -406,15 +421,15 @@ function rcDoOutputFeed( $rows, &$feed ) {
                $item = new FeedItem(
                        $title->getPrefixedText(),
                        rcFormatDiff( $obj ),
-                       $title->getFullURL(),
+                       $title->getFullURL( 'diff=' . $obj->rc_this_oldid . '&oldid=prev' ),
                        $obj->rc_timestamp,
-                       ($obj->rc_deleted & Revision::DELETED_USER) ? wfMsgHtml('rev-deleted-user') : $obj->rc_user_text,
+                       $obj->rc_user_text,
                        $talkpage->getFullURL()
                        );
                $feed->outItem( $item );
        }
        $feed->outFooter();
-       wfProfileOut( $fname );
+       wfProfileOut( __METHOD__ );
 }
 
 /**
@@ -617,18 +632,15 @@ function rcFormatDiff( $row ) {
        return rcFormatDiffRow( $titleObj,
                $row->rc_last_oldid, $row->rc_this_oldid,
                $timestamp,
-               ($row->rc_deleted & Revision::DELETED_COMMENT) ? wfMsgHtml('rev-deleted-comment') : $row->rc_comment,
-               ($row->rc_deleted & LogViewer::DELETED_ACTION) ? wfMsgHtml('rev-deleted-event') : $row->rc_actiontext );
+               $row->rc_comment );
 }
 
-function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment, $actiontext='' ) {
+function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment ) {
        global $wgFeedDiffCutoff, $wgContLang, $wgUser;
        $fname = 'rcFormatDiff';
        wfProfileIn( $fname );
 
        $skin = $wgUser->getSkin();
-       # log enties
-       if( $actiontext ) $comment = "$actiontext $comment";
        $completeText = '<p>' . $skin->formatComment( $comment ) . "</p>\n";
 
        //NOTE: Check permissions for anonymous users, not current user.