Merge "Use display name in category page subheadings if provided"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 28 Jul 2016 03:30:55 +0000 (03:30 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 28 Jul 2016 03:30:55 +0000 (03:30 +0000)
1  2 
includes/CategoryViewer.php

@@@ -407,11 -407,26 +407,26 @@@ class CategoryViewer extends ContextSou
                return $r;
        }
  
+       /**
+        * Return pretty name which is display name if given and different from prefix text or
+        * the unprefixed page name.
+        *
+        * @return string HTML safe name.
+        */
+       function getPrettyPageNameHtml() {
+               $displayTitle = $this->getOutput()->getPageTitle();
+               if ( $displayTitle === $this->getTitle()->getPrefixedText() ) {
+                       return htmlspecialchars( $this->getTitle()->getText() );
+               } else {
+                       return $displayTitle;
+               }
+       }
        /**
         * @return string
         */
        function getPagesSection() {
-               $ti = wfEscapeWikiText( $this->title->getText() );
+               $name = $this->getPrettyPageNameHtml();
                # Don't show articles section if there are none.
                $r = '';
  
  
                if ( $rescnt > 0 ) {
                        $r = "<div id=\"mw-pages\">\n";
-                       $r .= '<h2>' . $this->msg( 'category_header', $ti )->parse() . "</h2>\n";
+                       $r .= '<h2>' . $this->msg( 'category_header' )->rawParams( $name )->parse() . "</h2>\n";
                        $r .= $countmsg;
                        $r .= $this->getSectionPagingLinks( 'page' );
                        $r .= $this->formatList( $this->articles, $this->articles_start_char );
         * @return string
         */
        function getImageSection() {
+               $name = $this->getPrettyPageNameHtml();
                $r = '';
                $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
                $dbcnt = $this->cat->getFileCount();
                if ( $rescnt > 0 ) {
                        $r .= "<div id=\"mw-category-media\">\n";
                        $r .= '<h2>' .
-                               $this->msg(
-                                       'category-media-header',
-                                       wfEscapeWikiText( $this->title->getText() )
-                               )->text() .
+                               $this->msg( 'category-media-header' )->rawParams( $name )->parse() .
                                "</h2>\n";
                        $r .= $countmsg;
                        $r .= $this->getSectionPagingLinks( 'file' );
        }
  
        /**
 -       * Format a list of articles chunked by letter in a three-column
 -       * list, ordered vertically.
 +       * Format a list of articles chunked by letter in a three-column list, ordered
 +       * vertically. This is used for categories with a significant number of pages.
         *
         * TODO: Take the headers into account when creating columns, so they're
         * more visually equal.
         *
         * TODO: shortList and columnList are similar, need merging
         *
 -       * @param array $articles
 -       * @param string[] $articles_start_char
 -       * @return string
 +       * @param string[] $articles HTML links to each article
 +       * @param string[] $articles_start_char The header characters for each article
 +       * @return string HTML to output
         * @private
         */
        static function columnList( $articles, $articles_start_char ) {
        }
  
        /**
 -       * Format a list of articles chunked by letter in a bullet list.
 -       * @param array $articles
 -       * @param string[] $articles_start_char
 -       * @return string
 +       * Format a list of articles chunked by letter in a bullet list. This is used
 +       * for categories with a small number of pages (when columns aren't needed).
 +       * @param string[] $articles HTML links to each article
 +       * @param string[] $articles_start_char The header characters for each article
 +       * @return string HTML to output
         * @private
         */
        static function shortList( $articles, $articles_start_char ) {