@@ -29,4 +29,4 @@ |
||
29 | 29 | $meta ['toolbar_icon'] = array ('onoff' ); |
30 | 30 | $meta ['geotag_showsearch'] = array ('onoff' ); |
31 | 31 | $meta ['displayformat'] = array ('multichoice', |
32 | - '_choices' => array ('DD','DMS') ); |
|
32 | + '_choices' => array ('DD','DMS') ); |
@@ -21,12 +21,12 @@ |
||
21 | 21 | * @license BSD license |
22 | 22 | * @author Mark C. Prins <[email protected]> |
23 | 23 | */ |
24 | -$meta ['geotag_pinggeourl'] = array ('onoff'); |
|
25 | -$meta ['geotag_location_prefix'] = array ('string'); |
|
26 | -$meta ['geotag_showlocation'] = array ('onoff'); |
|
27 | -$meta ['geotag_hide'] = array ('onoff' ); |
|
28 | -$meta ['geotag_prevent_microformat_render'] = array ('onoff' ); |
|
29 | -$meta ['toolbar_icon'] = array ('onoff' ); |
|
30 | -$meta ['geotag_showsearch'] = array ('onoff' ); |
|
31 | -$meta ['displayformat'] = array ('multichoice', |
|
32 | - '_choices' => array ('DD','DMS') ); |
|
24 | +$meta ['geotag_pinggeourl'] = array('onoff'); |
|
25 | +$meta ['geotag_location_prefix'] = array('string'); |
|
26 | +$meta ['geotag_showlocation'] = array('onoff'); |
|
27 | +$meta ['geotag_hide'] = array('onoff'); |
|
28 | +$meta ['geotag_prevent_microformat_render'] = array('onoff'); |
|
29 | +$meta ['toolbar_icon'] = array('onoff'); |
|
30 | +$meta ['geotag_showsearch'] = array('onoff'); |
|
31 | +$meta ['displayformat'] = array('multichoice', |
|
32 | + '_choices' => array('DD', 'DMS')); |
@@ -14,7 +14,9 @@ |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (!defined('DOKU_INC')) die(); |
|
17 | +if (!defined('DOKU_INC')) { |
|
18 | + die(); |
|
19 | +} |
|
18 | 20 | |
19 | 21 | /** |
20 | 22 | * DokuWiki Plugin geotag (Helper Component). This helper class provides |
@@ -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() { |
|
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() { |
|
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() { |
|
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() { |
|
56 | + global $plugin_controller; |
|
57 | + $this->assertTrue( |
|
58 | + in_array('geotag', $plugin_controller->getList()), |
|
59 | + "geotag plugin is loaded" |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | } |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * Simple test to make sure the plugin.info.txt is in correct format |
30 | 30 | */ |
31 | 31 | public function test_plugininfo() { |
32 | - $file = __DIR__.'/../plugin.info.txt'; |
|
32 | + $file = __DIR__ . '/../plugin.info.txt'; |
|
33 | 33 | $this->assertFileExists($file); |
34 | 34 | |
35 | 35 | $info = confToHash($file); |
@@ -23,55 +23,55 @@ |
||
23 | 23 | */ |
24 | 24 | class syntax_plugin_geotag_test extends DokuWikiTest { |
25 | 25 | |
26 | - protected $pluginsEnabled = array('geotag'); |
|
26 | + protected $pluginsEnabled = array('geotag'); |
|
27 | 27 | |
28 | - /** |
|
29 | - * copy data and add pages to the index. |
|
30 | - */ |
|
31 | - public static function setUpBeforeClass() { |
|
32 | - parent::setUpBeforeClass(); |
|
33 | - global $conf; |
|
34 | - $conf['allowdebug'] = 1; |
|
28 | + /** |
|
29 | + * copy data and add pages to the index. |
|
30 | + */ |
|
31 | + public static function setUpBeforeClass() { |
|
32 | + parent::setUpBeforeClass(); |
|
33 | + global $conf; |
|
34 | + $conf['allowdebug'] = 1; |
|
35 | 35 | |
36 | - TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
36 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
37 | 37 | |
38 | - dbglog("\nset up class syntax_plugin_geotag_test"); |
|
39 | - } |
|
38 | + dbglog("\nset up class syntax_plugin_geotag_test"); |
|
39 | + } |
|
40 | 40 | |
41 | - function setUp() { |
|
42 | - parent::setUp(); |
|
41 | + function setUp() { |
|
42 | + parent::setUp(); |
|
43 | 43 | |
44 | - global $conf; |
|
45 | - $conf['allowdebug'] = 1; |
|
46 | - $conf['cachetime'] = -1; |
|
44 | + global $conf; |
|
45 | + $conf['allowdebug'] = 1; |
|
46 | + $conf['cachetime'] = -1; |
|
47 | 47 | |
48 | - $data = array(); |
|
49 | - search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
48 | + $data = array(); |
|
49 | + search($data, $conf['datadir'], 'search_allpages', array('skipacl' => true)); |
|
50 | 50 | |
51 | - //dbglog($data, "pages for indexing"); |
|
51 | + //dbglog($data, "pages for indexing"); |
|
52 | 52 | |
53 | - $verbose = false; |
|
54 | - $force = false; |
|
55 | - foreach ($data as $val) { |
|
56 | - idx_addPage($val['id'], $verbose, $force); |
|
57 | - } |
|
58 | - //idx_addPage('bob_ross_says', $verbose, $force); |
|
59 | - //idx_addPage('link', $verbose, $force); |
|
60 | - //idx_addPage('geotag_syntax', $verbose, $force); |
|
61 | - if ($conf['allowdebug']) { |
|
62 | - touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
63 | - } |
|
64 | - } |
|
53 | + $verbose = false; |
|
54 | + $force = false; |
|
55 | + foreach ($data as $val) { |
|
56 | + idx_addPage($val['id'], $verbose, $force); |
|
57 | + } |
|
58 | + //idx_addPage('bob_ross_says', $verbose, $force); |
|
59 | + //idx_addPage('link', $verbose, $force); |
|
60 | + //idx_addPage('geotag_syntax', $verbose, $force); |
|
61 | + if ($conf['allowdebug']) { |
|
62 | + touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
63 | + } |
|
64 | + } |
|
65 | 65 | |
66 | - public function tearDown() { |
|
67 | - parent::tearDown(); |
|
66 | + public function tearDown() { |
|
67 | + parent::tearDown(); |
|
68 | 68 | |
69 | - global $conf; |
|
70 | - // try to get the debug log after running the test, print and clear |
|
71 | - if ($conf['allowdebug']) { |
|
72 | - print "\n"; |
|
73 | - readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
74 | - unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
75 | - } |
|
76 | - } |
|
69 | + global $conf; |
|
70 | + // try to get the debug log after running the test, print and clear |
|
71 | + if ($conf['allowdebug']) { |
|
72 | + print "\n"; |
|
73 | + readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
74 | + unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | global $conf; |
34 | 34 | $conf['allowdebug'] = 1; |
35 | 35 | |
36 | - TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
36 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__) . '/data/'); |
|
37 | 37 | |
38 | 38 | dbglog("\nset up class syntax_plugin_geotag_test"); |
39 | 39 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | //idx_addPage('link', $verbose, $force); |
60 | 60 | //idx_addPage('geotag_syntax', $verbose, $force); |
61 | 61 | if ($conf['allowdebug']) { |
62 | - touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
62 | + touch(DOKU_TMP_DATA . 'cache/debug.log'); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | // try to get the debug log after running the test, print and clear |
71 | 71 | if ($conf['allowdebug']) { |
72 | 72 | print "\n"; |
73 | - readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
74 | - unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
73 | + readfile(DOKU_TMP_DATA . 'cache/debug.log'); |
|
74 | + unlink(DOKU_TMP_DATA . 'cache/debug.log'); |
|
75 | 75 | } |
76 | 76 | } |
77 | 77 | } |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (! defined ( 'DOKU_INC' )) |
|
17 | +if (!defined('DOKU_INC')) |
|
18 | 18 | die (); |
19 | 19 | |
20 | -if (! defined ( 'DOKU_PLUGIN' )) |
|
21 | - define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' ); |
|
20 | +if (!defined('DOKU_PLUGIN')) |
|
21 | + define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); |
|
22 | 22 | require_once (DOKU_PLUGIN . 'action.php'); |
23 | 23 | |
24 | 24 | /** |
@@ -36,10 +36,10 @@ discard block |
||
36 | 36 | * DokuWiki's event controller object. Also available as global $EVENT_HANDLER |
37 | 37 | */ |
38 | 38 | public function register(Doku_Event_Handler $controller) { |
39 | - $controller->register_hook ( 'TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_metaheader_output' ); |
|
40 | - $controller->register_hook ( 'IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'ping_geourl', array () ); |
|
41 | - if ($this->getConf ( 'toolbar_icon' )) { |
|
42 | - $controller->register_hook ( 'TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array () ); |
|
39 | + $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handle_metaheader_output'); |
|
40 | + $controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'ping_geourl', array()); |
|
41 | + if ($this->getConf('toolbar_icon')) { |
|
42 | + $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array()); |
|
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function handle_metaheader_output(Doku_Event $event, $param) { |
57 | 57 | global $ID; |
58 | - $title = p_get_metadata ( $ID, 'title', true ); |
|
59 | - $geotags = p_get_metadata ( $ID, 'geo', true ); |
|
58 | + $title = p_get_metadata($ID, 'title', true); |
|
59 | + $geotags = p_get_metadata($ID, 'geo', true); |
|
60 | 60 | $region = $geotags ['region']; |
61 | 61 | $lat = $geotags ['lat']; |
62 | 62 | $lon = $geotags ['lon']; |
@@ -65,45 +65,45 @@ discard block |
||
65 | 65 | $placename = $geotags ['placename']; |
66 | 66 | $geohash = $geotags ['geohash']; |
67 | 67 | |
68 | - if (! empty ( $region )) { |
|
69 | - $event->data ['meta'] [] = array ( |
|
68 | + if (!empty ($region)) { |
|
69 | + $event->data ['meta'] [] = array( |
|
70 | 70 | 'name' => 'geo.region', |
71 | 71 | 'content' => $region |
72 | 72 | ); |
73 | 73 | } |
74 | - if (! empty ( $placename )) { |
|
75 | - $event->data ['meta'] [] = array ( |
|
74 | + if (!empty ($placename)) { |
|
75 | + $event->data ['meta'] [] = array( |
|
76 | 76 | 'name' => 'geo.placename', |
77 | 77 | 'content' => $placename |
78 | 78 | ); |
79 | 79 | } |
80 | - if (! (empty ( $lat ) && empty ( $lon ))) { |
|
81 | - if (! empty ( $alt )) { |
|
82 | - $event->data ['meta'] [] = array ( |
|
80 | + if (!(empty ($lat) && empty ($lon))) { |
|
81 | + if (!empty ($alt)) { |
|
82 | + $event->data ['meta'] [] = array( |
|
83 | 83 | 'name' => 'geo.position', |
84 | 84 | 'content' => $lat . ';' . $lon . ';' . $alt |
85 | 85 | ); |
86 | 86 | } else { |
87 | - $event->data ['meta'] [] = array ( |
|
87 | + $event->data ['meta'] [] = array( |
|
88 | 88 | 'name' => 'geo.position', |
89 | 89 | 'content' => $lat . ';' . $lon |
90 | 90 | ); |
91 | 91 | } |
92 | 92 | } |
93 | - if (! empty ( $country )) { |
|
94 | - $event->data ['meta'] [] = array ( |
|
93 | + if (!empty ($country)) { |
|
94 | + $event->data ['meta'] [] = array( |
|
95 | 95 | 'name' => 'geo.country', |
96 | 96 | 'content' => $country |
97 | 97 | ); |
98 | 98 | } |
99 | - if (! (empty ( $lat ) && empty ( $lon ))) { |
|
100 | - $event->data ['meta'] [] = array ( |
|
99 | + if (!(empty ($lat) && empty ($lon))) { |
|
100 | + $event->data ['meta'] [] = array( |
|
101 | 101 | 'name' => "ICBM", |
102 | 102 | 'content' => $lat . ', ' . $lon |
103 | 103 | ); |
104 | 104 | // icbm is generally useless without a DC.title, |
105 | 105 | // so we copy that from title unless it's empty... |
106 | - if (! (empty ( $title ))) { |
|
106 | + if (!(empty ($title))) { |
|
107 | 107 | /* |
108 | 108 | * don't specify the DC namespace as this is incomplete; it should be done at the |
109 | 109 | * template level as it also needs a 'profile' attribute on the head/container, |
@@ -113,14 +113,14 @@ discard block |
||
113 | 113 | // 'rel' => 'schema.DC', |
114 | 114 | // 'href' => 'http://purl.org/dc/elements/1.1/' |
115 | 115 | // ); |
116 | - $event->data ['meta'] [] = array ( |
|
116 | + $event->data ['meta'] [] = array( |
|
117 | 117 | 'name' => "DC.title", |
118 | 118 | 'content' => $title |
119 | 119 | ); |
120 | 120 | } |
121 | 121 | } |
122 | - if (! empty ( $geohash )) { |
|
123 | - $event->data ['meta'] [] = array ( |
|
122 | + if (!empty ($geohash)) { |
|
123 | + $event->data ['meta'] [] = array( |
|
124 | 124 | 'name' => 'geo.geohash', |
125 | 125 | 'content' => $geohash |
126 | 126 | ); |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | // $data[1] – ns: The colon separated namespace path minus the trailing page name. (false if root ns) |
145 | 145 | // $data[2] – page_name: The wiki page name. |
146 | 146 | // $data[3] – rev: The page revision, false for current wiki pages. |
147 | - if (! $this->getConf ( 'geotag_pinggeourl' )) |
|
147 | + if (!$this->getConf('geotag_pinggeourl')) |
|
148 | 148 | return false; // config says don't ping |
149 | 149 | if ($event->data [3]) |
150 | 150 | return false; // old revision saved |
151 | - if (! $event->data [0] [1]) |
|
151 | + if (!$event->data [0] [1]) |
|
152 | 152 | return false; // file is empty |
153 | - if (@file_exists ( $event->data [0] [0] )) |
|
153 | + if (@file_exists($event->data [0] [0])) |
|
154 | 154 | return false; // file not new |
155 | - if (p_get_metadata ( $ID, 'geo', true )) |
|
155 | + if (p_get_metadata($ID, 'geo', true)) |
|
156 | 156 | return false; // no geo metadata available, ping is useless |
157 | 157 | |
158 | - $url = 'http://geourl.org/ping/?p=' . wl ( $ID, '', true ); |
|
159 | - $http = new DokuHTTPClient (); |
|
160 | - $result = $http->get ( $url ); |
|
158 | + $url = 'http://geourl.org/ping/?p=' . wl($ID, '', true); |
|
159 | + $http = new DokuHTTPClient(); |
|
160 | + $result = $http->get($url); |
|
161 | 161 | // dbglog ( $result, "GeoURL Ping response for $url" ); |
162 | 162 | return $result; |
163 | 163 | } |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | * the DokuWiki event |
170 | 170 | */ |
171 | 171 | function insert_button(Doku_Event $event, $param) { |
172 | - $event->data [] = array ( |
|
172 | + $event->data [] = array( |
|
173 | 173 | 'type' => 'format', |
174 | - 'title' => $this->getLang ( 'toolbar_desc' ), |
|
174 | + 'title' => $this->getLang('toolbar_desc'), |
|
175 | 175 | 'icon' => '../../plugins/geotag/images/geotag.png', |
176 | 176 | 'open' => '{{geotag>lat:', |
177 | 177 | 'sample' => '52.2345', |
@@ -14,11 +14,13 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (! defined ( 'DOKU_INC' )) |
|
17 | +if (! defined ( 'DOKU_INC' )) { |
|
18 | 18 | die (); |
19 | +} |
|
19 | 20 | |
20 | -if (! defined ( 'DOKU_PLUGIN' )) |
|
21 | +if (! defined ( 'DOKU_PLUGIN' )) { |
|
21 | 22 | define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' ); |
23 | +} |
|
22 | 24 | require_once (DOKU_PLUGIN . 'action.php'); |
23 | 25 | |
24 | 26 | /** |
@@ -144,16 +146,26 @@ discard block |
||
144 | 146 | // $data[1] – ns: The colon separated namespace path minus the trailing page name. (false if root ns) |
145 | 147 | // $data[2] – page_name: The wiki page name. |
146 | 148 | // $data[3] – rev: The page revision, false for current wiki pages. |
147 | - if (! $this->getConf ( 'geotag_pinggeourl' )) |
|
148 | - return false; // config says don't ping |
|
149 | - if ($event->data [3]) |
|
150 | - return false; // old revision saved |
|
151 | - if (! $event->data [0] [1]) |
|
152 | - return false; // file is empty |
|
153 | - if (@file_exists ( $event->data [0] [0] )) |
|
154 | - return false; // file not new |
|
155 | - if (p_get_metadata ( $ID, 'geo', true )) |
|
156 | - return false; // no geo metadata available, ping is useless |
|
149 | + if (! $this->getConf ( 'geotag_pinggeourl' )) { |
|
150 | + return false; |
|
151 | + } |
|
152 | + // config says don't ping |
|
153 | + if ($event->data [3]) { |
|
154 | + return false; |
|
155 | + } |
|
156 | + // old revision saved |
|
157 | + if (! $event->data [0] [1]) { |
|
158 | + return false; |
|
159 | + } |
|
160 | + // file is empty |
|
161 | + if (@file_exists ( $event->data [0] [0] )) { |
|
162 | + return false; |
|
163 | + } |
|
164 | + // file not new |
|
165 | + if (p_get_metadata ( $ID, 'geo', true )) { |
|
166 | + return false; |
|
167 | + } |
|
168 | + // no geo metadata available, ping is useless |
|
157 | 169 | |
158 | 170 | $url = 'http://geourl.org/ping/?p=' . wl ( $ID, '', true ); |
159 | 171 | $http = new DokuHTTPClient (); |
@@ -14,11 +14,11 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (! defined ( 'DOKU_INC' )) |
|
17 | +if (!defined('DOKU_INC')) |
|
18 | 18 | die (); |
19 | 19 | |
20 | -if (! defined ( 'DOKU_PLUGIN' )) |
|
21 | - define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' ); |
|
20 | +if (!defined('DOKU_PLUGIN')) |
|
21 | + define('DOKU_PLUGIN', DOKU_INC . 'lib/plugins/'); |
|
22 | 22 | |
23 | 23 | require_once (DOKU_PLUGIN . 'syntax.php'); |
24 | 24 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | * @see Doku_Parser_Mode::connectTo() |
60 | 60 | */ |
61 | 61 | public function connectTo($mode) { |
62 | - $this->Lexer->addSpecialPattern ( '\{\{geotag>.*?\}\}', $mode, 'plugin_geotag_geotag' ); |
|
62 | + $this->Lexer->addSpecialPattern('\{\{geotag>.*?\}\}', $mode, 'plugin_geotag_geotag'); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,44 +67,44 @@ discard block |
||
67 | 67 | * @see DokuWiki_Syntax_Plugin::handle() |
68 | 68 | */ |
69 | 69 | public function handle($match, $state, $pos, Doku_Handler $handler) { |
70 | - $tags = trim ( substr ( $match, 9, - 2 ) ); |
|
70 | + $tags = trim(substr($match, 9, - 2)); |
|
71 | 71 | // parse geotag content |
72 | - preg_match ( "(lat[:|=]\d*\.\d*)", $tags, $lat ); |
|
73 | - preg_match ( "(lon[:|=]\d*\.\d*)", $tags, $lon ); |
|
74 | - preg_match ( "(alt[:|=]\d*\.?\d*)", $tags, $alt ); |
|
75 | - preg_match ( "/(region[:|=][\p{L}\s\w'-]*)/u", $tags, $region ); |
|
76 | - preg_match ( "/(placename[:|=][\p{L}\s\w'-]*)/u", $tags, $placename ); |
|
77 | - preg_match ( "/(country[:|=][\p{L}\s\w'-]*)/u", $tags, $country ); |
|
78 | - preg_match ( "(hide|unhide)", $tags, $hide ); |
|
72 | + preg_match("(lat[:|=]\d*\.\d*)", $tags, $lat); |
|
73 | + preg_match("(lon[:|=]\d*\.\d*)", $tags, $lon); |
|
74 | + preg_match("(alt[:|=]\d*\.?\d*)", $tags, $alt); |
|
75 | + preg_match("/(region[:|=][\p{L}\s\w'-]*)/u", $tags, $region); |
|
76 | + preg_match("/(placename[:|=][\p{L}\s\w'-]*)/u", $tags, $placename); |
|
77 | + preg_match("/(country[:|=][\p{L}\s\w'-]*)/u", $tags, $country); |
|
78 | + preg_match("(hide|unhide)", $tags, $hide); |
|
79 | 79 | |
80 | - $showlocation = $this->getConf ( 'geotag_location_prefix' ); |
|
81 | - if ($this->getConf ( 'geotag_showlocation' )) { |
|
82 | - $showlocation = trim ( substr ( $placename [0], 10 ) ); |
|
83 | - if (strlen ( $showlocation ) < 1) { |
|
84 | - $showlocation = $this->getConf ( 'geotag_location_prefix' ); |
|
80 | + $showlocation = $this->getConf('geotag_location_prefix'); |
|
81 | + if ($this->getConf('geotag_showlocation')) { |
|
82 | + $showlocation = trim(substr($placename [0], 10)); |
|
83 | + if (strlen($showlocation) < 1) { |
|
84 | + $showlocation = $this->getConf('geotag_location_prefix'); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | // read config for system setting |
88 | 88 | $style = ''; |
89 | - if ($this->getConf ( 'geotag_hide' )) { |
|
89 | + if ($this->getConf('geotag_hide')) { |
|
90 | 90 | $style = ' style="display: none;"'; |
91 | 91 | } |
92 | 92 | // override config for the current tag |
93 | - if (trim ( $hide [0] ) == 'hide') { |
|
93 | + if (trim($hide [0]) == 'hide') { |
|
94 | 94 | $style = ' style="display: none;"'; |
95 | - } elseif (trim ( $hide [0] ) == 'unhide') { |
|
95 | + } elseif (trim($hide [0]) == 'unhide') { |
|
96 | 96 | $style = ''; |
97 | 97 | } |
98 | 98 | |
99 | - $data = array ( |
|
100 | - hsc ( trim ( substr ( $lat [0], 4 ) ) ), |
|
101 | - hsc ( trim ( substr ( $lon [0], 4 ) ) ), |
|
102 | - hsc ( trim ( substr ( $alt [0], 4 ) ) ), |
|
103 | - $this->_geohash ( substr ( $lat [0], 4 ), substr ( $lon [0], 4 ) ), |
|
104 | - hsc ( trim ( substr ( $region [0], 7 ) ) ), |
|
105 | - hsc ( trim ( substr ( $placename [0], 10 ) ) ), |
|
106 | - hsc ( trim ( substr ( $country [0], 8 ) ) ), |
|
107 | - hsc ( $showlocation ), |
|
99 | + $data = array( |
|
100 | + hsc(trim(substr($lat [0], 4))), |
|
101 | + hsc(trim(substr($lon [0], 4))), |
|
102 | + hsc(trim(substr($alt [0], 4))), |
|
103 | + $this->_geohash(substr($lat [0], 4), substr($lon [0], 4)), |
|
104 | + hsc(trim(substr($region [0], 7))), |
|
105 | + hsc(trim(substr($placename [0], 10))), |
|
106 | + hsc(trim(substr($country [0], 8))), |
|
107 | + hsc($showlocation), |
|
108 | 108 | $style |
109 | 109 | ); |
110 | 110 | return $data; |
@@ -117,44 +117,44 @@ discard block |
||
117 | 117 | public function render($mode, Doku_Renderer $renderer, $data) { |
118 | 118 | if ($data === false) |
119 | 119 | return false; |
120 | - list ( $lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style ) = $data; |
|
120 | + list ($lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style) = $data; |
|
121 | 121 | $ddlat = $lat; |
122 | 122 | $ddlon = $lon; |
123 | - if ($this->getConf ( 'displayformat' ) === 'DMS') { |
|
124 | - $lat = $this->convertLat ( $lat ); |
|
125 | - $lon = $this->convertLon ( $lon ); |
|
123 | + if ($this->getConf('displayformat') === 'DMS') { |
|
124 | + $lat = $this->convertLat($lat); |
|
125 | + $lon = $this->convertLon($lon); |
|
126 | 126 | } else { |
127 | 127 | $lat .= 'º'; |
128 | 128 | $lon .= 'º'; |
129 | 129 | } |
130 | 130 | |
131 | 131 | if ($mode == 'xhtml') { |
132 | - if ($this->getConf ( 'geotag_prevent_microformat_render' )) { |
|
132 | + if ($this->getConf('geotag_prevent_microformat_render')) { |
|
133 | 133 | return true; |
134 | 134 | } |
135 | - if ($this->getConf ( 'geotag_showsearch' )) { |
|
135 | + if ($this->getConf('geotag_showsearch')) { |
|
136 | 136 | $searchPre = ''; |
137 | 137 | $searchPost = ''; |
138 | - if ($spHelper = &plugin_load ( 'helper', 'spatialhelper_search' )) { |
|
139 | - $title = $this->getLang ( 'findnearby' ) . ' ' . $placename; |
|
140 | - $url = wl ( getID (), array ( |
|
138 | + if ($spHelper = &plugin_load('helper', 'spatialhelper_search')) { |
|
139 | + $title = $this->getLang('findnearby') . ' ' . $placename; |
|
140 | + $url = wl(getID(), array( |
|
141 | 141 | 'do' => 'findnearby', |
142 | 142 | 'lat' => $ddlat, |
143 | 143 | 'lon' => $ddlon |
144 | - ) ); |
|
144 | + )); |
|
145 | 145 | $searchPre = '<a href="' . $url . '" title="' . $title . '">'; |
146 | 146 | $searchPost = '<span class="a11y">' . $title . '</span></a>'; |
147 | 147 | } |
148 | 148 | } |
149 | 149 | |
150 | 150 | // render geotag microformat/schema.org microdata |
151 | - $renderer->doc .= '<span class="geotagPrint">' . $this->getLang ( 'geotag_desc' ) . '</span>'; |
|
152 | - $renderer->doc .= '<div class="h-geo geo"' . $style . ' title="' . $this->getLang ( 'geotag_desc' ) . $placename . '" itemscope itemtype="http://schema.org/Place">'; |
|
151 | + $renderer->doc .= '<span class="geotagPrint">' . $this->getLang('geotag_desc') . '</span>'; |
|
152 | + $renderer->doc .= '<div class="h-geo geo"' . $style . ' title="' . $this->getLang('geotag_desc') . $placename . '" itemscope itemtype="http://schema.org/Place">'; |
|
153 | 153 | $renderer->doc .= '<span itemprop="name">' . $showlocation . '</span>: ' . $searchPre; |
154 | 154 | $renderer->doc .= '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">'; |
155 | 155 | $renderer->doc .= '<span class="p-latitude latitude" itemprop="latitude" data-latitude="' . $ddlat . '">' . $lat . '</span>;'; |
156 | 156 | $renderer->doc .= '<span class="p-longitude longitude" itemprop="longitude" data-longitude="' . $ddlon . '">' . $lon . '</span>'; |
157 | - if (! empty ( $alt )) { |
|
157 | + if (!empty ($alt)) { |
|
158 | 158 | $renderer->doc .= ', <span class="p-altitude altitude" itemprop="elevation" data-altitude="' . $alt . '">' . $alt . 'm</span>'; |
159 | 159 | } |
160 | 160 | $renderer->doc .= '</span>' . $searchPost . '</div>' . DOKU_LF; |
@@ -170,15 +170,15 @@ discard block |
||
170 | 170 | $renderer->meta ['geo'] ['alt'] = $alt; |
171 | 171 | return true; |
172 | 172 | } elseif ($mode == 'odt') { |
173 | - if (! empty ( $alt )) |
|
173 | + if (!empty ($alt)) |
|
174 | 174 | $alt = ', ' . $alt . 'm'; |
175 | - $renderer->p_open (); |
|
176 | - $renderer->_odtAddImage ( DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', '' ); |
|
177 | - $renderer->doc .= '<text:span>' . $this->getLang ( 'geotag_desc' ) . ' ' . $placename . ': </text:span>'; |
|
178 | - $renderer->monospace_open (); |
|
175 | + $renderer->p_open(); |
|
176 | + $renderer->_odtAddImage(DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', ''); |
|
177 | + $renderer->doc .= '<text:span>' . $this->getLang('geotag_desc') . ' ' . $placename . ': </text:span>'; |
|
178 | + $renderer->monospace_open(); |
|
179 | 179 | $renderer->doc .= $lat . ';' . $lon . $alt; |
180 | - $renderer->monospace_close (); |
|
181 | - $renderer->p_close (); |
|
180 | + $renderer->monospace_close(); |
|
181 | + $renderer->p_close(); |
|
182 | 182 | return true; |
183 | 183 | } |
184 | 184 | return false; |
@@ -191,14 +191,14 @@ discard block |
||
191 | 191 | * @param float $lon |
192 | 192 | */ |
193 | 193 | private function _geohash($lat, $lon) { |
194 | - if (! $geophp = &plugin_load ( 'helper', 'geophp' )) { |
|
195 | - dbglog ( $geophp, 'syntax_plugin_geotag_geotag::_geohash: geophp plugin is not available.' ); |
|
194 | + if (!$geophp = &plugin_load('helper', 'geophp')) { |
|
195 | + dbglog($geophp, 'syntax_plugin_geotag_geotag::_geohash: geophp plugin is not available.'); |
|
196 | 196 | return ""; |
197 | 197 | } |
198 | - $_lat = floatval ( $lat ); |
|
199 | - $_lon = floatval ( $lon ); |
|
200 | - $geometry = new Point ( $_lon, $_lat ); |
|
201 | - return $geometry->out ( 'geohash' ); |
|
198 | + $_lat = floatval($lat); |
|
199 | + $_lon = floatval($lon); |
|
200 | + $geometry = new Point($_lon, $_lat); |
|
201 | + return $geometry->out('geohash'); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * @return string dms |
210 | 210 | */ |
211 | 211 | private function _convertDDtoDMS($decimaldegrees) { |
212 | - $dms = floor ( $decimaldegrees ); |
|
212 | + $dms = floor($decimaldegrees); |
|
213 | 213 | $secs = ($decimaldegrees - $dms) * 3600; |
214 | - $min = floor ( $secs / 60 ); |
|
215 | - $sec = round ( $secs - ($min * 60), 3 ); |
|
214 | + $min = floor($secs / 60); |
|
215 | + $sec = round($secs - ($min * 60), 3); |
|
216 | 216 | $dms .= 'º' . $min . '\'' . $sec . '"'; |
217 | 217 | return $dms; |
218 | 218 | } |
@@ -225,13 +225,13 @@ discard block |
||
225 | 225 | * @return string |
226 | 226 | */ |
227 | 227 | private function convertLat($decimaldegrees) { |
228 | - if (strpos ( $decimaldegrees, '-' ) !== false) { |
|
228 | + if (strpos($decimaldegrees, '-') !== false) { |
|
229 | 229 | $latPos = "S"; |
230 | 230 | } else { |
231 | 231 | $latPos = "N"; |
232 | 232 | } |
233 | - $dms = $this->_convertDDtoDMS ( abs ( floatval ( $decimaldegrees ) ) ); |
|
234 | - return hsc ( $dms . $latPos ); |
|
233 | + $dms = $this->_convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
234 | + return hsc($dms . $latPos); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -242,12 +242,12 @@ discard block |
||
242 | 242 | * @return string |
243 | 243 | */ |
244 | 244 | private function convertLon($decimaldegrees) { |
245 | - if (strpos ( $decimaldegrees, '-' ) !== false) { |
|
245 | + if (strpos($decimaldegrees, '-') !== false) { |
|
246 | 246 | $lonPos = "W"; |
247 | 247 | } else { |
248 | 248 | $lonPos = "E"; |
249 | 249 | } |
250 | - $dms = $this->_convertDDtoDMS ( abs ( floatval ( $decimaldegrees ) ) ); |
|
251 | - return hsc ( $dms . $lonPos ); |
|
250 | + $dms = $this->_convertDDtoDMS(abs(floatval($decimaldegrees))); |
|
251 | + return hsc($dms . $lonPos); |
|
252 | 252 | } |
253 | 253 | } |
@@ -14,11 +14,13 @@ discard block |
||
14 | 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
15 | 15 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
16 | 16 | */ |
17 | -if (! defined ( 'DOKU_INC' )) |
|
17 | +if (! defined ( 'DOKU_INC' )) { |
|
18 | 18 | die (); |
19 | +} |
|
19 | 20 | |
20 | -if (! defined ( 'DOKU_PLUGIN' )) |
|
21 | +if (! defined ( 'DOKU_PLUGIN' )) { |
|
21 | 22 | define ( 'DOKU_PLUGIN', DOKU_INC . 'lib/plugins/' ); |
23 | +} |
|
22 | 24 | |
23 | 25 | require_once (DOKU_PLUGIN . 'syntax.php'); |
24 | 26 | /** |
@@ -115,8 +117,9 @@ discard block |
||
115 | 117 | * @see DokuWiki_Syntax_Plugin::render() |
116 | 118 | */ |
117 | 119 | public function render($mode, Doku_Renderer $renderer, $data) { |
118 | - if ($data === false) |
|
119 | - return false; |
|
120 | + if ($data === false) { |
|
121 | + return false; |
|
122 | + } |
|
120 | 123 | list ( $lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style ) = $data; |
121 | 124 | $ddlat = $lat; |
122 | 125 | $ddlon = $lon; |
@@ -170,8 +173,9 @@ discard block |
||
170 | 173 | $renderer->meta ['geo'] ['alt'] = $alt; |
171 | 174 | return true; |
172 | 175 | } elseif ($mode == 'odt') { |
173 | - if (! empty ( $alt )) |
|
174 | - $alt = ', ' . $alt . 'm'; |
|
176 | + if (! empty ( $alt )) { |
|
177 | + $alt = ', ' . $alt . 'm'; |
|
178 | + } |
|
175 | 179 | $renderer->p_open (); |
176 | 180 | $renderer->_odtAddImage ( DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', '' ); |
177 | 181 | $renderer->doc .= '<text:span>' . $this->getLang ( 'geotag_desc' ) . ' ' . $placename . ': </text:span>'; |