MediaWiki  1.33.0
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->getOutput()->allowClickjacking();
43  $this->getOutput()->addModuleStyles( 'jquery.tablesorter.styles' );
44  $this->getOutput()->addModules( 'jquery.tablesorter' );
45  $this->getOutput()->addHTML(
46  Html::openElement( 'table', [ 'class' => 'mw-datatable sortable',
47  'id' => 'mw-trackingcategories-table' ] ) . "\n" .
48  "<thead><tr>
49  <th>" .
50  $this->msg( 'trackingcategories-msg' )->escaped() . "
51  </th>
52  <th>" .
53  $this->msg( 'trackingcategories-name' )->escaped() .
54  "</th>
55  <th>" .
56  $this->msg( 'trackingcategories-desc' )->escaped() . "
57  </th>
58  </tr></thead>"
59  );
60 
61  $trackingCategories = new TrackingCategories( $this->getConfig() );
62  $categoryList = $trackingCategories->getTrackingCategories();
63 
64  $batch = new LinkBatch();
65  foreach ( $categoryList as $catMsg => $data ) {
66  $batch->addObj( $data['msg'] );
67  foreach ( $data['cats'] as $catTitle ) {
68  $batch->addObj( $catTitle );
69  }
70  }
71  $batch->execute();
72 
73  Hooks::run( 'SpecialTrackingCategories::preprocess', [ $this, $categoryList ] );
74 
75  $linkRenderer = $this->getLinkRenderer();
76 
77  foreach ( $categoryList as $catMsg => $data ) {
78  $allMsgs = [];
79  $catDesc = $catMsg . '-desc';
80 
81  $catMsgTitleText = $linkRenderer->makeLink(
82  $data['msg'],
83  $catMsg
84  );
85 
86  foreach ( $data['cats'] as $catTitle ) {
87  $html = $linkRenderer->makeLink(
88  $catTitle,
89  $catTitle->getText()
90  );
91 
92  Hooks::run( 'SpecialTrackingCategories::generateCatLink',
93  [ $this, $catTitle, &$html ] );
94 
95  $allMsgs[] = $html;
96  }
97 
98  # Extra message, when no category was found
99  if ( $allMsgs === [] ) {
100  $allMsgs[] = $this->msg( 'trackingcategories-disabled' )->parse();
101  }
102 
103  /*
104  * Show category description if it exists as a system message
105  * as category-name-desc
106  */
107  $descMsg = $this->msg( $catDesc );
108  if ( $descMsg->isBlank() ) {
109  $descMsg = $this->msg( 'trackingcategories-nodesc' );
110  }
111 
112  $this->getOutput()->addHTML(
113  Html::openElement( 'tr' ) .
114  Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-name' ] ) .
115  $this->getLanguage()->commaList( array_unique( $allMsgs ) ) .
116  Html::closeElement( 'td' ) .
117  Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-msg' ] ) .
118  $catMsgTitleText .
119  Html::closeElement( 'td' ) .
120  Html::openElement( 'td', [ 'class' => 'mw-trackingcategories-desc' ] ) .
121  $descMsg->parse() .
122  Html::closeElement( 'td' ) .
123  Html::closeElement( 'tr' )
124  );
125  }
126  $this->getOutput()->addHTML( Html::closeElement( 'table' ) );
127  }
128 
129  protected function getGroupName() {
130  return 'pages';
131  }
132 }
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:796
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:34
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
SpecialTrackingCategories\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialTrackingCategories.php:129
SpecialTrackingCategories\__construct
__construct()
Definition: SpecialTrackingCategories.php:35
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:755
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
$data
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
Definition: generatePhpCharToUpperMappings.php:13
$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:1985
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:764
SpecialTrackingCategories
A special page that displays list of tracking categories Tracking categories allow pages with certain...
Definition: SpecialTrackingCategories.php:34
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:531
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialTrackingCategories\execute
execute( $par)
Default execute method Checks user permissions.
Definition: SpecialTrackingCategories.php:39
TrackingCategories
This class performs some operations related to tracking categories, such as creating a list of all su...
Definition: TrackingCategories.php:27
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:908
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
$batch
$batch
Definition: linkcache.txt:23
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
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:633