4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
20 if (!defined('MEDIAWIKI'))
23 class SpecialTags
extends SpecialPage
{
25 function __construct() {
26 parent
::__construct( 'Tags' );
29 function execute( $par ) {
30 global $wgOut, $wgMessageCache;
32 $wgMessageCache->loadAllMessages();
34 $wgOut->setPageTitle( wfMsg( 'tags-title' ) );
35 $wgOut->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1\n</div>", 'tags-intro' );
39 $html = Xml
::tags( 'tr', null, Xml
::tags( 'th', null, wfMsgExt( 'tags-tag', 'parseinline' ) ) .
40 Xml
::tags( 'th', null, wfMsgExt( 'tags-display-header', 'parseinline' ) ) .
41 Xml
::tags( 'th', null, wfMsgExt( 'tags-description-header', 'parseinline' ) ) .
42 Xml
::tags( 'th', null, wfMsgExt( 'tags-hitcount-header', 'parseinline' ) )
44 $dbr = wfGetDB( DB_SLAVE
);
45 $res = $dbr->select( 'change_tag', array( 'ct_tag', 'count(*) as hitcount' ), array(), __METHOD__
, array( 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ) );
47 while ( $row = $res->fetchObject() ) {
48 $html .= $this->doTagRow( $row->ct_tag
, $row->hitcount
);
51 foreach( ChangeTags
::listDefinedTags() as $tag ) {
52 $html .= $this->doTagRow( $tag, 0 );
55 $wgOut->addHTML( Xml
::tags( 'table', array( 'class' => 'wikitable mw-tags-table' ), $html ) );
58 function doTagRow( $tag, $hitcount ) {
59 static $sk=null, $doneTags=array();
62 $sk = $wgUser->getSkin();
65 if ( in_array( $tag, $doneTags ) ) {
72 $newRow .= Xml
::tags( 'td', null, Xml
::element( 'tt', null, $tag ) );
74 $disp = ChangeTags
::tagDescription( $tag );
75 $disp .= ' (' . $sk->link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag" ), wfMsgHtml( 'tags-edit' ) ) . ')';
76 $newRow .= Xml
::tags( 'td', null, $disp );
78 $desc = wfMsgExt( "tag-$tag-description", 'parseinline' );
79 $desc = wfEmptyMsg( "tag-$tag-description", $desc ) ?
'' : $desc;
80 $desc .= ' (' . $sk->link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag-description" ), wfMsgHtml( 'tags-edit' ) ) . ')';
81 $newRow .= Xml
::tags( 'td', null, $desc );
83 $hitcount = wfMsgExt( 'tags-hitcount', array( 'parsemag' ), $wgLang->formatNum( $hitcount ) );
84 $hitcount = $sk->link( SpecialPage
::getTitleFor( 'Recentchanges' ), $hitcount, array(), array( 'tagfilter' => $tag ) );
85 $newRow .= Xml
::tags( 'td', null, $hitcount );
89 return Xml
::tags( 'tr', null, $newRow ) . "\n";