summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticFormsSelect/SemanticFormsSelect.hooks.php
blob: 7138c0c4dacef6c897a4f13315b2a56181fcf3a9 (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
<?php

namespace SFS;

/**
 * @license GNU GPL v2+
 * @since 3.0
 * @author: Alexander Gesinn
 */
class Hooks {
	/**
	 * Register Page Forms Input Type
	 *
	 * This is attached to the MediaWiki 'ParserFirstCallInit' hook.
	 *
	 * @param $parser Parser
	 * @return bool
	 */
	public static function onSemanticFormsSelectSetup ( & $parser ) {

		if ( !defined( 'PF_VERSION' ) ) {
			die( '<b>Error:</b><a href="https://github.com/SemanticMediaWiki/SemanticFormsSelect/">Semantic Forms Select</a> requires the <a href="https://www.mediawiki.org/wiki/Extension:PageForms">Page Forms</a> extension. Please install and activate this extension first.' );
		}

		if ( isset( $GLOBALS['wgPageFormsFormPrinter'] ) ) {
			$GLOBALS['wgPageFormsFormPrinter']->registerInputType( \SFS\SemanticFormsSelectInput::class );
		}

		return true;
	}
	
	public static function onRegistration() {

		if ( isset( $GLOBALS['wgAPIModules'] ) ) {
			$GLOBALS['wgAPIModules']['sformsselect'] = \SFS\ApiSemanticFormsSelect::class;
		}
	}
}