add openstreetmap
authorfriendica <info@friendica.com>
Fri, 10 Feb 2012 02:10:12 +0000 (18:10 -0800)
committerfriendica <info@friendica.com>
Fri, 10 Feb 2012 02:10:12 +0000 (18:10 -0800)
openstreetmap.tgz [new file with mode: 0644]
openstreetmap/openstreetmap.php [new file with mode: 0755]
randplace.tgz
randplace/randplace.php

diff --git a/openstreetmap.tgz b/openstreetmap.tgz
new file mode 100644 (file)
index 0000000..85da074
Binary files /dev/null and b/openstreetmap.tgz differ
diff --git a/openstreetmap/openstreetmap.php b/openstreetmap/openstreetmap.php
new file mode 100755 (executable)
index 0000000..d76414c
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+/**
+ * Name: Open Street Map
+ * Description: Use openstreetmap.org for displaying locations.
+ * Version: 1.0
+ * Author: Mike Macgirvin <http://macgirvin.com/profile/mike>
+ * 
+ *
+ */
+
+
+function openstreetmap_install() {
+
+       register_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
+
+       logger("installed openstreetmap");
+}
+
+
+function openstreetmap_uninstall() {
+
+       unregister_hook('render_location', 'addon/openstreetmap/openstreetmap.php', 'openstreetmap_location');
+
+       logger("removed openstreetmap");
+}
+
+
+
+function openstreetmap_location($a, &$item) {
+
+       $location = '';
+       $coord = '';
+
+       $location = (($item['location']) ? '<a target="map" title="' . $item['location'] . '" href="http://www.openstreetmap.org/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
+
+       if($item['coord']) {
+               $coords = explode(' ', $item['coord']);
+               if(count($coords) > 1) {
+                       $coord = '<a target="map" title="' . $item['coord'] . '" href="http://www.openstreetmap.org/?lat=' . urlencode($coords[0]) . '&lon=' . urlencode($coords[1]) . '&zoom=10">' . $item['coord'] . '</a>' ;
+               }
+       }
+       if(strlen($coord)) {
+               if($location)
+                       $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
+               else
+                       $location = '<span class="smalltext">' . $coord . '</span>';
+       }
+       $item['html'] = $location;
+       return;
+}
+
index 937c02d5eeefb1d4c669ce3fd41c7e4235b71af2..98b28a9dc2b10fc991cd80437d707bd1119242dd 100755 (executable)
Binary files a/randplace.tgz and b/randplace.tgz differ
index 35503850f7058134c9bb75e051c16e5ee224af92..df713766c8902f6970d93d34dd251cec4ee82fe1 100755 (executable)
@@ -136,7 +136,8 @@ function randplace_post_hook($a, &$item) {
 function randplace_settings_post($a,$post) {
        if(! local_user())
                return;
-       set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace']));
+       if($_POST['randplace-submit'])
+               set_pconfig(local_user(),'randplace','enable',intval($_POST['randplace']));
 }
 
 
@@ -175,6 +176,6 @@ function randplace_settings(&$a,&$s) {
 
        /* provide a submit button */
 
-       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
+       $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
 
 }