MediaWiki  master
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...
 
 getHTML ()
 Format the category data list. More...
 
 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...
 
 getAuthority ()
 
 getConfig ()
 
 getContext ()
 Get the base IContextSource object. More...
 
 getLanguage ()
 
 getOutput ()
 
 getRequest ()
 
 getSkin ()
 
 getStats ()
 
 getTiming ()
 
 getTitle ()
 
 getUser ()
 
 getWikiPage ()
 Get the WikiPage object. More...
 
 msg ( $key,... $params)
 Get a Message object with context set Parameters are the same as wfMessage() More...
 
 setContext (IContextSource $context)
 

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
 
ImageGalleryBase $gallery
 
array $imgsNoGallery
 
array $imgsNoGallery_start_char
 
int $limit
 
array $nextPage
 
bool $showGallery
 
Title $title
 
array $until
 

Protected Member Functions

 clearCategoryState ()
 
 doCategoryQuery ()
 
 finaliseCategoryState ()
 
 getCategoryBottom ()
 
 getCategoryTop ()
 
 getImageSection ()
 
 getPagesSection ()
 
 getSubcategorySection ()
 

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...
 
 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)
 
 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...
 
ILanguageConverter $languageConverter
 
array $query
 The original query array, to be used in generating paging links. More...
 

Detailed Description

Definition at line 26 of file CategoryViewer.php.

Constructor & Destructor Documentation

◆ __construct()

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 95 of file CategoryViewer.php.

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

Member Function Documentation

◆ addFragmentToTitle()

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 684 of file CategoryViewer.php.

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

Referenced by pagingLinks().

◆ addImage()

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 262 of file CategoryViewer.php.

References $flip, $title, and generateLink().

Referenced by doCategoryQuery().

◆ addPage()

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

Add a miscellaneous page.

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

Definition at line 285 of file CategoryViewer.php.

References generateLink().

Referenced by doCategoryQuery().

◆ addSubcategoryObject()

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 189 of file CategoryViewer.php.

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

Referenced by doCategoryQuery().

◆ clearCategoryState()

CategoryViewer::clearCategoryState ( )
protected

◆ columnList()

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[]$articlesHTML links to each article
string[]$articles_start_charThe header characters for each article
Returns
string HTML to output
Access: internal

Definition at line 577 of file CategoryViewer.php.

References $articles, $articles_start_char, Html\closeElement(), and Html\openElement().

Referenced by formatList().

◆ doCategoryQuery()

◆ finaliseCategoryState()

CategoryViewer::finaliseCategoryState ( )
protected

Definition at line 292 of file CategoryViewer.php.

Referenced by getHTML().

◆ formatList()

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

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: internal

Definition at line 546 of file CategoryViewer.php.

References $articles, $articles_start_char, columnList(), Html\rawElement(), and shortList().

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

◆ generateLink()

CategoryViewer::generateLink (   $type,
Title  $title,
  $isRedirect,
  $html = null 
)
private
Parameters
string$type
Title$title
bool$isRedirect
string | null$html
Returns
string Annotations needed to tell taint about HtmlArmor, due to the use of the hook it is not possible to avoid raw html handling here
Parameters
-taint$htmltainted
Returns
-taint escaped

Definition at line 215 of file CategoryViewer.php.

References $title, and $type.

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

◆ getCategoryBottom()

CategoryViewer::getCategoryBottom ( )
protected
Returns
string

Definition at line 532 of file CategoryViewer.php.

Referenced by getCategoryTop(), and getHTML().

◆ getCategoryTop()

CategoryViewer::getCategoryTop ( )
protected
Returns
string

Definition at line 412 of file CategoryViewer.php.

References getCategoryBottom().

Referenced by getHTML().

◆ getCountMessage()

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 714 of file CategoryViewer.php.

References $type, and ContextSource\msg().

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

◆ getHTML()

◆ getImageSection()

CategoryViewer::getImageSection ( )
protected
Returns
string

Definition at line 476 of file CategoryViewer.php.

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

Referenced by getHTML().

◆ getPagesSection()

CategoryViewer::getPagesSection ( )
protected
Returns
string

Definition at line 446 of file CategoryViewer.php.

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

Referenced by getHTML().

◆ getSectionPagingLinks()

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 509 of file CategoryViewer.php.

References $type, and pagingLinks().

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

◆ getSubcategorySection()

CategoryViewer::getSubcategorySection ( )
protected
Returns
string

Definition at line 422 of file CategoryViewer.php.

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

Referenced by getHTML().

◆ getSubcategorySortChar()

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 243 of file CategoryViewer.php.

References $title, Title\getDBkey(), and Title\getPrefixedText().

Referenced by addSubcategoryObject().

◆ pagingLinks()

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 642 of file CategoryViewer.php.

References $query, $type, addFragmentToTitle(), and ContextSource\msg().

Referenced by getSectionPagingLinks().

◆ shortList()

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[]$articlesHTML links to each article
string[]$articles_start_charThe header characters for each article
Returns
string HTML to output
Access: internal

Definition at line 618 of file CategoryViewer.php.

References $articles, and $articles_start_char.

Referenced by formatList().

Member Data Documentation

◆ $articles

string [] CategoryViewer::$articles

Definition at line 39 of file CategoryViewer.php.

Referenced by columnList(), formatList(), and shortList().

◆ $articles_start_char

array CategoryViewer::$articles_start_char

Definition at line 42 of file CategoryViewer.php.

Referenced by columnList(), formatList(), and shortList().

◆ $cat

Category CategoryViewer::$cat
private

Category object for this page.

Definition at line 78 of file CategoryViewer.php.

Referenced by addSubcategoryObject(), and doCategoryQuery().

◆ $children

array CategoryViewer::$children

Definition at line 45 of file CategoryViewer.php.

◆ $children_start_char

array CategoryViewer::$children_start_char

Definition at line 48 of file CategoryViewer.php.

◆ $collation

Collation CategoryViewer::$collation

Definition at line 72 of file CategoryViewer.php.

◆ $flip

array CategoryViewer::$flip

Definition at line 66 of file CategoryViewer.php.

Referenced by addImage().

◆ $from

array CategoryViewer::$from

Definition at line 33 of file CategoryViewer.php.

Referenced by __construct().

◆ $gallery

ImageGalleryBase CategoryViewer::$gallery

Definition at line 75 of file CategoryViewer.php.

◆ $imgsNoGallery

array CategoryViewer::$imgsNoGallery

Definition at line 57 of file CategoryViewer.php.

◆ $imgsNoGallery_start_char

array CategoryViewer::$imgsNoGallery_start_char

Definition at line 54 of file CategoryViewer.php.

◆ $languageConverter

ILanguageConverter CategoryViewer::$languageConverter
private

Definition at line 84 of file CategoryViewer.php.

◆ $limit

int CategoryViewer::$limit

Definition at line 30 of file CategoryViewer.php.

◆ $nextPage

array CategoryViewer::$nextPage

Definition at line 60 of file CategoryViewer.php.

◆ $prevPage

array CategoryViewer::$prevPage
protected

Definition at line 63 of file CategoryViewer.php.

◆ $query

array CategoryViewer::$query
private

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

Definition at line 81 of file CategoryViewer.php.

Referenced by __construct(), and pagingLinks().

◆ $showGallery

bool CategoryViewer::$showGallery

Definition at line 51 of file CategoryViewer.php.

◆ $title

◆ $until

array CategoryViewer::$until

Definition at line 36 of file CategoryViewer.php.

Referenced by __construct().


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