includes/actions/: Use Config instead of globals
[lhc/web/wiklou.git] / includes / actions / RawAction.php
index b753407..cd4e4ba 100644 (file)
@@ -5,7 +5,7 @@
  * Copyright © 2004 Gabriel Wicke <wicke@wikidev.net>
  * http://wikidev.net/
  *
- * Based on HistoryPage and SpecialExport
+ * Based on HistoryAction and SpecialExport
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -48,10 +48,9 @@ class RawAction extends FormlessAction {
        }
 
        function onView() {
-               global $wgSquidMaxage, $wgForcedRawSMaxage;
-
                $this->getOutput()->disable();
                $request = $this->getRequest();
+               $config = $this->context->getConfig();
 
                if ( !$request->checkUrlExtension() ) {
                        return;
@@ -69,7 +68,7 @@ class RawAction extends FormlessAction {
                if ( $gen == 'css' || $gen == 'js' ) {
                        $this->mGen = $gen;
                        if ( $smaxage === null ) {
-                               $smaxage = $wgSquidMaxage;
+                               $smaxage = $config->get( 'SquidMaxage' );
                        }
                } else {
                        $this->mGen = false;
@@ -81,13 +80,13 @@ class RawAction extends FormlessAction {
                # Note: If using a canonical url for userpage css/js, we send an HTCP purge.
                if ( $smaxage === null ) {
                        if ( $contentType == 'text/css' || $contentType == 'text/javascript' ) {
-                               $smaxage = intval( $wgForcedRawSMaxage );
+                               $smaxage = intval( $config->get( 'ForcedRawSMaxage' ) );
                        } else {
                                $smaxage = 0;
                        }
                }
 
-               $maxage = $request->getInt( 'maxage', $wgSquidMaxage );
+               $maxage = $request->getInt( 'maxage', $config->get( 'SquidMaxage' ) );
 
                $response = $request->response();
 
@@ -125,7 +124,7 @@ class RawAction extends FormlessAction {
         * Get the text that should be returned, or false if the page or revision
         * was not found.
         *
-        * @return String|Bool
+        * @return string|bool
         */
        public function getRawText() {
                global $wgParser;
@@ -198,17 +197,18 @@ class RawAction extends FormlessAction {
        /**
         * Get the ID of the revision that should used to get the text.
         *
-        * @return Integer
+        * @return int
         */
        public function getOldId() {
                $oldid = $this->getRequest()->getInt( 'oldid' );
                switch ( $this->getRequest()->getText( 'direction' ) ) {
                        case 'next':
                                # output next revision, or nothing if there isn't one
+                               $nextid = 0;
                                if ( $oldid ) {
-                                       $oldid = $this->getTitle()->getNextRevisionID( $oldid );
+                                       $nextid = $this->getTitle()->getNextRevisionID( $oldid );
                                }
-                               $oldid = $oldid ? $oldid : -1;
+                               $oldid = $nextid ?: -1;
                                break;
                        case 'prev':
                                # output previous revision, or nothing if there isn't one
@@ -216,8 +216,8 @@ class RawAction extends FormlessAction {
                                        # get the current revision so we can get the penultimate one
                                        $oldid = $this->page->getLatest();
                                }
-                               $prev = $this->getTitle()->getPreviousRevisionID( $oldid );
-                               $oldid = $prev ? $prev : -1;
+                               $previd = $this->getTitle()->getPreviousRevisionID( $oldid );
+                               $oldid = $previd ?: -1;
                                break;
                        case 'cur':
                                $oldid = 0;
@@ -230,7 +230,7 @@ class RawAction extends FormlessAction {
        /**
         * Get the content type to use for the response
         *
-        * @return String
+        * @return string
         */
        public function getContentType() {
                $ctype = $this->getRequest()->getVal( 'ctype' );
@@ -252,40 +252,3 @@ class RawAction extends FormlessAction {
                return $ctype;
        }
 }
-
-/**
- * Backward compatibility for extensions
- *
- * @deprecated in 1.19
- */
-class RawPage extends RawAction {
-       public $mOldId;
-
-       /**
-        * @param Page $page
-        * @param WebRequest|bool $request The WebRequest (default: false).
-        */
-       function __construct( Page $page, $request = false ) {
-               wfDeprecated( __CLASS__, '1.19' );
-               parent::__construct( $page );
-
-               if ( $request !== false ) {
-                       $context = new DerivativeContext( $this->getContext() );
-                       $context->setRequest( $request );
-                       $this->context = $context;
-               }
-       }
-
-       public function view() {
-               $this->onView();
-       }
-
-       public function getOldId() {
-               # Some extensions like to set $mOldId
-               if ( $this->mOldId !== null ) {
-                       return $this->mOldId;
-               }
-
-               return parent::getOldId();
-       }
-}