MediaWiki  1.23.12
SpecialTags.php
Go to the documentation of this file.
1 <?php
29 class SpecialTags extends SpecialPage {
33  public $definedTags;
34 
35  function __construct() {
36  parent::__construct( 'Tags' );
37  }
38 
39  function execute( $par ) {
40  $this->setHeaders();
41  $this->outputHeader();
42 
43  $out = $this->getOutput();
44  $out->setPageTitle( $this->msg( 'tags-title' ) );
45  $out->wrapWikiMsg( "<div class='mw-tags-intro'>\n$1\n</div>", 'tags-intro' );
46 
47  // Write the headers
48  $html = Xml::tags( 'tr', null, Xml::tags( 'th', null, $this->msg( 'tags-tag' )->parse() ) .
49  Xml::tags( 'th', null, $this->msg( 'tags-display-header' )->parse() ) .
50  Xml::tags( 'th', null, $this->msg( 'tags-description-header' )->parse() ) .
51  Xml::tags( 'th', null, $this->msg( 'tags-active-header' )->parse() ) .
52  Xml::tags( 'th', null, $this->msg( 'tags-hitcount-header' )->parse() )
53  );
54 
55  // Used in #doTagRow()
56  $this->definedTags = array_fill_keys( ChangeTags::listDefinedTags(), true );
57 
58  foreach ( ChangeTags::tagUsageStatistics() as $tag => $hitcount ) {
59  $html .= $this->doTagRow( $tag, $hitcount );
60  }
61 
62  $out->addHTML( Xml::tags(
63  'table',
64  array( 'class' => 'wikitable sortable mw-tags-table' ),
65  $html
66  ) );
67  }
68 
69  function doTagRow( $tag, $hitcount ) {
70  $user = $this->getUser();
71  $newRow = '';
72  $newRow .= Xml::tags( 'td', null, Xml::element( 'code', null, $tag ) );
73 
74  $disp = ChangeTags::tagDescription( $tag );
75  if ( $user->isAllowed( 'editinterface' ) ) {
76  $disp .= ' ';
77  $editLink = Linker::link(
78  Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag" ),
79  $this->msg( 'tags-edit' )->escaped()
80  );
81  $disp .= $this->msg( 'parentheses' )->rawParams( $editLink )->escaped();
82  }
83  $newRow .= Xml::tags( 'td', null, $disp );
84 
85  $msg = $this->msg( "tag-$tag-description" );
86  $desc = !$msg->exists() ? '' : $msg->parse();
87  if ( $user->isAllowed( 'editinterface' ) ) {
88  $desc .= ' ';
89  $editDescLink = Linker::link(
90  Title::makeTitle( NS_MEDIAWIKI, "Tag-$tag-description" ),
91  $this->msg( 'tags-edit' )->escaped()
92  );
93  $desc .= $this->msg( 'parentheses' )->rawParams( $editDescLink )->escaped();
94  }
95  $newRow .= Xml::tags( 'td', null, $desc );
96 
97  $active = isset( $this->definedTags[$tag] ) ? 'tags-active-yes' : 'tags-active-no';
98  $active = $this->msg( $active )->escaped();
99  $newRow .= Xml::tags( 'td', null, $active );
100 
101  $hitcountLabel = $this->msg( 'tags-hitcount' )->numParams( $hitcount )->escaped();
102  $hitcountLink = Linker::link(
103  SpecialPage::getTitleFor( 'Recentchanges' ),
104  $hitcountLabel,
105  array(),
106  array( 'tagfilter' => $tag )
107  );
108 
109  // add raw $hitcount for sorting, because tags-hitcount contains numbers and letters
110  $newRow .= Xml::tags( 'td', array( 'data-sort-value' => $hitcount ), $hitcountLink );
111 
112  return Xml::tags( 'tr', null, $newRow ) . "\n";
113  }
114 
115  protected function getGroupName() {
116  return 'changes';
117  }
118 }
SpecialTags
A special page that lists tags for edits.
Definition: SpecialTags.php:29
Title\makeTitle
static & makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:398
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
$html
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
Definition: hooks.txt:1530
Xml\tags
static tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
Definition: Xml.php:131
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:535
SpecialTags\doTagRow
doTagRow( $tag, $hitcount)
Definition: SpecialTags.php:68
ChangeTags\tagDescription
static tagDescription( $tag)
Get a short description for a tag.
Definition: ChangeTags.php:71
SpecialPage\getTitleFor
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name.
Definition: SpecialPage.php:74
Linker\link
static link( $target, $html=null, $customAttribs=array(), $query=array(), $options=array())
This function returns an HTML link to the given target.
Definition: Linker.php:192
$out
$out
Definition: UtfNormalGenerate.php:167
SpecialTags\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialTags.php:114
SpecialTags\__construct
__construct()
Definition: SpecialTags.php:34
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:39
ChangeTags\listDefinedTags
static listDefinedTags()
Basically lists defined tags which count even if they aren't applied to anything.
Definition: ChangeTags.php:302
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:352
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:545
SpecialPage\msg
msg()
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:609
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:33
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:237
SpecialTags\execute
execute( $par)
Default execute method Checks user permissions, calls the function given in mFunction.
Definition: SpecialTags.php:38
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
ChangeTags\tagUsageStatistics
static tagUsageStatistics()
Returns a map of any tags used on the wiki to number of edits tagged with them, ordered descending by...
Definition: ChangeTags.php:335
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:87
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:443
SpecialTags\$definedTags
array $definedTags
List of defined tags.
Definition: SpecialTags.php:32