diff options
-rw-r--r-- | plugins/UserCountryMap/PiwikMap.swf | bin | 0 -> 225897 bytes | |||
-rw-r--r-- | plugins/UserCountryMap/UserCountryMap.php | 118 | ||||
-rw-r--r-- | plugins/UserCountryMap/lang/de.php | 17 | ||||
-rw-r--r-- | plugins/UserCountryMap/lang/en.php | 17 | ||||
-rw-r--r-- | plugins/UserCountryMap/lang/es.php | 16 | ||||
-rw-r--r-- | plugins/UserCountryMap/lang/fr.php | 16 | ||||
-rw-r--r-- | plugins/UserCountryMap/lang/it.php | 16 | ||||
-rw-r--r-- | plugins/UserCountryMap/lang/ru.php | 16 | ||||
-rw-r--r-- | plugins/UserCountryMap/templates/exportImage.tpl | 9 | ||||
-rw-r--r-- | plugins/UserCountryMap/templates/worldmap.tpl | 93 |
10 files changed, 318 insertions, 0 deletions
diff --git a/plugins/UserCountryMap/PiwikMap.swf b/plugins/UserCountryMap/PiwikMap.swf Binary files differnew file mode 100644 index 0000000000..654ddf6d1c --- /dev/null +++ b/plugins/UserCountryMap/PiwikMap.swf diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php new file mode 100644 index 0000000000..315a4c68f4 --- /dev/null +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -0,0 +1,118 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: UserCountryMap.php 1665 2010-07-25 21:25:57Z gka $ + * + * @category Piwik_Plugins + * @package Piwik_UserCountryMap + */ + +/** + * + * @package Piwik_UserCountryMap + */ +class Piwik_UserCountryMap extends Piwik_Plugin +{ + public function getInformation() + { + return array( + 'name' => 'User Country Map', + 'description' => 'This plugin shows a zoomable world map of your visitors location.', + 'author' => 'Gregor Aisch', + 'author_homepage' => 'http://vis4.net/', + 'version' => '0.7', + 'translationAvailable' => true, + ); + } + + function postLoad() + { + // we register the widgets so they appear in the "Add a new widget" window in the dashboard + // Note that the first two parameters can be either a normal string, or an index to a translation string + Piwik_AddWidget('General_Visitors', Piwik_Translate('UserCountry_WidgetCountries').' ('.Piwik_Translate('UserCountryMap_worldMap').')', 'UserCountryMap', 'worldMap'); + + } +} + +/** + * + * @package Piwik_ExamplePlugin + */ +class Piwik_UserCountryMap_Controller extends Piwik_Controller +{ + + + /** + * See the result on piwik/?module=ExamplePlugin&action=exampleWidget + * or in the dashboard > Add a new widget + * + */ + function worldMap() + { + + + $view = Piwik_View::factory('worldmap'); + + $view->dataUrl = "?module=API" + . "&method=API.getProcessedReport&format=XML" + . "&apiModule=UserCountry&apiAction=getCountry" + . "&idSite=" . Piwik_Common::getRequestVar('idSite', 1, 'int') + . "&period=" . Piwik_Common::getRequestVar('period') + . "&date=" . Piwik_Common::getRequestVar('date') + . "&token_auth=" . Piwik::getCurrentUserTokenAuth() + . "&filter_limit=-1"; + + // definition of the color scale + $view->hueMin = 218; + $view->hueMax = 216; + $view->satMin = "0.22"; + $view->satMax = "0.9"; + $view->lgtMin = ".97"; + $view->lgtMax = ".4"; + + $request = new Piwik_API_Request( + 'method=API.getMetadata&format=PHP' + . '&apiModule=UserCountry&apiAction=getCountry' + . '&idSite=' . Piwik_Common::getRequestVar('idSite', 1, 'int') + . '&period=' . Piwik_Common::getRequestVar('period') + . '&date=' . Piwik_Common::getRequestVar('date') + . '&token_auth=' . Piwik::getCurrentUserTokenAuth() + . '&filter_limit=-1' + ); + $metaData = $request->process(); + + $metrics = array(); + foreach ($metaData[0]['metrics'] as $id => $val) $metrics[] = array($id, $val); + foreach ($metaData[0]['processedMetrics'] as $id => $val) $metrics[] = array($id, $val); + + $view->metrics = $metrics; + + $view->defaultMetric = 'nb_visits'; + + echo $view->render(); + + } + + /* + * + */ + function exportImage() + { + $view = Piwik_View::factory('exportImage'); + $view->imageData = 'data:image/png;base64,'.$_POST['imageData']; + echo $view->render(); + + } + + function outputImage() + { + header('Content-Type: image/png'); + echo base64_decode($_POST['imagedata']); + exit; + } + + +} diff --git a/plugins/UserCountryMap/lang/de.php b/plugins/UserCountryMap/lang/de.php new file mode 100644 index 0000000000..5757271e4a --- /dev/null +++ b/plugins/UserCountryMap/lang/de.php @@ -0,0 +1,17 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: en.php 1495 2009-10-12 13:54:46Z vipsoft $ + * + * @category Piwik_Plugins + * @package UserCountryMap + */ + +$translations = array( + 'UserCountryMap_map' => 'Karte', + 'UserCountryMap_worldMap' => 'Weltkarte', + 'UserCountryMap_toggleFullscreen' => 'Vollbildmodus umschalten' +); diff --git a/plugins/UserCountryMap/lang/en.php b/plugins/UserCountryMap/lang/en.php new file mode 100644 index 0000000000..9e6460c804 --- /dev/null +++ b/plugins/UserCountryMap/lang/en.php @@ -0,0 +1,17 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: en.php 1495 2009-10-12 13:54:46Z vipsoft $ + * + * @category Piwik_Plugins + * @package UserCountryMap + */ + +$translations = array( + 'UserCountryMap_map' => 'map', + 'UserCountryMap_worldMap' => 'world map', + 'UserCountryMap_toggleFullscreen' => 'Toggle fullscreen' +); diff --git a/plugins/UserCountryMap/lang/es.php b/plugins/UserCountryMap/lang/es.php new file mode 100644 index 0000000000..bbb1bf930b --- /dev/null +++ b/plugins/UserCountryMap/lang/es.php @@ -0,0 +1,16 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: en.php 1495 2009-10-12 13:54:46Z vipsoft $ + * + * @category Piwik_Plugins + * @package UserCountryMap + */ + +$translations = array( + 'UserCountryMap_map' => 'mapa', + 'UserCountryMap_worldMap' => 'mapamundi' +); diff --git a/plugins/UserCountryMap/lang/fr.php b/plugins/UserCountryMap/lang/fr.php new file mode 100644 index 0000000000..40d27eda93 --- /dev/null +++ b/plugins/UserCountryMap/lang/fr.php @@ -0,0 +1,16 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: en.php 1495 2009-10-12 13:54:46Z vipsoft $ + * + * @category Piwik_Plugins + * @package UserCountryMap + */ + +$translations = array( + 'UserCountryMap_map' => 'carte', + 'UserCountryMap_worldMap' => 'mappemonde' +); diff --git a/plugins/UserCountryMap/lang/it.php b/plugins/UserCountryMap/lang/it.php new file mode 100644 index 0000000000..474996f4a8 --- /dev/null +++ b/plugins/UserCountryMap/lang/it.php @@ -0,0 +1,16 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: en.php 1495 2009-10-12 13:54:46Z vipsoft $ + * + * @category Piwik_Plugins + * @package UserCountryMap + */ + +$translations = array( + 'UserCountryMap_map' => 'mappa', + 'UserCountryMap_worldMap' => 'mappamondo' +); diff --git a/plugins/UserCountryMap/lang/ru.php b/plugins/UserCountryMap/lang/ru.php new file mode 100644 index 0000000000..2343df5db2 --- /dev/null +++ b/plugins/UserCountryMap/lang/ru.php @@ -0,0 +1,16 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html Gpl v3 or later + * @version $Id: en.php 1495 2009-10-12 13:54:46Z vipsoft $ + * + * @category Piwik_Plugins + * @package UserCountryMap + */ + +$translations = array( + 'UserCountryMap_map' => 'mappa', + 'UserCountryMap_worldMap' => 'карта мира' +); diff --git a/plugins/UserCountryMap/templates/exportImage.tpl b/plugins/UserCountryMap/templates/exportImage.tpl new file mode 100644 index 0000000000..e325373a95 --- /dev/null +++ b/plugins/UserCountryMap/templates/exportImage.tpl @@ -0,0 +1,9 @@ +<html>
+ <head>
+ <title>{'General_ExportAsImage_js'|translate}</title>
+ </head>
+ <body>
+ <img src="{$imageData}" />
+ <p>{'General_SaveImageOnYourComputer_js'|translate}</p>
+ </body>
+</html>
\ No newline at end of file diff --git a/plugins/UserCountryMap/templates/worldmap.tpl b/plugins/UserCountryMap/templates/worldmap.tpl new file mode 100644 index 0000000000..670d271d8c --- /dev/null +++ b/plugins/UserCountryMap/templates/worldmap.tpl @@ -0,0 +1,93 @@ +
+
+<script type="text/javascript">
+
+{literal}
+
+$(document).ready(function() {
+ var fv = {};
+
+ var params = {
+ menu: "false",
+ scale: "noScale",
+ allowFullscreen: "true",
+ allowScriptAccess: "always",
+ allowNetworking: "true",
+ wmode: "opaque",
+ bgcolor: "#FFFFFF"
+ };
+
+{/literal}
+
+ $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
+ if ($.browser.chrome) $.browser.safari = false;
+
+ fv.dataUrl = encodeURIComponent("{$dataUrl}");
+ fv.hueMin = {$hueMin};
+ fv.hueMax = {$hueMax};
+ fv.satMin = {$satMin};
+ fv.satMax = {$satMax};
+ fv.lgtMin = {$lgtMin};
+ fv.lgtMax = {$lgtMax};
+ fv.iconOffset = $('#userCountryMapSelectMetrics').width()+13+($.browser.safari ? 22 : 0);
+ fv.defaultMetric = "{$defaultMetric}";
+
+ fv.txtLoading = encodeURIComponent("{'General_Loading_js'|translate}");
+ fv.txtLoadingData = encodeURIComponent("{'General_LoadingData'|translate}");
+ fv.txtToggleFullscreen = encodeURIComponent("{'UserCountryMap_toggleFullscreen'|translate}");
+ fv.txtExportImage = encodeURIComponent("{'General_ExportAsImage_js'|translate}");
+
+{literal}
+
+ var attr = { id:"UserCountryMap" };
+ swfobject.embedSWF("plugins/UserCountryMap/PiwikMap.swf", "UserCountryMap_map", "100%", "300",
+ "9.0.0", "libs/swfobject/expressInstall.swf", fv, params, attr);
+
+ $("#userCountryMapSelectMetrics").change(function(el) {
+ $("#UserCountryMap")[0].changeMode(el.currentTarget.value);
+ });
+
+ $(".userCountryMapFooterIcons a.tableIcon[var=fullscreen]").click(function() {
+ $("#UserCountryMap")[0].setFullscreenMode();
+ });
+
+ $(".userCountryMapFooterIcons a.tableIcon[var=export_png]").click(function() {
+ $("#UserCountryMap")[0].exportPNG();
+ });
+
+ $(window).resize(function() {
+ $("#UserCountryMap")[0].height = Math.round($('#UserCountryMap').width() *.55);
+ $("#UserCountryMap")[0].setIconOffset($('#userCountryMapSelectMetrics').width()+13+($.browser.safari ? 22 : 0));
+ });
+
+ $("#UserCountryMap")[0].height = Math.round($('#widgetUserCountryMapworldMap').width() *.55);
+ $("#UserCountryMap")[0].setIconOffset($('#userCountryMapSelectMetrics').width()+13);
+});
+
+{/literal}
+
+</script>
+<div id="UserCountryMap_content" style="position:relative; overflow:hidden;">
+ <div id="UserCountryMap_map">{'General_RequiresFlash'|translate}</div>
+ <div style="height:3px"></div>
+ <select id="userCountryMapSelectMetrics" style="height: 19px; font-size: 10px; position:absolute; left: 5px; bottom: 7px;">
+ {foreach from=$metrics item=metric}
+ <option value="{$metric[0]}" {if $metric[0] == $defaultMetric}selected="selected"{/if}>{$metric[1]}</option>
+ {/foreach}
+ </select>
+<!--<div class="dataTableFooterIcons userCountryMapFooterIcons">
+ <div class="dataTableFooterWrap" var="table">
+ <div class="tableIconsGroup">
+ <select id="userCountryMapSelectMetrics" style="height: 19px; font-size: 10px;">
+ {foreach from=$metrics item=metric}
+ <option value="{$metric[0]}" {if $metric[0] == $defaultMetric}selected="selected"{/if}>{$metric[1]}</option>
+ {/foreach}
+ </select>
+ </div>
+ <div class="tableIconsGroup">
+ <span class="exportToFormatIcons"><a class="tableIcon" var="export_png"><img src="themes/default/images/image.png" title="{'General_ExportAsImage_js'|translate}" height="16" width="16"></a></span>
+ </div>
+ </div>
+
+</div>-->
+</div>
\ No newline at end of file |