@@ -23,115 +23,115 @@ |
||
23 | 23 | */ |
24 | 24 | class action_plugin_geotag extends DokuWiki_Action_Plugin { |
25 | 25 | |
26 | - /** |
|
27 | - * Register for events. |
|
28 | - * |
|
29 | - * @param Doku_Event_Handler $controller |
|
30 | - * DokuWiki's event controller object. Also available as global $EVENT_HANDLER |
|
31 | - */ |
|
32 | - public function register(Doku_Event_Handler $controller) { |
|
33 | - $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleMetaheaderOutput'); |
|
34 | - if($this->getConf('toolbar_icon')) { |
|
35 | - $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array()); |
|
36 | - } |
|
37 | - } |
|
26 | + /** |
|
27 | + * Register for events. |
|
28 | + * |
|
29 | + * @param Doku_Event_Handler $controller |
|
30 | + * DokuWiki's event controller object. Also available as global $EVENT_HANDLER |
|
31 | + */ |
|
32 | + public function register(Doku_Event_Handler $controller) { |
|
33 | + $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleMetaheaderOutput'); |
|
34 | + if($this->getConf('toolbar_icon')) { |
|
35 | + $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array()); |
|
36 | + } |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Retrieve metadata and add to the head of the page using appropriate meta tags. |
|
41 | - * |
|
42 | - * @param Doku_Event $event |
|
43 | - * the DokuWiki event. $event->data is a two-dimensional |
|
44 | - * array of all meta headers. The keys are meta, link and script. |
|
45 | - * @param unknown_type $param |
|
46 | - * |
|
47 | - * @see http://www.dokuwiki.org/devel:event:tpl_metaheader_output |
|
48 | - */ |
|
49 | - public function handleMetaheaderOutput(Doku_Event $event, $param) { |
|
50 | - global $ID; |
|
51 | - $title = p_get_metadata($ID, 'title', true); |
|
52 | - $geotags = p_get_metadata($ID, 'geo', true); |
|
53 | - $region = $geotags ['region']; |
|
54 | - $lat = $geotags ['lat']; |
|
55 | - $lon = $geotags ['lon']; |
|
56 | - $alt = $geotags ['alt']; |
|
57 | - $country = $geotags ['country']; |
|
58 | - $placename = $geotags ['placename']; |
|
59 | - $geohash = $geotags ['geohash']; |
|
39 | + /** |
|
40 | + * Retrieve metadata and add to the head of the page using appropriate meta tags. |
|
41 | + * |
|
42 | + * @param Doku_Event $event |
|
43 | + * the DokuWiki event. $event->data is a two-dimensional |
|
44 | + * array of all meta headers. The keys are meta, link and script. |
|
45 | + * @param unknown_type $param |
|
46 | + * |
|
47 | + * @see http://www.dokuwiki.org/devel:event:tpl_metaheader_output |
|
48 | + */ |
|
49 | + public function handleMetaheaderOutput(Doku_Event $event, $param) { |
|
50 | + global $ID; |
|
51 | + $title = p_get_metadata($ID, 'title', true); |
|
52 | + $geotags = p_get_metadata($ID, 'geo', true); |
|
53 | + $region = $geotags ['region']; |
|
54 | + $lat = $geotags ['lat']; |
|
55 | + $lon = $geotags ['lon']; |
|
56 | + $alt = $geotags ['alt']; |
|
57 | + $country = $geotags ['country']; |
|
58 | + $placename = $geotags ['placename']; |
|
59 | + $geohash = $geotags ['geohash']; |
|
60 | 60 | |
61 | - if(!empty ($region)) { |
|
62 | - $event->data ['meta'] [] = array( |
|
63 | - 'name' => 'geo.region', |
|
64 | - 'content' => $region |
|
65 | - ); |
|
66 | - } |
|
67 | - if(!empty ($placename)) { |
|
68 | - $event->data ['meta'] [] = array( |
|
69 | - 'name' => 'geo.placename', |
|
70 | - 'content' => $placename |
|
71 | - ); |
|
72 | - } |
|
73 | - if(!(empty ($lat) && empty ($lon))) { |
|
74 | - if(!empty ($alt)) { |
|
75 | - $event->data ['meta'] [] = array( |
|
76 | - 'name' => 'geo.position', |
|
77 | - 'content' => $lat . ';' . $lon . ';' . $alt |
|
78 | - ); |
|
79 | - } else { |
|
80 | - $event->data ['meta'] [] = array( |
|
81 | - 'name' => 'geo.position', |
|
82 | - 'content' => $lat . ';' . $lon |
|
83 | - ); |
|
84 | - } |
|
85 | - } |
|
86 | - if(!empty ($country)) { |
|
87 | - $event->data ['meta'] [] = array( |
|
88 | - 'name' => 'geo.country', |
|
89 | - 'content' => $country |
|
90 | - ); |
|
91 | - } |
|
92 | - if(!(empty ($lat) && empty ($lon))) { |
|
93 | - $event->data ['meta'] [] = array( |
|
94 | - 'name' => "ICBM", |
|
95 | - 'content' => $lat . ', ' . $lon |
|
96 | - ); |
|
97 | - // icbm is generally useless without a DC.title, |
|
98 | - // so we copy that from title unless it's empty... |
|
99 | - if(!(empty ($title))) { |
|
100 | - /* |
|
61 | + if(!empty ($region)) { |
|
62 | + $event->data ['meta'] [] = array( |
|
63 | + 'name' => 'geo.region', |
|
64 | + 'content' => $region |
|
65 | + ); |
|
66 | + } |
|
67 | + if(!empty ($placename)) { |
|
68 | + $event->data ['meta'] [] = array( |
|
69 | + 'name' => 'geo.placename', |
|
70 | + 'content' => $placename |
|
71 | + ); |
|
72 | + } |
|
73 | + if(!(empty ($lat) && empty ($lon))) { |
|
74 | + if(!empty ($alt)) { |
|
75 | + $event->data ['meta'] [] = array( |
|
76 | + 'name' => 'geo.position', |
|
77 | + 'content' => $lat . ';' . $lon . ';' . $alt |
|
78 | + ); |
|
79 | + } else { |
|
80 | + $event->data ['meta'] [] = array( |
|
81 | + 'name' => 'geo.position', |
|
82 | + 'content' => $lat . ';' . $lon |
|
83 | + ); |
|
84 | + } |
|
85 | + } |
|
86 | + if(!empty ($country)) { |
|
87 | + $event->data ['meta'] [] = array( |
|
88 | + 'name' => 'geo.country', |
|
89 | + 'content' => $country |
|
90 | + ); |
|
91 | + } |
|
92 | + if(!(empty ($lat) && empty ($lon))) { |
|
93 | + $event->data ['meta'] [] = array( |
|
94 | + 'name' => "ICBM", |
|
95 | + 'content' => $lat . ', ' . $lon |
|
96 | + ); |
|
97 | + // icbm is generally useless without a DC.title, |
|
98 | + // so we copy that from title unless it's empty... |
|
99 | + if(!(empty ($title))) { |
|
100 | + /* |
|
101 | 101 | * don't specify the DC namespace as this is incomplete; it should be done at the |
102 | 102 | * template level as it also needs a 'profile' attribute on the head/container, |
103 | 103 | * see: http://dublincore.org/documents/dc-html/#sect-3.1.1 |
104 | 104 | * $event->data ['link'] [] = array ('rel' => 'schema.DC', |
105 | 105 | * 'href' => 'http://purl.org/dc/elements/1.1/'); |
106 | 106 | */ |
107 | - $event->data ['meta'] [] = array( |
|
108 | - 'name' => "DC.title", |
|
109 | - 'content' => $title |
|
110 | - ); |
|
111 | - } |
|
112 | - } |
|
113 | - if(!empty ($geohash)) { |
|
114 | - $event->data ['meta'] [] = array( |
|
115 | - 'name' => 'geo.geohash', |
|
116 | - 'content' => $geohash |
|
117 | - ); |
|
118 | - } |
|
119 | - } |
|
107 | + $event->data ['meta'] [] = array( |
|
108 | + 'name' => "DC.title", |
|
109 | + 'content' => $title |
|
110 | + ); |
|
111 | + } |
|
112 | + } |
|
113 | + if(!empty ($geohash)) { |
|
114 | + $event->data ['meta'] [] = array( |
|
115 | + 'name' => 'geo.geohash', |
|
116 | + 'content' => $geohash |
|
117 | + ); |
|
118 | + } |
|
119 | + } |
|
120 | 120 | |
121 | - /** |
|
122 | - * Inserts the toolbar button. |
|
123 | - * |
|
124 | - * @param Doku_Event $event |
|
125 | - * the DokuWiki event |
|
126 | - */ |
|
127 | - public function insertButton(Doku_Event $event, $param) { |
|
128 | - $event->data [] = array( |
|
129 | - 'type' => 'format', |
|
130 | - 'title' => $this->getLang('toolbar_desc'), |
|
131 | - 'icon' => '../../plugins/geotag/images/geotag.png', |
|
132 | - 'open' => '{{geotag>lat:', |
|
133 | - 'sample' => '52.2345', |
|
134 | - 'close' => ', lon:7.521, alt: , placename: , country: , region: }}' |
|
135 | - ); |
|
136 | - } |
|
121 | + /** |
|
122 | + * Inserts the toolbar button. |
|
123 | + * |
|
124 | + * @param Doku_Event $event |
|
125 | + * the DokuWiki event |
|
126 | + */ |
|
127 | + public function insertButton(Doku_Event $event, $param) { |
|
128 | + $event->data [] = array( |
|
129 | + 'type' => 'format', |
|
130 | + 'title' => $this->getLang('toolbar_desc'), |
|
131 | + 'icon' => '../../plugins/geotag/images/geotag.png', |
|
132 | + 'open' => '{{geotag>lat:', |
|
133 | + 'sample' => '52.2345', |
|
134 | + 'close' => ', lon:7.521, alt: , placename: , country: , region: }}' |
|
135 | + ); |
|
136 | + } |
|
137 | 137 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function register(Doku_Event_Handler $controller) { |
33 | 33 | $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handleMetaheaderOutput'); |
34 | - if($this->getConf('toolbar_icon')) { |
|
34 | + if ($this->getConf('toolbar_icon')) { |
|
35 | 35 | $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array()); |
36 | 36 | } |
37 | 37 | } |
@@ -58,20 +58,20 @@ discard block |
||
58 | 58 | $placename = $geotags ['placename']; |
59 | 59 | $geohash = $geotags ['geohash']; |
60 | 60 | |
61 | - if(!empty ($region)) { |
|
61 | + if (!empty ($region)) { |
|
62 | 62 | $event->data ['meta'] [] = array( |
63 | 63 | 'name' => 'geo.region', |
64 | 64 | 'content' => $region |
65 | 65 | ); |
66 | 66 | } |
67 | - if(!empty ($placename)) { |
|
67 | + if (!empty ($placename)) { |
|
68 | 68 | $event->data ['meta'] [] = array( |
69 | 69 | 'name' => 'geo.placename', |
70 | 70 | 'content' => $placename |
71 | 71 | ); |
72 | 72 | } |
73 | - if(!(empty ($lat) && empty ($lon))) { |
|
74 | - if(!empty ($alt)) { |
|
73 | + if (!(empty ($lat) && empty ($lon))) { |
|
74 | + if (!empty ($alt)) { |
|
75 | 75 | $event->data ['meta'] [] = array( |
76 | 76 | 'name' => 'geo.position', |
77 | 77 | 'content' => $lat . ';' . $lon . ';' . $alt |
@@ -83,20 +83,20 @@ discard block |
||
83 | 83 | ); |
84 | 84 | } |
85 | 85 | } |
86 | - if(!empty ($country)) { |
|
86 | + if (!empty ($country)) { |
|
87 | 87 | $event->data ['meta'] [] = array( |
88 | 88 | 'name' => 'geo.country', |
89 | 89 | 'content' => $country |
90 | 90 | ); |
91 | 91 | } |
92 | - if(!(empty ($lat) && empty ($lon))) { |
|
92 | + if (!(empty ($lat) && empty ($lon))) { |
|
93 | 93 | $event->data ['meta'] [] = array( |
94 | 94 | 'name' => "ICBM", |
95 | 95 | 'content' => $lat . ', ' . $lon |
96 | 96 | ); |
97 | 97 | // icbm is generally useless without a DC.title, |
98 | 98 | // so we copy that from title unless it's empty... |
99 | - if(!(empty ($title))) { |
|
99 | + if (!(empty ($title))) { |
|
100 | 100 | /* |
101 | 101 | * don't specify the DC namespace as this is incomplete; it should be done at the |
102 | 102 | * template level as it also needs a 'profile' attribute on the head/container, |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | ); |
111 | 111 | } |
112 | 112 | } |
113 | - if(!empty ($geohash)) { |
|
113 | + if (!empty ($geohash)) { |
|
114 | 114 | $event->data ['meta'] [] = array( |
115 | 115 | 'name' => 'geo.geohash', |
116 | 116 | 'content' => $geohash |
@@ -24,232 +24,232 @@ |
||
24 | 24 | * @author Mark C. Prins <[email protected]> |
25 | 25 | */ |
26 | 26 | class syntax_plugin_geotag_geotag extends DokuWiki_Syntax_Plugin { |
27 | - /** |
|
28 | - * |
|
29 | - * @see DokuWiki_Syntax_Plugin::getType() |
|
30 | - */ |
|
31 | - public function getType() { |
|
32 | - return 'substition'; |
|
33 | - } |
|
27 | + /** |
|
28 | + * |
|
29 | + * @see DokuWiki_Syntax_Plugin::getType() |
|
30 | + */ |
|
31 | + public function getType() { |
|
32 | + return 'substition'; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * |
|
37 | - * @see DokuWiki_Syntax_Plugin::getPType() |
|
38 | - */ |
|
39 | - public function getPType() { |
|
40 | - return 'block'; |
|
41 | - } |
|
35 | + /** |
|
36 | + * |
|
37 | + * @see DokuWiki_Syntax_Plugin::getPType() |
|
38 | + */ |
|
39 | + public function getPType() { |
|
40 | + return 'block'; |
|
41 | + } |
|
42 | 42 | |
43 | - /** |
|
44 | - * |
|
45 | - * @see Doku_Parser_Mode::getSort() |
|
46 | - */ |
|
47 | - public function getSort() { |
|
48 | - return 305; |
|
49 | - } |
|
43 | + /** |
|
44 | + * |
|
45 | + * @see Doku_Parser_Mode::getSort() |
|
46 | + */ |
|
47 | + public function getSort() { |
|
48 | + return 305; |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * |
|
53 | - * @see Doku_Parser_Mode::connectTo() |
|
54 | - */ |
|
55 | - public function connectTo($mode) { |
|
56 | - $this->Lexer->addSpecialPattern('\{\{geotag>.*?\}\}', $mode, 'plugin_geotag_geotag'); |
|
57 | - } |
|
51 | + /** |
|
52 | + * |
|
53 | + * @see Doku_Parser_Mode::connectTo() |
|
54 | + */ |
|
55 | + public function connectTo($mode) { |
|
56 | + $this->Lexer->addSpecialPattern('\{\{geotag>.*?\}\}', $mode, 'plugin_geotag_geotag'); |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * |
|
61 | - * @see DokuWiki_Syntax_Plugin::handle() |
|
62 | - */ |
|
63 | - public function handle($match, $state, $pos, Doku_Handler $handler) { |
|
64 | - $tags = trim(substr($match, 9, -2)); |
|
65 | - // parse geotag content |
|
66 | - preg_match("(lat[:|=]-?\d*\.\d*)", $tags, $lat); |
|
67 | - preg_match("(lon[:|=]-?\d*\.\d*)", $tags, $lon); |
|
68 | - preg_match("(alt[:|=]-?\d*\.?\d*)", $tags, $alt); |
|
69 | - preg_match("/(region[:|=][\p{L}\s\w'-]*)/u", $tags, $region); |
|
70 | - preg_match("/(placename[:|=][\p{L}\s\w'-]*)/u", $tags, $placename); |
|
71 | - preg_match("/(country[:|=][\p{L}\s\w'-]*)/u", $tags, $country); |
|
72 | - preg_match("(hide|unhide)", $tags, $hide); |
|
59 | + /** |
|
60 | + * |
|
61 | + * @see DokuWiki_Syntax_Plugin::handle() |
|
62 | + */ |
|
63 | + public function handle($match, $state, $pos, Doku_Handler $handler) { |
|
64 | + $tags = trim(substr($match, 9, -2)); |
|
65 | + // parse geotag content |
|
66 | + preg_match("(lat[:|=]-?\d*\.\d*)", $tags, $lat); |
|
67 | + preg_match("(lon[:|=]-?\d*\.\d*)", $tags, $lon); |
|
68 | + preg_match("(alt[:|=]-?\d*\.?\d*)", $tags, $alt); |
|
69 | + preg_match("/(region[:|=][\p{L}\s\w'-]*)/u", $tags, $region); |
|
70 | + preg_match("/(placename[:|=][\p{L}\s\w'-]*)/u", $tags, $placename); |
|
71 | + preg_match("/(country[:|=][\p{L}\s\w'-]*)/u", $tags, $country); |
|
72 | + preg_match("(hide|unhide)", $tags, $hide); |
|
73 | 73 | |
74 | - $showlocation = $this->getConf('geotag_location_prefix'); |
|
75 | - if($this->getConf('geotag_showlocation')) { |
|
76 | - $showlocation = trim(substr($placename [0], 10)); |
|
77 | - if(strlen($showlocation) < 1) { |
|
78 | - $showlocation = $this->getConf('geotag_location_prefix'); |
|
79 | - } |
|
80 | - } |
|
81 | - // read config for system setting |
|
82 | - $style = ''; |
|
83 | - if($this->getConf('geotag_hide')) { |
|
84 | - $style = ' style="display: none;"'; |
|
85 | - } |
|
86 | - // override config for the current tag |
|
87 | - if(array_key_exists(0, $hide) && trim($hide [0]) == 'hide') { |
|
88 | - $style = ' style="display: none;"'; |
|
89 | - } elseif(array_key_exists(0, $hide) && trim($hide [0]) == 'unhide') { |
|
90 | - $style = ''; |
|
91 | - } |
|
74 | + $showlocation = $this->getConf('geotag_location_prefix'); |
|
75 | + if($this->getConf('geotag_showlocation')) { |
|
76 | + $showlocation = trim(substr($placename [0], 10)); |
|
77 | + if(strlen($showlocation) < 1) { |
|
78 | + $showlocation = $this->getConf('geotag_location_prefix'); |
|
79 | + } |
|
80 | + } |
|
81 | + // read config for system setting |
|
82 | + $style = ''; |
|
83 | + if($this->getConf('geotag_hide')) { |
|
84 | + $style = ' style="display: none;"'; |
|
85 | + } |
|
86 | + // override config for the current tag |
|
87 | + if(array_key_exists(0, $hide) && trim($hide [0]) == 'hide') { |
|
88 | + $style = ' style="display: none;"'; |
|
89 | + } elseif(array_key_exists(0, $hide) && trim($hide [0]) == 'unhide') { |
|
90 | + $style = ''; |
|
91 | + } |
|
92 | 92 | |
93 | - $data = array( |
|
94 | - hsc(trim(substr($lat [0], 4))), |
|
95 | - hsc(trim(substr($lon [0], 4))), |
|
96 | - hsc(trim(substr(($alt[0] ?? ''), 4))), |
|
97 | - $this->geohash(substr($lat [0], 4), substr($lon [0], 4)), |
|
98 | - hsc(trim(substr(($region[0] ?? ''), 7))), |
|
99 | - hsc(trim(substr(($placename[0] ?? ''), 10))), |
|
100 | - hsc(trim(substr(($country [0] ?? ''), 8))), |
|
101 | - hsc($showlocation), |
|
102 | - $style |
|
103 | - ); |
|
104 | - return $data; |
|
105 | - } |
|
93 | + $data = array( |
|
94 | + hsc(trim(substr($lat [0], 4))), |
|
95 | + hsc(trim(substr($lon [0], 4))), |
|
96 | + hsc(trim(substr(($alt[0] ?? ''), 4))), |
|
97 | + $this->geohash(substr($lat [0], 4), substr($lon [0], 4)), |
|
98 | + hsc(trim(substr(($region[0] ?? ''), 7))), |
|
99 | + hsc(trim(substr(($placename[0] ?? ''), 10))), |
|
100 | + hsc(trim(substr(($country [0] ?? ''), 8))), |
|
101 | + hsc($showlocation), |
|
102 | + $style |
|
103 | + ); |
|
104 | + return $data; |
|
105 | + } |
|
106 | 106 | |
107 | - /** |
|
108 | - * Calculate the geohash for this lat/lon pair. |
|
109 | - * |
|
110 | - * @param float $lat |
|
111 | - * @param float $lon |
|
112 | - */ |
|
113 | - private function geohash($lat, $lon) { |
|
114 | - if(!$geophp = plugin_load('helper', 'geophp')) { |
|
115 | - dbglog($geophp, 'syntax_plugin_geotag_geotag::geohash: geophp plugin is not available.'); |
|
116 | - return ""; |
|
117 | - } |
|
118 | - $_lat = floatval($lat); |
|
119 | - $_lon = floatval($lon); |
|
120 | - $geometry = new Point($_lon, $_lat); |
|
121 | - return $geometry->out('geohash'); |
|
122 | - } |
|
107 | + /** |
|
108 | + * Calculate the geohash for this lat/lon pair. |
|
109 | + * |
|
110 | + * @param float $lat |
|
111 | + * @param float $lon |
|
112 | + */ |
|
113 | + private function geohash($lat, $lon) { |
|
114 | + if(!$geophp = plugin_load('helper', 'geophp')) { |
|
115 | + dbglog($geophp, 'syntax_plugin_geotag_geotag::geohash: geophp plugin is not available.'); |
|
116 | + return ""; |
|
117 | + } |
|
118 | + $_lat = floatval($lat); |
|
119 | + $_lon = floatval($lon); |
|
120 | + $geometry = new Point($_lon, $_lat); |
|
121 | + return $geometry->out('geohash'); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * |
|
126 | - * @see DokuWiki_Syntax_Plugin::render() |
|
127 | - */ |
|
128 | - public function render($mode, Doku_Renderer $renderer, $data) { |
|
129 | - if($data === false) { |
|
130 | - return false; |
|
131 | - } |
|
132 | - list ($lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style) = $data; |
|
133 | - $ddlat = $lat; |
|
134 | - $ddlon = $lon; |
|
135 | - if($this->getConf('displayformat') === 'DMS') { |
|
136 | - $lat = $this->convertLat($lat); |
|
137 | - $lon = $this->convertLon($lon); |
|
138 | - } else { |
|
139 | - $lat .= 'º'; |
|
140 | - $lon .= 'º'; |
|
141 | - } |
|
124 | + /** |
|
125 | + * |
|
126 | + * @see DokuWiki_Syntax_Plugin::render() |
|
127 | + */ |
|
128 | + public function render($mode, Doku_Renderer $renderer, $data) { |
|
129 | + if($data === false) { |
|
130 | + return false; |
|
131 | + } |
|
132 | + list ($lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style) = $data; |
|
133 | + $ddlat = $lat; |
|
134 | + $ddlon = $lon; |
|
135 | + if($this->getConf('displayformat') === 'DMS') { |
|
136 | + $lat = $this->convertLat($lat); |
|
137 | + $lon = $this->convertLon($lon); |
|
138 | + } else { |
|
139 | + $lat .= 'º'; |
|
140 | + $lon .= 'º'; |
|
141 | + } |
|
142 | 142 | |
143 | - if($mode == 'xhtml') { |
|
144 | - if($this->getConf('geotag_prevent_microformat_render')) { |
|
145 | - return true; |
|
146 | - } |
|
147 | - $searchPre = ''; |
|
148 | - $searchPost = ''; |
|
149 | - if($this->getConf('geotag_showsearch')) { |
|
150 | - if($spHelper = &plugin_load('helper', 'spatialhelper_search')) { |
|
151 | - $title = $this->getLang('findnearby') . ' ' . $placename; |
|
152 | - $url = wl( |
|
153 | - getID(), array( |
|
154 | - 'do' => 'findnearby', |
|
155 | - 'lat' => $ddlat, |
|
156 | - 'lon' => $ddlon |
|
157 | - ) |
|
158 | - ); |
|
159 | - $searchPre = '<a href="' . $url . '" title="' . $title . '">'; |
|
160 | - $searchPost = '<span class="a11y">' . $title . '</span></a>'; |
|
161 | - } |
|
162 | - } |
|
143 | + if($mode == 'xhtml') { |
|
144 | + if($this->getConf('geotag_prevent_microformat_render')) { |
|
145 | + return true; |
|
146 | + } |
|
147 | + $searchPre = ''; |
|
148 | + $searchPost = ''; |
|
149 | + if($this->getConf('geotag_showsearch')) { |
|
150 | + if($spHelper = &plugin_load('helper', 'spatialhelper_search')) { |
|
151 | + $title = $this->getLang('findnearby') . ' ' . $placename; |
|
152 | + $url = wl( |
|
153 | + getID(), array( |
|
154 | + 'do' => 'findnearby', |
|
155 | + 'lat' => $ddlat, |
|
156 | + 'lon' => $ddlon |
|
157 | + ) |
|
158 | + ); |
|
159 | + $searchPre = '<a href="' . $url . '" title="' . $title . '">'; |
|
160 | + $searchPost = '<span class="a11y">' . $title . '</span></a>'; |
|
161 | + } |
|
162 | + } |
|
163 | 163 | |
164 | - // render geotag microformat/schema.org microdata |
|
165 | - $renderer->doc .= '<span class="geotagPrint">' . $this->getLang('geotag_desc') . '</span>'; |
|
166 | - $renderer->doc .= '<div class="h-geo geo"' . $style . ' title="' . $this->getLang('geotag_desc') |
|
167 | - . $placename . '" itemscope itemtype="http://schema.org/Place">'; |
|
168 | - $renderer->doc .= '<span itemprop="name">' . $showlocation . '</span>: ' . $searchPre; |
|
169 | - $renderer->doc .= '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">'; |
|
170 | - $renderer->doc .= '<span class="p-latitude latitude" itemprop="latitude" data-latitude="' . $ddlat . '">' |
|
171 | - . $lat . '</span>;'; |
|
172 | - $renderer->doc .= '<span class="p-longitude longitude" itemprop="longitude" data-longitude="' . $ddlon |
|
173 | - . '">' . $lon . '</span>'; |
|
174 | - if(!empty ($alt)) { |
|
175 | - $renderer->doc .= ', <span class="p-altitude altitude" itemprop="elevation" data-altitude="' . $alt |
|
176 | - . '">' . $alt . 'm</span>'; |
|
177 | - } |
|
178 | - $renderer->doc .= '</span>' . $searchPost . '</div>' . DOKU_LF; |
|
179 | - return true; |
|
180 | - } elseif($mode == 'metadata') { |
|
181 | - // render metadata (our action plugin will put it in the page head) |
|
182 | - $renderer->meta ['geo'] ['lat'] = $ddlat; |
|
183 | - $renderer->meta ['geo'] ['lon'] = $ddlon; |
|
184 | - $renderer->meta ['geo'] ['placename'] = $placename; |
|
185 | - $renderer->meta ['geo'] ['region'] = $region; |
|
186 | - $renderer->meta ['geo'] ['country'] = $country; |
|
187 | - $renderer->meta ['geo'] ['geohash'] = $geohash; |
|
188 | - $renderer->meta ['geo'] ['alt'] = $alt; |
|
189 | - return true; |
|
190 | - } elseif($mode == 'odt') { |
|
191 | - if(!empty ($alt)) { |
|
192 | - $alt = ', ' . $alt . 'm'; |
|
193 | - } |
|
194 | - $renderer->p_open(); |
|
195 | - $renderer->_odtAddImage(DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', ''); |
|
196 | - $renderer->cdata($this->getLang('geotag_desc') . ' ' . $placename); |
|
197 | - $renderer->monospace_open(); |
|
198 | - $renderer->cdata($lat . ';' . $lon . $alt); |
|
199 | - $renderer->monospace_close(); |
|
200 | - $renderer->p_close(); |
|
201 | - return true; |
|
202 | - } |
|
203 | - return false; |
|
204 | - } |
|
164 | + // render geotag microformat/schema.org microdata |
|
165 | + $renderer->doc .= '<span class="geotagPrint">' . $this->getLang('geotag_desc') . '</span>'; |
|
166 | + $renderer->doc .= '<div class="h-geo geo"' . $style . ' title="' . $this->getLang('geotag_desc') |
|
167 | + . $placename . '" itemscope itemtype="http://schema.org/Place">'; |
|
168 | + $renderer->doc .= '<span itemprop="name">' . $showlocation . '</span>: ' . $searchPre; |
|
169 | + $renderer->doc .= '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">'; |
|
170 | + $renderer->doc .= '<span class="p-latitude latitude" itemprop="latitude" data-latitude="' . $ddlat . '">' |
|
171 | + . $lat . '</span>;'; |
|
172 | + $renderer->doc .= '<span class="p-longitude longitude" itemprop="longitude" data-longitude="' . $ddlon |
|
173 | + . '">' . $lon . '</span>'; |
|
174 | + if(!empty ($alt)) { |
|
175 | + $renderer->doc .= ', <span class="p-altitude altitude" itemprop="elevation" data-altitude="' . $alt |
|
176 | + . '">' . $alt . 'm</span>'; |
|
177 | + } |
|
178 | + $renderer->doc .= '</span>' . $searchPost . '</div>' . DOKU_LF; |
|
179 | + return true; |
|
180 | + } elseif($mode == 'metadata') { |
|
181 | + // render metadata (our action plugin will put it in the page head) |
|
182 | + $renderer->meta ['geo'] ['lat'] = $ddlat; |
|
183 | + $renderer->meta ['geo'] ['lon'] = $ddlon; |
|
184 | + $renderer->meta ['geo'] ['placename'] = $placename; |
|
185 | + $renderer->meta ['geo'] ['region'] = $region; |
|
186 | + $renderer->meta ['geo'] ['country'] = $country; |
|
187 | + $renderer->meta ['geo'] ['geohash'] = $geohash; |
|
188 | + $renderer->meta ['geo'] ['alt'] = $alt; |
|
189 | + return true; |
|
190 | + } elseif($mode == 'odt') { |
|
191 | + if(!empty ($alt)) { |
|
192 | + $alt = ', ' . $alt . 'm'; |
|
193 | + } |
|
194 | + $renderer->p_open(); |
|
195 | + $renderer->_odtAddImage(DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', ''); |
|
196 | + $renderer->cdata($this->getLang('geotag_desc') . ' ' . $placename); |
|
197 | + $renderer->monospace_open(); |
|
198 | + $renderer->cdata($lat . ';' . $lon . $alt); |
|
199 | + $renderer->monospace_close(); |
|
200 | + $renderer->p_close(); |
|
201 | + return true; |
|
202 | + } |
|
203 | + return false; |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
207 | - * convert latitude in decimal degrees to DMS+hemisphere. |
|
208 | - * |
|
209 | - * @param float $decimaldegrees |
|
210 | - * @return string |
|
211 | - * @todo move this into a shared library |
|
212 | - */ |
|
213 | - private function convertLat($decimaldegrees) { |
|
214 | - if(strpos($decimaldegrees, '-') !== false) { |
|
215 | - $latPos = "S"; |
|
216 | - } else { |
|
217 | - $latPos = "N"; |
|
218 | - } |
|
219 | - $dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
220 | - return hsc($dms . $latPos); |
|
221 | - } |
|
206 | + /** |
|
207 | + * convert latitude in decimal degrees to DMS+hemisphere. |
|
208 | + * |
|
209 | + * @param float $decimaldegrees |
|
210 | + * @return string |
|
211 | + * @todo move this into a shared library |
|
212 | + */ |
|
213 | + private function convertLat($decimaldegrees) { |
|
214 | + if(strpos($decimaldegrees, '-') !== false) { |
|
215 | + $latPos = "S"; |
|
216 | + } else { |
|
217 | + $latPos = "N"; |
|
218 | + } |
|
219 | + $dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
220 | + return hsc($dms . $latPos); |
|
221 | + } |
|
222 | 222 | |
223 | - /** |
|
224 | - * Convert decimal degrees to degrees, minutes, seconds format |
|
225 | - * |
|
226 | - * @param float $decimaldegrees |
|
227 | - * @return string dms |
|
228 | - * @todo move this into a shared library |
|
229 | - */ |
|
230 | - private function convertDDtoDMS($decimaldegrees) { |
|
231 | - $dms = floor($decimaldegrees); |
|
232 | - $secs = ($decimaldegrees - $dms) * 3600; |
|
233 | - $min = floor($secs / 60); |
|
234 | - $sec = round($secs - ($min * 60), 3); |
|
235 | - $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
236 | - return $dms; |
|
237 | - } |
|
223 | + /** |
|
224 | + * Convert decimal degrees to degrees, minutes, seconds format |
|
225 | + * |
|
226 | + * @param float $decimaldegrees |
|
227 | + * @return string dms |
|
228 | + * @todo move this into a shared library |
|
229 | + */ |
|
230 | + private function convertDDtoDMS($decimaldegrees) { |
|
231 | + $dms = floor($decimaldegrees); |
|
232 | + $secs = ($decimaldegrees - $dms) * 3600; |
|
233 | + $min = floor($secs / 60); |
|
234 | + $sec = round($secs - ($min * 60), 3); |
|
235 | + $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
236 | + return $dms; |
|
237 | + } |
|
238 | 238 | |
239 | - /** |
|
240 | - * convert longitude in decimal degrees to DMS+hemisphere. |
|
241 | - * |
|
242 | - * @param float $decimaldegrees |
|
243 | - * @return string |
|
244 | - * @todo move this into a shared library |
|
245 | - */ |
|
246 | - private function convertLon($decimaldegrees) { |
|
247 | - if(strpos($decimaldegrees, '-') !== false) { |
|
248 | - $lonPos = "W"; |
|
249 | - } else { |
|
250 | - $lonPos = "E"; |
|
251 | - } |
|
252 | - $dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
253 | - return hsc($dms . $lonPos); |
|
254 | - } |
|
239 | + /** |
|
240 | + * convert longitude in decimal degrees to DMS+hemisphere. |
|
241 | + * |
|
242 | + * @param float $decimaldegrees |
|
243 | + * @return string |
|
244 | + * @todo move this into a shared library |
|
245 | + */ |
|
246 | + private function convertLon($decimaldegrees) { |
|
247 | + if(strpos($decimaldegrees, '-') !== false) { |
|
248 | + $lonPos = "W"; |
|
249 | + } else { |
|
250 | + $lonPos = "E"; |
|
251 | + } |
|
252 | + $dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
253 | + return hsc($dms . $lonPos); |
|
254 | + } |
|
255 | 255 | } |
@@ -72,21 +72,21 @@ discard block |
||
72 | 72 | preg_match("(hide|unhide)", $tags, $hide); |
73 | 73 | |
74 | 74 | $showlocation = $this->getConf('geotag_location_prefix'); |
75 | - if($this->getConf('geotag_showlocation')) { |
|
75 | + if ($this->getConf('geotag_showlocation')) { |
|
76 | 76 | $showlocation = trim(substr($placename [0], 10)); |
77 | - if(strlen($showlocation) < 1) { |
|
77 | + if (strlen($showlocation) < 1) { |
|
78 | 78 | $showlocation = $this->getConf('geotag_location_prefix'); |
79 | 79 | } |
80 | 80 | } |
81 | 81 | // read config for system setting |
82 | 82 | $style = ''; |
83 | - if($this->getConf('geotag_hide')) { |
|
83 | + if ($this->getConf('geotag_hide')) { |
|
84 | 84 | $style = ' style="display: none;"'; |
85 | 85 | } |
86 | 86 | // override config for the current tag |
87 | - if(array_key_exists(0, $hide) && trim($hide [0]) == 'hide') { |
|
87 | + if (array_key_exists(0, $hide) && trim($hide [0]) == 'hide') { |
|
88 | 88 | $style = ' style="display: none;"'; |
89 | - } elseif(array_key_exists(0, $hide) && trim($hide [0]) == 'unhide') { |
|
89 | + } elseif (array_key_exists(0, $hide) && trim($hide [0]) == 'unhide') { |
|
90 | 90 | $style = ''; |
91 | 91 | } |
92 | 92 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | * @param float $lon |
112 | 112 | */ |
113 | 113 | private function geohash($lat, $lon) { |
114 | - if(!$geophp = plugin_load('helper', 'geophp')) { |
|
114 | + if (!$geophp = plugin_load('helper', 'geophp')) { |
|
115 | 115 | dbglog($geophp, 'syntax_plugin_geotag_geotag::geohash: geophp plugin is not available.'); |
116 | 116 | return ""; |
117 | 117 | } |
@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | * @see DokuWiki_Syntax_Plugin::render() |
127 | 127 | */ |
128 | 128 | public function render($mode, Doku_Renderer $renderer, $data) { |
129 | - if($data === false) { |
|
129 | + if ($data === false) { |
|
130 | 130 | return false; |
131 | 131 | } |
132 | 132 | list ($lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style) = $data; |
133 | 133 | $ddlat = $lat; |
134 | 134 | $ddlon = $lon; |
135 | - if($this->getConf('displayformat') === 'DMS') { |
|
135 | + if ($this->getConf('displayformat') === 'DMS') { |
|
136 | 136 | $lat = $this->convertLat($lat); |
137 | 137 | $lon = $this->convertLon($lon); |
138 | 138 | } else { |
@@ -140,14 +140,14 @@ discard block |
||
140 | 140 | $lon .= 'º'; |
141 | 141 | } |
142 | 142 | |
143 | - if($mode == 'xhtml') { |
|
144 | - if($this->getConf('geotag_prevent_microformat_render')) { |
|
143 | + if ($mode == 'xhtml') { |
|
144 | + if ($this->getConf('geotag_prevent_microformat_render')) { |
|
145 | 145 | return true; |
146 | 146 | } |
147 | 147 | $searchPre = ''; |
148 | 148 | $searchPost = ''; |
149 | - if($this->getConf('geotag_showsearch')) { |
|
150 | - if($spHelper = &plugin_load('helper', 'spatialhelper_search')) { |
|
149 | + if ($this->getConf('geotag_showsearch')) { |
|
150 | + if ($spHelper = &plugin_load('helper', 'spatialhelper_search')) { |
|
151 | 151 | $title = $this->getLang('findnearby') . ' ' . $placename; |
152 | 152 | $url = wl( |
153 | 153 | getID(), array( |
@@ -171,13 +171,13 @@ discard block |
||
171 | 171 | . $lat . '</span>;'; |
172 | 172 | $renderer->doc .= '<span class="p-longitude longitude" itemprop="longitude" data-longitude="' . $ddlon |
173 | 173 | . '">' . $lon . '</span>'; |
174 | - if(!empty ($alt)) { |
|
174 | + if (!empty ($alt)) { |
|
175 | 175 | $renderer->doc .= ', <span class="p-altitude altitude" itemprop="elevation" data-altitude="' . $alt |
176 | 176 | . '">' . $alt . 'm</span>'; |
177 | 177 | } |
178 | 178 | $renderer->doc .= '</span>' . $searchPost . '</div>' . DOKU_LF; |
179 | 179 | return true; |
180 | - } elseif($mode == 'metadata') { |
|
180 | + } elseif ($mode == 'metadata') { |
|
181 | 181 | // render metadata (our action plugin will put it in the page head) |
182 | 182 | $renderer->meta ['geo'] ['lat'] = $ddlat; |
183 | 183 | $renderer->meta ['geo'] ['lon'] = $ddlon; |
@@ -187,8 +187,8 @@ discard block |
||
187 | 187 | $renderer->meta ['geo'] ['geohash'] = $geohash; |
188 | 188 | $renderer->meta ['geo'] ['alt'] = $alt; |
189 | 189 | return true; |
190 | - } elseif($mode == 'odt') { |
|
191 | - if(!empty ($alt)) { |
|
190 | + } elseif ($mode == 'odt') { |
|
191 | + if (!empty ($alt)) { |
|
192 | 192 | $alt = ', ' . $alt . 'm'; |
193 | 193 | } |
194 | 194 | $renderer->p_open(); |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @todo move this into a shared library |
212 | 212 | */ |
213 | 213 | private function convertLat($decimaldegrees) { |
214 | - if(strpos($decimaldegrees, '-') !== false) { |
|
214 | + if (strpos($decimaldegrees, '-') !== false) { |
|
215 | 215 | $latPos = "S"; |
216 | 216 | } else { |
217 | 217 | $latPos = "N"; |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | $secs = ($decimaldegrees - $dms) * 3600; |
233 | 233 | $min = floor($secs / 60); |
234 | 234 | $sec = round($secs - ($min * 60), 3); |
235 | - $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
235 | + $dms .= 'º' . $min . '\'' . $sec . '"'; |
|
236 | 236 | return $dms; |
237 | 237 | } |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @todo move this into a shared library |
245 | 245 | */ |
246 | 246 | private function convertLon($decimaldegrees) { |
247 | - if(strpos($decimaldegrees, '-') !== false) { |
|
247 | + if (strpos($decimaldegrees, '-') !== false) { |
|
248 | 248 | $lonPos = "W"; |
249 | 249 | } else { |
250 | 250 | $lonPos = "E"; |
@@ -23,40 +23,40 @@ |
||
23 | 23 | */ |
24 | 24 | class general_plugin_geotag_test extends DokuWikiTest { |
25 | 25 | |
26 | - protected $pluginsEnabled = array('geotag'); |
|
26 | + protected $pluginsEnabled = array('geotag'); |
|
27 | 27 | |
28 | - /** |
|
29 | - * Simple test to make sure the plugin.info.txt is in correct format |
|
30 | - */ |
|
31 | - public function test_plugininfo(): void { |
|
32 | - $file = __DIR__ . '/../plugin.info.txt'; |
|
33 | - $this->assertFileExists($file); |
|
28 | + /** |
|
29 | + * Simple test to make sure the plugin.info.txt is in correct format |
|
30 | + */ |
|
31 | + public function test_plugininfo(): void { |
|
32 | + $file = __DIR__ . '/../plugin.info.txt'; |
|
33 | + $this->assertFileExists($file); |
|
34 | 34 | |
35 | - $info = confToHash($file); |
|
35 | + $info = confToHash($file); |
|
36 | 36 | |
37 | - $this->assertArrayHasKey('base', $info); |
|
38 | - $this->assertArrayHasKey('author', $info); |
|
39 | - $this->assertArrayHasKey('email', $info); |
|
40 | - $this->assertArrayHasKey('date', $info); |
|
41 | - $this->assertArrayHasKey('name', $info); |
|
42 | - $this->assertArrayHasKey('desc', $info); |
|
43 | - $this->assertArrayHasKey('url', $info); |
|
37 | + $this->assertArrayHasKey('base', $info); |
|
38 | + $this->assertArrayHasKey('author', $info); |
|
39 | + $this->assertArrayHasKey('email', $info); |
|
40 | + $this->assertArrayHasKey('date', $info); |
|
41 | + $this->assertArrayHasKey('name', $info); |
|
42 | + $this->assertArrayHasKey('desc', $info); |
|
43 | + $this->assertArrayHasKey('url', $info); |
|
44 | 44 | |
45 | - $this->assertEquals('geotag', $info['base']); |
|
46 | - $this->assertRegExp('/^https?:\/\//', $info['url']); |
|
47 | - $this->assertTrue(mail_isvalid($info['email'])); |
|
48 | - $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); |
|
49 | - $this->assertTrue(false !== strtotime($info['date'])); |
|
50 | - } |
|
45 | + $this->assertEquals('geotag', $info['base']); |
|
46 | + $this->assertRegExp('/^https?:\/\//', $info['url']); |
|
47 | + $this->assertTrue(mail_isvalid($info['email'])); |
|
48 | + $this->assertRegExp('/^\d\d\d\d-\d\d-\d\d$/', $info['date']); |
|
49 | + $this->assertTrue(false !== strtotime($info['date'])); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * test if plugin is loaded. |
|
54 | - */ |
|
55 | - public function test_plugin_geotag_isloaded(): void { |
|
56 | - global $plugin_controller; |
|
57 | - $this->assertTrue( |
|
58 | - in_array('geotag', $plugin_controller->getList()), |
|
59 | - "geotag plugin is loaded" |
|
60 | - ); |
|
61 | - } |
|
52 | + /** |
|
53 | + * test if plugin is loaded. |
|
54 | + */ |
|
55 | + public function test_plugin_geotag_isloaded(): void { |
|
56 | + global $plugin_controller; |
|
57 | + $this->assertTrue( |
|
58 | + in_array('geotag', $plugin_controller->getList()), |
|
59 | + "geotag plugin is loaded" |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | } |
@@ -23,119 +23,119 @@ |
||
23 | 23 | */ |
24 | 24 | class syntax_plugin_geotag_test extends DokuWikiTest { |
25 | 25 | |
26 | - protected $pluginsEnabled = array('geotag'); |
|
27 | - |
|
28 | - /** |
|
29 | - * copy data and add pages to the index. |
|
30 | - */ |
|
31 | - public static function setUpBeforeClass(): void { |
|
32 | - parent::setUpBeforeClass(); |
|
33 | - global $conf; |
|
34 | - $conf['allowdebug'] = 1; |
|
35 | - |
|
36 | - TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
37 | - |
|
38 | - dbglog("\nset up class syntax_plugin_geotag_test"); |
|
39 | - } |
|
40 | - |
|
41 | - public function setUp(): void { |
|
42 | - parent::setUp(); |
|
43 | - |
|
44 | - global $conf; |
|
45 | - $conf['allowdebug'] = 1; |
|
46 | - $conf['cachetime'] = -1; |
|
47 | - |
|
48 | - $data = array(); |
|
49 | - search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
50 | - |
|
51 | - $verbose = false; |
|
52 | - $force = false; |
|
53 | - foreach($data as $val) { |
|
54 | - idx_addPage($val['id'], $verbose, $force); |
|
55 | - } |
|
56 | - if($conf['allowdebug']) { |
|
57 | - touch(DOKU_TMP_DATA . 'cache/debug.log'); |
|
58 | - } |
|
59 | - } |
|
60 | - |
|
61 | - public function tearDown(): void { |
|
62 | - parent::tearDown(); |
|
63 | - |
|
64 | - global $conf; |
|
65 | - // try to get the debug log after running the test, print and clear |
|
66 | - if($conf['allowdebug']) { |
|
67 | - print "\n"; |
|
68 | - readfile(DOKU_TMP_DATA . 'cache/debug.log'); |
|
69 | - unlink(DOKU_TMP_DATA . 'cache/debug.log'); |
|
70 | - } |
|
71 | - } |
|
72 | - |
|
73 | - public function test_geotag(): void { |
|
74 | - $request = new TestRequest(); |
|
75 | - $response = $request->get(array('id' => 'minimalgeotag'), '/doku.php'); |
|
76 | - |
|
77 | - $this->assertEquals( |
|
78 | - 'minimalgeotag', |
|
79 | - $response->queryHTML('meta[name="keywords"]')->attr('content') |
|
80 | - ); |
|
81 | - $this->assertEquals( |
|
82 | - '51.565696;5.324596', |
|
83 | - $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
84 | - ); |
|
85 | - $this->assertEquals( |
|
86 | - '51.565696, 5.324596', |
|
87 | - $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
88 | - ); |
|
89 | - |
|
90 | - $this->assertTrue( |
|
91 | - strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
92 | - '"Geotag (location) for:" was not in the output' |
|
93 | - ); |
|
94 | - } |
|
95 | - |
|
96 | - public function test_fullgeotag(): void { |
|
97 | - $request = new TestRequest(); |
|
98 | - $response = $request->get(array('id' => 'fullgeotag'), '/doku.php'); |
|
99 | - |
|
100 | - $this->assertEquals( |
|
101 | - 'fullgeotag', |
|
102 | - $response->queryHTML('meta[name="keywords"]')->attr('content') |
|
103 | - ); |
|
104 | - $this->assertEquals( |
|
105 | - '52.132633;5.291266;9', |
|
106 | - $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
107 | - ); |
|
108 | - $this->assertEquals( |
|
109 | - '52.132633, 5.291266', |
|
110 | - $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
111 | - ); |
|
112 | - |
|
113 | - $this->assertTrue( |
|
114 | - strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
115 | - '"Geotag (location) for:" was not in the output' |
|
116 | - ); |
|
117 | - } |
|
118 | - |
|
119 | - public function test_fullgeotagnegativecoords(): void { |
|
120 | - $request = new TestRequest(); |
|
121 | - $response = $request->get(array('id' => 'fullgeotagnegativecoords'), '/doku.php'); |
|
122 | - |
|
123 | - $this->assertEquals( |
|
124 | - 'fullgeotagnegativecoords', |
|
125 | - $response->queryHTML('meta[name="keywords"]')->attr('content') |
|
126 | - ); |
|
127 | - $this->assertEquals( |
|
128 | - '-52.132633;-5.291266;-9', |
|
129 | - $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
130 | - ); |
|
131 | - $this->assertEquals( |
|
132 | - '-52.132633, -5.291266', |
|
133 | - $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
134 | - ); |
|
135 | - |
|
136 | - $this->assertTrue( |
|
137 | - strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
138 | - '"Geotag (location) for:" was not in the output' |
|
139 | - ); |
|
140 | - } |
|
26 | + protected $pluginsEnabled = array('geotag'); |
|
27 | + |
|
28 | + /** |
|
29 | + * copy data and add pages to the index. |
|
30 | + */ |
|
31 | + public static function setUpBeforeClass(): void { |
|
32 | + parent::setUpBeforeClass(); |
|
33 | + global $conf; |
|
34 | + $conf['allowdebug'] = 1; |
|
35 | + |
|
36 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
37 | + |
|
38 | + dbglog("\nset up class syntax_plugin_geotag_test"); |
|
39 | + } |
|
40 | + |
|
41 | + public function setUp(): void { |
|
42 | + parent::setUp(); |
|
43 | + |
|
44 | + global $conf; |
|
45 | + $conf['allowdebug'] = 1; |
|
46 | + $conf['cachetime'] = -1; |
|
47 | + |
|
48 | + $data = array(); |
|
49 | + search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
50 | + |
|
51 | + $verbose = false; |
|
52 | + $force = false; |
|
53 | + foreach($data as $val) { |
|
54 | + idx_addPage($val['id'], $verbose, $force); |
|
55 | + } |
|
56 | + if($conf['allowdebug']) { |
|
57 | + touch(DOKU_TMP_DATA . 'cache/debug.log'); |
|
58 | + } |
|
59 | + } |
|
60 | + |
|
61 | + public function tearDown(): void { |
|
62 | + parent::tearDown(); |
|
63 | + |
|
64 | + global $conf; |
|
65 | + // try to get the debug log after running the test, print and clear |
|
66 | + if($conf['allowdebug']) { |
|
67 | + print "\n"; |
|
68 | + readfile(DOKU_TMP_DATA . 'cache/debug.log'); |
|
69 | + unlink(DOKU_TMP_DATA . 'cache/debug.log'); |
|
70 | + } |
|
71 | + } |
|
72 | + |
|
73 | + public function test_geotag(): void { |
|
74 | + $request = new TestRequest(); |
|
75 | + $response = $request->get(array('id' => 'minimalgeotag'), '/doku.php'); |
|
76 | + |
|
77 | + $this->assertEquals( |
|
78 | + 'minimalgeotag', |
|
79 | + $response->queryHTML('meta[name="keywords"]')->attr('content') |
|
80 | + ); |
|
81 | + $this->assertEquals( |
|
82 | + '51.565696;5.324596', |
|
83 | + $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
84 | + ); |
|
85 | + $this->assertEquals( |
|
86 | + '51.565696, 5.324596', |
|
87 | + $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
88 | + ); |
|
89 | + |
|
90 | + $this->assertTrue( |
|
91 | + strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
92 | + '"Geotag (location) for:" was not in the output' |
|
93 | + ); |
|
94 | + } |
|
95 | + |
|
96 | + public function test_fullgeotag(): void { |
|
97 | + $request = new TestRequest(); |
|
98 | + $response = $request->get(array('id' => 'fullgeotag'), '/doku.php'); |
|
99 | + |
|
100 | + $this->assertEquals( |
|
101 | + 'fullgeotag', |
|
102 | + $response->queryHTML('meta[name="keywords"]')->attr('content') |
|
103 | + ); |
|
104 | + $this->assertEquals( |
|
105 | + '52.132633;5.291266;9', |
|
106 | + $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
107 | + ); |
|
108 | + $this->assertEquals( |
|
109 | + '52.132633, 5.291266', |
|
110 | + $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
111 | + ); |
|
112 | + |
|
113 | + $this->assertTrue( |
|
114 | + strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
115 | + '"Geotag (location) for:" was not in the output' |
|
116 | + ); |
|
117 | + } |
|
118 | + |
|
119 | + public function test_fullgeotagnegativecoords(): void { |
|
120 | + $request = new TestRequest(); |
|
121 | + $response = $request->get(array('id' => 'fullgeotagnegativecoords'), '/doku.php'); |
|
122 | + |
|
123 | + $this->assertEquals( |
|
124 | + 'fullgeotagnegativecoords', |
|
125 | + $response->queryHTML('meta[name="keywords"]')->attr('content') |
|
126 | + ); |
|
127 | + $this->assertEquals( |
|
128 | + '-52.132633;-5.291266;-9', |
|
129 | + $response->queryHTML('meta[name="geo.position"]')->attr('content') |
|
130 | + ); |
|
131 | + $this->assertEquals( |
|
132 | + '-52.132633, -5.291266', |
|
133 | + $response->queryHTML('meta[name="ICBM"]')->attr('content') |
|
134 | + ); |
|
135 | + |
|
136 | + $this->assertTrue( |
|
137 | + strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
138 | + '"Geotag (location) for:" was not in the output' |
|
139 | + ); |
|
140 | + } |
|
141 | 141 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | |
51 | 51 | $verbose = false; |
52 | 52 | $force = false; |
53 | - foreach($data as $val) { |
|
53 | + foreach ($data as $val) { |
|
54 | 54 | idx_addPage($val['id'], $verbose, $force); |
55 | 55 | } |
56 | - if($conf['allowdebug']) { |
|
56 | + if ($conf['allowdebug']) { |
|
57 | 57 | touch(DOKU_TMP_DATA . 'cache/debug.log'); |
58 | 58 | } |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | global $conf; |
65 | 65 | // try to get the debug log after running the test, print and clear |
66 | - if($conf['allowdebug']) { |
|
66 | + if ($conf['allowdebug']) { |
|
67 | 67 | print "\n"; |
68 | 68 | readfile(DOKU_TMP_DATA . 'cache/debug.log'); |
69 | 69 | unlink(DOKU_TMP_DATA . 'cache/debug.log'); |
@@ -26,5 +26,5 @@ |
||
26 | 26 | $lang['geotag_hide'] = 'Verstecken Geotag (css)'; |
27 | 27 | $lang['geotag_prevent_microformat_render'] = 'Verhindern Rendering Geotag Mikroformat'; |
28 | 28 | $lang['toolbar_icon'] = 'Toolbar-Symbol anzeigen'; |
29 | -$lang['geotag_showsearch'] = 'Geotag verknüpfen an Suchen in der Nähe (spatialhelper plugin erforderlich)'; |
|
29 | +$lang['geotag_showsearch'] = 'Geotag verknüpfen an Suchen in der Nähe (spatialhelper plugin erforderlich)'; |
|
30 | 30 | $lang['displayformat'] = 'Koordinaten Anzeigeformat; Dezimalgrad oder Grad, Minuten, Sekunden '; |
@@ -27,4 +27,4 @@ |
||
27 | 27 | $lang['geotag_prevent_microformat_render'] = 'Voorkom geotag microformat rendering'; |
28 | 28 | $lang['toolbar_icon'] = 'Toon toolbar icon'; |
29 | 29 | $lang['geotag_showsearch'] = 'Link geotag als zoekactie (spatialhelper plugin benodigd)'; |
30 | -$lang['displayformat'] = 'Coördinaten weergave formaat; decimale graden of graden, minuten, seconden'; |
|
30 | +$lang['displayformat'] = 'Coördinaten weergave formaat; decimale graden of graden, minuten, seconden'; |
@@ -22,9 +22,9 @@ |
||
22 | 22 | * @author Aleksej Kozlov <[email protected]> |
23 | 23 | */ |
24 | 24 | $lang['geotag_location_prefix'] = 'Текст, по умолчанию показываемый перед геотегом'; |
25 | -$lang['geotag_showlocation'] = 'Показывать название местоположения в геотеге (вместо текста по умолчанию)'; |
|
25 | +$lang['geotag_showlocation'] = 'Показывать название местоположения в геотеге (вместо текста по умолчанию)'; |
|
26 | 26 | $lang['geotag_hide'] = 'Прятать геотег (средствами css)'; |
27 | 27 | $lang['geotag_prevent_microformat_render'] = 'Запретить рендеринг микроформата геотега'; |
28 | 28 | $lang['toolbar_icon'] = 'Показывать иконку'; |
29 | -$lang['geotag_showsearch'] = 'Геотег является ссылкой на страницу поиска около точки (нужен плагин spatialhelper)'; |
|
30 | -$lang['displayformat'] = 'Формат отображения координат: DD - градусы с дробной частью, DMS - градусы, минуты, секунды'; |
|
29 | +$lang['geotag_showsearch'] = 'Геотег является ссылкой на страницу поиска около точки (нужен плагин spatialhelper)'; |
|
30 | +$lang['displayformat'] = 'Формат отображения координат: DD - градусы с дробной частью, DMS - градусы, минуты, секунды'; |