merge latest master into Wikidata branch
[lhc/web/wiklou.git] / includes / OutputPage.php
index 3ab68f4..a03282a 100644 (file)
@@ -255,7 +255,7 @@ class OutputPage extends ContextSource {
        function __construct( IContextSource $context = null ) {
                if ( $context === null ) {
                        # Extensions should use `new RequestContext` instead of `new OutputPage` now.
-                       wfDeprecated( __METHOD__ );
+                       wfDeprecated( __METHOD__, '1.18' );
                } else {
                        $this->setContext( $context );
                }
@@ -851,11 +851,10 @@ class OutputPage extends ContextSource {
                $this->getContext()->setTitle( $t );
        }
 
-
        /**
         * Replace the subtile with $str
         *
-        * @param $str String|Message: new value of the subtitle
+        * @param $str String|Message: new value of the subtitle. String should be safe HTML.
         */
        public function setSubtitle( $str ) {
                $this->clearSubtitle();
@@ -875,7 +874,7 @@ class OutputPage extends ContextSource {
        /**
         * Add $str to the subtitle
         *
-        * @param $str String|Message to add to the subtitle
+        * @param $str String|Message to add to the subtitle. String should be safe HTML.
         */
        public function addSubtitle( $str ) {
                if ( $str instanceof Message ) {
@@ -1903,7 +1902,7 @@ class OutputPage extends ContextSource {
         * @deprecated since 1.18 Use HttpStatus::getMessage() instead.
         */
        public static function getStatusMessage( $code ) {
-               wfDeprecated( __METHOD__ );
+               wfDeprecated( __METHOD__, '1.18' );
                return HttpStatus::getMessage( $code );
        }
 
@@ -1990,6 +1989,9 @@ class OutputPage extends ContextSource {
                        wfProfileOut( 'Output-skin' );
                }
 
+               // This hook allows last minute changes to final overall output by modifying output buffer
+               wfRunHooks( 'AfterFinalPageOutput', array( $this ) );
+
                $this->sendCacheControl();
 
                wfRunHooks( 'AfterFinalPageOutput', array( &$this ) );
@@ -2344,11 +2346,20 @@ $templates
         * @param $title Title to link
         * @param $query Array query string parameters
         * @param $text String text of the link (input is not escaped)
+        * @param $options Options array to pass to Linker
         */
-       public function addReturnTo( $title, $query = array(), $text = null ) {
-               $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL() ) );
+       public function addReturnTo( $title, $query = array(), $text = null, $options = array() ) {
+               if( in_array( 'http', $options ) ) {
+                       $proto = PROTO_HTTP;
+               } elseif( in_array( 'https', $options ) ) {
+                       $proto = PROTO_HTTPS;
+               } else {
+                       $proto = PROTO_RELATIVE;
+               }
+
+               $this->addLink( array( 'rel' => 'next', 'href' => $title->getFullURL( '', false, $proto ) ) );
                $link = $this->msg( 'returnto' )->rawParams(
-                       Linker::link( $title, $text, array(), $query ) )->escaped();
+                       Linker::link( $title, $text, array(), $query, $options ) )->escaped();
                $this->addHTML( "<p id=\"mw-returnto\">{$link}</p>\n" );
        }
 
@@ -2452,7 +2463,7 @@ $templates
         */
        private function addDefaultModules() {
                global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
-                       $wgAjaxWatch, $wgEnableMWSuggest;
+                       $wgAjaxWatch;
 
                // Add base resources
                $this->addModules( array(
@@ -2480,8 +2491,8 @@ $templates
                                $this->addModules( 'mediawiki.page.watch.ajax' );
                        }
 
-                       if ( $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) {
-                               $this->addModules( 'mediawiki.legacy.mwsuggest' );
+                       if ( !$this->getUser()->getOption( 'disablesuggest', false ) ) {
+                               $this->addModules( 'mediawiki.searchSuggest' );
                        }
                }
 
@@ -2905,7 +2916,7 @@ $templates
         * @return array
         */
        public function getJSVars() {
-               global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
+               global $wgUseAjax, $wgContLang;
 
                $latestRevID = 0;
                $pageID = 0;
@@ -2971,9 +2982,6 @@ $templates
                foreach ( $title->getRestrictionTypes() as $type ) {
                        $vars['wgRestriction' . ucfirst( $type )] = $title->getRestrictions( $type );
                }
-               if ( $wgUseAjax && $wgEnableMWSuggest && !$this->getUser()->getOption( 'disablesuggest', false ) ) {
-                       $vars['wgSearchNamespaces'] = SearchEngine::userNamespaces( $this->getUser() );
-               }
                if ( $title->isMainPage() ) {
                        $vars['wgIsMainPage'] = true;
                }
@@ -3549,7 +3557,7 @@ $templates
         *
         * Is equivalent to:
         *
-        *    $wgOut->addWikiText( "<div class='error'>\n" . wfMsgNoTrans( 'some-error' ) . "\n</div>" );
+        *    $wgOut->addWikiText( "<div class='error'>\n" . wfMessage( 'some-error' )->plain() . "\n</div>" );
         *
         * The newline after opening div is needed in some wikitext. See bug 19226.
         *