00001 <?php
00002
00003 if (!defined('MEDIAWIKI'))
00004 die;
00005
00006 class SpecialTags extends SpecialPage {
00007
00008 function __construct() {
00009 parent::__construct( 'Tags' );
00010 }
00011
00012 function execute( $par ) {
00013 global $wgOut, $wgUser, $wgMessageCache;
00014
00015 $wgMessageCache->loadAllMessages();
00016
00017 $sk = $wgUser->getSkin();
00018 $wgOut->setPageTitle( wfMsg( 'tags-title' ) );
00019 $wgOut->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1</div>", 'tags-intro' );
00020
00021
00022 $html = '';
00023 $html = Xml::tags( 'tr', null, Xml::tags( 'th', null, wfMsgExt( 'tags-tag', 'parseinline' ) ) .
00024 Xml::tags( 'th', null, wfMsgExt( 'tags-display-header', 'parseinline' ) ) .
00025 Xml::tags( 'th', null, wfMsgExt( 'tags-description-header', 'parseinline' ) ) .
00026 Xml::tags( 'th', null, wfMsgExt( 'tags-hitcount-header', 'parseinline' ) )
00027 );
00028 $dbr = wfGetDB( DB_SLAVE );
00029 $res = $dbr->select( 'change_tag', array( 'ct_tag', 'count(*) as hitcount' ), array(), __METHOD__, array( 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ) );
00030
00031 while ( $row = $res->fetchObject() ) {
00032 $html .= $this->doTagRow( $row->ct_tag, $row->hitcount );
00033 }
00034
00035 foreach( ChangeTags::listDefinedTags() as $tag ) {
00036 $html .= $this->doTagRow( $tag, 0 );
00037 }
00038
00039 $wgOut->addHTML( Xml::tags( 'table', array( 'class' => 'mw-tags-table' ), $html ) );
00040 }
00041
00042 function doTagRow( $tag, $hitcount ) {
00043 static $sk=null, $doneTags=array();
00044 if (!$sk) {
00045 global $wgUser;
00046 $sk = $wgUser->getSkin();
00047 }
00048
00049 if ( in_array( $tag, $doneTags ) ) {
00050 return '';
00051 }
00052
00053 $newRow = '';
00054 $newRow .= Xml::tags( 'td', null, Xml::element( 'tt', null, $tag ) );
00055
00056 $disp = ChangeTags::tagDescription( $tag );
00057 $disp .= ' (' . $sk->link( Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag" ), wfMsg( 'tags-edit' ) ) . ')';
00058 $newRow .= Xml::tags( 'td', null, $disp );
00059
00060 $desc = wfMsgExt( "tag-$tag-description", 'parseinline' );
00061 $desc = wfEmptyMsg( "tag-$tag-description", $desc ) ? '' : $desc;
00062 $desc .= ' (' . $sk->link( Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag-description" ), wfMsg( 'tags-edit' ) ) . ')';
00063 $newRow .= Xml::tags( 'td', null, $desc );
00064
00065 $hitcount = wfMsg( 'tags-hitcount', $hitcount );
00066 $hitcount = $sk->link( SpecialPage::getTitleFor( 'RecentChanges' ), $hitcount, array(), array( 'tagfilter' => $tag ) );
00067 $newRow .= Xml::tags( 'td', null, $hitcount );
00068
00069 $doneTags[] = $tag;
00070
00071 return Xml::tags( 'tr', null, $newRow ) . "\n";
00072 }
00073 }