3 if (!defined('MEDIAWIKI'))
6 class SpecialTags
extends SpecialPage
{
8 function __construct() {
9 parent
::__construct( 'Tags' );
13 global $wgOut, $wgUser, $wgMessageCache;
15 $wgMessageCache->loadAllMessages();
17 $sk = $wgUser->getSkin();
18 $wgOut->setPageTitle( wfMsg( 'tags-title' ) );
19 $wgOut->addWikiMsg( 'tags-intro' );
23 $html = Xml
::tags( 'tr', null, Xml
::tags( 'th', null, wfMsgExt( 'tags-tag', 'parseinline' ) ) .
24 Xml
::tags( 'th', null, wfMsgExt( 'tags-display-header', 'parseinline' ) ) .
25 Xml
::tags( 'th', null, wfMsgExt( 'tags-description-header', 'parseinline' ) ) .
26 Xml
::tags( 'th', null, wfMsgExt( 'tags-hitcount-header', 'parseinline' ) )
28 $dbr = wfGetDB( DB_SLAVE
);
29 $res = $dbr->select( 'change_tag', array( 'ct_tag', 'count(*) as hitcount' ), array(), __METHOD__
, array( 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ) );
31 while ( $row = $res->fetchObject() ) {
32 $html .= $this->doTagRow( $row->ct_tag
, $row->hitcount
);
35 foreach( ChangeTags
::listDefinedTags() as $tag ) {
36 $html .= $this->doTagRow( $tag, 0 );
39 $html = "<table style='width: 80%'><tbody>$html</tbody></table>";
41 $wgOut->addHTML( $html );
44 function doTagRow( $tag, $hitcount ) {
45 static $sk=null, $doneTags=array();
48 $sk = $wgUser->getSkin();
51 if ( in_array( $tag, $doneTags ) ) {
56 $newRow .= Xml
::tags( 'td', null, Xml
::element( 'tt', null, $tag ) );
58 $disp = ChangeTags
::tagDescription( $tag );
59 $disp .= ' (' . $sk->link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag" ), wfMsg( 'tag-edit' ) ) . ')';
60 $newRow .= Xml
::tags( 'td', null, $disp );
62 $desc = wfMsgExt( "tag-$tag-description", 'parseinline' );
63 $desc = wfEmptyMsg( "tag-$tag-description", $desc ) ?
'' : $desc;
64 $desc .= ' (' . $sk->link( Title
::makeTitle( NS_MEDIAWIKI
, "Tag-$tag-description" ), wfMsg( 'tag-edit' ) ) . ')';
65 $newRow .= Xml
::tags( 'td', null, $desc );
67 $hitcount = wfMsg( 'tags-hitcount', $hitcount );
68 $hitcount = $sk->link( SpecialPage
::getTitleFor( 'RecentChanges' ), $hitcount, array(), array( 'tagfilter' => $tag ) );
69 $newRow .= Xml
::tags( 'td', null, $hitcount );
73 return Xml
::tags( 'tr', null, $newRow ) . "\n";