Completed
Pull Request — master (#18)
by Mark
01:55
created
_test/general.test.php 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -23,40 +23,40 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
_test/syntax.test.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -23,101 +23,101 @@
 block discarded – undo
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('minimalgeotag',
78
-                        $response->queryHTML('meta[name="keywords"]')->attr('content'));
79
-        $this->assertEquals('51.565696;5.324596',
80
-                        $response->queryHTML('meta[name="geo.position"]')->attr('content'));
81
-        $this->assertEquals('51.565696, 5.324596',
82
-                        $response->queryHTML('meta[name="ICBM"]')->attr('content'));
83
-
84
-        $this->assertTrue(
85
-            strpos($response->getContent(), 'Geotag (location) for:') !== false,
86
-            '"Geotag (location) for:" was not in the output'
87
-        );
88
-    }
89
-
90
-    public function test_fullgeotag(): void {
91
-        $request = new TestRequest();
92
-        $response = $request->get(array('id'=>'fullgeotag'), '/doku.php');
93
-
94
-        $this->assertEquals('fullgeotag',
95
-                        $response->queryHTML('meta[name="keywords"]')->attr('content'));
96
-        $this->assertEquals('52.132633;5.291266;9',
97
-                        $response->queryHTML('meta[name="geo.position"]')->attr('content'));
98
-        $this->assertEquals('52.132633, 5.291266',
99
-                        $response->queryHTML('meta[name="ICBM"]')->attr('content'));
100
-
101
-        $this->assertTrue(
102
-            strpos($response->getContent(), 'Geotag (location) for:') !== false,
103
-            '"Geotag (location) for:" was not in the output'
104
-        );
105
-    }
106
-
107
-    public function test_fullgeotagnegativecoords(): void {
108
-        $request = new TestRequest();
109
-        $response = $request->get(array('id'=>'fullgeotagnegativecoords'), '/doku.php');
110
-
111
-        $this->assertEquals('fullgeotagnegativecoords',
112
-                        $response->queryHTML('meta[name="keywords"]')->attr('content'));
113
-        $this->assertEquals('-52.132633;-5.291266;-9',
114
-                        $response->queryHTML('meta[name="geo.position"]')->attr('content'));
115
-        $this->assertEquals('-52.132633, -5.291266',
116
-                        $response->queryHTML('meta[name="ICBM"]')->attr('content'));
117
-
118
-        $this->assertTrue(
119
-            strpos($response->getContent(), 'Geotag (location) for:') !== false,
120
-            '"Geotag (location) for:" was not in the output'
121
-        );
122
-    }
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('minimalgeotag',
78
+						$response->queryHTML('meta[name="keywords"]')->attr('content'));
79
+		$this->assertEquals('51.565696;5.324596',
80
+						$response->queryHTML('meta[name="geo.position"]')->attr('content'));
81
+		$this->assertEquals('51.565696, 5.324596',
82
+						$response->queryHTML('meta[name="ICBM"]')->attr('content'));
83
+
84
+		$this->assertTrue(
85
+			strpos($response->getContent(), 'Geotag (location) for:') !== false,
86
+			'"Geotag (location) for:" was not in the output'
87
+		);
88
+	}
89
+
90
+	public function test_fullgeotag(): void {
91
+		$request = new TestRequest();
92
+		$response = $request->get(array('id'=>'fullgeotag'), '/doku.php');
93
+
94
+		$this->assertEquals('fullgeotag',
95
+						$response->queryHTML('meta[name="keywords"]')->attr('content'));
96
+		$this->assertEquals('52.132633;5.291266;9',
97
+						$response->queryHTML('meta[name="geo.position"]')->attr('content'));
98
+		$this->assertEquals('52.132633, 5.291266',
99
+						$response->queryHTML('meta[name="ICBM"]')->attr('content'));
100
+
101
+		$this->assertTrue(
102
+			strpos($response->getContent(), 'Geotag (location) for:') !== false,
103
+			'"Geotag (location) for:" was not in the output'
104
+		);
105
+	}
106
+
107
+	public function test_fullgeotagnegativecoords(): void {
108
+		$request = new TestRequest();
109
+		$response = $request->get(array('id'=>'fullgeotagnegativecoords'), '/doku.php');
110
+
111
+		$this->assertEquals('fullgeotagnegativecoords',
112
+						$response->queryHTML('meta[name="keywords"]')->attr('content'));
113
+		$this->assertEquals('-52.132633;-5.291266;-9',
114
+						$response->queryHTML('meta[name="geo.position"]')->attr('content'));
115
+		$this->assertEquals('-52.132633, -5.291266',
116
+						$response->queryHTML('meta[name="ICBM"]')->attr('content'));
117
+
118
+		$this->assertTrue(
119
+			strpos($response->getContent(), 'Geotag (location) for:') !== false,
120
+			'"Geotag (location) for:" was not in the output'
121
+		);
122
+	}
123 123
 }
