MediaWiki  1.28.0
CategoryViewer Class Reference
Inheritance diagram for CategoryViewer:
Collaboration diagram for CategoryViewer:

Public Member Functions

 __construct ($title, IContextSource $context, $from=[], $until=[], $query=[])
 
 addImage (Title $title, $sortkey, $pageLength, $isRedirect=false)
 Add a page in the image namespace. More...
 
 addPage ($title, $sortkey, $pageLength, $isRedirect=false)
 Add a miscellaneous page. More...
 
 addSubcategoryObject (Category $cat, $sortkey, $pageLength)
 Add a subcategory to the internal lists, using a Category object. More...
 
 clearCategoryState ()
 
 doCategoryQuery ()
 
 finaliseCategoryState ()
 
 formatList ($articles, $articles_start_char, $cutoff=6)
 Format a list of articles chunked by letter, either as a bullet list or a columnar format, depending on the length. More...
 
 generateLink ($type, Title $title, $isRedirect, $html=null)
 
 getCategoryBottom ()
 
 getCategoryTop ()
 
 getHTML ()
 Format the category data list. More...
 
 getImageSection ()
 
 getPagesSection ()
 
 getSubcategorySection ()
 
 getSubcategorySortChar ($title, $sortkey)
 Get the character to be used for sorting subcategories. More...
 
- Public Member Functions inherited from ContextSource
 canUseWikiPage ()
 Check whether a WikiPage object can be get with getWikiPage(). More...
 
 exportSession ()
 Export the resolved user IP, HTTP headers, user ID, and session ID. More...
 
 getConfig ()
 Get the Config object. More...
 
 getContext ()
 Get the base IContextSource object. More...
 
 getLanguage ()
 Get the Language object. More...
 
 getOutput ()
 Get the OutputPage object. More...
 
 getRequest ()
 Get the WebRequest object. More...
 
 getSkin ()
 Get the Skin object. More...
 
 getStats ()
 Get the Stats object. More...
 
 getTiming ()
 Get the Timing object. More...
 
 getTitle ()
 Get the Title object. More...
 
 getUser ()
 Get the User object. More...
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ()
 Get a Message object with context set Parameters are the same as wfMessage() More...
 
 setContext (IContextSource $context)
 Set the IContextSource object. More...
 

Static Public Member Functions

static columnList ($articles, $articles_start_char)
 Format a list of articles chunked by letter in a three-column list, ordered vertically. More...
 
static shortList ($articles, $articles_start_char)
 Format a list of articles chunked by letter in a bullet list. More...
 

Public Attributes

string[] $articles
 
array $articles_start_char
 
array $children
 
array $children_start_char
 
Collation $collation
 
array $flip
 
array $from
 
ImageGallery $gallery
 
array $imgsNoGallery
 
array $imgsNoGallery_start_char
 
int $limit
 
array $nextPage
 
bool $showGallery
 
Title $title
 
array $until
 

Protected Attributes

array $prevPage
 

Private Member Functions

 addFragmentToTitle ($title, $section)
 Takes a title, and adds the fragment identifier that corresponds to the correct segment of the category. More...
 
 getCountMessage ($rescnt, $dbcnt, $type)
 What to do if the category table conflicts with the number of results returned? This function says what. More...
 
 getSectionPagingLinks ($type)
 Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output. More...
 
 pagingLinks ($first, $last, $type= '')
 Create paging links, as a helper method to getSectionPagingLinks(). More...
 

Private Attributes

Category $cat
 Category object for this page. More...
 
array $query
 The original query array, to be used in generating paging links. More...
 

Detailed Description

Definition at line 24 of file CategoryViewer.php.

Constructor & Destructor Documentation

CategoryViewer::__construct (   $title,
IContextSource  $context,
  $from = [],
  $until = [],
  $query = [] 
)
Since
1.19 $context is a second, required parameter
Parameters
Title$title
IContextSource$context
array$fromAn array with keys page, subcat, and file for offset of results of each section (since 1.17)
array$untilAn array with 3 keys for until of each section (since 1.17)
array$query

Definition at line 88 of file CategoryViewer.php.

References $from, $query, $title, $until, from, IContextSource\getConfig(), ContextSource\getOutput(), Category\newFromTitle(), query, ContextSource\setContext(), Collation\singleton(), and title.

Member Function Documentation

CategoryViewer::addFragmentToTitle (   $title,
  $section 
)
private

