@@ -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>'; |
@@ -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(); |
@@ -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')); |
@@ -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,86 +23,86 @@ |
||
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() { |
|
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 | - function setUp() { |
|
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 | - //dbglog($data, "pages for indexing"); |
|
52 | - |
|
53 | - $verbose = false; |
|
54 | - $force = false; |
|
55 | - foreach ($data as $val) { |
|
56 | - idx_addPage($val['id'], $verbose, $force); |
|
57 | - } |
|
58 | - if ($conf['allowdebug']) { |
|
59 | - touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
60 | - } |
|
61 | - } |
|
62 | - |
|
63 | - public function tearDown() { |
|
64 | - parent::tearDown(); |
|
65 | - |
|
66 | - global $conf; |
|
67 | - // try to get the debug log after running the test, print and clear |
|
68 | - if ($conf['allowdebug']) { |
|
69 | - print "\n"; |
|
70 | - readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
71 | - unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
72 | - } |
|
73 | - } |
|
74 | - |
|
75 | - public function test_geotag(){ |
|
76 | - $request = new TestRequest(); |
|
77 | - $response = $request->get(array('id'=>'minimalgeotag'), '/doku.php'); |
|
78 | - |
|
79 | - $this->assertEquals('minimalgeotag', |
|
80 | - $response->queryHTML('meta[name="keywords"]')->attr('content')); |
|
81 | - $this->assertEquals('51.565696;5.324596', |
|
82 | - $response->queryHTML('meta[name="geo.position"]')->attr('content')); |
|
83 | - $this->assertEquals('51.565696, 5.324596', |
|
84 | - $response->queryHTML('meta[name="ICBM"]')->attr('content')); |
|
85 | - |
|
86 | - $this->assertTrue( |
|
87 | - strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
88 | - '"Geotag (location) for:" was not in the output' |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - public function test_fullgeotag(){ |
|
93 | - $request = new TestRequest(); |
|
94 | - $response = $request->get(array('id'=>'fullgeotag'), '/doku.php'); |
|
95 | - |
|
96 | - $this->assertEquals('fullgeotag', |
|
97 | - $response->queryHTML('meta[name="keywords"]')->attr('content')); |
|
98 | - $this->assertEquals('52.132633;5.291266;9', |
|
99 | - $response->queryHTML('meta[name="geo.position"]')->attr('content')); |
|
100 | - $this->assertEquals('52.132633, 5.291266', |
|
101 | - $response->queryHTML('meta[name="ICBM"]')->attr('content')); |
|
102 | - |
|
103 | - $this->assertTrue( |
|
104 | - strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
105 | - '"Geotag (location) for:" was not in the output' |
|
106 | - ); |
|
107 | - } |
|
26 | + protected $pluginsEnabled = array('geotag'); |
|
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; |
|
35 | + |
|
36 | + TestUtils::rcopy(TMP_DIR, dirname(__FILE__).'/data/'); |
|
37 | + |
|
38 | + dbglog("\nset up class syntax_plugin_geotag_test"); |
|
39 | + } |
|
40 | + |
|
41 | + function setUp() { |
|
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 | + //dbglog($data, "pages for indexing"); |
|
52 | + |
|
53 | + $verbose = false; |
|
54 | + $force = false; |
|
55 | + foreach ($data as $val) { |
|
56 | + idx_addPage($val['id'], $verbose, $force); |
|
57 | + } |
|
58 | + if ($conf['allowdebug']) { |
|
59 | + touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
60 | + } |
|
61 | + } |
|
62 | + |
|
63 | + public function tearDown() { |
|
64 | + parent::tearDown(); |
|
65 | + |
|
66 | + global $conf; |
|
67 | + // try to get the debug log after running the test, print and clear |
|
68 | + if ($conf['allowdebug']) { |
|
69 | + print "\n"; |
|
70 | + readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
71 | + unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
72 | + } |
|
73 | + } |
|
74 | + |
|
75 | + public function test_geotag(){ |
|
76 | + $request = new TestRequest(); |
|
77 | + $response = $request->get(array('id'=>'minimalgeotag'), '/doku.php'); |
|
78 | + |
|
79 | + $this->assertEquals('minimalgeotag', |
|
80 | + $response->queryHTML('meta[name="keywords"]')->attr('content')); |
|
81 | + $this->assertEquals('51.565696;5.324596', |
|
82 | + $response->queryHTML('meta[name="geo.position"]')->attr('content')); |
|
83 | + $this->assertEquals('51.565696, 5.324596', |
|
84 | + $response->queryHTML('meta[name="ICBM"]')->attr('content')); |
|
85 | + |
|
86 | + $this->assertTrue( |
|
87 | + strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
88 | + '"Geotag (location) for:" was not in the output' |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + public function test_fullgeotag(){ |
|
93 | + $request = new TestRequest(); |
|
94 | + $response = $request->get(array('id'=>'fullgeotag'), '/doku.php'); |
|
95 | + |
|
96 | + $this->assertEquals('fullgeotag', |
|
97 | + $response->queryHTML('meta[name="keywords"]')->attr('content')); |
|
98 | + $this->assertEquals('52.132633;5.291266;9', |
|
99 | + $response->queryHTML('meta[name="geo.position"]')->attr('content')); |
|
100 | + $this->assertEquals('52.132633, 5.291266', |
|
101 | + $response->queryHTML('meta[name="ICBM"]')->attr('content')); |
|
102 | + |
|
103 | + $this->assertTrue( |
|
104 | + strpos($response->getContent(), 'Geotag (location) for:') !== false, |
|
105 | + '"Geotag (location) for:" was not in the output' |
|
106 | + ); |
|
107 | + } |
|
108 | 108 | } |
@@ -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 | } |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | idx_addPage($val['id'], $verbose, $force); |
57 | 57 | } |
58 | 58 | if ($conf['allowdebug']) { |
59 | - touch(DOKU_TMP_DATA.'cache/debug.log'); |
|
59 | + touch(DOKU_TMP_DATA . 'cache/debug.log'); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | // try to get the debug log after running the test, print and clear |
68 | 68 | if ($conf['allowdebug']) { |
69 | 69 | print "\n"; |
70 | - readfile(DOKU_TMP_DATA.'cache/debug.log'); |
|
71 | - unlink(DOKU_TMP_DATA.'cache/debug.log'); |
|
70 | + readfile(DOKU_TMP_DATA . 'cache/debug.log'); |
|
71 | + unlink(DOKU_TMP_DATA . 'cache/debug.log'); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - public function test_geotag(){ |
|
75 | + public function test_geotag() { |
|
76 | 76 | $request = new TestRequest(); |
77 | 77 | $response = $request->get(array('id'=>'minimalgeotag'), '/doku.php'); |
78 | 78 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | ); |
90 | 90 | } |
91 | 91 | |
92 | - public function test_fullgeotag(){ |
|
92 | + public function test_fullgeotag() { |
|
93 | 93 | $request = new TestRequest(); |
94 | 94 | $response = $request->get(array('id'=>'fullgeotag'), '/doku.php'); |
95 | 95 |