Please login to merge, or discard this patch.
helper.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,6 +25,6 @@
 block discarded – undo
25 25
  * @see http://www.dokuwiki.org/devel:helper_plugins
26 26
  */
27 27
 class helper_plugin_geotag extends DokuWiki_Plugin {
28
-    /** Constructor. */
29
-    public function helper_plugin_geotag() {}
28
+	/** Constructor. */
29
+	public function helper_plugin_geotag() {}
30 30
 }
Please login to merge, or discard this patch.
action.php 1 patch
Indentation   +140 added lines, -140 removed lines patch added patch discarded remove patch
@@ -23,155 +23,155 @@
 block discarded – undo
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
-        $controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'ping_geourl', array());
35
-        if ($this->getConf('toolbar_icon')) {
36
-            $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array());
37
-        }
38
-    }
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
+		$controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'ping_geourl', array());
35
+		if ($this->getConf('toolbar_icon')) {
36
+			$controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insertButton', array());
37
+		}
38
+	}
39 39
 
40
-    /**
41
-     * Retrieve metadata and add to the head of the page using appropriate meta tags.
42
-     *
43
-     * @param Doku_Event $event
44
-     *          the DokuWiki event. $event->data is a two-dimensional
45
-     *          array of all meta headers. The keys are meta, link and script.
46
-     * @param unknown_type $param
47
-     *
48
-     * @see http://www.dokuwiki.org/devel:event:tpl_metaheader_output
49
-     */
50
-    public function handleMetaheaderOutput(Doku_Event $event, $param) {
51
-        global $ID;
52
-        $title = p_get_metadata($ID, 'title', true);
53
-        $geotags = p_get_metadata($ID, 'geo', true);
54
-        $region = $geotags ['region'];
55
-        $lat = $geotags ['lat'];
56
-        $lon = $geotags ['lon'];
57
-        $alt = $geotags ['alt'];
58
-        $country = $geotags ['country'];
59
-        $placename = $geotags ['placename'];
60
-        $geohash = $geotags ['geohash'];
40
+	/**
41
+	 * Retrieve metadata and add to the head of the page using appropriate meta tags.
42
+	 *
43
+	 * @param Doku_Event $event
44
+	 *          the DokuWiki event. $event->data is a two-dimensional
45
+	 *          array of all meta headers. The keys are meta, link and script.
46
+	 * @param unknown_type $param
47
+	 *
48
+	 * @see http://www.dokuwiki.org/devel:event:tpl_metaheader_output
49
+	 */
50
+	public function handleMetaheaderOutput(Doku_Event $event, $param) {
51
+		global $ID;
52
+		$title = p_get_metadata($ID, 'title', true);
53
+		$geotags = p_get_metadata($ID, 'geo', true);
54
+		$region = $geotags ['region'];
55
+		$lat = $geotags ['lat'];
56
+		$lon = $geotags ['lon'];
57
+		$alt = $geotags ['alt'];
58
+		$country = $geotags ['country'];
59
+		$placename = $geotags ['placename'];
60
+		$geohash = $geotags ['geohash'];
61 61
 
62
-        if (!empty ($region)) {
63
-            $event->data ['meta'] [] = array(
64
-                    'name' => 'geo.region',
65
-                    'content' => $region
66
-            );
67
-        }
68
-        if (!empty ($placename)) {
69
-            $event->data ['meta'] [] = array(
70
-                    'name' => 'geo.placename',
71
-                    'content' => $placename
72
-            );
73
-        }
74
-        if (!(empty ($lat) && empty ($lon))) {
75
-            if (!empty ($alt)) {
76
-                $event->data ['meta'] [] = array(
77
-                        'name' => 'geo.position',
78
-                        'content' => $lat . ';' . $lon . ';' . $alt
79
-                );
80
-            } else {
81
-                $event->data ['meta'] [] = array(
82
-                        'name' => 'geo.position',
83
-                        'content' => $lat . ';' . $lon
84
-                );
85
-            }
86
-        }
87
-        if (!empty ($country)) {
88
-            $event->data ['meta'] [] = array(
89
-                    'name' => 'geo.country',
90
-                    'content' => $country
91
-            );
92
-        }
93
-        if (!(empty ($lat) && empty ($lon))) {
94
-            $event->data ['meta'] [] = array(
95
-                    'name' => "ICBM",
96
-                    'content' => $lat . ', ' . $lon
97
-            );
98
-            // icbm is generally useless without a DC.title,
99
-            // so we copy that from title unless it's empty...
100
-            if (!(empty ($title))) {
101
-                /*
62
+		if (!empty ($region)) {
63
+			$event->data ['meta'] [] = array(
64
+					'name' => 'geo.region',
65
+					'content' => $region
66
+			);
67
+		}
68
+		if (!empty ($placename)) {
69
+			$event->data ['meta'] [] = array(
70
+					'name' => 'geo.placename',
71
+					'content' => $placename
72
+			);
73
+		}
74
+		if (!(empty ($lat) && empty ($lon))) {
75
+			if (!empty ($alt)) {
76
+				$event->data ['meta'] [] = array(
77
+						'name' => 'geo.position',
78
+						'content' => $lat . ';' . $lon . ';' . $alt
79
+				);
80
+			} else {
81
+				$event->data ['meta'] [] = array(
82
+						'name' => 'geo.position',
83
+						'content' => $lat . ';' . $lon
84
+				);
85
+			}
86
+		}
87
+		if (!empty ($country)) {
88
+			$event->data ['meta'] [] = array(
89
+					'name' => 'geo.country',
90
+					'content' => $country
91
+			);
92
+		}
93
+		if (!(empty ($lat) && empty ($lon))) {
94
+			$event->data ['meta'] [] = array(
95
+					'name' => "ICBM",
96
+					'content' => $lat . ', ' . $lon
97
+			);
98
+			// icbm is generally useless without a DC.title,
99
+			// so we copy that from title unless it's empty...
100
+			if (!(empty ($title))) {
101
+				/*
102 102
                  * don't specify the DC namespace as this is incomplete; it should be done at the
103 103
                  * template level as it also needs a 'profile' attribute on the head/container,
104 104
                  * see: http://dublincore.org/documents/dc-html/#sect-3.1.1
105 105
                  * $event->data ['link'] [] = array ('rel' => 'schema.DC',
106 106
                  * 'href' => 'http://purl.org/dc/elements/1.1/');
107 107
                  */
108
-                $event->data ['meta'] [] = array(
109
-                        'name' => "DC.title",
110
-                        'content' => $title
111
-                );
112
-            }
113
-        }
114
-        if (!empty ($geohash)) {
115
-            $event->data ['meta'] [] = array(
116
-                    'name' => 'geo.geohash',
117
-                    'content' => $geohash
118
-            );
119
-        }
120
-    }
108
+				$event->data ['meta'] [] = array(
109
+						'name' => "DC.title",
110
+						'content' => $title
111
+				);
112
+			}
113
+		}
114
+		if (!empty ($geohash)) {
115
+			$event->data ['meta'] [] = array(
116
+					'name' => 'geo.geohash',
117
+					'content' => $geohash
118
+			);
119
+		}
120
+	}
121 121
 
