Type check the APC value in LoadBalancer::doWait()
[mediawiki.git] / includes / specials / SpecialTrackingCategories.php
blobe503d92b41c0f14c38eaa9c243e5211ec56d03cc
1 <?php
2 /**
3 * Implements Special:TrackingCategories
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * A special page that displays list of tracking categories
26 * Tracking categories allow pages with certain characteristics to be tracked.
27 * It works by adding any such page to a category automatically.
28 * Category is specified by the tracking category's system message.
30 * @ingroup SpecialPage
31 * @since 1.23
34 class SpecialTrackingCategories extends SpecialPage {
35 function __construct() {
36 parent::__construct( 'TrackingCategories' );
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>"
59 $trackingCategories = new TrackingCategories( $this->getConfig() );
60 $categoryList = $trackingCategories->getTrackingCategories();
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 );
69 $batch->execute();
71 Hooks::run( 'SpecialTrackingCategories::preprocess', [ $this, $categoryList ] );
73 $linkRenderer = $this->getLinkRenderer();
75 foreach ( $categoryList as $catMsg => $data ) {
76 $allMsgs = [];
77 $catDesc = $catMsg . '-desc';
79 $catMsgTitleText = $linkRenderer->makeLink(
80 $data['msg'],
81 $catMsg
84 foreach ( $data['cats'] as $catTitle ) {
85 $html = $linkRenderer->makeLink(
86 $catTitle,
87 $catTitle->getText()
90 Hooks::run( 'SpecialTrackingCategories::generateCatLink',
91 [ $this, $catTitle, &$html ] );
93 $allMsgs[] = $html;
96 # Extra message, when no category was found
97 if ( !count( $allMsgs ) ) {
98 $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
102 * Show category description if it exists as a system message
103 * as category-name-desc
105 $descMsg = $this->msg( $catDesc );
106 if ( $descMsg->isBlank() ) {
107 $descMsg = $this->msg( 'trackingcategories-nodesc' );
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' )
124 $this->getOutput()->addHTML( Html::closeElement( 'table' ) );
127 protected function getGroupName() {
128 return 'pages';