94 'mediawiki.action.view.categoryPage.styles'
98 $this->limit = $context->
getConfig()->get(
'CategoryPagingLimit' );
102 unset( $this->
query[
'title'] );
112 $this->showGallery = $this->
getConfig()->get(
'CategoryMagicGallery' )
138 $r = $this->
msg(
'category-empty' )->parseAsBlock();
143 'class' =>
'mw-category-generated',
144 'lang' =>
$lang->getHtmlCode(),
145 'dir' =>
$lang->getDir()
147 # put a div around the headings which are in the user language
154 $this->articles = [];
155 $this->articles_start_char = [];
156 $this->children = [];
157 $this->children_start_char = [];
158 if ( $this->showGallery ) {
160 $mode = $this->
getRequest()->getVal(
'gallerymode', null );
168 $this->gallery->setHideBadImages();
170 $this->imgsNoGallery = [];
171 $this->imgsNoGallery_start_char = [];
192 $this->children_start_char[] =
199 if (
$link === null ) {
203 $link =
'<span class="redirect-in-category">' .
$link .
'</span>';
229 $firstChar = $this->collation->getFirstLetter( $word );
231 return $wgContLang->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[] = $wgContLang->convert(
254 $this->collation->getFirstLetter( $sortkey ) );
270 $this->articles_start_char[] = $wgContLang->convert(
271 $this->collation->getFirstLetter( $sortkey ) );
275 if ( $this->flip[
'subcat'] ) {
276 $this->children = array_reverse( $this->children );
277 $this->children_start_char = array_reverse( $this->children_start_char );
279 if ( $this->flip[
'page'] ) {
280 $this->articles = array_reverse( $this->articles );
281 $this->articles_start_char = array_reverse( $this->articles_start_char );
283 if ( !$this->showGallery && $this->flip[
'file'] ) {
284 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
285 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
303 $this->flip = [
'page' =>
false,
'subcat' =>
false,
'file' =>
false ];
305 foreach ( [
'page',
'subcat',
'file' ]
as $type ) {
306 # Get the sortkeys for start/end, if applicable. Note that if
307 # the collation in the database differs from the one
308 # set in $wgCategoryCollation, pagination might go totally haywire.
309 $extraConds = [
'cl_type' =>
$type ];
310 if ( isset( $this->
from[$type] ) && $this->
from[$type] !== null ) {
311 $extraConds[] =
'cl_sortkey >= '
312 .
$dbr->addQuotes( $this->collation->getSortKey( $this->from[$type] ) );
313 } elseif ( isset( $this->until[$type] ) && $this->until[$type] !== null ) {
314 $extraConds[] =
'cl_sortkey < '
315 .
$dbr->addQuotes( $this->collation->getSortKey( $this->until[$type] ) );
316 $this->flip[
$type] =
true;
320 [
'page',
'categorylinks',
'category' ],
336 array_merge( [
'cl_to' => $this->
title->getDBkey() ], $extraConds ),
339 'USE INDEX' => [
'categorylinks' =>
'cl_sortkey' ],
340 'LIMIT' => $this->limit + 1,
341 'ORDER BY' => $this->flip[$type] ?
'cl_sortkey DESC' :
'cl_sortkey',
344 'categorylinks' => [
'INNER JOIN',
'cl_from = page_id' ],
345 'category' => [
'LEFT JOIN', [
346 'cat_title = page_title',
353 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
356 foreach (
$res as $row ) {
358 $linkCache->addGoodLinkObjFromRow(
$title, $row );
360 if ( $row->cl_collation ===
'' ) {
364 $humanSortkey = $row->cl_sortkey;
369 if ( ++
$count > $this->limit ) {
370 # We've reached the one extra which shows that there
371 # are additional pages to be had. Stop here...
372 $this->nextPage[
$type] = $humanSortkey;
375 if (
$count == $this->limit ) {
376 $this->prevPage[
$type] = $humanSortkey;
383 $this->
addImage(
$title, $humanSortkey, $row->page_len, $row->page_is_redirect );
385 $this->
addPage(
$title, $humanSortkey, $row->page_len, $row->page_is_redirect );
398 :
"<br style=\"clear:both;\"/>\n" . $r;
405 # Don't show subcategories section if there are none.
407 $rescnt = count( $this->children );
408 $dbcnt = $this->cat->getSubcatCount();
413 # Showing subcategories
414 $r .=
"<div id=\"mw-subcategories\">\n";
415 $r .=
'<h2>' . $this->
msg(
'subcategories' )->parse() .
"</h2>\n";
418 $r .= $this->
formatList( $this->children, $this->children_start_char );
430 # Don't show articles section if there are none.
433 # @todo FIXME: Here and in the other two sections: we don't need to bother
434 # with this rigmarole if the entire category contents fit on one page
435 # and have already been retrieved. We can just use $rescnt in that
436 # case and save a query and some logic.
437 $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
438 - $this->cat->getFileCount();
439 $rescnt = count( $this->articles );
444 $r =
"<div id=\"mw-pages\">\n";
445 $r .=
'<h2>' . $this->
msg(
'category_header', $ti )->parse() .
"</h2>\n";
448 $r .= $this->
formatList( $this->articles, $this->articles_start_char );
460 $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
461 $dbcnt = $this->cat->getFileCount();
466 $r .=
"<div id=\"mw-category-media\">\n";
469 'category-media-header',
475 if ( $this->showGallery ) {
476 $r .= $this->gallery->toHTML();
478 $r .= $this->
formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
494 if ( isset( $this->until[
$type] ) && $this->until[$type] !== null ) {
499 if ( $this->nextPage[$type] !== null ) {
500 return $this->
pagingLinks( $this->prevPage[$type], $this->until[$type], $type );
504 return $this->
pagingLinks( null, $this->until[$type], $type );
506 } elseif ( $this->nextPage[$type] !== null
507 || ( isset( $this->
from[$type] ) && $this->
from[$type] !== null )
509 return $this->
pagingLinks( $this->
from[$type], $this->nextPage[$type], $type );
541 $pageLang = $this->
title->getPageLanguage();
542 $attribs = [
'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
543 'class' =>
'mw-content-' . $pageLang->getDir() ];
570 # Kind of like array_flip() here, but we keep duplicates in an
571 # array instead of dropping them.
573 if ( !isset( $colContents[$char] ) ) {
574 $colContents[$char] = [];
580 # Change space to non-breaking space to keep headers aligned
581 $h3char = $char ===
' ' ?
' ' : htmlspecialchars( $char );
583 $ret .=
'<div class="mw-category-group"><h3>' . $h3char;
588 $ret .=
'</li></ul></div>';
606 $r .=
'<ul><li>' .
$articles[0] .
'</li>';
608 for ( $index = 1; $index < $articleCount; $index++ ) {
613 $r .=
"<li>{$articles[$index]}</li>";
629 $prevLink = $this->
msg(
'prev-page' )->text();
631 if ( $first !=
'' ) {
633 $prevQuery[
"{$type}until"] = $first;
634 unset( $prevQuery[
"{$type}from"] );
643 $nextLink = $this->
msg(
'next-page' )->text();
647 $lastQuery[
"{$type}from"] =
$last;
648 unset( $lastQuery[
"{$type}until"] );
657 return $this->
msg(
'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
672 $fragment =
'mw-pages';
675 $fragment =
'mw-subcategories';
678 $fragment =
'mw-category-media';
682 " Invalid section $section." );
714 if (
$type ===
'article' ) {
715 $pagingType =
'page';
720 $fromOrUntil =
false;
721 if ( ( isset( $this->
from[$pagingType] ) && $this->
from[$pagingType] !== null ) ||
722 ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !== null )
727 if ( $dbcnt == $rescnt ||
728 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
732 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
740 $category->refreshCounts();
746 return $this->
msg(
"category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
749 return $this->
msg(
"category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
setContext(IContextSource $context)
Set the IContextSource object.
static newFromRow($row)
Make a Title object from a DB row.
formatList($articles, $articles_start_char, $cutoff=6)
Format a list of articles chunked by letter, either as a bullet list or a columnar format...
array $articles_start_char
static closeElement($element)
Returns "$element>".
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
Interface for objects which can provide a MediaWiki context on request.
wfGetDB($db, $groups=[], $wiki=false)
Get a Database object.
getLanguage()
Get the Language object.
generateLink($type, Title $title, $isRedirect, $html=null)
getText()
Get the text form (spaces not underscores) of the main part.
processing should stop and the error should be shown to the user * false
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
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException'returning false will NOT prevent logging $e
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
static rawElement($element, $attribs=[], $contents= '')
Returns an HTML element in a string.
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
if(!isset($args[0])) $lang
isRedirect($flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
array $children_start_char
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 MediaWikiServices
getPrefixedText()
Get the prefixed title with spaces.
when a variable name is used in a it is silently declared as a new local masking the global
usually copyright or history_copyright This message must be in HTML not wikitext & $link
getRequest()
Get the WebRequest object.
static factory($mode=false, IContextSource $context=null)
Get a new image gallery.
getCountMessage($rescnt, $dbcnt, $type)
What to do if the category table conflicts with the number of results returned? This function says wh...
msg()
Get a Message object with context set Parameters are the same as wfMessage()
getConfig()
Get the site configuration.
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
wfEscapeWikiText($text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
getDBkey()
Get the main part with underscores.
getConfig()
Get the Config object.
getContext()
Get the base IContextSource object.
static newFromTitle($title)
Factory function.
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
array $query
The original query array, to be used in generating paging links.
addImage(Title $title, $sortkey, $pageLength, $isRedirect=false)
Add a page in the image namespace.
static linkKnown($target, $html=null, $customAttribs=[], $query=[], $options=[ 'known'])
Identical to link(), except $options defaults to 'known'.
static run($event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
getNamespace()
Get the namespace index, i.e.
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.
pagingLinks($first, $last, $type= '')
Create paging links, as a helper method to getSectionPagingLinks().
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
addFragmentToTitle($title, $section)
Takes a title, and adds the fragment identifier that corresponds to the correct segment of the catego...
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
static link($target, $html=null, $customAttribs=[], $query=[], $options=[])
This function returns an HTML link to the given target.
array $imgsNoGallery_start_char
static getSelectFields()
Fields that LinkCache needs to select.
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
getSectionPagingLinks($type)
Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output...
__construct($title, IContextSource $context, $from=[], $until=[], $query=[])
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
getCategorySortkey($prefix= '')
Returns the raw sort key to be used for categories, with the specified prefix.
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
addPage($title, $sortkey, $pageLength, $isRedirect=false)
Add a miscellaneous page.
static addCallableUpdate($callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
static newFromRow($row, $title=null)
Factory function, for constructing a Category object from a result set.
static shortList($articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached one of or reset my talk my contributions etc etc otherwise the built in rate limiting checks are if enabled allows for interception of redirect as a string mapping parameter names to values & $type
static makeTitle($ns, $title, $fragment= '', $interwiki= '')
Create a new Title from a namespace index and a DB key.
getHTML()
Format the category data list.
Category $cat
Category object for this page.
getOutput()
Get the OutputPage object.