summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/MediaWiki/Hooks/BeforeDisplayNoArticleText.php
blob: 66c05ce5b49cddb21dc027caf8d2235b1b111405 (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
<?php

namespace SMW\MediaWiki\Hooks;

use SMW\DIProperty;

/**
 * Before displaying noarticletext or noarticletext-nopermission messages
 *
 * @see https://www.mediawiki.org/wiki/Manual:Hooks/BeforeDisplayNoArticleText
 *
 * @license GNU GPL v2+
 * @since 2.0
 *
 * @author mwjames
 */
class BeforeDisplayNoArticleText {

	/**
	 * @var Page
	 */
	private $article;

	/**
	 * @since  2.0
	 *
	 * @param Page $article
	 */
	public function __construct( $article ) {
		$this->article = $article;
	}

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

		// Avoid having "noarticletext" info being generated for predefined
		// properties as we are going to display an introductory text
		if ( $this->article->getTitle()->getNamespace() === SMW_NS_PROPERTY ) {
			return DIProperty::newFromUserLabel( $this->article->getTitle()->getText() )->isUserDefined();
		}

		return true;
	}

}