Takes a title, and adds the fragment identifier that corresponds to the correct segment of the category.

Parameters
Title$titleThe title (usually $this->title)
string$sectionWhich section
Exceptions
MWException
Returns
Title

Definition at line 669 of file CategoryViewer.php.

References $section, Title\getDBkey(), Title\getNamespace(), and Title\makeTitle().

Referenced by pagingLinks().

CategoryViewer::addImage ( Title  $title,
  $sortkey,
  $pageLength,
  $isRedirect = false 
)

Add a page in the image namespace.

Parameters
Title$title
string$sortkey
int$pageLength
bool$isRedirect

Definition at line 241 of file CategoryViewer.php.

References $wgContLang, generateLink(), and global.

Referenced by doCategoryQuery().

CategoryViewer::addPage (   $title,
  $sortkey,
  $pageLength,
  $isRedirect = false 
)

Add a miscellaneous page.

Parameters
Title$title
string$sortkey
int$pageLength
bool$isRedirect

Definition at line 265 of file CategoryViewer.php.

References $wgContLang, generateLink(), and global.

Referenced by doCategoryQuery().

CategoryViewer::addSubcategoryObject ( Category  $cat,
  $sortkey,
  $pageLength 
)

Add a subcategory to the internal lists, using a Category object.

Parameters
Category$cat
string$sortkey
int$pageLength

Definition at line 181 of file CategoryViewer.php.

References generateLink(), getSubcategorySortChar(), Title\getText(), Category\getTitle(), and Title\isRedirect().

Referenced by doCategoryQuery().

CategoryViewer::clearCategoryState ( )
static CategoryViewer::columnList (   $articles,
  $articles_start_char 
)
static

Format a list of articles chunked by letter in a three-column list, ordered vertically.

This is used for categories with a significant number of pages.

TODO: Take the headers into account when creating columns, so they're more visually equal.

TODO: shortList and columnList are similar, need merging

Parameters
string[]$articles HTML links to each article
string[]$articles_start_char The header characters for each article
Returns
string HTML to output
Access:
private

Definition at line 563 of file CategoryViewer.php.

References $article, $ret, as, Html\closeElement(), and Html\openElement().

CategoryViewer::finaliseCategoryState ( )

Definition at line 274 of file CategoryViewer.php.

Referenced by getHTML().

CategoryViewer::formatList (   $articles,
  $articles_start_char,
  $cutoff = 6 
)

Format a list of articles chunked by letter, either as a bullet list or a columnar format, depending on the length.

Parameters
array$articles
array$articles_start_char
int$cutoff
Returns
string
Access:
private

Definition at line 532 of file CategoryViewer.php.

References $attribs, Html\rawElement(), and title.

Referenced by getImageSection(), getPagesSection(), and getSubcategorySection().

CategoryViewer::generateLink (   $type,
Title  $title,
  $isRedirect,
  $html = null 
)

Definition at line 196 of file CategoryViewer.php.

References $html, $link, $type, Linker\link(), and Hooks\run().

Referenced by addImage(), addPage(), and addSubcategoryObject().

CategoryViewer::getCategoryBottom ( )
Returns
string

Definition at line 518 of file CategoryViewer.php.

Referenced by getCategoryTop(), and getHTML().

CategoryViewer::getCategoryTop ( )
Returns
string

Definition at line 394 of file CategoryViewer.php.

References getCategoryBottom().

Referenced by getHTML().

CategoryViewer::getCountMessage (   $rescnt,
  $dbcnt,
  $type 
)
private

What to do if the category table conflicts with the number of results returned? This function says what.

Each type is considered independently of the other types.

Parameters
int$rescntThe number of items returned by our database query.
int$dbcntThe number of items according to the category table.
string$type'subcat', 'article', or 'file'
Returns
string A message giving the number of items, to output to HTML.

Definition at line 699 of file CategoryViewer.php.

References $cat, $type, DeferredUpdates\addCallableUpdate(), from, ContextSource\msg(), and use.

Referenced by getImageSection(), getPagesSection(), and getSubcategorySection().

CategoryViewer::getImageSection ( )
Returns
string

Definition at line 458 of file CategoryViewer.php.

References formatList(), getCountMessage(), getSectionPagingLinks(), ContextSource\msg(), title, and wfEscapeWikiText().

Referenced by getHTML().

CategoryViewer::getPagesSection ( )
Returns
string