122
-    /**
123
-     * Ping the geourl webservice with the url of the for indexing, only if the page is new.
124
-     *
125
-     * @param Doku_Event $event
126
-     *          the DokuWiki event
127
-     * @param mixed $param
128
-     *          not used
129
-     */
130
-    public function ping_geourl(Doku_Event $event, $param) {
131
-        global $ID;
132
-        // see: http://www.dokuwiki.org/devel:event:io_wikipage_write event data:
133
-        if (!$this->getConf('geotag_pinggeourl')) {
134
-            // config says don't ping
135
-            return false; 
136
-        }
137
-        if ($event->data [3]) {
138
-            // old revision saved
139
-            return false; 
140
-        }
141
-        if (!$event->data [0] [1]) {
142
-            // file/block is empty
143
-            return false; 
144
-        }
145
-        if (@file_exists($event->data [0] [0])) {
146
-            // file not new
147
-            return false; 
148
-        }
149
-        if (p_get_metadata($ID, 'geo', true)) {
150
-            // no geo metadata available, ping is useless
151
-            return false; 
152
-        }
122
+	/**
123
+	 * Ping the geourl webservice with the url of the for indexing, only if the page is new.
124
+	 *
125
+	 * @param Doku_Event $event
126
+	 *          the DokuWiki event
127
+	 * @param mixed $param
128
+	 *          not used
129
+	 */
130
+	public function ping_geourl(Doku_Event $event, $param) {
131
+		global $ID;
132
+		// see: http://www.dokuwiki.org/devel:event:io_wikipage_write event data:
133
+		if (!$this->getConf('geotag_pinggeourl')) {
134
+			// config says don't ping
135
+			return false; 
136
+		}
137
+		if ($event->data [3]) {
138
+			// old revision saved
139
+			return false; 
140
+		}
141
+		if (!$event->data [0] [1]) {
142
+			// file/block is empty
143
+			return false; 
144
+		}
145
+		if (@file_exists($event->data [0] [0])) {
146
+			// file not new
147
+			return false; 
148
+		}
149
+		if (p_get_metadata($ID, 'geo', true)) {
150
+			// no geo metadata available, ping is useless
151
+			return false; 
152
+		}
153 153
 
154
-        $url = 'http://geourl.org/ping/?p=' . wl($ID, '', true);
155
-        $http = new DokuHTTPClient();
156
-        $result = $http->get($url);
157
-        dbglog($result, "GeoURL Ping response for $url");
158
-        return $result;
159
-    }
154
+		$url = 'http://geourl.org/ping/?p=' . wl($ID, '', true);
155
+		$http = new DokuHTTPClient();
156
+		$result = $http->get($url);
157
+		dbglog($result, "GeoURL Ping response for $url");
158
+		return $result;
159
+	}
160 160
 
