@@ -22,113 +22,113 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class syntax_plugin_openlayersmap_wmslayer extends DokuWiki_Syntax_Plugin |
| 24 | 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.3.0', |
|
| 34 | - 'format' => 'image/png', |
|
| 35 | - 'transparent' => 'true' |
|
| 36 | - ); |
|
| 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.3.0', |
|
| 34 | + 'format' => 'image/png', |
|
| 35 | + 'transparent' => 'true' |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * (non-PHPdoc) |
|
| 40 | - * |
|
| 41 | - * @see DokuWiki_Syntax_Plugin::getPType() |
|
| 42 | - */ |
|
| 43 | - public function getPType(): string |
|
| 44 | - { |
|
| 45 | - return 'block'; |
|
| 46 | - } |
|
| 38 | + /** |
|
| 39 | + * (non-PHPdoc) |
|
| 40 | + * |
|
| 41 | + * @see DokuWiki_Syntax_Plugin::getPType() |
|
| 42 | + */ |
|
| 43 | + public function getPType(): string |
|
| 44 | + { |
|
| 45 | + return 'block'; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * (non-PHPdoc) |
|
| 50 | - * |
|
| 51 | - * @see DokuWiki_Syntax_Plugin::getType() |
|
| 52 | - */ |
|
| 53 | - public function getType(): string |
|
| 54 | - { |
|
| 55 | - // return 'FIXME: container|baseonly|formatting|substition|protected|disabled|paragraphs'; |
|
| 56 | - return 'baseonly'; |
|
| 57 | - } |
|
| 48 | + /** |
|
| 49 | + * (non-PHPdoc) |
|
| 50 | + * |
|
| 51 | + * @see DokuWiki_Syntax_Plugin::getType() |
|
| 52 | + */ |
|
| 53 | + public function getType(): string |
|
| 54 | + { |
|
| 55 | + // return 'FIXME: container|baseonly|formatting|substition|protected|disabled|paragraphs'; |
|
| 56 | + return 'baseonly'; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * (non-PHPdoc) |
|
| 61 | - * |
|
| 62 | - * @see Doku_Parser_Mode::getSort() |
|
| 63 | - */ |
|
| 64 | - public function getSort(): int |
|
| 65 | - { |
|
| 66 | - return 902; |
|
| 67 | - } |
|
| 59 | + /** |
|
| 60 | + * (non-PHPdoc) |
|
| 61 | + * |
|
| 62 | + * @see Doku_Parser_Mode::getSort() |
|
| 63 | + */ |
|
| 64 | + public function getSort(): int |
|
| 65 | + { |
|
| 66 | + return 902; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Connect to our special pattern. |
|
| 71 | - * |
|
| 72 | - * @see Doku_Parser_Mode::connectTo() |
|
| 73 | - */ |
|
| 74 | - public function connectTo($mode): void |
|
| 75 | - { |
|
| 76 | - // look for: <olmap_wmslayer id="olmap" name="cloud" url="http://openweathermap.org/t/tile.cgi?SERVICE=WMS" |
|
| 77 | - // attribution="OpenWeatherMap" visible="true" layers="GLBETA_PR"></olmap_wmslayer> |
|
| 78 | - $this->Lexer->addSpecialPattern( |
|
| 79 | - '<olmap_wmslayer ?[^>\n]*>.*?</olmap_wmslayer>', |
|
| 80 | - $mode, |
|
| 81 | - 'plugin_openlayersmap_wmslayer' |
|
| 82 | - ); |
|
| 83 | - } |
|
| 69 | + /** |
|
| 70 | + * Connect to our special pattern. |
|
| 71 | + * |
|
| 72 | + * @see Doku_Parser_Mode::connectTo() |
|
| 73 | + */ |
|
| 74 | + public function connectTo($mode): void |
|
| 75 | + { |
|
| 76 | + // look for: <olmap_wmslayer id="olmap" name="cloud" url="http://openweathermap.org/t/tile.cgi?SERVICE=WMS" |
|
| 77 | + // attribution="OpenWeatherMap" visible="true" layers="GLBETA_PR"></olmap_wmslayer> |
|
| 78 | + $this->Lexer->addSpecialPattern( |
|
| 79 | + '<olmap_wmslayer ?[^>\n]*>.*?</olmap_wmslayer>', |
|
| 80 | + $mode, |
|
| 81 | + 'plugin_openlayersmap_wmslayer' |
|
| 82 | + ); |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * (non-PHPdoc) |
|
| 87 | - * |
|
| 88 | - * @see DokuWiki_Syntax_Plugin::handle() |
|
| 89 | - */ |
|
| 90 | - public function handle($match, $state, $pos, Doku_Handler $handler): array |
|
| 91 | - { |
|
| 92 | - $param = array(); |
|
| 93 | - $data = $this->dflt; |
|
| 85 | + /** |
|
| 86 | + * (non-PHPdoc) |
|
| 87 | + * |
|
| 88 | + * @see DokuWiki_Syntax_Plugin::handle() |
|
| 89 | + */ |
|
| 90 | + public function handle($match, $state, $pos, Doku_Handler $handler): array |
|
| 91 | + { |
|
| 92 | + $param = array(); |
|
| 93 | + $data = $this->dflt; |
|
| 94 | 94 | |
| 95 | - preg_match_all('/(\w*)="(.*?)"/us', $match, $param, PREG_SET_ORDER); |
|
| 95 | + preg_match_all('/(\w*)="(.*?)"/us', $match, $param, PREG_SET_ORDER); |
|
| 96 | 96 | |
| 97 | - foreach ($param as $kvpair) { |
|
| 98 | - list ($matched, $key, $val) = $kvpair; |
|
| 99 | - if (isset ($data [$key])) { |
|
| 100 | - $key = strtolower($key); |
|
| 101 | - $data [$key] = $val; |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - // dbglog($data,'syntax_plugin_overlayer::handle: parsed data is:'); |
|
| 105 | - return $data; |
|
| 106 | - } |
|
| 97 | + foreach ($param as $kvpair) { |
|
| 98 | + list ($matched, $key, $val) = $kvpair; |
|
| 99 | + if (isset ($data [$key])) { |
|
| 100 | + $key = strtolower($key); |
|
| 101 | + $data [$key] = $val; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + // dbglog($data,'syntax_plugin_overlayer::handle: parsed data is:'); |
|
| 105 | + return $data; |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * (non-PHPdoc) |
|
| 110 | - * |
|
| 111 | - * @see DokuWiki_Syntax_Plugin::render() |
|
| 112 | - */ |
|
| 113 | - public function render($format, Doku_Renderer $renderer, $data): bool |
|
| 114 | - { |
|
| 115 | - if ($format !== 'xhtml') { |
|
| 116 | - return false; |
|
| 117 | - } |
|
| 108 | + /** |
|
| 109 | + * (non-PHPdoc) |
|
| 110 | + * |
|
| 111 | + * @see DokuWiki_Syntax_Plugin::render() |
|
| 112 | + */ |
|
| 113 | + public function render($format, Doku_Renderer $renderer, $data): bool |
|
| 114 | + { |
|
| 115 | + if ($format !== 'xhtml') { |
|
| 116 | + return false; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - // incremented for each olmap_wmslayer tag in the page source |
|
| 120 | - static $overlaynumber = 0; |
|
| 119 | + // incremented for each olmap_wmslayer tag in the page source |
|
| 120 | + static $overlaynumber = 0; |
|
| 121 | 121 | |
| 122 | - list ($id, $url, $name, $visible) = $data; |
|
| 123 | - $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
| 124 | - $str = '{'; |
|
| 125 | - foreach ($data as $key => $val) { |
|
| 126 | - $str .= "'" . $key . "' : '" . $val . "',"; |
|
| 127 | - } |
|
| 128 | - $str .= "'type':'wms'}"; |
|
| 129 | - $renderer->doc .= base64_encode("olMapOverlays['wms" . $overlaynumber . "'] = " . $str . ";") |
|
| 130 | - . '"></script>'; |
|
| 131 | - $overlaynumber++; |
|
| 132 | - return true; |
|
| 133 | - } |
|
| 122 | + list ($id, $url, $name, $visible) = $data; |
|
| 123 | + $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
| 124 | + $str = '{'; |
|
| 125 | + foreach ($data as $key => $val) { |
|
| 126 | + $str .= "'" . $key . "' : '" . $val . "',"; |
|
| 127 | + } |
|
| 128 | + $str .= "'type':'wms'}"; |
|
| 129 | + $renderer->doc .= base64_encode("olMapOverlays['wms" . $overlaynumber . "'] = " . $str . ";") |
|
| 130 | + . '"></script>'; |
|
| 131 | + $overlaynumber++; |
|
| 132 | + return true; |
|
| 133 | + } |
|
| 134 | 134 | } |
| 135 | 135 | \ No newline at end of file |
@@ -120,13 +120,13 @@ |
||
| 120 | 120 | static $overlaynumber = 0; |
| 121 | 121 | |
| 122 | 122 | list ($id, $url, $name, $visible) = $data; |
| 123 | - $renderer->doc .= DOKU_LF . '<script defer="defer" src="data:text/javascript;base64,'; |
|
| 124 | - $str = '{'; |
|
| 123 | + $renderer->doc .= DOKU_LF.'<script defer="defer" src="data:text/javascript;base64,'; |
|
| 124 | + $str = '{'; |
|
| 125 | 125 | foreach ($data as $key => $val) { |
| 126 | - $str .= "'" . $key . "' : '" . $val . "',"; |
|
| 126 | + $str .= "'".$key."' : '".$val."',"; |
|
| 127 | 127 | } |
| 128 | 128 | $str .= "'type':'wms'}"; |
| 129 | - $renderer->doc .= base64_encode("olMapOverlays['wms" . $overlaynumber . "'] = " . $str . ";") |
|
| 129 | + $renderer->doc .= base64_encode("olMapOverlays['wms".$overlaynumber."'] = ".$str.";") |
|
| 130 | 130 | . '"></script>'; |
| 131 | 131 | $overlaynumber++; |
| 132 | 132 | return true; |