Merge branch 'Wikidata' into master.
[lhc/web/wiklou.git] / includes / OutputPage.php
index 7b67144..53f6da1 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 );
        }
 
@@ -1994,7 +1993,9 @@ class OutputPage extends ContextSource {
                wfRunHooks( 'AfterFinalPageOutput', array( $this ) );
 
                $this->sendCacheControl();
+
                ob_end_flush();
+
                wfProfileOut( __METHOD__ );
        }
 
@@ -2072,8 +2073,6 @@ class OutputPage extends ContextSource {
         * @param $action String: action that was denied or null if unknown
         */
        public function showPermissionsErrorPage( $errors, $action = null ) {
-               global $wgGroupPermissions;
-
                // For some action (read, edit, create and upload), display a "login to do this action"
                // error if all of the following conditions are met:
                // 1. the user is not logged in
@@ -2082,8 +2081,8 @@ class OutputPage extends ContextSource {
                if ( in_array( $action, array( 'read', 'edit', 'createpage', 'createtalk', 'upload' ) )
                        && $this->getUser()->isAnon() && count( $errors ) == 1 && isset( $errors[0][0] )
                        && ( $errors[0][0] == 'badaccess-groups' || $errors[0][0] == 'badaccess-group0' )
-                       && ( ( isset( $wgGroupPermissions['user'][$action] ) && $wgGroupPermissions['user'][$action] )
-                       || ( isset( $wgGroupPermissions['autoconfirmed'][$action] ) && $wgGroupPermissions['autoconfirmed'][$action] ) )
+                       && ( User::groupHasPermission( 'user', $action )
+                       || User::groupHasPermission( 'autoconfirmed', $action ) )
                ) {
                        $displayReturnto = null;
 
@@ -2343,11 +2342,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" );
        }
 
@@ -2451,7 +2459,7 @@ $templates
         */
        private function addDefaultModules() {
                global $wgIncludeLegacyJavaScript, $wgPreloadJavaScriptMwUtil, $wgUseAjax,
-                       $wgAjaxWatch, $wgEnableMWSuggest;
+                       $wgAjaxWatch;
 
                // Add base resources
                $this->addModules( array(
@@ -2479,8 +2487,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' );
                        }
                }
 
@@ -2904,7 +2912,7 @@ $templates
         * @return array
         */
        public function getJSVars() {
-               global $wgUseAjax, $wgEnableMWSuggest, $wgContLang;
+               global $wgUseAjax, $wgContLang;
 
                $latestRevID = 0;
                $pageID = 0;
@@ -2970,9 +2978,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;
                }
@@ -3548,7 +3553,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.
         *