|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright (c) 2012-2020 Mark C. Prins <[email protected]> |
|
4
|
|
|
* |
|
5
|
|
|
* Permission to use, copy, modify, and distribute this software for any |
|
6
|
|
|
* purpose with or without fee is hereby granted, provided that the above |
|
7
|
|
|
* copyright notice and this permission notice appear in all copies. |
|
8
|
|
|
* |
|
9
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
|
10
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
|
11
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
|
12
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
13
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
14
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
|
15
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
16
|
|
|
* |
|
17
|
|
|
* @phpcs:disable Squiz.Classes.ValidClassName.NotCamelCaps |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* adds a WMTS 1.0.0 layer to your map. |
|
22
|
|
|
*/ |
|
23
|
|
|
class syntax_plugin_openlayersmap_wmtslayer extends DokuWiki_Syntax_Plugin |
|
|
|
|
|
|
24
|
|
|
{ |
|
25
|
|
|
private $dflt = array( |
|
26
|
|
|
'id' => 'olmap', |
|
27
|
|
|
'name' => '', |
|
28
|
|
|
'url' => '', |
|
29
|
|
|
'opacity' => 0.8, |
|
30
|
|
|
'attribution' => '', |
|
31
|
|
|
'visible' => false, |
|
32
|
|
|
'layers' => '', |
|
33
|
|
|
'version' => '1.0.0', |
|
34
|
|
|
'format' => 'image/png', |
|
35
|
|
|
'transparent' => 'true' |
|
36
|
|
|
); |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* (non-PHPdoc) |
|
40
|
|
|
* |
|
41
|
|
|
* @see DokuWiki_Syntax_Plugin::getPType() |
|
42
|
|
|
*/ |
|
43
|
|
|
final public function getPType(): string |
|
44
|
|
|
{ |
|
45
|
|
|
return 'block'; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* (non-PHPdoc) |
|
50
|
|
|
* |
|
51
|
|
|
* @see DokuWiki_Syntax_Plugin::getType() |
|
52
|
|
|
*/ |
|
53
|
|
|
final public function getType(): string |
|
54
|
|
|
{ |
|
55
|
|
|
return 'baseonly'; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* (non-PHPdoc) |
|
60
|
|
|
* |
|
61
|
|
|
* @see Doku_Parser_Mode::getSort() |
|
62
|
|
|
*/ |
|
63
|
|
|
final public function getSort(): int |
|
64
|
|
|
{ |
|
65
|
|
|
return 902; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Connect to our special pattern. |
|
70
|
|
|
* |
|
71
|
|
|
* @see Doku_Parser_Mode::connectTo() |
|
72
|
|
|
*/ |
|
73
|
|
|
final public function connectTo($mode): void |
|
74
|
|
|
{ |
|
75
|
|
|
// look for: <olmap_wmstlayer id="olmap" name="geolandbasemap" url="https://mapsneu.wien.gv.at/basemapneu/1.0.0/WMTSCapabilities.xml" |
|
76
|
|
|
// attribution="basemap.at" visible="true" layer="geolandbasemap" matrixSet=google3857></olmap_wmtslayer> |
|
77
|
|
|
$this->Lexer->addSpecialPattern( |
|
78
|
|
|
'<olmap_wmtslayer ?[^>\n]*>.*?</olmap_wmtslayer>', |
|
79
|
|
|
$mode, |
|
80
|
|
|
'plugin_openlayersmap_wmtslayer' |
|
81
|
|
|
); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* (non-PHPdoc) |
|
86
|
|
|
* |
|
87
|
|
|
* @see DokuWiki_Syntax_Plugin::handle() |
|
88
|
|
|
*/ |
|
89
|
|
|
final public function handle($match, $state, $pos, Doku_Handler $handler): array |
|
|
|
|
|
|
90
|
|
|
{ |
|
91
|
|
|
$param = array(); |
|
92
|
|
|
$data = $this->dflt; |
|
93
|
|
|
|
|
94
|
|
|
preg_match_all('/(\w*)="(.*?)"/us', $match, $param, PREG_SET_ORDER); |
|
95
|
|
|
|
|
96
|
|
|
foreach ($param as $kvpair) { |
|
97
|
|
|
list ($matched, $key, $val) = $kvpair; |
|
98
|
|
|
if (isset ($data [$key])) { |
|
99
|
|
|
$key = strtolower($key); |
|
100
|
|
|
$data [$key] = $val; |
|
101
|
|
|
} |
|
102
|
|
|
} |
|
103
|
|
|
return $data; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* (non-PHPdoc) |
|
108
|
|
|
* |
|
109
|
|
|
* @see DokuWiki_Syntax_Plugin::render() |
|
110
|
|
|
*/ |
|
111
|
|
|
final public function render($format, Doku_Renderer $renderer, $data): bool |
|
|
|
|
|
|
112
|
|
|
{ |
|
113
|
|
|
if ($format !== 'xhtml') { |
|
114
|
|
|
return false; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
// incremented for each olmap_wmtslayer tag in the page source |
|
118
|
|
|
static $overlaynumber = 0; |
|
119
|
|
|
|
|
120
|
|
|
$renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
|
|
|
|
|
121
|
|
|
$str = '{'; |
|
122
|
|
|
foreach ($data as $key => $val) { |
|
123
|
|
|
$str .= "'" . $key . "' : '" . $val . "',"; |
|
124
|
|
|
} |
|
125
|
|
|
$str .= "'type':'wmts'}"; |
|
126
|
|
|
$renderer->doc .= base64_encode("olMapOverlays['wmts" . $overlaynumber . "'] = " . $str . ";") |
|
127
|
|
|
. '"></script>'; |
|
128
|
|
|
$overlaynumber++; |
|
129
|
|
|
return true; |
|
130
|
|
|
} |
|
131
|
|
|
} |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths