Merge "Surround edit notices with appropriate classes"
[lhc/web/wiklou.git] / includes / OutputPage.php
index fb2d6f4..4e14b7b 100644 (file)
@@ -247,8 +247,9 @@ class OutputPage extends ContextSource {
        protected $mSquidMaxage = 0;
 
        /**
-        * @var bool
-        * @todo Document
+        * @var bool Controls if anti-clickjacking / frame-breaking headers will
+        * be sent. This should be done for pages where edit actions are possible.
+        * Setters: $this->preventClickjacking() and $this->allowClickjacking().
         */
        protected $mPreventClickjacking = true;
 
@@ -786,7 +787,7 @@ class OutputPage extends ContextSource {
                        // bug 44570: the core page itself may not change, but resources might
                        $modifiedTimes['sepoch'] = wfTimestamp( TS_MW, time() - $config->get( 'SquidMaxage' ) );
                }
-               wfRunHooks( 'OutputPageCheckLastModified', array( &$modifiedTimes ) );
+               Hooks::run( 'OutputPageCheckLastModified', array( &$modifiedTimes ) );
 
                $maxModified = max( $modifiedTimes );
                $this->mLastModified = wfTimestamp( TS_RFC2822, $maxModified );
@@ -1033,17 +1034,29 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Add a subtitle containing a backlink to a page
+        * Build message object for a subtitle containing a backlink to a page
         *
         * @param Title $title Title to link to
         * @param array $query Array of additional parameters to include in the link
+        * @return Message
+        * @since 1.25
         */
-       public function addBacklinkSubtitle( Title $title, $query = array() ) {
+       public static function buildBacklinkSubtitle( Title $title, $query = array() ) {
                if ( $title->isRedirect() ) {
                        $query['redirect'] = 'no';
                }
-               $this->addSubtitle( $this->msg( 'backlinksubtitle' )
-                       ->rawParams( Linker::link( $title, null, array(), $query ) ) );
+               return wfMessage( 'backlinksubtitle' )
+                       ->rawParams( Linker::link( $title, null, array(), $query ) );
+       }
+
+       /**
+        * Add a subtitle containing a backlink to a page
+        *
+        * @param Title $title Title to link to
+        * @param array $query Array of additional parameters to include in the link
+        */
+       public function addBacklinkSubtitle( Title $title, $query = array() ) {
+               $this->addSubtitle( self::buildBacklinkSubtitle( $title, $query ) );
        }
 
        /**
@@ -1063,7 +1076,7 @@ class OutputPage extends ContextSource {
        }
 
        /**
-        * Set the page as printable, i.e. it'll be displayed with with all
+        * Set the page as printable, i.e. it'll be displayed with all
         * print styles included
         */
        public function setPrintable() {
@@ -1313,7 +1326,7 @@ class OutputPage extends ContextSource {
                }
 
                # Add the remaining categories to the skin
-               if ( wfRunHooks(
+               if ( Hooks::run(
                        'OutputPageMakeCategoryLinks',
                        array( &$this, $categories, &$this->mCategoryLinks ) )
                ) {
@@ -1614,6 +1627,7 @@ class OutputPage extends ContextSource {
         * @param string $text
         * @param bool $linestart Is this the start of a line?
         * @param bool $interface Is this text in the user interface language?
+        * @throws MWException
         */
        public function addWikiText( $text, $linestart = true, $interface = true ) {
                $title = $this->getTitle(); // Work around E_STRICT
@@ -1671,8 +1685,6 @@ class OutputPage extends ContextSource {
        ) {
                global $wgParser;
 
-               wfProfileIn( __METHOD__ );
-
                $popts = $this->parserOptions();
                $oldTidy = $popts->setTidy( $tidy );
                $popts->setInterfaceMessage( (bool)$interface );
@@ -1686,7 +1698,6 @@ class OutputPage extends ContextSource {
 
                $this->addParserOutput( $parserOutput );
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -1753,8 +1764,8 @@ class OutputPage extends ContextSource {
                // Link flags are ignored for now, but may in the future be
                // used to mark individual language links.
                $linkFlags = array();
-               wfRunHooks( 'LanguageLinks', array( $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ) );
-               wfRunHooks( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
+               Hooks::run( 'LanguageLinks', array( $this->getTitle(), &$this->mLanguageLinks, &$linkFlags ) );
+               Hooks::run( 'OutputPageParserOutput', array( &$this, $parserOutput ) );
        }
 
        /**
@@ -1783,7 +1794,7 @@ class OutputPage extends ContextSource {
         */
        public function addParserOutputText( $parserOutput ) {
                $text = $parserOutput->getText();
-               wfRunHooks( 'OutputPageBeforeHTML', array( &$this, &$text ) );
+               Hooks::run( 'OutputPageBeforeHTML', array( &$this, &$text ) );
                $this->addHTML( $text );
        }
 
@@ -1908,7 +1919,7 @@ class OutputPage extends ContextSource {
                                ),
                                $config->get( 'CacheVaryCookies' )
                        );
-                       wfRunHooks( 'GetCacheVaryCookies', array( $this, &$cookies ) );
+                       Hooks::run( 'GetCacheVaryCookies', array( $this, &$cookies ) );
                }
                return $cookies;
        }
@@ -2159,8 +2170,6 @@ class OutputPage extends ContextSource {
                        return;
                }
 
-               wfProfileIn( __METHOD__ );
-
                $response = $this->getRequest()->response();
                $config = $this->getConfig();
 
@@ -2171,7 +2180,7 @@ class OutputPage extends ContextSource {
                        $redirect = $this->mRedirect;
                        $code = $this->mRedirectCode;
 
-                       if ( wfRunHooks( "BeforePageRedirect", array( $this, &$redirect, &$code ) ) ) {
+                       if ( Hooks::run( "BeforePageRedirect", array( $this, &$redirect, &$code ) ) ) {
                                if ( $code == '301' || $code == '303' ) {
                                        if ( !$config->get( 'DebugRedirects' ) ) {
                                                $message = HttpStatus::getMessage( $code );
@@ -2195,7 +2204,6 @@ class OutputPage extends ContextSource {
                                }
                        }
 
-                       wfProfileOut( __METHOD__ );
                        return;
                } elseif ( $this->mStatusCode ) {
                        $message = HttpStatus::getMessage( $this->mStatusCode );
@@ -2248,21 +2256,18 @@ class OutputPage extends ContextSource {
 
                        // Hook that allows last minute changes to the output page, e.g.
                        // adding of CSS or Javascript by extensions.
-                       wfRunHooks( 'BeforePageDisplay', array( &$this, &$sk ) );
+                       Hooks::run( 'BeforePageDisplay', array( &$this, &$sk ) );
 
-                       wfProfileIn( 'Output-skin' );
                        $sk->outputPage();
-                       wfProfileOut( 'Output-skin' );
                }
 
                // This hook allows last minute changes to final overall output by modifying output buffer
-               wfRunHooks( 'AfterFinalPageOutput', array( $this ) );
+               Hooks::run( 'AfterFinalPageOutput', array( $this ) );
 
                $this->sendCacheControl();
 
                ob_end_flush();
 
-               wfProfileOut( __METHOD__ );
        }
 
        /**
@@ -2612,8 +2617,6 @@ class OutputPage extends ContextSource {
        public function headElement( Skin $sk, $includeStyle = true ) {
                global $wgContLang;
 
-               $section = new ProfileSection( __METHOD__ );
-
                $userdir = $this->getLanguage()->getDir();
                $sitedir = $wgContLang->getDir();
 
@@ -2685,7 +2688,7 @@ class OutputPage extends ContextSource {
 
                // Allow skins and extensions to add body attributes they need
                $sk->addToBodyAttributes( $this, $bodyAttrs );
-               wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
+               Hooks::run( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
 
                $ret .= Html::openElement( 'body', $bodyAttrs ) . "\n";
 
@@ -2715,7 +2718,7 @@ class OutputPage extends ContextSource {
         *   call rather than a "<script src='...'>" tag.
         * @return string The html "<script>", "<link>" and "<style>" tags
         */
-       protected function makeResourceLoaderLink( $modules, $only, $useESI = false,
+       public function makeResourceLoaderLink( $modules, $only, $useESI = false,
                array $extraQuery = array(), $loadCall = false
        ) {
                $modules = (array)$modules;
@@ -3124,7 +3127,7 @@ class OutputPage extends ContextSource {
         * have to be purged on configuration changes.
         * @return array
         */
-       private function getJSVars() {
+       public function getJSVars() {
                global $wgContLang;
 
                $curRevisionId = 0;
@@ -3235,7 +3238,7 @@ class OutputPage extends ContextSource {
                // Use the 'ResourceLoaderGetConfigVars' hook if the variable is not
                // page-dependant but site-wide (without state).
                // Alternatively, you may want to use OutputPage->addJsConfigVars() instead.
-               wfRunHooks( 'MakeGlobalVariablesScript', array( &$vars, $this ) );
+               Hooks::run( 'MakeGlobalVariablesScript', array( &$vars, $this ) );
 
                // Merge in variables from addJsConfigVars last
                return array_merge( $vars, $this->getJsConfigVars() );