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
24 if (!defined('MEDIAWIKI'))
28 * A special page that lists tags for edits
30 * @ingroup SpecialPage
32 class SpecialTags
extends SpecialPage
{
34 function __construct() {
35 parent
::__construct( 'Tags' );
38 function execute( $par ) {
41 $wgOut->setPageTitle( wfMsg( 'tags-title' ) );
42 $wgOut->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1\n</div>", 'tags-intro' );
45 $html = Xml
::tags( 'tr', null, Xml
::tags( 'th', null, wfMsgExt( 'tags-tag', 'parseinline' ) ) .
46 Xml
::tags( 'th', null, wfMsgExt( 'tags-display-header', 'parseinline' ) ) .
47 Xml
::tags( 'th', null, wfMsgExt( 'tags-description-header', 'parseinline' ) ) .
48 Xml
::tags( 'th', null, wfMsgExt( 'tags-hitcount-header', 'parseinline' ) )
50 $dbr = wfGetDB( DB_SLAVE
);
51 $res = $dbr->select( 'change_tag', array( 'ct_tag', 'count(*) AS hitcount' ),
52 array(), __METHOD__
, array( 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ) );
54 foreach ( $res as $row ) {
55 $html .= $this->doTagRow( $row->ct_tag
, $row->hitcount
);
58 foreach( ChangeTags
::listDefinedTags() as $tag ) {
59 $html .= $this->doTagRow( $tag, 0 );
62 $wgOut->addHTML( Xml
::tags( 'table', array( 'class' => 'wikitable mw-tags-table' ), $html ) );
65 function doTagRow( $tag, $hitcount ) {
66 static $sk=null, $doneTags=array();
69 $sk = $wgUser->getSkin();
72 if ( in_array( $tag, $doneTags ) ) {
79 $newRow .= Xml
::tags( 'td', null, Xml
::element( 'tt', null, $tag ) );
81 $disp = ChangeTags
::tagDescription( $tag );
82 $disp .= ' (' . $sk->link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag" ), wfMsgHtml( 'tags-edit' ) ) . ')';
83 $newRow .= Xml
::tags( 'td', null, $disp );
85 $msg = wfMessage( "tag-$tag-description" );
86 $desc = !$msg->exists() ?
'' : $msg->parse();
87 $desc .= ' (' . $sk->link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag-description" ), wfMsgHtml( 'tags-edit' ) ) . ')';
88 $newRow .= Xml
::tags( 'td', null, $desc );
90 $hitcount = wfMsgExt( 'tags-hitcount', array( 'parsemag' ), $wgLang->formatNum( $hitcount ) );
91 $hitcount = $sk->link( SpecialPage
::getTitleFor( 'Recentchanges' ), $hitcount, array(), array( 'tagfilter' => $tag ) );
92 $newRow .= Xml
::tags( 'td', null, $hitcount );
96 return Xml
::tags( 'tr', null, $newRow ) . "\n";