Add a way for packagers to override some installation details
[mediawiki.git] / includes / specials / SpecialTags.php
blobdf720a125cb7098e0df6981bfe40b06d393e2b7c
1 <?php
2 /**
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
20 * @file
21 * @ingroup SpecialPage
24 /**
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 ) {
36 $this->setHeaders();
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' );
43 // Write the headers
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-hitcount-header' )->parse() )
49 $dbr = wfGetDB( DB_SLAVE );
50 $res = $dbr->select( 'change_tag', array( 'ct_tag', 'count(*) AS hitcount' ),
51 array(), __METHOD__, array( 'GROUP BY' => 'ct_tag', 'ORDER BY' => 'hitcount DESC' ) );
53 foreach ( $res as $row ) {
54 $html .= $this->doTagRow( $row->ct_tag, $row->hitcount );
57 foreach( ChangeTags::listDefinedTags() as $tag ) {
58 $html .= $this->doTagRow( $tag, 0 );
61 $out->addHTML( Xml::tags( 'table', array( 'class' => 'wikitable mw-tags-table' ), $html ) );
64 function doTagRow( $tag, $hitcount ) {
65 static $doneTags = array();
67 if ( in_array( $tag, $doneTags ) ) {
68 return '';
71 $newRow = '';
72 $newRow .= Xml::tags( 'td', null, Xml::element( 'tt', null, $tag ) );
74 $disp = ChangeTags::tagDescription( $tag );
75 $disp .= ' ';
76 $editLink = Linker::link( Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag" ), $this->msg( 'tags-edit' )->escaped() );
77 $disp .= $this->msg( 'parentheses' )->rawParams( $editLink )->escaped();
78 $newRow .= Xml::tags( 'td', null, $disp );
80 $msg = $this->msg( "tag-$tag-description" );
81 $desc = !$msg->exists() ? '' : $msg->parse();
82 $desc .= ' ';
83 $editDescLink = Linker::link( Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag-description" ), $this->msg( 'tags-edit' )->escaped() );
84 $desc .= $this->msg( 'parentheses' )->rawParams( $editDescLink )->escaped();
85 $newRow .= Xml::tags( 'td', null, $desc );
87 $hitcount = $this->msg( 'tags-hitcount' )->numParams( $hitcount )->escaped();
88 $hitcount = Linker::link( SpecialPage::getTitleFor( 'Recentchanges' ), $hitcount, array(), array( 'tagfilter' => $tag ) );
89 $newRow .= Xml::tags( 'td', null, $hitcount );
91 $doneTags[] = $tag;
93 return Xml::tags( 'tr', null, $newRow ) . "\n";