X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FMapstraction%2FMapstractionPlugin.php;h=c802fbfb917f2b3e00401708e68f6b3144892915;hb=f2bfcdc2c1d7bc4634bb06285380884a57075759;hp=c4ba6464eaa1077e5ca81b8e2fb65439d2f5d782;hpb=34f95c26fd9f51c730d05287d5b201a6cbedc285;p=quix0rs-gnu-social.git diff --git a/plugins/Mapstraction/MapstractionPlugin.php b/plugins/Mapstraction/MapstractionPlugin.php index c4ba6464ea..c802fbfb91 100644 --- a/plugins/Mapstraction/MapstractionPlugin.php +++ b/plugins/Mapstraction/MapstractionPlugin.php @@ -46,7 +46,7 @@ if (!defined('STATUSNET')) { */ class MapstractionPlugin extends Plugin { - const VERSION = STATUSNET_VERSION; + const VERSION = GNUSOCIAL_VERSION; /** provider name, one of: 'cloudmade', 'google', 'microsoft', 'openlayers', 'yahoo' */ @@ -63,40 +63,17 @@ class MapstractionPlugin extends Plugin * * @return boolean event handler return */ - function onRouterInitialized($m) + function onRouterInitialized(URLMapper $m) { $m->connect(':nickname/all/map', array('action' => 'allmap'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}')); + array('nickname' => Nickname::DISPLAY_FMT)); $m->connect(':nickname/map', array('action' => 'usermap'), - array('nickname' => '['.NICKNAME_FMT.']{1,64}')); + array('nickname' => Nickname::DISPLAY_FMT)); return true; } - /** - * Hook for autoloading classes - * - * This makes sure our classes get autoloaded from our directory - * - * @param string $cls name of class being used - * - * @return boolean event handler return - */ - function onAutoload($cls) - { - switch ($cls) - { - case 'AllmapAction': - case 'UsermapAction': - case 'MapAction': - include_once INSTALLDIR.'/plugins/Mapstraction/' . strtolower(mb_substr($cls, 0, -6)) . '.php'; - return false; - default: - return true; - } - } - /** * Hook for adding extra JavaScript * @@ -125,11 +102,11 @@ class MapstractionPlugin extends Plugin urlencode($this->apikey))); break; case 'microsoft': - $action->script('http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6'); + $action->script((StatusNet::isHTTPS()?'https':'http') + '://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6'); break; case 'openlayers': - // XXX: is this not nice...? - $action->script('http://openlayers.org/api/OpenLayers.js'); + // Use our included stripped & minified OpenLayers. + $action->script($this->path('OpenLayers/OpenLayers.js')); break; case 'yahoo': $action->script(sprintf('http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=%s', @@ -139,12 +116,10 @@ class MapstractionPlugin extends Plugin default: return true; } - $action->script(sprintf('%s?(%s)', - common_path('plugins/Mapstraction/js/mxn.js'), + $this->path('js/mxn.js'), $this->provider)); - - $action->script(common_path('plugins/Mapstraction/usermap.js')); + $action->script($this->path('usermap.js')); $action->inlineScript(sprintf('var _provider = "%s";', $this->provider)); @@ -156,14 +131,15 @@ class MapstractionPlugin extends Plugin ' var user = null; '. (($actionName == 'showstream') ? ' user = scrapeUser(); ' : '') . ' var notices = scrapeNotices(user); ' . - ' showMapstraction($("#map_canvas"), notices); '. + ' var canvas = $("#map_canvas")[0]; ' . + ' if (typeof(canvas) != "undefined") { showMapstraction(canvas, notices); } '. '});'); } return true; } - function onEndShowSections($action) + function onEndShowSections(Action $action) { $actionName = $action->trimmed('action'); // These are the ones that have maps on 'em @@ -175,6 +151,7 @@ class MapstractionPlugin extends Plugin $action->elementStart('div', array('id' => 'entity_map', 'class' => 'section')); + // TRANS: Header for Map widget that displays a map with geodata for notices. $action->element('h2', null, _m('Map')); $action->element('div', array('id' => 'map_canvas', @@ -187,18 +164,19 @@ class MapstractionPlugin extends Plugin $action->element('a', array('href' => $mapUrl), // TRANS: Clickable item to allow opening the map in full size. - _m("Full size")); + _m('Full size')); $action->elementEnd('div'); } - function onPluginVersion(&$versions) + function onPluginVersion(array &$versions) { $versions[] = array('name' => 'Mapstraction', 'version' => self::VERSION, 'author' => 'Evan Prodromou', 'homepage' => 'http://status.net/wiki/Plugin:Mapstraction', 'rawdescription' => + // TRANS: Plugin description. _m('Show maps of users\' and friends\' notices '. 'with Mapstraction.')); return true;