Introducing $wgFeed variable. Allows tuning sydication feeds off, when desired.
[lhc/web/wiklou.git] / includes / PageHistory.php
index d81e7ff..2cd56f9 100644 (file)
@@ -67,6 +67,7 @@ class PageHistory {
                $wgOut->setArticleRelated( true );
                $wgOut->setRobotpolicy( 'noindex,nofollow' );
                $wgOut->setSyndicated( true );
+               $wgOut->setFeedAppendQuery( 'action=history' );
 
                $logPage = SpecialPage::getTitleFor( 'Log' );
                $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() );
@@ -82,7 +83,7 @@ class PageHistory {
                 * Fail if article doesn't exist.
                 */
                if( !$this->mTitle->exists() ) {
-                       $wgOut->addWikiText( wfMsg( 'nohistory' ) );
+                       $wgOut->addWikiMsg( 'nohistory' );
                        wfProfileOut( $fname );
                        return;
                }
@@ -164,16 +165,17 @@ class PageHistory {
         */
        function submitButton( $bits = array() ) {
                # Disable submit button if history has 1 revision only
-               if ( $this->linesonpage == 1 ) {
-                       $bits = $bits + array( 'disabled' => 'disabled' );
-               }
-               return Xml::submitButton( wfMsg( 'compareselectedversions' ),
+               if ( $this->linesonpage > 1 ) {
+                       return Xml::submitButton( wfMsg( 'compareselectedversions' ),
                                $bits + array(
                                        'class'     => 'historysubmit',
                                        'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
                                        'title'     => wfMsg( 'tooltip-compareselectedversions' ),
                                        )
                                );
+               } else {
+                       return '';
+               }
        }
 
        /**
@@ -260,18 +262,22 @@ class PageHistory {
                $tools = array();
                
                if ( !is_null( $next ) && is_object( $next ) ) {
-                       if( $wgUser->isAllowed( 'rollback' ) && $latest ) {
+                       if( !$this->mTitle->getUserPermissionsErrors( 'rollback', $wgUser )
+                       && !$this->mTitle->getUserPermissionsErrors( 'edit', $wgUser )
+                       && $latest ) {
                                $tools[] = '<span class="mw-rollback-link">'
                                        . $this->mSkin->buildRollbackLink( $rev )
                                        . '</span>';
                        }
 
-                       $undolink = $this->mSkin->makeKnownLinkObj(
-                               $this->mTitle,
-                               wfMsgHtml( 'editundo' ),
-                               'action=edit&undoafter=' . $next->rev_id . '&undo=' . $rev->getId()
-                       );
-                       $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
+                       if( $this->mTitle->quickUserCan( 'edit' ) ) {
+                               $undolink = $this->mSkin->makeKnownLinkObj(
+                                       $this->mTitle,
+                                       wfMsgHtml( 'editundo' ),
+                                       'action=edit&undoafter=' . $next->rev_id . '&undo=' . $rev->getId()
+                               );
+                               $tools[] = "<span class=\"mw-history-undo\">{$undolink}</span>";
+                       }
                }
                
                if( $tools ) {
@@ -477,10 +483,17 @@ class PageHistory {
        function feed( $type ) {
                require_once 'SpecialRecentchanges.php';
                
-               global $wgFeedClasses;
+               global $wgFeed, $wgFeedClasses;
+               
+               if ( !$wgFeed ) {
+                       global $wgOut;
+                       $wgOut->addWikiMsg( 'feed-unavailable' );
+                       return;
+               }
+               
                if( !isset( $wgFeedClasses[$type] ) ) {
                        global $wgOut;
-                       $wgOut->addWikiText( wfMsg( 'feed-invalid' ) );
+                       $wgOut->addWikiMsg( 'feed-invalid' );
                        return;
                }