(Bug 19725) Do not include suppressed edits in the "View X deleted edits" message...
[lhc/web/wiklou.git] / includes / OutputPage.php
index cc7a8a6..1de0b65 100644 (file)
@@ -79,7 +79,7 @@ class OutputPage {
         * to compare its cached version with the server version. Client sends
         * headers If-Match and If-None-Match containing its locally cached ETAG value.
         *
-        * To get more information, you will have to look at HTTP1/1 protocols which
+        * To get more information, you will have to look at HTTP/1.1 protocol which
         * is properly described in RFC 2616 : http://tools.ietf.org/html/rfc2616
         */
        var $mETag = false;
@@ -190,6 +190,8 @@ class OutputPage {
        /// should be private. To include the variable {{REVISIONID}}
        var $mRevisionId = null;
 
+       var $mFileVersion = null;
+
        private $mContext;
 
        /**
@@ -1129,7 +1131,7 @@ class OutputPage {
                                }
                                $text = $wgContLang->convertHtml( $title->getText() );
                                $this->mCategories[] = $title->getText();
-                               $this->mCategoryLinks[$type][] = $this->getSkin()->link( $title, $text );
+                               $this->mCategoryLinks[$type][] = Linker::link( $title, $text );
                        }
                }
        }
@@ -1290,7 +1292,7 @@ class OutputPage {
        }
 
        /**
-        * Get the current revision ID
+        * Get the displayed revision ID
         *
         * @return Integer
         */
@@ -1298,6 +1300,28 @@ class OutputPage {
                return $this->mRevisionId;
        }
 
+       /**
+        * Set the displayed file version
+        *
+        * @param $file File|false
+        * @return Mixed: previous value
+        */
+       public function setFileVersion( $file ) {
+               if ( $file instanceof File && $file->exists() ) {
+                       $val = array( 'time' => $file->getTimestamp(), 'sha1' => $file->getSha1() );
+               }
+               return wfSetVar( $this->mFileVersion, $val );
+       }
+
+       /**
+        * Get the displayed file version
+        *
+        * @return Array|null ('time' => MW timestamp, 'sha1' => sha1)
+        */
+       public function getFileVersion() {
+               return $this->mFileVersion;
+       }
+
        /**
         * Get the templates used on this page
         *
@@ -1803,58 +1827,13 @@ class OutputPage {
         *
         * @param $code Integer: status code
         * @return String or null: message or null if $code is not in the list of
-        *         messages
+        *         messages 
+        *
+        * @deprecated since 1.19 Use HttpStatus::getMessage() instead.
         */
        public static function getStatusMessage( $code ) {
-               static $statusMessage = array(
-                       100 => 'Continue',
-                       101 => 'Switching Protocols',
-                       102 => 'Processing',
-                       200 => 'OK',
-                       201 => 'Created',
-                       202 => 'Accepted',
-                       203 => 'Non-Authoritative Information',
-                       204 => 'No Content',
-                       205 => 'Reset Content',
-                       206 => 'Partial Content',
-                       207 => 'Multi-Status',
-                       300 => 'Multiple Choices',
-                       301 => 'Moved Permanently',
-                       302 => 'Found',
-                       303 => 'See Other',
-                       304 => 'Not Modified',
-                       305 => 'Use Proxy',
-                       307 => 'Temporary Redirect',
-                       400 => 'Bad Request',
-                       401 => 'Unauthorized',
-                       402 => 'Payment Required',
-                       403 => 'Forbidden',
-                       404 => 'Not Found',
-                       405 => 'Method Not Allowed',
-                       406 => 'Not Acceptable',
-                       407 => 'Proxy Authentication Required',
-                       408 => 'Request Timeout',
-                       409 => 'Conflict',
-                       410 => 'Gone',
-                       411 => 'Length Required',
-                       412 => 'Precondition Failed',
-                       413 => 'Request Entity Too Large',
-                       414 => 'Request-URI Too Large',
-                       415 => 'Unsupported Media Type',
-                       416 => 'Request Range Not Satisfiable',
-                       417 => 'Expectation Failed',
-                       422 => 'Unprocessable Entity',
-                       423 => 'Locked',
-                       424 => 'Failed Dependency',
-                       500 => 'Internal Server Error',
-                       501 => 'Not Implemented',
-                       502 => 'Bad Gateway',
-                       503 => 'Service Unavailable',
-                       504 => 'Gateway Timeout',
-                       505 => 'HTTP Version Not Supported',
-                       507 => 'Insufficient Storage'
-               );
-               return isset( $statusMessage[$code] ) ? $statusMessage[$code] : null;
+               wfDeprecated( __METHOD__ );
+               return HttpStatus::getMessage( $code );
        }
 
        /**
@@ -1877,7 +1856,7 @@ class OutputPage {
                        $this->mRedirect = wfExpandUrl( $this->mRedirect );
                        if( $this->mRedirectCode == '301' || $this->mRedirectCode == '303' ) {
                                if( !$wgDebugRedirects ) {
-                                       $message = self::getStatusMessage( $this->mRedirectCode );
+                                       $message = HttpStatus::getMessage( $this->mRedirectCode );
                                        $response->header( "HTTP/1.1 {$this->mRedirectCode} $message" );
                                }
                                $this->mLastModified = wfTimestamp( TS_RFC2822 );
@@ -1896,7 +1875,7 @@ class OutputPage {
                        wfProfileOut( __METHOD__ );
                        return;
                } elseif ( $this->mStatusCode ) {
-                       $message = self::getStatusMessage( $this->mStatusCode );
+                       $message = HttpStatus::getMessage( $this->mStatusCode );
                        if ( $message ) {
                                $response->header( 'HTTP/1.1 ' . $this->mStatusCode . ' ' . $message );
                        }
@@ -1919,7 +1898,7 @@ class OutputPage {
                } else {
                        $this->addDefaultModules();
 
-                       $sk = $this->getSkin( $this->getTitle() );
+                       $sk = $this->getSkin();
 
                        // Hook that allows last minute changes to the output page, e.g.
                        // adding of CSS or Javascript by extensions.
@@ -2035,7 +2014,7 @@ class OutputPage {
                $this->setArticleRelated( false );
 
                $loginTitle = SpecialPage::getTitleFor( 'Userlogin' );
-               $loginLink = $this->getSkin()->link(
+               $loginLink = Linker::link(
                        $loginTitle,
                        wfMsgHtml( 'loginreqlink' ),
                        array(),
@@ -2125,7 +2104,7 @@ class OutputPage {
                        if( $source ) {
                                $this->setPageTitle( wfMsg( 'viewsource' ) );
                                $this->setSubtitle(
-                                       wfMsg( 'viewsourcefor', $this->getSkin()->linkKnown( $this->getTitle() ) )
+                                       wfMsg( 'viewsourcefor', Linker::linkKnown( $this->getTitle() ) )
                                );
                        } else {
                                $this->setPageTitle( wfMsg( 'badaccess' ) );
@@ -2150,10 +2129,10 @@ class OutputPage {
                        $this->addHTML( Html::element( 'textarea', $params, $source ) );
 
                        // Show templates used by this article
-                       $skin = $this->getSkin();
                        $article = new Article( $this->getTitle() );
+                       $templates = Linker::formatTemplates( $article->getUsedTemplates() );
                        $this->addHTML( "<div class='templatesUsed'>
-{$skin->formatTemplates( $article->getUsedTemplates() )}
+$templates
 </div>
 " );
                }
@@ -2234,7 +2213,7 @@ class OutputPage {
                $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL() ) );
                $link = wfMsgHtml(
                        'returnto',
-                       $this->getSkin()->link( $title, $text, array(), $query )
+                       Linker::link( $title, $text, array(), $query )
                );
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
        }
@@ -2278,15 +2257,14 @@ class OutputPage {
         * @return String: The doctype, opening <html>, and head element.
         */
        public function headElement( Skin $sk, $includeStyle = true ) {
-               global $wgUseTrackbacks;
+               global $wgUseTrackbacks, $wgLang;
 
                if ( $sk->commonPrintStylesheet() ) {
                        $this->addModuleStyles( 'mediawiki.legacy.wikiprintable' );
                }
                $sk->setupUserCss( $this );
 
-               $lang = wfUILang();
-               $ret = Html::htmlHeader( array( 'lang' => $lang->getCode(), 'dir' => $lang->getDir() ) );
+               $ret = Html::htmlHeader( array( 'lang' => $wgLang->getCode(), 'dir' => $wgLang->getDir() ) );
 
                if ( $this->getHTMLTitle() == '' ) {
                        $this->setHTMLTitle( wfMsg( 'pagetitle', $this->getPageTitle() ) );
@@ -2332,9 +2310,11 @@ class OutputPage {
                                Xml::escapeJsString( $editUrl ) . "'";
                }
 
-               # Class bloat
-               $dir = wfUILang()->getDir();
-               $bodyAttrs['class'] = "mediawiki $dir";
+               # Classes for LTR/RTL directionality support
+               global $wgLang, $wgContLang;
+               $userdir = $wgLang->getDir();
+               $sitedir = $wgContLang->getDir();
+               $bodyAttrs['class'] = "mediawiki $userdir sitedir-$sitedir";
 
                if ( $this->getContext()->getLang()->capitalizeAllNouns() ) {
                        # A <body> class is probably not the best way to do this . . .
@@ -2359,7 +2339,12 @@ class OutputPage {
                        $wgUseAjax, $wgAjaxWatch, $wgEnableMWSuggest;
 
                // Add base resources
-               $this->addModules( array( 'mediawiki.user', 'mediawiki.util', 'mediawiki.action.view.tablesorting' ) );
+               $this->addModules( array(
+                       'mediawiki.user',
+                       'mediawiki.util',
+                       'mediawiki.page.startup',
+                       'mediawiki.page.ready',
+               ) );
                if ( $wgIncludeLegacyJavaScript ){
                        $this->addModules( 'mediawiki.legacy.wikibits' );
                }
@@ -2689,7 +2674,7 @@ class OutputPage {
                        $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $this->getUser() );
                }
                if ( $title->isMainPage() ) {
-                       $vars['wgIsMainPage'] = $title->isMainPage();
+                       $vars['wgIsMainPage'] = true;
                }
 
                // Allow extensions to add their custom variables to the global JS variables
@@ -3036,8 +3021,8 @@ class OutputPage {
         */
        protected function styleLink( $style, $options ) {
                if( isset( $options['dir'] ) ) {
-                       $siteDir = wfUILang()->getDir();
-                       if( $siteDir != $options['dir'] ) {
+                       global $wgLang;
+                       if( $wgLang->getDir() != $options['dir'] ) {
                                return '';
                        }
                }