Go to the documentation of this file.
82 global $wgCategoryPagingLimit;
87 $this->limit = $wgCategoryPagingLimit;
91 unset( $this->
query[
'title'] );
100 global $wgCategoryMagicGallery;
103 $this->showGallery = $wgCategoryMagicGallery && !$this->
getOutput()->mNoGallery;
128 $r = $this->
msg(
'category-empty' )->parseAsBlock();
132 $langAttribs =
array(
'lang' => $lang->getCode(),
'dir' => $lang->getDir() );
133 # put a div around the headings which are in the user language
141 $this->articles =
array();
142 $this->articles_start_char =
array();
143 $this->children =
array();
144 $this->children_start_char =
array();
145 if ( $this->showGallery ) {
147 $mode = $this->
getRequest()->getVal(
'gallerymode',
null );
155 $this->gallery->setHideBadImages();
156 $this->gallery->setContext( $this->
getContext() );
158 $this->imgsNoGallery =
array();
159 $this->imgsNoGallery_start_char =
array();
178 $link =
'<span class="redirect-in-category">' .
$link .
'</span>';
180 $this->children[] =
$link;
182 $this->children_start_char[] =
206 $firstChar = $this->collation->getFirstLetter( $word );
220 if ( $this->showGallery ) {
221 $flip = $this->flip[
'file'];
223 $this->gallery->insert(
$title );
225 $this->gallery->add(
$title );
232 $link =
'<span class="redirect-in-category">' .
$link .
'</span>';
234 $this->imgsNoGallery[] =
$link;
236 $this->imgsNoGallery_start_char[] =
$wgContLang->convert(
237 $this->collation->getFirstLetter( $sortkey ) );
248 function addPage(
$title, $sortkey, $pageLength, $isRedirect =
false ) {
255 $link =
'<span class="redirect-in-category">' .
$link .
'</span>';
257 $this->articles[] =
$link;
259 $this->articles_start_char[] =
$wgContLang->convert(
260 $this->collation->getFirstLetter( $sortkey ) );
264 if ( $this->flip[
'subcat'] ) {
265 $this->children = array_reverse( $this->children );
266 $this->children_start_char = array_reverse( $this->children_start_char );
268 if ( $this->flip[
'page'] ) {
269 $this->articles = array_reverse( $this->articles );
270 $this->articles_start_char = array_reverse( $this->articles_start_char );
272 if ( !$this->showGallery && $this->flip[
'file'] ) {
273 $this->imgsNoGallery = array_reverse( $this->imgsNoGallery );
274 $this->imgsNoGallery_start_char = array_reverse( $this->imgsNoGallery_start_char );
281 $this->nextPage =
array(
286 $this->flip =
array(
'page' =>
false,
'subcat' =>
false,
'file' =>
false );
288 foreach (
array(
'page',
'subcat',
'file' )
as $type ) {
289 # Get the sortkeys for start/end, if applicable. Note that if
290 # the collation in the database differs from the one
291 # set in $wgCategoryCollation, pagination might go totally haywire.
293 if ( isset( $this->
from[$type] ) && $this->
from[$type] !==
null ) {
294 $extraConds[] =
'cl_sortkey >= '
295 .
$dbr->addQuotes( $this->collation->getSortKey( $this->from[
$type] ) );
296 } elseif ( isset( $this->until[
$type] ) && $this->until[
$type] !==
null ) {
297 $extraConds[] =
'cl_sortkey < '
298 .
$dbr->addQuotes( $this->collation->getSortKey( $this->until[
$type] ) );
299 $this->flip[
$type] =
true;
303 array(
'page',
'categorylinks',
'category' ),
304 array(
'page_id',
'page_title',
'page_namespace',
'page_len',
305 'page_is_redirect',
'cl_sortkey',
'cat_id',
'cat_title',
306 'cat_subcats',
'cat_pages',
'cat_files',
307 'cl_sortkey_prefix',
'cl_collation' ),
308 array_merge(
array(
'cl_to' => $this->
title->getDBkey() ), $extraConds ),
311 'USE INDEX' =>
array(
'categorylinks' =>
'cl_sortkey' ),
312 'LIMIT' => $this->limit + 1,
313 'ORDER BY' => $this->flip[
$type] ?
'cl_sortkey DESC' :
'cl_sortkey',
316 'categorylinks' =>
array(
'INNER JOIN',
'cl_from = page_id' ),
318 'cat_title = page_title',
325 foreach (
$res as $row ) {
327 if ( $row->cl_collation ===
'' ) {
331 $humanSortkey = $row->cl_sortkey;
336 if ( ++
$count > $this->limit ) {
337 # We've reached the one extra which shows that there
338 # are additional pages to be had. Stop here...
339 $this->nextPage[
$type] = $humanSortkey;
347 $this->
addImage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
349 $this->
addPage( $title, $humanSortkey, $row->page_len, $row->page_is_redirect );
362 :
"<br style=\"clear:both;\"/>\n" . $r;
369 # Don't show subcategories section if there are none.
371 $rescnt = count( $this->children );
372 $dbcnt = $this->cat->getSubcatCount();
376 # Showing subcategories
377 $r .=
"<div id=\"mw-subcategories\">\n";
378 $r .=
'<h2>' . $this->
msg(
'subcategories' )->text() .
"</h2>\n";
381 $r .= $this->
formatList( $this->children, $this->children_start_char );
393 # Don't show articles section if there are none.
396 # @todo FIXME: Here and in the other two sections: we don't need to bother
397 # with this rigmarole if the entire category contents fit on one page
398 # and have already been retrieved. We can just use $rescnt in that
399 # case and save a query and some logic.
400 $dbcnt = $this->cat->getPageCount() - $this->cat->getSubcatCount()
401 - $this->cat->getFileCount();
402 $rescnt = count( $this->articles );
406 $r =
"<div id=\"mw-pages\">\n";
407 $r .=
'<h2>' . $this->
msg(
'category_header', $ti )->text() .
"</h2>\n";
410 $r .= $this->
formatList( $this->articles, $this->articles_start_char );
422 $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery );
424 $dbcnt = $this->cat->getFileCount();
427 $r .=
"<div id=\"mw-category-media\">\n";
430 'category-media-header',
436 if ( $this->showGallery ) {
437 $r .= $this->gallery->toHTML();
439 $r .= $this->
formatList( $this->imgsNoGallery, $this->imgsNoGallery_start_char );
455 if ( isset( $this->until[
$type] ) && $this->until[
$type] !==
null ) {
457 } elseif ( $this->nextPage[
$type] !==
null
458 || ( isset( $this->
from[$type] ) && $this->
from[$type] !==
null )
492 $pageLang = $this->
title->getPageLanguage();
493 $attribs =
array(
'lang' => $pageLang->getCode(),
'dir' => $pageLang->getDir(),
494 'class' =>
'mw-content-' . $pageLang->getDir() );
517 # Split into three columns
520 $ret =
'<table style="width: 100%;"><tr style="vertical-align: top;">';
524 $ret .=
'<td style="width: 33.3%;">';
525 $colContents =
array();
527 # Kind of like array_flip() here, but we keep duplicates in an
528 # array instead of dropping them.
530 if ( !isset( $colContents[$char] ) ) {
531 $colContents[$char] =
array();
538 # Change space to non-breaking space to keep headers aligned
539 $h3char = $char ===
' ' ?
' ' : htmlspecialchars( $char );
541 $ret .=
'<h3>' . $h3char;
542 if ( $first && $char === $prevchar ) {
543 # We're continuing a previous chunk at the top of a new
544 # column, so add " cont." after the letter.
545 $ret .=
' ' .
wfMessage(
'listingcontinuesabbrev' )->escaped();
551 $ret .=
'</li></ul>';
560 $ret .=
'</tr></table>';
573 $r .=
'<ul><li>' .
$articles[0] .
'</li>';
575 for ( $index = 1; $index < $articleCount; $index++ ) {
580 $r .=
"<li>{$articles[$index]}</li>";
596 $prevLink = $this->
msg(
'prevn' )->numParams( $this->limit )->escaped();
598 if ( $first !=
'' ) {
600 $prevQuery[
"{$type}until"] = $first;
601 unset( $prevQuery[
"{$type}from"] );
610 $nextLink = $this->
msg(
'nextn' )->numParams( $this->limit )->escaped();
614 $lastQuery[
"{$type}from"] =
$last;
615 unset( $lastQuery[
"{$type}until"] );
624 return $this->
msg(
'categoryviewer-pagedlinks' )->rawParams( $prevLink, $nextLink )->escaped();
639 $fragment =
'mw-pages';
642 $fragment =
'mw-subcategories';
645 $fragment =
'mw-category-media';
649 " Invalid section $section." );
681 if (
$type ===
'article' ) {
682 $pagingType =
'page';
687 $fromOrUntil =
false;
688 if ( ( isset( $this->
from[$pagingType] ) && $this->
from[$pagingType] !==
null ) ||
689 ( isset( $this->until[$pagingType] ) && $this->until[$pagingType] !==
null )
694 if ( $dbcnt == $rescnt ||
695 ( ( $rescnt == $this->limit || $fromOrUntil ) && $dbcnt > $rescnt )
699 } elseif ( $rescnt < $this->limit && !$fromOrUntil ) {
705 $this->cat->refreshCounts();
710 return $this->
msg(
"category-$type-count-limited" )->numParams( $rescnt )->parseAsBlock();
713 return $this->
msg(
"category-$type-count" )->numParams( $rescnt, $totalcnt )->parseAsBlock();
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.
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
getContext()
Get the RequestContext object.
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
msg()
Get a Message object with context set Parameters are the same as wfMessage()
& wfGetDB( $db, $groups=array(), $wiki=false)
Get a Database object.
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.
wfProfileIn( $functionname)
Begin profiling of a function.
static columnList( $articles, $articles_start_char)
Format a list of articles chunked by letter in a three-column list, ordered vertically.
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
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.
static factory( $mode=false)
Get a new image gallery.
getSubcategorySortChar( $title, $sortkey)
Get the character to be used for sorting subcategories.
getRequest()
Get the WebRequest object.
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
set to $title object and return false for a match for latest after cache objects are set use the ContentHandler facility to handle CSS and JavaScript for highlighting & $link
static linkKnown( $target, $html=null, $customAttribs=array(), $query=array(), $options=array( 'known', 'noclasses'))
Identical to link(), except $options defaults to 'known'.
formatList( $articles, $articles_start_char, $cutoff=6)
Format a list of articles chunked by letter, either as a bullet list or a columnar format,...
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
getLanguage()
Get the Language object.
Category $cat
Category object for this page.
to move a page</td >< td > &*You are moving the page across *A non empty talk page already exists under the new or *You uncheck the box below In those you will have to move or merge the page manually if desired</td >< td > be sure to &You are responsible for making sure that links continue to point where they are supposed to go Note that the page will &a page at the new title
getSectionPagingLinks( $type)
Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output.
static openElement( $element, $attribs=array())
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
getDBkey()
Get the main part with underscores.
getNamespace()
Get the namespace index, i.e.
static newFromRow( $row)
Make a Title object from a DB row.
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 ...
wfProfileOut( $functionname='missing')
Stop profiling of a 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 after in associative array form externallinks including delete and has completed for all link tables default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
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.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Interface for objects which can provide a context on request.
$imgsNoGallery_start_char
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().
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
Please log in again after you receive it</td >< td > s a saved copy from
addPage( $title, $sortkey, $pageLength, $isRedirect=false)
Add a miscellaneous page.
static rawElement( $element, $attribs=array(), $contents='')
Returns an HTML element in a string.
__construct( $title, IContextSource $context, $from=array(), $until=array(), $query=array())
Constructor.
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
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
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.