MediaWiki  master
SpecialTrackingCategories.php
Go to the documentation of this file.
1 <?php
35  function __construct() {
36  parent::__construct( 'TrackingCategories' );
37  }
38 
39  function execute( $par ) {
40  $this->setHeaders();
41  $this->outputHeader();
42  $this->addHelpLink( 'Help:Categories' );
43  $this->getOutput()->allowClickjacking();
44  $this->getOutput()->addModuleStyles( 'jquery.tablesorter.styles' );
45  $this->getOutput()->addModules( 'jquery.tablesorter' );
46  $this->getOutput()->addHTML(
47  Html::openElement( 'table', [ 'class' => 'mw-datatable sortable',
48  'id' => 'mw-trackingcategories-table' ] ) . "\n" .
49  "<thead><tr>
50  <th>" .
51  $this->msg( 'trackingcategories-msg' )->escaped() . "
52  </th>
53  <th>" .
54  $this->msg( 'trackingcategories-name' )->escaped() .
55  "</th>
56  <th>" .
57  $this->msg( 'trackingcategories-desc' )->escaped() . "
58  </th>
59  </tr></thead>"
60  );
61 
62  $trackingCategories = new TrackingCategories( $this->getConfig() );
63  $categoryList = $trackingCategories->getTrackingCategories();
64 
65  $batch = new LinkBatch();
66  foreach ( $categoryList as $catMsg => $data ) {
67  $batch->addObj( $data['msg'] );
68  foreach ( $data['cats'] as $catTitle ) {
69  $batch->addObj( $catTitle );
70  }
71  }
72  $batch->execute();
73 
74  Hooks::run( 'SpecialTrackingCategories::preprocess', [ $this, $categoryList ] );
75 
76  $linkRenderer = $this->getLinkRenderer();
77 
78  foreach ( $categoryList as $catMsg => $data ) {
79  $allMsgs = [];
80  $catDesc = $catMsg . '-desc';
81 
82  $catMsgTitleText = $linkRenderer->makeLink(
83  $data['msg'],
84  $catMsg
85  );
86 
87  foreach ( $data['cats'] as $catTitle ) {
88  $html = $linkRenderer->makeLink(
89  $catTitle,
90  $catTitle->getText()
91  );
92 
93  Hooks::run( 'SpecialTrackingCategories::generateCatLink',
94  [ $this, $catTitle, &$html ] );
95 
96  $allMsgs[] = $html;
97  }
98 
99  # Extra message, when no category was found
100  if ( $allMsgs === [] ) {
101  $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
102  }
103 
104  /*
105  * Show category description if it exists as a system message
106  * as category-name-desc
107  */
108  $descMsg = $this->msg( $catDesc );
109  if ( $descMsg->isBlank() ) {
110  $descMsg = $this->msg( 'trackingcategories-nodesc' );
111  }
112 
113  $this->getOutput()->addHTML(
114  Html::openElement( 'tr' ) .
115  Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-name' ] ) .
116  $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
117  Html::closeElement( 'td' ) .
118  Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-msg' ] ) .
119  $catMsgTitleText .
120  Html::closeElement( 'td' ) .
121  Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-desc' ] ) .
122  $descMsg->parse() .
123  Html::closeElement( 'td' ) .
124  Html::closeElement( 'tr' )
125  );
126  }
127  $this->getOutput()->addHTML( Html::closeElement( 'table' ) );
128  }
129 
130  protected function getGroupName() {
131  return 'pages';
132  }
133 }
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing &#39;/&#39;...
Definition: Html.php:251
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getOutput()
Get the OutputPage being used for this instance.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static closeElement( $element)
Returns "</$element>".
Definition: Html.php:315
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
A special page that displays list of tracking categories Tracking categories allow pages with certain...
getConfig()
Shortcut to get main config object.
getLanguage()
Shortcut to get user&#39;s language.
This class performs some operations related to tracking categories, such as creating a list of all su...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67