~ubuntu-branches/ubuntu/maverick/mediawiki/maverick

« back to all changes in this revision

Viewing changes to includes/specials/SpecialTags.php

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis
  • Date: 2009-06-19 01:38:50 UTC
  • mfrom: (16.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090619013850-dsn4lrxvs90ab4rx
Tags: 1:1.15.0-1
* New upstream release. 
* Upstream added support for OASIS documents.
Closes: #530328
* Refreshed quilt patches
* Bumped standards versions to 3.8.2
* Bumped compat to 7
* Pointed to GPL-2 in debian/copyright
* Added php5-sqlite to possible DB backend dependencies.
Closes: #501569
* Proofread README.Debian, upgrade is documented there.
Closes: #520121

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
if (!defined('MEDIAWIKI'))
 
4
        die;
 
5
 
 
6
class SpecialTags extends SpecialPage {
 
7
 
 
8
        function __construct() {
 
9
                parent::__construct( 'Tags' );
 
10
        }
 
11
 
 
12
        function execute( $par ) {
 
13
                global $wgOut, $wgUser, $wgMessageCache;
 
14
 
 
15
                $wgMessageCache->loadAllMessages();
 
16
 
 
17
                $sk = $wgUser->getSkin();
 
18
                $wgOut->setPageTitle( wfMsg( 'tags-title' ) );
 
19
                $wgOut->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1</div>", 'tags-intro' );
 
20
 
 
21
                // Write the headers
 
22
                $html = '';
 
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' ) )
 
27
                        );
 
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' ) );
 
30
 
 
31
                while ( $row = $res->fetchObject() ) {
 
32
                        $html .= $this->doTagRow( $row->ct_tag, $row->hitcount );
 
33
                }
 
34
 
 
35
                foreach( ChangeTags::listDefinedTags() as $tag ) {
 
36
                        $html .= $this->doTagRow( $tag, 0 );
 
37
                }
 
38
 
 
39
                $wgOut->addHTML( Xml::tags( 'table', array( 'class' => 'mw-tags-table' ), $html ) );
 
40
        }
 
41
 
 
42
        function doTagRow( $tag, $hitcount ) {
 
43
                static $sk=null, $doneTags=array();
 
44
                if (!$sk) {
 
45
                        global $wgUser;
 
46
                        $sk = $wgUser->getSkin();
 
47
                }
 
48
 
 
49
                if ( in_array( $tag, $doneTags ) ) {
 
50
                        return '';
 
51
                }
 
52
                
 
53
                $newRow = '';
 
54
                $newRow .= Xml::tags( 'td', null, Xml::element( 'tt', null, $tag ) );
 
55
 
 
56
                $disp = ChangeTags::tagDescription( $tag );
 
57
                $disp .= ' (' . $sk->link( Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag" ), wfMsg( 'tags-edit' ) ) . ')';
 
58
                $newRow .= Xml::tags( 'td', null, $disp );
 
59
 
 
60
                $desc = wfMsgExt( "tag-$tag-description", 'parseinline' );
 
61
                $desc = wfEmptyMsg( "tag-$tag-description", $desc ) ? '' : $desc;
 
62
                $desc .= ' (' . $sk->link( Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag-description" ), wfMsg( 'tags-edit' ) ) . ')';
 
63
                $newRow .= Xml::tags( 'td', null, $desc );
 
64
 
 
65
                $hitcount = wfMsg( 'tags-hitcount', $hitcount );
 
66
                $hitcount = $sk->link( SpecialPage::getTitleFor( 'RecentChanges' ), $hitcount, array(), array( 'tagfilter' => $tag ) );
 
67
                $newRow .= Xml::tags( 'td', null, $hitcount );
 
68
 
 
69
                $doneTags[] = $tag;
 
70
 
 
71
                return Xml::tags( 'tr', null, $newRow ) . "\n";
 
72
        }
 
73
}
 
 
b'\\ No newline at end of file'