]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Mapstraction/MapstractionPlugin.php
Added missing position paramater
[quix0rs-gnu-social.git] / plugins / Mapstraction / MapstractionPlugin.php
index 37306a23ca0d9134a008d194a9d3f14d3af1e00a..868933fd432461a887c0697c1d1681a1ab6d4a6e 100644 (file)
@@ -47,6 +47,8 @@ if (!defined('STATUSNET')) {
 
 class MapstractionPlugin extends Plugin
 {
+    const VERSION = STATUSNET_VERSION;
+
     /** provider name, one of:
      'cloudmade', 'google', 'microsoft', 'openlayers', 'yahoo' */
     public $provider = 'openlayers';
@@ -90,6 +92,7 @@ class MapstractionPlugin extends Plugin
         {
         case 'AllmapAction':
         case 'UsermapAction':
+        case 'MapAction':
             include_once INSTALLDIR.'/plugins/Mapstraction/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
             return false;
         default:
@@ -111,6 +114,11 @@ class MapstractionPlugin extends Plugin
     {
         $actionName = $action->trimmed('action');
 
+        if (!in_array($actionName,
+                      array('showstream', 'all', 'usermap', 'allmap'))) {
+            return true;
+        }
+
         switch ($this->provider)
         {
         case 'cloudmade':
@@ -142,9 +150,19 @@ class MapstractionPlugin extends Plugin
 
         $action->script(common_path('plugins/Mapstraction/usermap.js'));
 
-        $action->elementStart('script', array('type' => 'text/javascript'));
-        $action->raw(sprintf('var _provider = "%s";', $this->provider));
-        $action->elementEnd('script');
+        $action->inlineScript(sprintf('var _provider = "%s";', $this->provider));
+
+        // usermap and allmap handle this themselves
+
+        if (in_array($actionName,
+                     array('showstream', 'all'))) {
+            $action->inlineScript('$(document).ready(function() { '.
+                                  ' var user = null; '.
+                                  (($actionName == 'showstream') ? ' user = scrapeUser(); ' : '') .
+                                  ' var notices = scrapeNotices(user); ' .
+                                  ' showMapstraction($("#map_canvas"), notices); '.
+                                  '});');
+        }
 
         return true;
     }
@@ -161,7 +179,7 @@ class MapstractionPlugin extends Plugin
         $action->elementStart('div', array('id' => 'entity_map',
                                          'class' => 'section'));
 
-        $action->element('h2', null, _('Map'));
+        $action->element('h2', null, _m('Map'));
 
         $action->element('div', array('id' => 'map_canvas',
                                     'class' => 'gray smallmap',
@@ -172,8 +190,21 @@ class MapstractionPlugin extends Plugin
                                     array('nickname' => $action->trimmed('nickname')));
 
         $action->element('a', array('href' => $mapUrl),
-                         _("Full size"));
+                         _m("Full size"));
 
         $action->elementEnd('div');
     }
+
+    function onPluginVersion(&$versions)
+    {
+        $versions[] = array('name' => 'Mapstraction',
+                            'version' => self::VERSION,
+                            'author' => 'Evan Prodromou',
+                            'homepage' => 'http://status.net/wiki/Plugin:Mapstraction',
+                            'rawdescription' =>
+                            _m('Show maps of users\' and friends\' notices '.
+                               'with <a href="http://www.mapstraction.com/">Mapstraction</a> '.
+                               'JavaScript library.'));
+        return true;
+    }
 }