summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/ParserFunctions/ShowParserFunction.php
blob: 81d149f0019026feba350074696072997c96f3b0 (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
60
<?php

namespace SMW\ParserFunctions;

/**
 * Class that provides the {{#show}} parser function
 *
 * @license GNU GPL v2+
 * @since 1.9
 *
 * @author mwjames
 */
class ShowParserFunction {

	/**
	 * @var AskParserFunction
	 */
	private $askParserFunction;

	/**
	 * @since 1.9
	 *
	 * @param AskParserFunction $askParserFunction
	 */
	public function __construct( AskParserFunction $askParserFunction ) {
		$this->askParserFunction = $askParserFunction;
	}

	/**
	 * Parse parameters, return results from the query printer and update the
	 * ParserOutput with meta data from the query
	 *
	 * @note The {{#show}} parser function internally uses the AskParserFunction
	 * and while an extra ShowParserFunction constructor is not really necessary
	 * it allows for separate unit testing
	 *
	 * @since 1.9
	 *
	 * @param array $params
	 *
	 * @return string|null
	 */
	public function parse( array $rawParams ) {
		$this->askParserFunction->setShowMode( true );
		return $this->askParserFunction->parse( $rawParams );
	}

	/**
	 * Returns a message about inline queries being disabled
	 * @see $smwgQEnabled
	 *
	 * @since 1.9
	 *
	 * @return string|null
	 */
	public function isQueryDisabled() {
		return $this->askParserFunction->isQueryDisabled();
	}

}