X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FCategoryViewer.php;h=a8e988f614b50da99487a6d57c26178573f37e51;hb=0a806b75f1450646bf54c36567e4085968ca0829;hp=389b07747499bdbaee391d743cbcc7c1f59c934f;hpb=68bb0bb062dfffab59d1109edf224d271d814fa7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 389b077474..a8e988f614 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -286,7 +286,7 @@ class CategoryViewer extends ContextSource { } function doCategoryQuery() { - $dbr = wfGetDB( DB_SLAVE, 'category' ); + $dbr = wfGetDB( DB_REPLICA, 'category' ); $this->nextPage = [ 'page' => null, @@ -407,11 +407,26 @@ class CategoryViewer extends ContextSource { 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 = ''; @@ -427,7 +442,7 @@ class CategoryViewer extends ContextSource { if ( $rescnt > 0 ) { $r = "
\n"; - $r .= '

' . $this->msg( 'category_header', $ti )->parse() . "

\n"; + $r .= '

' . $this->msg( 'category_header' )->rawParams( $name )->parse() . "

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'page' ); $r .= $this->formatList( $this->articles, $this->articles_start_char ); @@ -441,6 +456,7 @@ class CategoryViewer extends ContextSource { * @return string */ function getImageSection() { + $name = $this->getPrettyPageNameHtml(); $r = ''; $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ); $dbcnt = $this->cat->getFileCount(); @@ -450,10 +466,7 @@ class CategoryViewer extends ContextSource { if ( $rescnt > 0 ) { $r .= "
\n"; $r .= '

' . - $this->msg( - 'category-media-header', - wfEscapeWikiText( $this->title->getText() ) - )->text() . + $this->msg( 'category-media-header' )->rawParams( $name )->parse() . "

\n"; $r .= $countmsg; $r .= $this->getSectionPagingLinks( 'file' ); @@ -532,17 +545,17 @@ class CategoryViewer extends ContextSource { } /** - * 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 ) { @@ -579,10 +592,11 @@ class CategoryViewer extends ContextSource { } /** - * 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 ) {