MediaWiki REL1_34
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->addHelpLink( 'Help:Categories' );
43 $this->getOutput()->allowClickjacking();
44 $this->getOutput()->addModuleStyles( 'jquery.tablesorter.styles' );
45 $this->getOutput()->addModules( 'jquery.tablesorter' );
46 $this->getOutput()->addHTML(
47 Html::openElement( 'table', [ 'class' => 'mw-datatable sortable',
48 'id' => 'mw-trackingcategories-table' ] ) . "\n" .
49 "<thead><tr>
50 <th>" .
51 $this->msg( 'trackingcategories-msg' )->escaped() . "
52 </th>
53 <th>" .
54 $this->msg( 'trackingcategories-name' )->escaped() .
55 "</th>
56 <th>" .
57 $this->msg( 'trackingcategories-desc' )->escaped() . "
58 </th>
59 </tr></thead>"
60 );
61
62 $trackingCategories = new TrackingCategories( $this->getConfig() );
63 $categoryList = $trackingCategories->getTrackingCategories();
64
65 $batch = new LinkBatch();
66 foreach ( $categoryList as $catMsg => $data ) {
67 $batch->addObj( $data['msg'] );
68 foreach ( $data['cats'] as $catTitle ) {
69 $batch->addObj( $catTitle );
70 }
71 }
72 $batch->execute();
73
74 Hooks::run( 'SpecialTrackingCategories::preprocess', [ $this, $categoryList ] );
75
77
78 foreach ( $categoryList as $catMsg => $data ) {
79 $allMsgs = [];
80 $catDesc = $catMsg . '-desc';
81
82 $catMsgTitleText = $linkRenderer->makeLink(
83 $data['msg'],
84 $catMsg
85 );
86
87 foreach ( $data['cats'] as $catTitle ) {
88 $html = $linkRenderer->makeLink(
89 $catTitle,
90 $catTitle->getText()
91 );
92
93 Hooks::run( 'SpecialTrackingCategories::generateCatLink',
94 [ $this, $catTitle, &$html ] );
95
96 $allMsgs[] = $html;
97 }
98
99 # Extra message, when no category was found
100 if ( $allMsgs === [] ) {
101 $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
102 }
103
104 /*
105 * Show category description if it exists as a system message
106 * as category-name-desc
107 */
108 $descMsg = $this->msg( $catDesc );
109 if ( $descMsg->isBlank() ) {
110 $descMsg = $this->msg( 'trackingcategories-nodesc' );
111 }
112
113 $this->getOutput()->addHTML(
114 Html::openElement( 'tr' ) .
115 Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-name' ] ) .
116 $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
117 Html::closeElement( 'td' ) .
118 Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-msg' ] ) .
119 $catMsgTitleText .
120 Html::closeElement( 'td' ) .
121 Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-desc' ] ) .
122 $descMsg->parse() .
123 Html::closeElement( 'td' ) .
124 Html::closeElement( 'tr' )
125 );
126 }
127 $this->getOutput()->addHTML( Html::closeElement( 'table' ) );
128 }
129
130 protected function getGroupName() {
131 return 'pages';
132 }
133}
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,... $params)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
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...