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
21 * @ingroup SpecialPage
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
34 class SpecialTrackingCategories
extends SpecialPage
{
35 function __construct() {
36 parent
::__construct( 'TrackingCategories' );
39 function execute( $par ) {
40 // Global array containing names of tracking categories
41 global $wgTrackingCategories;
44 $this->outputHeader();
45 $this->getOutput()->allowClickjacking();
46 $this->getOutput()->addHTML(
47 Html
::openElement( 'table', array( 'class' => 'mw-datatable TablePager',
48 'id' => 'mw-trackingcategories-table' ) ) . "\n" .
51 $this->msg( 'trackingcategories-msg' )->escaped() . "
54 $this->msg( 'trackingcategories-name' )->escaped() .
57 $this->msg( 'trackingcategories-desc' )->escaped() . "
62 foreach( $wgTrackingCategories as $catMsg ) {
64 * Check if the tracking category varies by namespace
65 * Otherwise only pages in the current namespace will be displayed
66 * If it does vary, show pages considering all namespaces
68 $msgObj = $this->msg( $catMsg )->inContentLanguage();
70 $catDesc = $catMsg . '-desc';
71 $catMsgTitle = Title
::makeTitleSafe( NS_MEDIAWIKI
, $catMsg );
72 $catMsgTitleText = Linker
::link(
74 htmlspecialchars( $catMsg )
77 if ( strpos( $msgObj->plain(), '{{NAMESPACE}}' ) !== false ) {
78 $ns = MWNamespace
::getValidNamespaces();
79 foreach ( $ns as $namesp ) {
80 $tempTitle = Title
::makeTitleSafe( $namesp, $catMsg );
81 $catName = $msgObj->title( $tempTitle )->text();
82 if ( !$msgObj->isDisabled() ) {
83 $catTitle = Title
::makeTitleSafe( NS_CATEGORY
, $catName );
84 $catTitleText = Linker
::link(
86 htmlspecialchars( $catName )
88 $allMsgs[] = $catTitleText;
92 $catName = $msgObj->text();
93 if ( !$msgObj->isDisabled() ) {
94 $catTitle = Title
::makeTitleSafe( NS_CATEGORY
, $catName );
95 $catTitleText = Linker
::link(
97 htmlspecialchars( $catName )
100 $catTitleText = $this->msg( 'trackingcategories-disabled' )->parse();
102 $allMsgs[] = $catTitleText;
106 * Show category description if it exists as a system message
107 * as category-name-desc
109 $descMsg = $this->msg( $catDesc );
110 if ( $descMsg->isBlank() ) {
111 $descMsg = $this->msg( 'trackingcategories-nodesc' );
114 $this->getOutput()->addHTML(
115 Html
::openElement( 'tr' ) .
116 Html
::openElement( 'td', array( 'class' => 'mw-trackingcategories-name' ) ) .
117 $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
118 Html
::closeElement( 'td' ) .
119 Html
::openElement( 'td', array( 'class' => 'mw-trackingcategories-msg' ) ) .
121 Html
::closeElement( 'td' ) .
122 Html
::openElement( 'td', array( 'class' => 'mw-trackingcategories-desc' ) ) .
124 Html
::closeElement( 'td' ) .
125 Html
::closeElement( 'tr' )
128 $this->getOutput()->addHTML( Html
::closeElement( 'table' ) );
131 protected function getGroupName() {