Merge "WebResponse: Implement statusHeader() using the new HttpStatus::header()"
[lhc/web/wiklou.git] / includes / page / Article.php
index 91e9971..11a3638 100644 (file)
@@ -1238,7 +1238,7 @@ class Article implements Page {
                if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
                        // If there's no backing content, send a 404 Not Found
                        // for better machine handling of broken links.
-                       $this->getContext()->getRequest()->response()->header( "HTTP/1.1 404 Not Found" );
+                       $this->getContext()->getRequest()->response()->statusHeader( 404 );
                }
 
                // Also apply the robot policy for nonexisting pages (even if a 404 was used for sanity)
@@ -1254,22 +1254,22 @@ class Article implements Page {
 
                # Show error message
                $oldid = $this->getOldID();
-               if ( $oldid ) {
-                       $text = wfMessage( 'missing-revision', $oldid )->plain();
-               } elseif ( $title->getNamespace() === NS_MEDIAWIKI ) {
-                       // Use the default message text
-                       $text = $title->getDefaultMessageText();
-               } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
-                       && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
-               ) {
-                       $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
-                       $text = wfMessage( $message )->plain();
+               if ( !$oldid && $title->getNamespace() === NS_MEDIAWIKI ) {
+                       $outputPage->addParserOutput( $this->getContentObject()->getParserOutput( $title ) );
                } else {
-                       $text = wfMessage( 'noarticletext-nopermission' )->plain();
-               }
-               $text = "<div class='noarticletext'>\n$text\n</div>";
+                       if ( $oldid ) {
+                               $text = wfMessage( 'missing-revision', $oldid )->plain();
+                       } elseif ( $title->quickUserCan( 'create', $this->getContext()->getUser() )
+                               && $title->quickUserCan( 'edit', $this->getContext()->getUser() )
+                       ) {
+                               $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
+                               $text = wfMessage( $message )->plain();
+                       } else {
+                               $text = wfMessage( 'noarticletext-nopermission' )->plain();
+                       }
 
-               $outputPage->addWikiText( $text );
+                       $outputPage->addWikiText( "<div class='noarticletext'>\n$text\n</div>" );
+               }
        }
 
        /**
@@ -1505,6 +1505,28 @@ class Article implements Page {
                        '</div>';
        }
 
+       /**
+        * Adds help link with an icon via page indicators.
+        * Link target can be overridden by a local message containing a wikilink:
+        * the message key is: 'namespace-' + namespace number + '-helppage'.
+        * @param string $to Target MediaWiki.org page title or encoded URL.
+        * @param bool $overrideBaseUrl Whether $url is a full URL, to avoid MW.o.
+        * @since 1.25
+        */
+       public function addHelpLink( $to, $overrideBaseUrl = false ) {
+               $msg = wfMessage(
+                       'namespace-' . $this->getTitle()->getNamespace() . '-helppage'
+               );
+
+               $out = $this->getContext()->getOutput();
+               if ( !$msg->isDisabled() ) {
+                       $helpUrl = Skin::makeUrl( $msg->plain() );
+                       $out->addHelpLink( $helpUrl, true );
+               } else {
+                       $out->addHelpLink( $to, $overrideBaseUrl );
+               }
+       }
+
        /**
         * Handle action=render
         */
@@ -1750,9 +1772,8 @@ class Article implements Page {
                        Xml::closeElement( 'form' );
 
                        if ( $user->isAllowed( 'editinterface' ) ) {
-                               $dropdownTitle = Title::makeTitle( NS_MEDIAWIKI, 'Deletereason-dropdown' );
                                $link = Linker::link(
-                                       $dropdownTitle,
+                                       $ctx->msg( 'deletereason-dropdown' )->inContentLanguage()->getTitle(),
                                        wfMessage( 'delete-edit-reasonlist' )->escaped(),
                                        array(),
                                        array( 'action' => 'edit' )