7e34e9846dee6748edca912c09e92f11c118fb13
3 * Implements Special:Tags
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 lists tags for edits
27 * @ingroup SpecialPage
29 class SpecialTags
extends SpecialPage
{
31 function __construct() {
32 parent
::__construct( 'Tags' );
35 function execute( $par ) {
37 $this->outputHeader();
39 $out = $this->getOutput();
40 $out->setPageTitle( $this->msg( 'tags-title' ) );
41 $out->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1\n</div>", 'tags-intro' );
44 $html = Xml
::tags( 'tr', null, Xml
::tags( 'th', null, $this->msg( 'tags-tag' )->parse() ) .
45 Xml
::tags( 'th', null, $this->msg( 'tags-display-header' )->parse() ) .
46 Xml
::tags( 'th', null, $this->msg( 'tags-description-header' )->parse() ) .
47 Xml
::tags( 'th', null, $this->msg( 'tags-active-header' )->parse() ) .
48 Xml
::tags( 'th', null, $this->msg( 'tags-hitcount-header' )->parse() )
51 // Used in #doTagRow()
52 $this->definedTags
= array_fill_keys( ChangeTags
::listDefinedTags(), true );
54 foreach ( ChangeTags
::tagUsageStatistics() as $tag => $hitcount ) {
55 $html .= $this->doTagRow( $tag, $hitcount );
58 $out->addHTML( Xml
::tags( 'table', array( 'class' => 'wikitable sortable mw-tags-table' ), $html ) );
61 function doTagRow( $tag, $hitcount ) {
62 $user = $this->getUser();
64 $newRow .= Xml
::tags( 'td', null, Xml
::element( 'code', null, $tag ) );
66 $disp = ChangeTags
::tagDescription( $tag );
67 if ( $user->isAllowed( 'editinterface' ) ) {
69 $editLink = Linker
::link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag" ), $this->msg( 'tags-edit' )->escaped() );
70 $disp .= $this->msg( 'parentheses' )->rawParams( $editLink )->escaped();
72 $newRow .= Xml
::tags( 'td', null, $disp );
74 $msg = $this->msg( "tag-$tag-description" );
75 $desc = !$msg->exists() ?
'' : $msg->parse();
76 if ( $user->isAllowed( 'editinterface' ) ) {
78 $editDescLink = Linker
::link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag-description" ), $this->msg( 'tags-edit' )->escaped() );
79 $desc .= $this->msg( 'parentheses' )->rawParams( $editDescLink )->escaped();
81 $newRow .= Xml
::tags( 'td', null, $desc );
83 $active = $this->msg( isset( $this->definedTags
[$tag] ) ?
'tags-active-yes' : 'tags-active-no' )->escaped();
84 $newRow .= Xml
::tags( 'td', null, $active );
86 $hitcountLabel = $this->msg( 'tags-hitcount' )->numParams( $hitcount )->escaped();
87 $hitcountLink = Linker
::link( SpecialPage
::getTitleFor( 'Recentchanges' ), $hitcountLabel, array(), array( 'tagfilter' => $tag ) );
88 // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters
89 $newRow .= Xml
::tags( 'td', array( 'data-sort-value' => $hitcount ), $hitcountLink );
91 return Xml
::tags( 'tr', null, $newRow ) . "\n";
94 protected function getGroupName() {