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 ) {
41 $this->outputHeader();
42 $this->getOutput()->allowClickjacking();
43 $this->getOutput()->addHTML(
44 Html
::openElement( 'table', array( 'class' => 'mw-datatable',
45 'id' => 'mw-trackingcategories-table' ) ) . "\n" .
48 $this->msg( 'trackingcategories-msg' )->escaped() . "
51 $this->msg( 'trackingcategories-name' )->escaped() .
54 $this->msg( 'trackingcategories-desc' )->escaped() . "
59 foreach ( $this->getConfig()->get( 'TrackingCategories' ) as $catMsg ) {
61 * Check if the tracking category varies by namespace
62 * Otherwise only pages in the current namespace will be displayed
63 * If it does vary, show pages considering all namespaces
65 $msgObj = $this->msg( $catMsg )->inContentLanguage();
67 $catDesc = $catMsg . '-desc';
68 $catMsgTitle = Title
::makeTitleSafe( NS_MEDIAWIKI
, $catMsg );
69 if ( !$catMsgTitle ) {
72 $catMsgTitleText = Linker
::link(
74 htmlspecialchars( $catMsg )
77 // Match things like {{NAMESPACE}} and {{NAMESPACENUMBER}}.
78 // False positives are ok, this is just an efficiency shortcut
79 if ( strpos( $msgObj->plain(), '{{' ) !== false ) {
80 $ns = MWNamespace
::getValidNamespaces();
81 foreach ( $ns as $namesp ) {
82 $tempTitle = Title
::makeTitleSafe( $namesp, $catMsg );
86 $catName = $msgObj->title( $tempTitle )->text();
87 # Allow tracking categories to be disabled by setting them to "-"
88 if ( $catName !== '-' ) {
89 $catTitle = Title
::makeTitleSafe( NS_CATEGORY
, $catName );
91 $catTitleText = Linker
::link(
93 htmlspecialchars( $catName )
95 $allMsgs[] = $catTitleText;
100 $catName = $msgObj->text();
101 # Allow tracking categories to be disabled by setting them to "-"
102 if ( $catName !== '-' ) {
103 $catTitle = Title
::makeTitleSafe( NS_CATEGORY
, $catName );
105 $catTitleText = Linker
::link(
107 htmlspecialchars( $catName )
109 $allMsgs[] = $catTitleText;
114 # Extra message, when no category was found
115 if ( !count( $allMsgs ) ) {
116 $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
120 * Show category description if it exists as a system message
121 * as category-name-desc
123 $descMsg = $this->msg( $catDesc );
124 if ( $descMsg->isBlank() ) {
125 $descMsg = $this->msg( 'trackingcategories-nodesc' );
128 $this->getOutput()->addHTML(
129 Html
::openElement( 'tr' ) .
130 Html
::openElement( 'td', array( 'class' => 'mw-trackingcategories-name' ) ) .
131 $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
132 Html
::closeElement( 'td' ) .
133 Html
::openElement( 'td', array( 'class' => 'mw-trackingcategories-msg' ) ) .
135 Html
::closeElement( 'td' ) .
136 Html
::openElement( 'td', array( 'class' => 'mw-trackingcategories-desc' ) ) .
138 Html
::closeElement( 'td' ) .
139 Html
::closeElement( 'tr' )
142 $this->getOutput()->addHTML( Html
::closeElement( 'table' ) );
145 protected function getGroupName() {