summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticFormsSelect/src/Output.php
blob: 578a0ab5f271576f72caa7758b406b4e354cc544 (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
<?php

/**
 * @license GNU GPL v2+
 * @since 1.3
 *
 * @author mwjames
 * @author Alexander Gesinn
 */

namespace SFS;

//use MWDebug;

class Output {

	/**
	 * @var array
	 */
	private static $headItems = [];

	/**
	 * Add an array of SF_Select field parameters as defined in Page Form's field tag.
	 *
	 * This will later be added to $wgOut so that JS can access it via mw.config.get
	 *
	 * @param array $data
	 */
	public static function addToHeadItem( Array $data = [] ) {
		return self::$headItems[] = $data;
	}

	/**
	 * Commit all SF_Select field parameters to Output
	 *
	 */
	public static function commitToParserOutput() {
		global $wgOut;	# is there a better way to get $output/$parser without using a global? (testability!)

		// to be used in JS like:
		// var SFSelect_fobjs = $.parseJSON( mw.config.get( 'sf_select' ) );
		$wgOut->addJsConfigVars('sf_select', json_encode( self::$headItems ));

		//self::$resourceModules = array();
		//self::$headItems = array();
	}
}