94 'mediawiki.action.view.categoryPage.styles'
99 $this->cat = Category::newFromTitle(
$title );
102 unset( $this->
query[
'title'] );
111 $this->showGallery = $this->
getConfig()->get(
'CategoryMagicGallery' )
137 $r = $this->
msg(
'category-empty' )->parseAsBlock();
142 'class' =>
'mw-category-generated',
143 'lang' =>
$lang->getHtmlCode(),
144 'dir' =>
$lang->getDir()
146 # put a div around the headings which are in the user language
147 $r = Html::openElement(
'div',
$attribs ) . $r .
'</div>';
153 $this->articles = [];
154 $this->articles_start_char = [];
155 $this->children = [];
156 $this->children_start_char = [];
157 if ( $this->showGallery ) {
159 $mode = $this->
getRequest()->getVal(
'gallerymode',
null );
162 }
catch ( Exception
$e ) {
167 $this->gallery->setHideBadImages();
169 $this->imgsNoGallery = [];
170 $this->imgsNoGallery_start_char = [];
191 $this->children_start_char[] =
198 if (
$link ===
null ) {
199 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
200 if (
$html !==
null ) {
206 $link =
'<span class="redirect-in-category">' .
$link .
'</span>';
230 $firstChar = $this->collation->getFirstLetter( $word );
232 return MediaWikiServices::getInstance()->getContentLanguage()->convert( $firstChar );
243 if ( $this->showGallery ) {
244 $flip = $this->flip[
'file'];
246 $this->gallery->insert(
$title );
248 $this->gallery->add(
$title );
251 $this->imgsNoGallery[] = $this->
generateLink(
'image', $title, $isRedirect );
253 $this->imgsNoGallery_start_char[] = MediaWikiServices::getInstance()->
254 getContentLanguage()->convert( $this->collation->getFirstLetter( $sortkey ) );
268 $this->articles_start_char[] = MediaWikiServices::getInstance()->
269 getContentLanguage()->convert( $this->collation->getFirstLetter( $sortkey ) );
273 if ( $this->flip[
'subcat'] ) {
274 $this->children = array_reverse( $this->children );
275 $this->children_start_char = array_reverse( $this->children_start_char );
277 if ( $this->flip[
'page'] ) {
278 $this->articles = array_reverse( $this->articles );
279 $this->articles_start_char = array_reverse( $this->articles_start_char );
281 if ( !$this->showGallery && $this->flip[
'file'] ) {
282 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
283 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
301 $this->flip = [
'page' =>
false,
'subcat' =>
false,
'file' =>
false ];
303 foreach ( [
'page',
'subcat',
'file' ]
as $type ) {
304 # Get the sortkeys for start/end, if applicable. Note that if
305 # the collation in the database differs from the one
306 # set in $wgCategoryCollation, pagination might go totally haywire.
307 $extraConds = [
'cl_type' =>
$type ];
309 $extraConds[] =
'cl_sortkey >= '
310 .
$dbr->addQuotes( $this->collation->getSortKey( $this->from[
$type] ) );
311 } elseif ( isset( $this->until[
$type] ) && $this->until[
$type] !==
null ) {
312 $extraConds[] =
'cl_sortkey < '
313 .
$dbr->addQuotes( $this->collation->getSortKey( $this->until[
$type] ) );
314 $this->flip[
$type] =
true;
318 [
'page',
'categorylinks',
'category' ],
320 LinkCache::getSelectFields(),
334 array_merge( [
'cl_to' => $this->
title->getDBkey() ], $extraConds ),
337 'USE INDEX' => [
'categorylinks' =>
'cl_sortkey' ],
338 'LIMIT' => $this->limit + 1,
339 'ORDER BY' => $this->flip[
$type] ?
'cl_sortkey DESC' :
'cl_sortkey',
342 'categorylinks' => [
'JOIN',
'cl_from = page_id' ],
343 'category' => [
'LEFT JOIN', [
344 'cat_title = page_title',
350 Hooks::run(
'CategoryViewer::doCategoryQuery', [
$type,
$res ] );
351 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
354 foreach (
$res as $row ) {
355 $title = Title::newFromRow( $row );
356 $linkCache->addGoodLinkObjFromRow(
$title, $row );
358 if ( $row->cl_collation ===
'' ) {
362 $humanSortkey = $row->cl_sortkey;
367 if ( ++$count > $this->limit ) {
368 # We've reached the one extra which shows that there
369 # are additional pages to be had. Stop here...
370 $this->nextPage[
$type] = $humanSortkey;
373 if ( $count == $this->limit ) {
374 $this->prevPage[
$type] = $humanSortkey;
381 $this->
addImage(
$title, $humanSortkey, $row->page_len, $row->page_is_redirect );
383 $this->
addPage(
$title, $humanSortkey, $row->page_len, $row->page_is_redirect );
396 :
"<br style=\"clear:both;\"/>\n" . $r;
403 # Don't show subcategories section if there are none.
405 $rescnt = count( $this->children );
406 $dbcnt = $this->cat->getSubcatCount();
411 # Showing subcategories
412 $r .=
"<div id=\"mw-subcategories\">\n";
413 $r .=
'<h2>' . $this->
msg(
'subcategories' )->parse() .
"</h2>\n";
416 $r .= $this->
formatList( $this->children, $this->children_start_char );
428 # Don't show articles section if there are none.
431 # @todo FIXME: Here and in the other two sections: we don't need to bother
432 # with this rigmarole if the entire category contents fit on one page
433 # and have already been retrieved. We can just use $rescnt in that
434 # case and save a query and some logic.
435 $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
436 - $this->cat->getFileCount();
437 $rescnt = count( $this->articles );
442 $r =
"<div id=\"mw-pages\">\n";
443 $r .=
'<h2>' . $this->
msg(
'category_header' )->rawParams(
$name )->parse() .
"</h2>\n";
446 $r .= $this->
formatList( $this->articles, $this->articles_start_char );
459 $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
460 $dbcnt = $this->cat->getFileCount();
465 $r .=
"<div id=\"mw-category-media\">\n";
467 $this->
msg(
'category-media-header' )->rawParams(
$name )->parse() .
471 if ( $this->showGallery ) {
472 $r .= $this->gallery->toHTML();
474 $r .= $this->
formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
490 if ( isset( $this->until[
$type] ) && $this->until[
$type] !==
null ) {
495 if ( $this->nextPage[
$type] !==
null ) {
502 } elseif ( $this->nextPage[
$type] !==
null
537 $pageLang = $this->
title->getPageLanguage();
538 $attribs = [
'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
539 'class' =>
'mw-content-' . $pageLang->getDir() ];
540 $list = Html::rawElement(
'div',
$attribs, $list );
562 $ret = Html::openElement(
'div', [
'class' =>
'mw-category' ] );
566 # Kind of like array_flip() here, but we keep duplicates in an
567 # array instead of dropping them.
569 if ( !isset( $colContents[$char] ) ) {
570 $colContents[$char] = [];
576 # Change space to non-breaking space to keep headers aligned
577 $h3char = $char ===
' ' ?
"\u{00A0}" : htmlspecialchars( $char );
579 $ret .=
'<div class="mw-category-group"><h3>' . $h3char;
584 $ret .=
'</li></ul></div>';
588 $ret .= Html::closeElement(
'div' );
602 $r .=
'<ul><li>' .
$articles[0] .
'</li>';
604 for ( $index = 1; $index < $articleCount; $index++ ) {
609 $r .=
"<li>{$articles[$index]}</li>";
625 $prevLink = $this->
msg(
'prev-page' )->escaped();
627 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
628 if ( $first !=
'' ) {
630 $prevQuery[
"{$type}until"] = $first;
631 unset( $prevQuery[
"{$type}from"] );
640 $nextLink = $this->
msg(
'next-page' )->escaped();
644 $lastQuery[
"{$type}from"] =
$last;
645 unset( $lastQuery[
"{$type}until"] );
654 return $this->
msg(
'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
669 $fragment =
'mw-pages';
672 $fragment =
'mw-subcategories';
675 $fragment =
'mw-category-media';
679 " Invalid section $section." );
711 if (
$type ===
'article' ) {
712 $pagingType =
'page';
717 $fromOrUntil =
false;
718 if ( ( isset( $this->
from[$pagingType] ) && $this->
from[$pagingType] !==
null ) ||
719 ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !==
null )
724 if ( $dbcnt == $rescnt ||
725 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
729 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
736 return $this->
msg(
"category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
739 return $this->
msg(
"category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for and distribution as defined by Sections through of this document Licensor shall mean the copyright owner or entity authorized by the copyright owner that is granting the License Legal Entity shall mean the union of the acting entity and all other entities that control are controlled by or are under common control with that entity For the purposes of this definition control direct or to cause the direction or management of such whether by contract or including but not limited to software source documentation and configuration files Object form shall mean any form resulting from mechanical transformation or translation of a Source including but not limited to compiled object generated and conversions to other media types Work shall mean the work of whether in Source or Object made available under the as indicated by a copyright notice that is included in or attached to the whether in Source or Object that is based or other modifications as a an original work of authorship For the purposes of this Derivative Works shall not include works that remain separable from
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getCountMessage( $rescnt, $dbcnt, $type)
What to do if the category table conflicts with the number of results returned? This function says wh...
array $articles_start_char
array $children_start_char
pagingLinks( $first, $last, $type='')
Create paging links, as a helper method to getSectionPagingLinks().
getSectionPagingLinks( $type)
Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output.
Category $cat
Category object for this page.
__construct( $title, IContextSource $context, $from=[], $until=[], $query=[])
addPage( $title, $sortkey, $pageLength, $isRedirect=false)
Add a miscellaneous page.
ImageGalleryBase $gallery
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
formatList( $articles, $articles_start_char, $cutoff=6)
Format a list of articles chunked by letter, either as a bullet list or a columnar format,...
addImage(Title $title, $sortkey, $pageLength, $isRedirect=false)
Add a page in the image namespace.
static columnList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a three-column list, ordered vertically.
getSubcategorySortChar( $title, $sortkey)
Get the character to be used for sorting subcategories.
getHTML()
Format the category data list.
addFragmentToTitle( $title, $section)
Takes a title, and adds the fragment identifier that corresponds to the correct segment of the catego...
array $imgsNoGallery_start_char
generateLink( $type, Title $title, $isRedirect, $html=null)
array $query
The original query array, to be used in generating paging links.
static shortList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
Category objects are immutable, strictly speaking.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
msg( $key)
Get a Message object with context set Parameters are the same as wfMessage()
getContext()
Get the base IContextSource object.
setContext(IContextSource $context)
Marks HTML that shouldn't be escaped.
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
Represents a title within MediaWiki.
getNamespace()
Get the namespace index, i.e.
getDBkey()
Get the main part with underscores.
getText()
Get the text form (spaces not underscores) of the main part.
isRedirect( $flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
getPrefixedText()
Get the prefixed title with spaces.
getCategorySortkey( $prefix='')
Returns the raw sort key to be used for categories, with the specified prefix.
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Allows to change the fields on the form that will be generated $name
return true to allow those checks to and false if checking is done remove or add to the links of a group of changes in EnhancedChangesList Hook subscribers can return false to omit this line from recentchanges use this to change the tables headers change it to an object instance and return false override the list derivative used the name of the old file & $article
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
processing should stop and the error should be shown to the user * false
returning false will NOT prevent logging $e
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Interface for objects which can provide a MediaWiki context on request.
getConfig()
Get the site configuration.
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
if(!isset( $args[0])) $lang