Go to the documentation of this file.
94 'mediawiki.action.view.categoryPage.styles'
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 );
163 }
catch ( Exception
$e ) {
168 $this->gallery->setHideBadImages();
170 $this->imgsNoGallery = [];
171 $this->imgsNoGallery_start_char = [];
192 $this->children_start_char[] =
199 if (
$link ===
null ) {
200 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
201 if (
$html !==
null ) {
207 $link =
'<span class="redirect-in-category">' .
$link .
'</span>';
233 $firstChar = $this->collation->getFirstLetter( $word );
247 if ( $this->showGallery ) {
248 $flip = $this->flip[
'file'];
250 $this->gallery->insert(
$title );
252 $this->gallery->add(
$title );
255 $this->imgsNoGallery[] = $this->
generateLink(
'image', $title, $isRedirect );
257 $this->imgsNoGallery_start_char[] =
$wgContLang->convert(
258 $this->collation->getFirstLetter( $sortkey ) );
274 $this->articles_start_char[] =
$wgContLang->convert(
275 $this->collation->getFirstLetter( $sortkey ) );
279 if ( $this->flip[
'subcat'] ) {
280 $this->children = array_reverse( $this->children );
281 $this->children_start_char = array_reverse( $this->children_start_char );
283 if ( $this->flip[
'page'] ) {
284 $this->articles = array_reverse( $this->articles );
285 $this->articles_start_char = array_reverse( $this->articles_start_char );
287 if ( !$this->showGallery && $this->flip[
'file'] ) {
288 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
289 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
307 $this->flip = [
'page' =>
false,
'subcat' =>
false,
'file' =>
false ];
309 foreach ( [
'page',
'subcat',
'file' ]
as $type ) {
310 # Get the sortkeys for start/end, if applicable. Note that if
311 # the collation in the database differs from the one
312 # set in $wgCategoryCollation, pagination might go totally haywire.
313 $extraConds = [
'cl_type' =>
$type ];
314 if ( isset( $this->
from[$type] ) && $this->
from[$type] !==
null ) {
315 $extraConds[] =
'cl_sortkey >= '
316 .
$dbr->addQuotes( $this->collation->getSortKey( $this->from[
$type] ) );
317 } elseif ( isset( $this->until[
$type] ) && $this->until[
$type] !==
null ) {
318 $extraConds[] =
'cl_sortkey < '
319 .
$dbr->addQuotes( $this->collation->getSortKey( $this->until[
$type] ) );
320 $this->flip[
$type] =
true;
324 [
'page',
'categorylinks',
'category' ],
340 array_merge( [
'cl_to' => $this->
title->getDBkey() ], $extraConds ),
343 'USE INDEX' => [
'categorylinks' =>
'cl_sortkey' ],
344 'LIMIT' => $this->limit + 1,
345 'ORDER BY' => $this->flip[
$type] ?
'cl_sortkey DESC' :
'cl_sortkey',
348 'categorylinks' => [
'INNER JOIN',
'cl_from = page_id' ],
349 'category' => [
'LEFT JOIN', [
350 'cat_title = page_title',
357 $linkCache = MediaWikiServices::getInstance()->getLinkCache();
360 foreach (
$res as $row ) {
362 $linkCache->addGoodLinkObjFromRow(
$title, $row );
364 if ( $row->cl_collation ===
'' ) {
368 $humanSortkey = $row->cl_sortkey;
373 if ( ++$count > $this->limit ) {
374 # We've reached the one extra which shows that there
375 # are additional pages to be had. Stop here...
376 $this->nextPage[
$type] = $humanSortkey;
379 if ( $count == $this->limit ) {
380 $this->prevPage[
$type] = $humanSortkey;
387 $this->
addImage(
$title, $humanSortkey, $row->page_len, $row->page_is_redirect );
389 $this->
addPage(
$title, $humanSortkey, $row->page_len, $row->page_is_redirect );
402 :
"<br style=\"clear:both;\"/>\n" . $r;
409 # Don't show subcategories section if there are none.
411 $rescnt =
count( $this->children );
412 $dbcnt = $this->cat->getSubcatCount();
417 # Showing subcategories
418 $r .=
"<div id=\"mw-subcategories\">\n";
419 $r .=
'<h2>' . $this->
msg(
'subcategories' )->parse() .
"</h2>\n";
422 $r .= $this->
formatList( $this->children, $this->children_start_char );
434 # Don't show articles section if there are none.
437 # @todo FIXME: Here and in the other two sections: we don't need to bother
438 # with this rigmarole if the entire category contents fit on one page
439 # and have already been retrieved. We can just use $rescnt in that
440 # case and save a query and some logic.
441 $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
442 - $this->cat->getFileCount();
443 $rescnt =
count( $this->articles );
448 $r =
"<div id=\"mw-pages\">\n";
449 $r .=
'<h2>' . $this->
msg(
'category_header', $ti )->parse() .
"</h2>\n";
452 $r .= $this->
formatList( $this->articles, $this->articles_start_char );
464 $rescnt = $this->showGallery ? $this->gallery->count() :
count( $this->imgsNoGallery );
465 $dbcnt = $this->cat->getFileCount();
470 $r .=
"<div id=\"mw-category-media\">\n";
473 'category-media-header',
479 if ( $this->showGallery ) {
480 $r .= $this->gallery->toHTML();
482 $r .= $this->
formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
498 if ( isset( $this->until[
$type] ) && $this->until[
$type] !==
null ) {
503 if ( $this->nextPage[
$type] !==
null ) {
510 } elseif ( $this->nextPage[
$type] !==
null
511 || ( isset( $this->
from[$type] ) && $this->
from[$type] !==
null )
545 $pageLang = $this->
title->getPageLanguage();
546 $attribs = [
'lang' => $pageLang->getHtmlCode(),
'dir' => $pageLang->getDir(),
547 'class' =>
'mw-content-' . $pageLang->getDir() ];
574 # Kind of like array_flip() here, but we keep duplicates in an
575 # array instead of dropping them.
577 if ( !isset( $colContents[$char] ) ) {
578 $colContents[$char] = [];
584 # Change space to non-breaking space to keep headers aligned
585 $h3char = $char ===
' ' ?
' ' : htmlspecialchars( $char );
587 $ret .=
'<div class="mw-category-group"><h3>' . $h3char;
592 $ret .=
'</li></ul></div>';
610 $r .=
'<ul><li>' .
$articles[0] .
'</li>';
612 for ( $index = 1; $index < $articleCount; $index++ ) {
617 $r .=
"<li>{$articles[$index]}</li>";
633 $prevLink = $this->
msg(
'prev-page' )->text();
635 $linkRenderer = MediaWikiServices::getInstance()->getLinkRenderer();
636 if ( $first !=
'' ) {
638 $prevQuery[
"{$type}until"] = $first;
639 unset( $prevQuery[
"{$type}from"] );
648 $nextLink = $this->
msg(
'next-page' )->text();
652 $lastQuery[
"{$type}from"] =
$last;
653 unset( $lastQuery[
"{$type}until"] );
662 return $this->
msg(
'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
677 $fragment =
'mw-pages';
680 $fragment =
'mw-subcategories';
683 $fragment =
'mw-category-media';
687 " Invalid section $section." );
719 if (
$type ===
'article' ) {
720 $pagingType =
'page';
725 $fromOrUntil =
false;
726 if ( ( isset( $this->
from[$pagingType] ) && $this->
from[$pagingType] !==
null ) ||
727 ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !==
null )
732 if ( $dbcnt == $rescnt ||
733 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
737 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
748 return $this->
msg(
"category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
751 return $this->
msg(
"category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
array $query
The original query array, to be used in generating paging links.
getConfig()
Get the Config object.
static shortList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a bullet list.
ImageGalleryBase $gallery
getContext()
Get the base IContextSource object.
Marks HTML that shouldn't be escaped.
processing should stop and the error should be shown to the user * false
msg()
Get a Message object with context set Parameters are the same as wfMessage()
if(!isset( $args[0])) $lang
addFragmentToTitle( $title, $section)
Takes a title, and adds the fragment identifier that corresponds to the correct segment of the catego...
Category objects are immutable, strictly speaking.
static columnList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a three-column list, ordered vertically.
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
getCountMessage( $rescnt, $dbcnt, $type)
What to do if the category table conflicts with the number of results returned? This function says wh...
getPrefixedText()
Get the prefixed title with spaces.
getSubcategorySortChar( $title, $sortkey)
Get the character to be used for sorting subcategories.
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
getRequest()
Get the WebRequest object.
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 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
array $imgsNoGallery_start_char
static getSelectFields()
Fields that LinkCache needs to select.
__construct( $title, IContextSource $context, $from=[], $until=[], $query=[])
formatList( $articles, $articles_start_char, $cutoff=6)
Format a list of articles chunked by letter, either as a bullet list or a columnar format,...
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
getLanguage()
Get the Language object.
Category $cat
Category object for this page.
static closeElement( $element)
Returns "</$element>".
getSectionPagingLinks( $type)
Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output.
static addCallableUpdate( $callable, $stage=self::POSTSEND, IDatabase $dbw=null)
Add a callable update.
getDBkey()
Get the main part with underscores.
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
array $articles_start_char
getNamespace()
Get the namespace index, i.e.
static newFromRow( $row)
Make a Title object from a DB row.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
getCategorySortkey( $prefix='')
Returns the raw sort key to be used for categories, with the specified prefix.
getOutput()
Get the OutputPage object.
The simplest way of implementing IContextSource is to hold a RequestContext as a member variable and ...
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
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
when a variable name is used in a it is silently declared as a new masking the global
addSubcategoryObject(Category $cat, $sortkey, $pageLength)
Add a subcategory to the internal lists, using a Category object.
setContext(IContextSource $context)
Set the IContextSource object.
static newFromRow( $row, $title=null)
Factory function, for constructing a Category object from a result set.
getHTML()
Format the category data list.
static newFromTitle( $title)
Factory function.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
generateLink( $type, Title $title, $isRedirect, $html=null)
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
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
Interface for objects which can provide a MediaWiki context on request.
Represents a title within MediaWiki.
isRedirect( $flags=0)
Is this an article that is a redirect page? Uses link cache, adding it if necessary.
pagingLinks( $first, $last, $type='')
Create paging links, as a helper method to getSectionPagingLinks().
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
getConfig()
Get the site configuration.
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
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
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
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
usually copyright or history_copyright This message must be in HTML not wikitext & $link
static factory( $mode=false, IContextSource $context=null)
Get a new image gallery.
addPage( $title, $sortkey, $pageLength, $isRedirect=false)
Add a miscellaneous page.
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
array $children_start_char
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
addImage(Title $title, $sortkey, $pageLength, $isRedirect=false)
Add a page in the image namespace.
getText()
Get the text form (spaces not underscores) of the main part.
the array() calling protocol came about after MediaWiki 1.4rc1.
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 content language as $wgContLang