161
-    /**
162
-     * Inserts the toolbar button.
163
-     *
164
-     * @param Doku_Event $event
165
-     *          the DokuWiki event
166
-     */
167
-    public function insertButton(Doku_Event $event, $param) {
168
-        $event->data [] = array(
169
-                'type' => 'format',
170
-                'title' => $this->getLang('toolbar_desc'),
171
-                'icon' => '../../plugins/geotag/images/geotag.png',
172
-                'open' => '{{geotag>lat:',
173
-                'sample' => '52.2345',
174
-                'close' => ', lon:7.521, alt: , placename: , country: , region: }}'
175
-        );
176
-    }
161
+	/**
162
+	 * Inserts the toolbar button.
163
+	 *
164
+	 * @param Doku_Event $event
165
+	 *          the DokuWiki event
166
+	 */
167
+	public function insertButton(Doku_Event $event, $param) {
168
+		$event->data [] = array(
169
+				'type' => 'format',
170
+				'title' => $this->getLang('toolbar_desc'),
171
+				'icon' => '../../plugins/geotag/images/geotag.png',
172
+				'open' => '{{geotag>lat:',
173
+				'sample' => '52.2345',
174
+				'close' => ', lon:7.521, alt: , placename: , country: , region: }}'
175
+		);
176
+	}
177 177
 }
