X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FArticle.php;h=87b94ae97584cfbc3845b72be1806f5ea4c8d845;hb=acd231fa2423d8d64f864c697b2d9d91700ff1b3;hp=1dc27a72215317f94e9f46282b4a0785427bc976;hpb=c8ddc2ab37639803ff5987b57179e4967d33063d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Article.php b/includes/Article.php index 1dc27a7221..87b94ae975 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -134,7 +134,7 @@ class Article implements Page { /** * Constructor from a page id - * @param $id Int article ID to load + * @param int $id article ID to load * @return Article|null */ public static function newFromID( $id ) { @@ -160,7 +160,7 @@ class Article implements Page { $page = null; wfRunHooks( 'ArticleFromTitle', array( &$title, &$page ) ); if ( !$page ) { - switch( $title->getNamespace() ) { + switch ( $title->getNamespace() ) { case NS_FILE: $page = new ImagePage( $title ); break; @@ -393,7 +393,6 @@ class Article implements Page { return $this->mContent; } - /** * Get text content object * Does *NOT* follow redirects. @@ -610,7 +609,7 @@ class Article implements Page { $this->mParserOutput = false; while ( !$outputDone && ++$pass ) { - switch( $pass ) { + switch ( $pass ) { case 1: wfRunHooks( 'ArticleViewHeader', array( &$this, &$outputDone, &$useParserCache ) ); break; @@ -674,12 +673,12 @@ class Article implements Page { wfDebug( __METHOD__ . ": showing CSS/JS source\n" ); $this->showCssOrJsPage(); $outputDone = true; - } elseif( !wfRunHooks( 'ArticleContentViewCustom', + } elseif ( !wfRunHooks( 'ArticleContentViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { # Allow extensions do their own custom view for certain pages $outputDone = true; - } elseif( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', + } elseif ( !ContentHandler::runLegacyHooks( 'ArticleViewCustom', array( $this->fetchContentObject(), $this->getTitle(), $outputPage ) ) ) { # Allow extensions do their own custom view for certain pages @@ -767,6 +766,8 @@ class Article implements Page { $this->showViewFooter(); $this->mPage->doViewUpdates( $user ); + $outputPage->addModules( 'mediawiki.action.view.postEdit' ); + wfProfileOut( __METHOD__ ); } @@ -852,7 +853,7 @@ class Article implements Page { /** * Get the robot policy to be used for the current view - * @param $action String the action= GET parameter + * @param string $action the action= GET parameter * @param $pOutput ParserOutput * @return Array the policy that should be set * TODO: actions other than 'view' @@ -874,7 +875,7 @@ class Article implements Page { } if ( Block::newFromTarget( $specificTarget, $vagueTarget ) instanceof Block ) { return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'nofollow' ); } @@ -883,19 +884,19 @@ class Article implements Page { if ( $this->mPage->getID() === 0 || $this->getOldID() ) { # Non-articles (special pages etc), and old revisions return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'nofollow' ); } elseif ( $this->getContext()->getOutput()->isPrintable() ) { # Discourage indexing of printable versions, but encourage following return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'follow' ); } elseif ( $this->getContext()->getRequest()->getInt( 'curid' ) ) { # For ?curid=x urls, disallow indexing return array( - 'index' => 'noindex', + 'index' => 'noindex', 'follow' => 'follow' ); } @@ -987,8 +988,9 @@ class Article implements Page { // Set the fragment if one was specified in the redirect if ( strval( $this->getTitle()->getFragment() ) != '' ) { - $fragment = Xml::escapeJsString( $this->getTitle()->getFragmentForURL() ); - $outputPage->addInlineScript( "redirectToFragment(\"$fragment\");" ); + $outputPage->addInlineScript( Xml::encodeJsCall( + 'redirectToFragment', array( $this->getTitle()->getFragmentForURL() ) + ) ); } // Add a tag @@ -1089,6 +1091,7 @@ class Article implements Page { public function showMissingArticle() { global $wgSend404Code; $outputPage = $this->getContext()->getOutput(); + $validUserPage = false; # Show info in user (talk) namespace. Does the user exist? Is he blocked? if ( $this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK ) { @@ -1097,7 +1100,7 @@ class Article implements Page { $user = User::newFromName( $rootPart, false /* allow IP users*/ ); $ip = User::isIP( $rootPart ); - if ( !($user && $user->isLoggedIn()) && !$ip ) { # User does not exist + if ( !( $user && $user->isLoggedIn() ) && !$ip ) { # User does not exist $outputPage->wrapWikiMsg( "
\n\$1\n
", array( 'userpage-userdoesnotexist-view', wfEscapeWikiText( $rootPart ) ) ); } elseif ( $user->isBlocked() ) { # Show log extract if the user is currently blocked @@ -1115,6 +1118,9 @@ class Article implements Page { ) ) ); + $validUserPage = true; + } else { + $validUserPage = true; } } @@ -1128,7 +1134,7 @@ class Article implements Page { 'msgKey' => array( 'moveddeleted-notice' ) ) ); - if ( !$this->mPage->hasViewableContent() && $wgSend404Code ) { + 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" ); @@ -1183,7 +1189,7 @@ class Article implements Page { } elseif ( $this->getContext()->getRequest()->getInt( 'unhide' ) != 1 ) { # Give explanation and add a link to view the revision... $oldid = intval( $this->getOldID() ); - $link = $this->getTitle()->getFullUrl( "oldid={$oldid}&unhide=1" ); + $link = $this->getTitle()->getFullURL( "oldid={$oldid}&unhide=1" ); $msg = $this->mRevision->isDeleted( Revision::DELETED_RESTRICTED ) ? 'rev-suppressed-text-unhide' : 'rev-deleted-text-unhide'; $outputPage->wrapWikiMsg( "\n", @@ -1206,7 +1212,7 @@ class Article implements Page { * Revision as of \; view current revision * \<- Previous version | Next Version -\> * - * @param $oldid int: revision ID of this article revision + * @param int $oldid revision ID of this article revision */ public function setOldSubtitle( $oldid = 0 ) { if ( !wfRunHooks( 'DisplayOldSubtitle', array( &$this, &$oldid ) ) ) { @@ -1514,7 +1520,7 @@ class Article implements Page { /** * Output deletion confirmation dialog * @todo FIXME: Move to another file? - * @param $reason String: prefilled reason + * @param string $reason prefilled reason */ public function confirmDelete( $reason ) { wfDebug( "Article::confirmDelete\n" ); @@ -1722,7 +1728,7 @@ class Article implements Page { * * @param $oldid mixed integer Revision ID or null * @param $user User The relevant user - * @return ParserOutput or false if the given revsion ID is not found + * @return ParserOutput or false if the given revision ID is not found */ public function getParserOutput( $oldid = null, User $user = null ) { //XXX: bypasses mParserOptions and thus setParserOptions() @@ -1882,8 +1888,8 @@ class Article implements Page { * * @deprecated in 1.18; call OutputPage::redirect() directly * @param $noRedir Boolean: add redirect=no - * @param $sectionAnchor String: section to redirect to, including "#" - * @param $extraQuery String: extra query params + * @param string $sectionAnchor section to redirect to, including "#" + * @param string $extraQuery extra query params */ public function doRedirect( $noRedir = false, $sectionAnchor = '', $extraQuery = '' ) { wfDeprecated( __METHOD__, '1.18' ); @@ -1903,7 +1909,7 @@ class Article implements Page { * Use PHP's magic __get handler to handle accessing of * raw WikiPage fields for backwards compatibility. * - * @param $fname String Field name + * @param string $fname Field name */ public function __get( $fname ) { if ( property_exists( $this->mPage, $fname ) ) { @@ -1917,7 +1923,7 @@ class Article implements Page { * Use PHP's magic __set handler to handle setting of * raw WikiPage fields for backwards compatibility. * - * @param $fname String Field name + * @param string $fname Field name * @param $fvalue mixed New value */ public function __set( $fname, $fvalue ) { @@ -1936,8 +1942,8 @@ class Article implements Page { * Use PHP's magic __call handler to transform instance calls to * WikiPage functions for backwards compatibility. * - * @param $fname String Name of called method - * @param $args Array Arguments to the method + * @param string $fname Name of called method + * @param array $args Arguments to the method * @return mixed */ public function __call( $fname, $args ) {