MapEditorHtml::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\LegacyMapEditor;
6
7
use ContextSource;
8
use Html;
9
10
/**
11
 * Class to Handle HTML generation for Special:MapEditor
12
 *
13
 * @since 2.1
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Nischayn22
17
 */
18
class MapEditorHtml extends ContextSource {
19
20
	/**
21
	 * Array holding the additional attributes for the canvas div.
22
	 *
23
	 * @var array()
24
	 * @since 2.1
25
	 */
26
	protected $attribs;
27
28
	public function __construct( $attribs = [] ) {
29
		$this->attribs = $attribs;
30
	}
31
32
	/**
33
	 * Returns the HTML for the MapEditor.
34
	 *
35
	 * @return string
36
	 * @since 2.1
37
	 */
38
	public function getEditorHTML() {
39
40
		$output = <<<EOT
41
	{$this->getCanvasDiv()}<div style="display: none;">
42
	<div id="code-output-container" title="%1\$s">
43
		<textarea id="code-output" rows="15" readonly></textarea>
44
	</div>
45
	<div id="code-input-container" title="%2\$s" >
46
		<p>%3\$s</p>
47
		<textarea id="code-input" rows="15"></textarea>
48
	</div>
49
	<div id="marker-form" class="mapeditor-dialog" title="%4\$s">
50
		<div class="link-title-switcher">
51
			<input type="radio" name="switch" value="text" /> %5\$s
52
			<input type="radio" name="switch" value="link" /> %6\$s
53
		</div>
54
		<form class="mapeditor-dialog-form">
55
			<fieldset>
56
				<label for="m-title">%7\$s</label>
57
				<input type="text" name="title" id="m-title" class="text ui-widget-content ui-corner-all"/>
58
				<label for="m-text">%8\$s</label>
59
				<input type="text" name="text" id="m-text" class="text ui-widget-content ui-corner-all"/>
60
				<label for="m-link">%9\$s</label>
61
				<input type="text" name="link" id="m-link" class="text ui-widget-content ui-corner-all"/>
62
				<label for="m-icon">%10\$s</label>
63
				<input type="text" name="icon" id="m-icon" class="text ui-widget-content ui-corner-all"/>
64
				<label for="m-group">%11\$s</label>
65
				<input type="text" name="group" id="m-group" class="text ui-widget-content ui-corner-all"/>
66
				<label for="m-inlinelabel">%12\$s</label>
67
				<input type="text" name="inlinelabel" id="m-inlinelabel" class="text ui-widget-content ui-corner-all"/>
68
				<label for="m-visitedicon">%23\$s</label>
69
				<input type="text" name="visitedicon" id="m-visitedicon" class="text ui-widget-content ui-corner-all"/>
70
			</fieldset>
71
		</form>
72
	</div>
73
74
	<div id="strokable-form" class="mapeditor-dialog" title="%4\$s">
75
		<div class="link-title-switcher">
76
			<input type="radio" name="switch" value="text" /> %5\$s
77
			<input type="radio" name="switch" value="link" /> %6\$s
78
		</div>
79
		<form class="mapeditor-dialog-form">
80
			<fieldset>
81
				<label for="s-title">%7\$s</label>
82
				<input type="text" name="title" id="s-title" class="text ui-widget-content ui-corner-all"/>
83
				<label for="s-text">%8\$s</label>
84
				<input type="text" name="text" id="s-text" value="" class="text ui-widget-content ui-corner-all"/>
85
				<label for="s-link">%9\$s</label>
86
				<input type="text" name="link" id="s-link" class="text ui-widget-content ui-corner-all"/>
87
				<label for="s-strokecolor">%13\$s</label>
88
				<input type="text" name="strokeColor" id="s-strokecolor" class="text ui-widget-content ui-corner-all"/>
89
				<label for="s-strokeopacity">%14\$s</label>
90
				<input type="hidden" name="strokeOpacity" id="s-strokeopacity" class="text ui-widget-content ui-corner-all"/>
91
				<label for="s-strokeweight">%15\$s</label>
92
				<input type="text" name="strokeWeight" id="s-strokeweight" class="text ui-widget-content ui-corner-all"/>
93
			</fieldset>
94
		</form>
95
	</div>
96
97
	<div id="fillable-form" class="mapeditor-dialog" title="%4\$s">
98
		<div class="link-title-switcher">
99
			<input type="radio" name="switch" value="text" /> %5\$s
100
			<input type="radio" name="switch" value="link" /> %6\$s
101
		</div>
102
		<form class="mapeditor-dialog-form">
103
			<fieldset>
104
				<label for="f-title">%7\$s</label>
105
				<input type="text" name="title" id="f-title" class="text ui-widget-content ui-corner-all"/>
106
				<label for="f-text">%8\$s</label>
107
				<input type="text" name="text" id="f-text" value="" class="text ui-widget-content ui-corner-all"/>
108
				<label for="f-link">%9\$s</label>
109
				<input type="text" name="link" id="f-link" class="text ui-widget-content ui-corner-all"/>
110
				<label for="f-strokecolor">%13\$s</label>
111
				<input type="text" name="strokeColor" id="f-strokecolor" class="text ui-widget-content ui-corner-all"/>
112
				<label for="f-strokeopacity">%14\$s</label>
113
				<input type="hidden" name="strokeOpacity" id="f-strokeopacity" class="text ui-widget-content ui-corner-all"/>
114
				<label for="f-strokeweight">%15\$s</label>
115
				<input type="text" name="strokeWeight" id="f-strokeweight" class="text ui-widget-content ui-corner-all"/>
116
				<label for="f-fillcolor">%16\$s</label>
117
				<input type="text" name="fillColor" id="f-fillcolor" class="text ui-widget-content ui-corner-all"/>
118
				<label for="f-fillopacity">%17\$s</label>
119
				<input type="hidden" name="fillOpacity" id="f-fillopacity" class="text ui-widget-content ui-corner-all"/>
120
			</fieldset>
121
		</form>
122
	</div>
123
124
	<div id="polygon-form" class="mapeditor-dialog" title="%4\$s">
125
		<div class="link-title-switcher">
126
			<input type="radio" name="switch" value="text" /> %5\$s
127
			<input type="radio" name="switch" value="link" /> %6\$s
128
		</div>
129
		<form class="mapeditor-dialog-form">
130
			<fieldset>
131
				<label for="p-title">%7\$s</label>
132
				<input type="text" name="title" id="p-title" class="text ui-widget-content ui-corner-all"/>
133
				<label for="p-text">%8\$s</label>
134
				<input type="text" name="text" id="p-text" value="" class="text ui-widget-content ui-corner-all"/>
135
				<label for="p-link">%9\$s</label>
136
				<input type="text" name="link" id="p-link" class="text ui-widget-content ui-corner-all"/>
137
				<label for="p-strokecolor">%13\$s</label>
138
				<input type="text" name="strokeColor" id="p-strokecolor" class="text ui-widget-content ui-corner-all"/>
139
				<label for="p-strokeopacity">%14\$s</label>
140
				<input type="hidden" name="strokeOpacity" id="p-strokeopacity" class="text ui-widget-content ui-corner-all"/>
141
				<label for="p-strokeweight">%15\$s</label>
142
				<input type="text" name="strokeWeight" id="p-strokeweight" class="text ui-widget-content ui-corner-all"/>
143
				<label for="p-fillcolor">%16\$s</label>
144
				<input type="text" name="fillColor" id="p-fillcolor" class="text ui-widget-content ui-corner-all"/>
145
				<label for="p-fillopacity">%17\$s</label>
146
				<input type="hidden" name="fillOpacity" id="p-fillopacity" class="text ui-widget-content ui-corner-all"/>
147
				<label for="p-showonhover">%18\$s</label>
148
				<input type="checkbox" name="showOnHover" id="p-showonhover" class="text ui-widget-content ui-corner-all"/>
149
			</fieldset>
150
		</form>
151
	</div>
152
	<div id="map-parameter-form" class="mapeditor-dialog" title="%19\$s">
153
		<form class="mapeditor-dialog-form">
154
			<div>
155
				<select name="key">
156
					<option value="">%20\$s</option>
157
				</select>
158
			</div>
159
		</form>
160
	</div>
161
	<div id="imageoverlay-form" title="%22\$s">
162
		<div class="link-title-switcher">
163
			<input type="radio" name="switch" value="text" /> %5\$s
164
			<input type="radio" name="switch" value="link" /> %6\$s
165
		</div>
166
		<form class="mapeditor-dialog-form">
167
			<fieldset>
168
				<label for="i-title">%7\$s</label>
169
				<input type="text" name="title" id="i-title" class="text ui-widget-content ui-corner-all"/>
170
				<label for="i-text">%8\$s</label>
171
				<input type="text" name="text" id="i-text" class="text ui-widget-content ui-corner-all"/>
172
				<label for="i-link">%9\$s</label>
173
				<input type="text" name="link" id="i-link" class="text ui-widget-content ui-corner-all"/>
174
				<label for="i-image">%21\$s</label>
175
				<input type="text" name="image" id="i-image" class="text ui-widget-content ui-corner-all"/>
176
			</fieldset>
177
		</form>
178
	</div>
179
</div>
180
EOT;
181
182
		return sprintf(
183
			$output,
184
			$this->msg( 'mapeditor-code-title' ),
185
			$this->msg( 'mapeditor-import-title' ),
186
			$this->msg( 'mapeditor-import-note' ),
187
			$this->msg( 'mapeditor-form-title' ),
188
			$this->msg( 'mapeditor-link-title-switcher-popup-text' ),
189
			$this->msg( 'mapeditor-link-title-switcher-link-text' ),
190
			$this->msg( 'mapeditor-form-field-title' ),
191
			$this->msg( 'mapeditor-form-field-text' ),
192
			$this->msg( 'mapeditor-form-field-link' ),
193
			$this->msg( 'mapeditor-form-field-icon' ),
194
			$this->msg( 'mapeditor-form-field-group' ),
195
			$this->msg( 'mapeditor-form-field-inlinelabel' ),
196
			$this->msg( 'mapeditor-form-field-strokecolor' ),
197
			$this->msg( 'mapeditor-form-field-strokeopacity' ),
198
			$this->msg( 'mapeditor-form-field-strokeweight' ),
199
			$this->msg( 'mapeditor-form-field-fillcolor' ),
200
			$this->msg( 'mapeditor-form-field-fillopcaity' ),
201
			$this->msg( 'mapeditor-form-field-showonhover' ),
202
			$this->msg( 'mapeditor-mapparam-title' ),
203
			$this->msg( 'mapeditor-mapparam-defoption' ),
204
			$this->msg( 'mapeditor-form-field-image' ),
205
			$this->msg( 'mapeditor-imageoverlay-title' ),
206
			$this->msg( 'mapeditor-form-field-visitedicon' )
207
		);
208
	}
209
210
	/**
211
	 * @return string
212
	 * @since 2.1
213
	 */
214
	public function getCanvasDiv() {
215
		return Html::element(
216
			'div',
217
			$this->attribs
218
		);
219
	}
220
221
}
222