summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Factbox/FactboxFactory.php
blob: 239d037a1c6413cfc5de3a109ae4f2158b37977f (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
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php

namespace SMW\Factbox;

use IContextSource;
use OutputPage;
use SMW\ApplicationFactory;
use Title;
use ParserOutput;

/**
 * @license GNU GPL v2+
 * @since 2.0
 *
 * @author mwjames
 */
class FactboxFactory {

	/**
	 * @since 2.0
	 *
	 * @return CachedFactbox
	 */
	public function newCachedFactbox() {

		$applicationFactory = ApplicationFactory::getInstance();
		$settings = $applicationFactory->getSettings();

		$cachedFactbox = new CachedFactbox(
			$applicationFactory->getCache(
				$settings->get( 'smwgMainCacheType' )
			)
		);

		// Month = 30 * 24 * 3600
		$cachedFactbox->setExpiryInSeconds( 2592000 );

		$cachedFactbox->isEnabled(
			$settings->isFlagSet( 'smwgFactboxFeatures', SMW_FACTBOX_CACHE )
		);

		$cachedFactbox->setFeatureSet(
			$settings->get( 'smwgFactboxFeatures' )
		);

		return $cachedFactbox;
	}

	/**
	 * @since 2.0
	 *
	 * @param Title $title
	 * @param ParserOutput $parserOutput
	 *
	 * @return Factbox
	 */
	public function newFactbox( Title $title, ParserOutput $parserOutput ) {

		$applicationFactory = ApplicationFactory::getInstance();

		$factbox = new Factbox(
			$applicationFactory->getStore(),
			$applicationFactory->newParserData( $title, $parserOutput )
		);

		$factbox->setFeatureSet(
			$applicationFactory->getSettings()->get( 'smwgFactboxFeatures' )
		);

		return $factbox;
	}

}