dépôts
/
lhc
/
web
/
wiklou.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge "registration: Refactor validation logic to avoid duplication"
[lhc/web/wiklou.git]
/
includes
/
CategoryViewer.php
diff --git
a/includes/CategoryViewer.php
b/includes/CategoryViewer.php
index
a8e988f
..
4c4b8bb
100644
(file)
--- a/
includes/CategoryViewer.php
+++ b/
includes/CategoryViewer.php
@@
-19,6
+19,7
@@
*
* @file
*/
*
* @file
*/
+use MediaWiki\MediaWikiServices;
class CategoryViewer extends ContextSource {
/** @var int */
class CategoryViewer extends ContextSource {
/** @var int */
@@
-196,7
+197,11
@@
class CategoryViewer extends ContextSource {
$link = null;
Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] );
if ( $link === null ) {
$link = null;
Hooks::run( 'CategoryViewer::generateLink', [ $type, $title, $html, &$link ] );
if ( $link === null ) {
- $link = Linker::link( $title, $html );
+ $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
+ if ( $html !== null ) {
+ $html = new HtmlArmor( $html );
+ }
+ $link = $linkRenderer->makeLink( $title, $html );
}
if ( $isRedirect ) {
$link = '<span class="redirect-in-category">' . $link . '</span>';
}
if ( $isRedirect ) {
$link = '<span class="redirect-in-category">' . $link . '</span>';
@@
-317,10
+322,21
@@
class CategoryViewer extends ContextSource {
$res = $dbr->select(
[ 'page', 'categorylinks', 'category' ],
$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__,
[
array_merge( [ 'cl_to' => $this->title->getDBkey() ], $extraConds ),
__METHOD__,
[
@@
-338,10
+354,13
@@
class CategoryViewer extends ContextSource {
);
Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] );
);
Hooks::run( 'CategoryViewer::doCategoryQuery', [ $type, $res ] );
+ $linkCache = MediaWikiServices::getInstance()->getLinkCache();
$count = 0;
foreach ( $res as $row ) {
$title = Title::newFromRow( $row );
$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.
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,26
+426,11
@@
class CategoryViewer extends ContextSource {
return $r;
}
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() {
/**
* @return string
*/
function getPagesSection() {
- $
name = $this->getPrettyPageNameHtml(
);
+ $
ti = wfEscapeWikiText( $this->title->getText()
);
# Don't show articles section if there are none.
$r = '';
# Don't show articles section if there are none.
$r = '';
@@
-442,7
+446,7
@@
class CategoryViewer extends ContextSource {
if ( $rescnt > 0 ) {
$r = "<div id=\"mw-pages\">\n";
if ( $rescnt > 0 ) {
$r = "<div id=\"mw-pages\">\n";
- $r .= '<h2>' . $this->msg( 'category_header'
)->rawParams( $name
)->parse() . "</h2>\n";
+ $r .= '<h2>' . $this->msg( 'category_header'
, $ti
)->parse() . "</h2>\n";
$r .= $countmsg;
$r .= $this->getSectionPagingLinks( 'page' );
$r .= $this->formatList( $this->articles, $this->articles_start_char );
$r .= $countmsg;
$r .= $this->getSectionPagingLinks( 'page' );
$r .= $this->formatList( $this->articles, $this->articles_start_char );
@@
-456,7
+460,6
@@
class CategoryViewer extends ContextSource {
* @return string
*/
function getImageSection() {
* @return string
*/
function getImageSection() {
- $name = $this->getPrettyPageNameHtml();
$r = '';
$rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
$dbcnt = $this->cat->getFileCount();
$r = '';
$rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
$dbcnt = $this->cat->getFileCount();
@@
-466,7
+469,10
@@
class CategoryViewer extends ContextSource {
if ( $rescnt > 0 ) {
$r .= "<div id=\"mw-category-media\">\n";
$r .= '<h2>' .
if ( $rescnt > 0 ) {
$r .= "<div id=\"mw-category-media\">\n";
$r .= '<h2>' .
- $this->msg( 'category-media-header' )->rawParams( $name )->parse() .
+ $this->msg(
+ 'category-media-header',
+ wfEscapeWikiText( $this->title->getText() )
+ )->text() .
"</h2>\n";
$r .= $countmsg;
$r .= $this->getSectionPagingLinks( 'file' );
"</h2>\n";
$r .= $countmsg;
$r .= $this->getSectionPagingLinks( 'file' );