Definition at line 428 of file CategoryViewer.php.

References formatList(), getCountMessage(), getSectionPagingLinks(), ContextSource\msg(), title, and wfEscapeWikiText().

Referenced by getHTML().

CategoryViewer::getSectionPagingLinks (   $type)
private

Get the paging links for a section (subcats/pages/files), to go at the top and bottom of the output.

Parameters
string$type'page', 'subcat', or 'file'
Returns
string HTML output, possibly empty if there are no other pages

Definition at line 493 of file CategoryViewer.php.

References $type, from, and pagingLinks().

Referenced by getImageSection(), getPagesSection(), and getSubcategorySection().

CategoryViewer::getSubcategorySection ( )
Returns
string

Definition at line 404 of file CategoryViewer.php.

References formatList(), getCountMessage(), getSectionPagingLinks(), and ContextSource\msg().

Referenced by getHTML().

CategoryViewer::getSubcategorySortChar (   $title,
  $sortkey 
)

Get the character to be used for sorting subcategories.

If there's a link from Category:A to Category:B, the sortkey of the resulting entry in the categorylinks table is Category:A, not A, which it SHOULD be. Workaround: If sortkey == "Category:".$title, than use $title for sorting, else use sortkey...

Parameters
Title$title
string$sortkeyThe human-readable sortkey (before transforming to icu or whatever).
Returns
string

Definition at line 220 of file CategoryViewer.php.

References $wgContLang, Title\getDBkey(), Title\getPrefixedText(), and global.

Referenced by addSubcategoryObject().

CategoryViewer::pagingLinks (   $first,
  $last,
  $type = '' 
)
private

Create paging links, as a helper method to getSectionPagingLinks().

Parameters
string$firstThe 'until' parameter for the generated URL
string$lastThe 'from' parameter for the generated URL
string$typeA prefix for parameters, 'page' or 'subcat' or 'file'
Returns
string HTML

Definition at line 628 of file CategoryViewer.php.

References $last, $query, $type, addFragmentToTitle(), Linker\linkKnown(), ContextSource\msg(), and title.

Referenced by getSectionPagingLinks().

static CategoryViewer::shortList (   $articles,
  $articles_start_char 
)
static

Format a list of articles chunked by letter in a bullet list.

This is used for categories with a small number of pages (when columns aren't needed).

Parameters
string[]$articles HTML links to each article
string[]$articles_start_char The header characters for each article
Returns
string HTML to output
Access:
private

Definition at line 604 of file CategoryViewer.php.

Member Data Documentation

string [] CategoryViewer::$articles

Definition at line 35 of file CategoryViewer.php.

array CategoryViewer::$articles_start_char

Definition at line 38 of file CategoryViewer.php.

Category CategoryViewer::$cat
private

Category object for this page.

Definition at line 74 of file CategoryViewer.php.

Referenced by getCountMessage().

array CategoryViewer::$children

Definition at line 41 of file CategoryViewer.php.

array CategoryViewer::$children_start_char

Definition at line 44 of file CategoryViewer.php.

Collation CategoryViewer::$collation

Definition at line 68 of file CategoryViewer.php.

array CategoryViewer::$flip

Definition at line 62 of file CategoryViewer.php.

array CategoryViewer::$from

Definition at line 29 of file CategoryViewer.php.

Referenced by __construct().

ImageGallery CategoryViewer::$gallery

Definition at line 71 of file CategoryViewer.php.

array CategoryViewer::$imgsNoGallery

Definition at line 53 of file CategoryViewer.php.

array CategoryViewer::$imgsNoGallery_start_char

Definition at line 50 of file CategoryViewer.php.

int CategoryViewer::$limit

Definition at line 26 of file CategoryViewer.php.

array CategoryViewer::$nextPage

Definition at line 56 of file CategoryViewer.php.

array CategoryViewer::$prevPage
protected

Definition at line 59 of file CategoryViewer.php.

array CategoryViewer::$query
private

The original query array, to be used in generating paging links.

Definition at line 77 of file CategoryViewer.php.

Referenced by __construct(), and pagingLinks().

bool CategoryViewer::$showGallery

Definition at line 47 of file CategoryViewer.php.

Title CategoryViewer::$title

Definition at line 65 of file CategoryViewer.php.

Referenced by __construct().

array CategoryViewer::$until

Definition at line 32 of file CategoryViewer.php.

Referenced by __construct().


The documentation for this class was generated from the following file: