X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2FCategoryViewer.php;h=c858dd7164f9b611e9c1f193dc449d5fce63193b;hb=8585cc9ffb75cda2f923d3c16760f357aff074d0;hp=8dd3f5c5162ccce06bc43bbebde91b03a652d373;hpb=fd9559cb4da5582565eba6216e828efb2cde8db8;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index 8dd3f5c516..c858dd7164 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -19,6 +19,7 @@ * * @file */ +use MediaWiki\MediaWikiServices; class CategoryViewer extends ContextSource { /** @var int */ @@ -286,7 +287,7 @@ class CategoryViewer extends ContextSource { } function doCategoryQuery() { - $dbr = wfGetDB( DB_SLAVE, 'category' ); + $dbr = wfGetDB( DB_REPLICA, 'category' ); $this->nextPage = [ 'page' => null, @@ -317,10 +318,21 @@ class CategoryViewer extends ContextSource { $res = $dbr->select( [ 'page', 'categorylinks', 'category' ], - [ 'page_id', 'page_title', 'page_namespace', 'page_len', - 'page_is_redirect', 'cl_sortkey', 'cat_id', 'cat_title', - 'cat_subcats', 'cat_pages', 'cat_files', - 'cl_sortkey_prefix', 'cl_collation' ], + array_merge( + LinkCache::getSelectFields(), + [ + 'page_namespace', + 'page_title', + 'cl_sortkey', + 'cat_id', + 'cat_title', + 'cat_subcats', + 'cat_pages', + 'cat_files', + 'cl_sortkey_prefix', + 'cl_collation' + ] + ), array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ), __METHOD__, [ @@ -338,10 +350,13 @@ class CategoryViewer extends ContextSource { ); Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] ); + $linkCache = MediaWikiServices::getInstance()->getLinkCache(); $count = 0; foreach ( $res as $row ) { $title = Title::newFromRow( $row ); + $linkCache->addGoodLinkObjFromRow( $title, $row ); + if ( $row->cl_collation === '' ) { // Hack to make sure that while updating from 1.16 schema // and db is inconsistent, that the sky doesn't fall. @@ -407,11 +422,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 +457,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 +471,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 +481,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' );