SpecialMapEditor::getAttribs()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\LegacyMapEditor;
6
7
use Maps\GoogleMapsService;
8
use SpecialPage;
9
10
/**
11
 * Special page with map editor interface using Google Maps.
12
 *
13
 * @since 2.0
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Kim Eik
17
 * @author Jeroen De Dauw < [email protected] >
18
 */
19
class SpecialMapEditor extends SpecialPage {
20
21
	/**
22
	 * @see SpecialPage::__construct
23
	 *
24
	 * @since 2.0
25
	 */
26
	public function __construct() {
27
		parent::__construct( 'MapEditor' );
28
	}
29
30
	/**
31
	 * @see SpecialPage::execute
32
	 *
33
	 * @since 2.0
34
	 *
35
	 * @param null|string $subPage
36
	 */
37
	public function execute( $subPage ) {
38
		$this->setHeaders();
39
40
		$outputPage = $this->getOutput();
41
42
		$outputPage->addHtml(
43
			GoogleMapsService::getApiScript(
44
				$this->getLanguage()->getCode(),
45
				[ 'libraries' => 'drawing' ]
46
			)
47
		);
48
49
		$outputPage->addModules( 'ext.maps.wikitext.editor' );
50
		$editorHtml = new MapEditorHtml( $this->getAttribs() );
51
		$html = $editorHtml->getEditorHtml();
52
		$outputPage->addHTML( $html );
53
	}
54
55
	/**
56
	 * @since 2.1
57
	 *
58
	 * @return array
59
	 */
60
	protected function getAttribs() {
61
		return [
62
			'id' => 'map-canvas',
63
			'context' => 'Maps\MediaWiki\Specials\SpecialMapEditor'
64
		];
65
	}
66
67
}
68