Completed
Push — mv ( 13ee4c...ac2590 )
by Jeroen De
03:53
created

MapEditorHtml   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 206
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 206
ccs 0
cts 176
cp 0
rs 10
c 0
b 0
f 0

3 Methods

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