summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Hooks/SkinTemplateNavigation.php
blob: a1a5b1092cd9b4b56ed192a4361336f1d690d818 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php

namespace SMW\MediaWiki\Hooks;

use SkinTemplate;

/**
 * Alter the structured navigation links in SkinTemplates.
 *
 * @see https://www.mediawiki.org/wiki/Manual:Hooks/SkinTemplateNavigation
 *
 * @license GNU GPL v2+
 * @since 2.0
 *
 * @author mwjames
 */
class SkinTemplateNavigation {

	/**
	 * @var SkinTemplate
	 */
	private $skinTemplate = null;

	/**
	 * @var array
	 */
	private $links;

	/**
	 * @since  2.0
	 *
	 * @param SkinTemplate $skinTemplate
	 * @param array $links
	 */
	public function __construct( SkinTemplate &$skinTemplate, array &$links ) {
		$this->skinTemplate = $skinTemplate;
		$this->links =& $links;
	}

	/**
	 * @since 2.0
	 *
	 * @return true
	 */
	public function process() {

		if ( $this->skinTemplate->getUser()->isAllowed( 'purge' ) ) {
			$this->skinTemplate->getOutput()->addModules( 'ext.smw.purge' );
			$this->links['actions']['purge'] = [
				'class' => 'is-disabled',
				'text' => $this->skinTemplate->msg( 'smw_purge' )->text(),
				'href' => $this->skinTemplate->getTitle()->getLocalUrl( [ 'action' => 'purge' ] )
			];
		}

		return true;
	}

}