Please login to merge, or discard this patch.
syntax/geotag.php 1 patch
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -24,230 +24,230 @@
 block discarded – undo
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 (trim($hide [0]) == 'hide') {
88
-            $style = ' style="display: none;"';
89
-        } elseif (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 (trim($hide [0]) == 'hide') {
88
+			$style = ' style="display: none;"';
89
+		} elseif (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
-     *
109
-     * @see DokuWiki_Syntax_Plugin::render()
110
-     */
111
-    public function render($mode, Doku_Renderer $renderer, $data) {
112
-        if ($data === false) {
113
-                    return false;
114
-        }
115
-        list ($lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style) = $data;
116
-        $ddlat = $lat;
117
-        $ddlon = $lon;
118
-        if ($this->getConf('displayformat') === 'DMS') {
119
-            $lat = $this->convertLat($lat);
120
-            $lon = $this->convertLon($lon);
121
-        } else {
122
-            $lat .= 'º';
123
-            $lon .= 'º';
124
-        }
107
+	/**
108
+	 *
109
+	 * @see DokuWiki_Syntax_Plugin::render()
110
+	 */
111
+	public function render($mode, Doku_Renderer $renderer, $data) {
112
+		if ($data === false) {
113
+					return false;
114
+		}
115
+		list ($lat, $lon, $alt, $geohash, $region, $placename, $country, $showlocation, $style) = $data;
116
+		$ddlat = $lat;
117
+		$ddlon = $lon;
118
+		if ($this->getConf('displayformat') === 'DMS') {
119
+			$lat = $this->convertLat($lat);
120
+			$lon = $this->convertLon($lon);
121
+		} else {
122
+			$lat .= 'º';
123
+			$lon .= 'º';
124
+		}
125 125
 
126
-        if ($mode == 'xhtml') {
127
-            if ($this->getConf('geotag_prevent_microformat_render')) {
128
-                return true;
129
-            }
130
-            $searchPre = '';
131
-            $searchPost = '';
132
-            if ($this->getConf('geotag_showsearch')) {
133
-                if ($spHelper = &plugin_load('helper', 'spatialhelper_search')) {
134
-                    $title = $this->getLang('findnearby') . '&nbsp;' . $placename;
135
-                    $url = wl(getID(), array(
136
-                            'do' => 'findnearby',
137
-                            'lat' => $ddlat,
138
-                            'lon' => $ddlon
139
-                    ));
140
-                    $searchPre = '<a href="' . $url . '" title="' . $title . '">';
141
-                    $searchPost = '<span class="a11y">' . $title . '</span></a>';
142
-                }
143
-            }
126
+		if ($mode == 'xhtml') {
127
+			if ($this->getConf('geotag_prevent_microformat_render')) {
128
+				return true;
129
+			}
130
+			$searchPre = '';
131
+			$searchPost = '';
132
+			if ($this->getConf('geotag_showsearch')) {
133
+				if ($spHelper = &plugin_load('helper', 'spatialhelper_search')) {
134
+					$title = $this->getLang('findnearby') . '&nbsp;' . $placename;
135
+					$url = wl(getID(), array(
136
+							'do' => 'findnearby',
137
+							'lat' => $ddlat,
138
+							'lon' => $ddlon
139
+					));
140
+					$searchPre = '<a href="' . $url . '" title="' . $title . '">';
141
+					$searchPost = '<span class="a11y">' . $title . '</span></a>';
142
+				}
143
+			}
144 144
 
145
-            // render geotag microformat/schema.org microdata
146
-            $renderer->doc .= '<span class="geotagPrint">' . $this->getLang('geotag_desc') . '</span>';
147
-            $renderer->doc .= '<div class="h-geo geo"' . $style . ' title="' . $this->getLang('geotag_desc')
148
-                                . $placename . '" itemscope itemtype="http://schema.org/Place">';
149
-            $renderer->doc .= '<span itemprop="name">' . $showlocation . '</span>:&nbsp;' . $searchPre;
150
-            $renderer->doc .= '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">';
151
-            $renderer->doc .= '<span class="p-latitude latitude" itemprop="latitude" data-latitude="' . $ddlat . '">'
152
-                                . $lat . '</span>;';
153
-            $renderer->doc .= '<span class="p-longitude longitude" itemprop="longitude" data-longitude="' . $ddlon
154
-                                . '">' . $lon . '</span>';
155
-            if (!empty ($alt)) {
156
-                $renderer->doc .= ', <span class="p-altitude altitude" itemprop="elevation" data-altitude="' . $alt
157
-                                    . '">' . $alt . 'm</span>';
158
-            }
159
-            $renderer->doc .= '</span>' . $searchPost . '</div>' . DOKU_LF;
160
-            return true;
161
-        } elseif ($mode == 'metadata') {
162
-            // render metadata (our action plugin will put it in the page head)
163
-            $renderer->meta ['geo'] ['lat'] = $ddlat;
164
-            $renderer->meta ['geo'] ['lon'] = $ddlon;
165
-            $renderer->meta ['geo'] ['placename'] = $placename;
166
-            $renderer->meta ['geo'] ['region'] = $region;
167
-            $renderer->meta ['geo'] ['country'] = $country;
168
-            $renderer->meta ['geo'] ['geohash'] = $geohash;
169
-            $renderer->meta ['geo'] ['alt'] = $alt;
170
-            return true;
171
-        } elseif ($mode == 'odt') {
172
-            if (!empty ($alt)) {
173
-                $alt = ', ' . $alt . 'm';
174
-            }
175
-            $renderer->p_open();
176
-            $renderer->_odtAddImage(DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', '');
177
-            $renderer->cdata($this->getLang('geotag_desc') . ' ' . $placename);
178
-            $renderer->monospace_open();
179
-            $renderer->cdata($lat . ';' . $lon . $alt);
180
-            $renderer->monospace_close();
181
-            $renderer->p_close();
182
-            return true;
183
-        }
184
-        return false;
185
-    }
145
+			// render geotag microformat/schema.org microdata
146
+			$renderer->doc .= '<span class="geotagPrint">' . $this->getLang('geotag_desc') . '</span>';
147
+			$renderer->doc .= '<div class="h-geo geo"' . $style . ' title="' . $this->getLang('geotag_desc')
148
+								. $placename . '" itemscope itemtype="http://schema.org/Place">';
149
+			$renderer->doc .= '<span itemprop="name">' . $showlocation . '</span>:&nbsp;' . $searchPre;
150
+			$renderer->doc .= '<span itemprop="geo" itemscope itemtype="http://schema.org/GeoCoordinates">';
151
+			$renderer->doc .= '<span class="p-latitude latitude" itemprop="latitude" data-latitude="' . $ddlat . '">'
152
+								. $lat . '</span>;';
153
+			$renderer->doc .= '<span class="p-longitude longitude" itemprop="longitude" data-longitude="' . $ddlon
154
+								. '">' . $lon . '</span>';
155
+			if (!empty ($alt)) {
156
+				$renderer->doc .= ', <span class="p-altitude altitude" itemprop="elevation" data-altitude="' . $alt
157
+									. '">' . $alt . 'm</span>';
158
+			}
159
+			$renderer->doc .= '</span>' . $searchPost . '</div>' . DOKU_LF;
160
+			return true;
161
+		} elseif ($mode == 'metadata') {
162
+			// render metadata (our action plugin will put it in the page head)
163
+			$renderer->meta ['geo'] ['lat'] = $ddlat;
164
+			$renderer->meta ['geo'] ['lon'] = $ddlon;
165
+			$renderer->meta ['geo'] ['placename'] = $placename;
166
+			$renderer->meta ['geo'] ['region'] = $region;
167
+			$renderer->meta ['geo'] ['country'] = $country;
168
+			$renderer->meta ['geo'] ['geohash'] = $geohash;
169
+			$renderer->meta ['geo'] ['alt'] = $alt;
170
+			return true;
171
+		} elseif ($mode == 'odt') {
172
+			if (!empty ($alt)) {
173
+				$alt = ', ' . $alt . 'm';
174
+			}
175
+			$renderer->p_open();
176
+			$renderer->_odtAddImage(DOKU_PLUGIN . 'geotag/images/geotag.png', null, null, 'left', '');
177
+			$renderer->cdata($this->getLang('geotag_desc') . ' ' . $placename);
178
+			$renderer->monospace_open();
179
+			$renderer->cdata($lat . ';' . $lon . $alt);
180
+			$renderer->monospace_close();
181
+			$renderer->p_close();
182
+			return true;
183
+		}
184
+		return false;
185
+	}
186 186
 
187
-    /**
188
-     * Calculate the geohash for this lat/lon pair.
189
-     *
190
-     * @param float $lat
191
-     * @param float $lon
192
-     */
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.');
196
-            return "";
197
-        }
198
-        $_lat = floatval($lat);
199
-        $_lon = floatval($lon);
200
-        $geometry = new Point($_lon, $_lat);
201
-        return $geometry->out('geohash');
202
-    }
187
+	/**
188
+	 * Calculate the geohash for this lat/lon pair.
189
+	 *
190
+	 * @param float $lat
191
+	 * @param float $lon
192
+	 */
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.');
196
+			return "";
197
+		}
198
+		$_lat = floatval($lat);
199
+		$_lon = floatval($lon);
200
+		$geometry = new Point($_lon, $_lat);
201
+		return $geometry->out('geohash');
202
+	}
203 203
 
