Merge "Show the revision list immediately on "umerge" log action links"
[lhc/web/wiklou.git] / includes / page / Article.php
index 984b01d..9772d4f 100644 (file)
@@ -1190,15 +1190,18 @@ class Article implements Page {
         */
        public function showMissingArticle() {
                global $wgSend404Code;
+
                $outputPage = $this->getContext()->getOutput();
                // Whether the page is a root user page of an existing user (but not a subpage)
                $validUserPage = false;
 
+               $title = $this->getTitle();
+
                # 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
+               if ( $title->getNamespace() == NS_USER
+                       || $title->getNamespace() == NS_USER_TALK
                ) {
-                       $parts = explode( '/', $this->getTitle()->getText() );
+                       $parts = explode( '/', $title->getText() );
                        $rootPart = $parts[0];
                        $user = User::newFromName( $rootPart, false /* allow IP users*/ );
                        $ip = User::isIP( $rootPart );
@@ -1222,9 +1225,9 @@ class Article implements Page {
                                                )
                                        )
                                );
-                               $validUserPage = !$this->getTitle()->isSubpage();
+                               $validUserPage = !$title->isSubpage();
                        } else {
-                               $validUserPage = !$this->getTitle()->isSubpage();
+                               $validUserPage = !$title->isSubpage();
                        }
                }
 
@@ -1236,12 +1239,16 @@ class Article implements Page {
                wfRunHooks( 'Article::MissingArticleConditions', array( &$conds, $logTypes ) );
 
                # Show delete and move logs
-               LogEventsList::showLogExtract( $outputPage, $logTypes, $this->getTitle(), '',
-                       array( 'lim' => 10,
-                               'conds' => $conds,
-                               'showIfEmpty' => false,
-                               'msgKey' => array( 'moveddeleted-notice' ) )
-               );
+               $member = $title->getNamespace() . ':' . $title->getDBkey();
+               // @todo: move optimization to showLogExtract()?
+               if ( BloomCache::get( 'main' )->check( wfWikiId(), 'TitleHasLogs', $member ) ) {
+                       LogEventsList::showLogExtract( $outputPage, $logTypes, $title, '',
+                               array( 'lim' => 10,
+                                       'conds' => $conds,
+                                       'showIfEmpty' => false,
+                                       'msgKey' => array( 'moveddeleted-notice' ) )
+                       );
+               }
 
                if ( !$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage ) {
                        // If there's no backing content, send a 404 Not Found
@@ -1264,11 +1271,11 @@ class Article implements Page {
                $oldid = $this->getOldID();
                if ( $oldid ) {
                        $text = wfMessage( 'missing-revision', $oldid )->plain();
-               } elseif ( $this->getTitle()->getNamespace() === NS_MEDIAWIKI ) {
+               } elseif ( $title->getNamespace() === NS_MEDIAWIKI ) {
                        // Use the default message text
-                       $text = $this->getTitle()->getDefaultMessageText();
-               } elseif ( $this->getTitle()->quickUserCan( 'create', $this->getContext()->getUser() )
-                       && $this->getTitle()->quickUserCan( 'edit', $this->getContext()->getUser() )
+                       $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();
@@ -1455,14 +1462,15 @@ class Article implements Page {
         * @param Title|array $target Destination(s) to redirect
         * @param bool $appendSubtitle [optional]
         * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
-        * @return string Containing HMTL with redirect link
+        * @return string Containing HTML with redirect link
         */
        public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
                $lang = $this->getTitle()->getPageLanguage();
+               $out = $this->getContext()->getOutput();
                if ( $appendSubtitle ) {
-                       $out = $this->getContext()->getOutput();
                        $out->addSubtitle( wfMessage( 'redirectpagesub' )->parse() );
                }
+               $out->addModuleStyles( 'mediawiki.action.view.redirectPage' );
                return static::getRedirectHeaderHtml( $lang, $target, $forceKnown );
        }
 
@@ -1476,58 +1484,33 @@ class Article implements Page {
         * @param Language $lang
         * @param Title|array $target Destination(s) to redirect
         * @param bool $forceKnown Should the image be shown as a bluelink regardless of existence?
-        * @return string Containing HMTL with redirect link
+        * @return string Containing HTML with redirect link
         */
        public static function getRedirectHeaderHtml( Language $lang, $target, $forceKnown = false ) {
-               global $wgStylePath;
-
                if ( !is_array( $target ) ) {
                        $target = array( $target );
                }
 
-               $imageDir = $lang->getDir();
-
-               // the loop prepends the arrow image before the link, so the first case needs to be outside
-
-               /** @var $title Title */
-               $title = array_shift( $target );
-
-               if ( $forceKnown ) {
-                       $link = Linker::linkKnown( $title, htmlspecialchars( $title->getFullText() ) );
-               } else {
-                       $link = Linker::link( $title, htmlspecialchars( $title->getFullText() ) );
+               $html = '<ul class="redirectText">';
+               /** @var Title $title */
+               foreach ( $target as $title ) {
+                       $html .= '<li>' . Linker::link(
+                               $title,
+                               htmlspecialchars( $title->getFullText() ),
+                               array(),
+                               // Automatically append redirect=no to each link, since most of them are
+                               // redirect pages themselves.
+                               array( 'redirect' => 'no' ),
+                               ( $forceKnown ? array( 'known', 'noclasses' ) : array() )
+                       ) . '</li>';
                }
 
-               $nextRedirect = $wgStylePath . '/common/images/nextredirect' . $imageDir . '.png';
-               $alt = $lang->isRTL() ? '←' : '→';
+               $redirectToText = wfMessage( 'redirectto' )->inLanguage( $lang )->text();
 
-               // Automatically append redirect=no to each link, since most of them are
-               // redirect pages themselves.
-               /** @var Title $rt */
-               foreach ( $target as $rt ) {
-                       $link .= Html::element( 'img', array( 'src' => $nextRedirect, 'alt' => $alt ) );
-                       if ( $forceKnown ) {
-                               $link .= Linker::linkKnown(
-                                       $rt,
-                                       htmlspecialchars( $rt->getFullText(),
-                                       array(),
-                                       array( 'redirect' => 'no' )
-                               )
-                               );
-                       } else {
-                               $link .= Linker::link(
-                                       $rt,
-                                       htmlspecialchars( $rt->getFullText() ),
-                                       array(),
-                                       array( 'redirect' => 'no' )
-                               );
-                       }
-               }
-
-               $imageUrl = $wgStylePath . '/common/images/redirect' . $imageDir . '.png';
                return '<div class="redirectMsg">' .
-                       Html::element( 'img', array( 'src' => $imageUrl, 'alt' => '#REDIRECT' ) ) .
-                       '<span class="redirectText">' . $link . '</span></div>';
+                       '<p>' . $redirectToText . '</p>' .
+                       $html .
+                       '</div>';
        }
 
        /**
@@ -1976,6 +1959,7 @@ class Article implements Page {
         * raw WikiPage fields for backwards compatibility.
         *
         * @param string $fname Field name
+        * @return mixed
         */
        public function __get( $fname ) {
                if ( property_exists( $this->mPage, $fname ) ) {