MediaWiki REL1_31
SpecialTrackingCategories.php
Go to the documentation of this file.
1<?php
35 function __construct() {
36 parent::__construct( 'TrackingCategories' );
37 }
38
39 function execute( $par ) {
40 $this->setHeaders();
41 $this->outputHeader();
42 $this->getOutput()->allowClickjacking();
43 $this->getOutput()->addHTML(
44 Html::openElement( 'table', [ 'class' => 'mw-datatable',
45 'id' => 'mw-trackingcategories-table' ] ) . "\n" .
46 "<thead><tr>
47 <th>" .
48 $this->msg( 'trackingcategories-msg' )->escaped() . "
49 </th>
50 <th>" .
51 $this->msg( 'trackingcategories-name' )->escaped() .
52 "</th>
53 <th>" .
54 $this->msg( 'trackingcategories-desc' )->escaped() . "
55 </th>
56 </tr></thead>"
57 );
58
59 $trackingCategories = new TrackingCategories( $this->getConfig() );
60 $categoryList = $trackingCategories->getTrackingCategories();
61
62 $batch = new LinkBatch();
63 foreach ( $categoryList as $catMsg => $data ) {
64 $batch->addObj( $data['msg'] );
65 foreach ( $data['cats'] as $catTitle ) {
66 $batch->addObj( $catTitle );
67 }
68 }
69 $batch->execute();
70
71 Hooks::run( 'SpecialTrackingCategories::preprocess', [ $this, $categoryList ] );
72
74
75 foreach ( $categoryList as $catMsg => $data ) {
76 $allMsgs = [];
77 $catDesc = $catMsg . '-desc';
78
79 $catMsgTitleText = $linkRenderer->makeLink(
80 $data['msg'],
81 $catMsg
82 );
83
84 foreach ( $data['cats'] as $catTitle ) {
85 $html = $linkRenderer->makeLink(
86 $catTitle,
87 $catTitle->getText()
88 );
89
90 Hooks::run( 'SpecialTrackingCategories::generateCatLink',
91 [ $this, $catTitle, &$html ] );
92
93 $allMsgs[] = $html;
94 }
95
96 # Extra message, when no category was found
97 if ( !count( $allMsgs ) ) {
98 $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
99 }
100
101 /*
102 * Show category description if it exists as a system message
103 * as category-name-desc
104 */
105 $descMsg = $this->msg( $catDesc );
106 if ( $descMsg->isBlank() ) {
107 $descMsg = $this->msg( 'trackingcategories-nodesc' );
108 }
109
110 $this->getOutput()->addHTML(
111 Html::openElement( 'tr' ) .
112 Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-name' ] ) .
113 $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
114 Html::closeElement( 'td' ) .
115 Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-msg' ] ) .
116 $catMsgTitleText .
117 Html::closeElement( 'td' ) .
118 Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-desc' ] ) .
119 $descMsg->parse() .
120 Html::closeElement( 'td' ) .
121 Html::closeElement( 'tr' )
122 );
123 }
124 $this->getOutput()->addHTML( Html::closeElement( 'table' ) );
125 }
126
127 protected function getGroupName() {
128 return 'pages';
129 }
130}
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition LinkBatch.php:34
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
MediaWiki Linker LinkRenderer null $linkRenderer
A special page that displays list of tracking categories Tracking categories allow pages with certain...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
execute( $par)
Default execute method Checks user permissions.
This class performs some operations related to tracking categories, such as creating a list of all su...
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
Definition hooks.txt:2013
$batch
Definition linkcache.txt:23