204
-    /**
205
-     * Convert decimal degrees to degrees, minutes, seconds format
206
-     *
207
-     * @todo move this into a shared library
208
-     * @param float $decimaldegrees
209
-     * @return string dms
210
-     */
211
-    private function convertDDtoDMS($decimaldegrees) {
212
-        $dms = floor($decimaldegrees);
213
-        $secs = ($decimaldegrees - $dms) * 3600;
214
-        $min = floor($secs / 60);
215
-        $sec = round($secs - ($min * 60), 3);
216
-        $dms .= 'º' . $min . '\'' . $sec . '"';
217
-        return $dms;
218
-    }
204
+	/**
205
+	 * Convert decimal degrees to degrees, minutes, seconds format
206
+	 *
207
+	 * @todo move this into a shared library
208
+	 * @param float $decimaldegrees
209
+	 * @return string dms
210
+	 */
211
+	private function convertDDtoDMS($decimaldegrees) {
212
+		$dms = floor($decimaldegrees);
213
+		$secs = ($decimaldegrees - $dms) * 3600;
214
+		$min = floor($secs / 60);
215
+		$sec = round($secs - ($min * 60), 3);
216
+		$dms .= 'º' . $min . '\'' . $sec . '"';
217
+		return $dms;
218
+	}
219 219
 
220
-    /**
221
-     * convert latitude in decimal degrees to DMS+hemisphere.
222
-     *
223
-     * @todo move this into a shared library
224
-     * @param float $decimaldegrees
225
-     * @return string
226
-     */
227
-    private function convertLat($decimaldegrees) {
228
-        if (strpos($decimaldegrees, '-') !== false) {
229
-            $latPos = "S";
230
-        } else {
231
-            $latPos = "N";
232
-        }
233
-        $dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees)));
234
-        return hsc($dms . $latPos);
235
-    }
220
+	/**
221
+	 * convert latitude in decimal degrees to DMS+hemisphere.
222
+	 *
223
+	 * @todo move this into a shared library
224
+	 * @param float $decimaldegrees
225
+	 * @return string
226
+	 */
227
+	private function convertLat($decimaldegrees) {
228
+		if (strpos($decimaldegrees, '-') !== false) {
229
+			$latPos = "S";
230
+		} else {
231
+			$latPos = "N";
232
+		}
233
+		$dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees)));
234
+		return hsc($dms . $latPos);
235
+	}
236 236
 
237
-    /**
238
-     * convert longitude in decimal degrees to DMS+hemisphere.
239
-     *
240
-     * @todo move this into a shared library
241
-     * @param float $decimaldegrees
242
-     * @return string
243
-     */
244
-    private function convertLon($decimaldegrees) {
245
-        if (strpos($decimaldegrees, '-') !== false) {
246
-            $lonPos = "W";
247
-        } else {
248
-            $lonPos = "E";
249
-        }
250
-        $dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees)));
251
-        return hsc($dms . $lonPos);
252
-    }
237
+	/**
238
+	 * convert longitude in decimal degrees to DMS+hemisphere.
239
+	 *
240
+	 * @todo move this into a shared library
241
+	 * @param float $decimaldegrees
242
+	 * @return string
243
+	 */
244
+	private function convertLon($decimaldegrees) {
245
+		if (strpos($decimaldegrees, '-') !== false) {
246
+			$lonPos = "W";
247
+		} else {
248
+			$lonPos = "E";
249
+		}
250
+		$dms = $this->convertDDtoDMS(abs(floatval($decimaldegrees)));
251
+		return hsc($dms . $lonPos);
252
+	}
253 253
 }
Please login to merge, or discard this patch.