update Piwik to version 2.16 (fixes #91)

This commit is contained in:
oliver 2016-04-10 18:55:57 +02:00
commit 47263617c5
60 changed files with 418860 additions and 226988 deletions

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -12,19 +12,34 @@ use Exception;
use Piwik\API\Request;
use Piwik\Common;
use Piwik\Config;
use Piwik\Container\StaticContainer;
use Piwik\Piwik;
use Piwik\Plugins\Goals\API as APIGoals;
use Piwik\Site;
use Piwik\Translation\Translator;
use Piwik\View;
require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php';
/**
*
*/
class Controller extends \Piwik\Plugin\Controller
{
// By default plot up to the last 30 days of visitors on the map, for low traffic sites
const REAL_TIME_WINDOW = 'last30';
/**
* @var Translator
*/
private $translator;
public function __construct(Translator $translator)
{
$this->translator = $translator;
parent::__construct();
}
public function visitorMap($fetch = false, $segmentOverride = false)
{
@ -63,18 +78,19 @@ class Controller extends \Piwik\Plugin\Controller
$view->defaultMetric = 'nb_visits';
// some translations
$view->localeJSON = Common::json_encode(array(
'nb_visits' => Piwik::translate('General_NVisits'),
'one_visit' => Piwik::translate('General_OneVisit'),
'no_visit' => Piwik::translate('UserCountryMap_NoVisit'),
'nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'),
'nb_actions_per_visit' => Piwik::translate('VisitsSummary_NbActionsPerVisit'),
'bounce_rate' => Piwik::translate('VisitsSummary_NbVisitsBounced'),
'avg_time_on_site' => Piwik::translate('VisitsSummary_AverageVisitDuration'),
'and_n_others' => Piwik::translate('UserCountryMap_AndNOthers'),
'no_data' => Piwik::translate('CoreHome_ThereIsNoDataForThisReport'),
'nb_uniq_visitors' => Piwik::translate('VisitsSummary_NbUniqueVisitors')
));
$view->localeJSON = json_encode(array(
'nb_visits' => $this->translator->translate('General_NVisits'),
'one_visit' => $this->translator->translate('General_OneVisit'),
'no_visit' => $this->translator->translate('UserCountryMap_NoVisit'),
'nb_actions' => $this->translator->translate('VisitsSummary_NbActionsDescription'),
'nb_actions_per_visit' => $this->translator->translate('VisitsSummary_NbActionsPerVisit'),
'bounce_rate' => $this->translator->translate('VisitsSummary_NbVisitsBounced'),
'avg_time_on_site' => $this->translator->translate('VisitsSummary_AverageVisitDuration'),
'and_n_others' => $this->translator->translate('UserCountryMap_AndNOthers'),
'no_data' => $this->translator->translate('CoreHome_ThereIsNoDataForThisReport'),
'nb_uniq_visitors' => $this->translator->translate('VisitsSummary_NbUniqueVisitors'),
'nb_users' => $this->translator->translate('VisitsSummary_NbUsers'),
));
$view->reqParamsJSON = $this->getEnrichedRequest($params = array(
'period' => $period,
@ -89,9 +105,28 @@ class Controller extends \Piwik\Plugin\Controller
$view->metrics = $config['metrics'] = $this->getMetrics($idSite, $period, $date, $token_auth);
$config['svgBasePath'] = 'plugins/UserCountryMap/svg/';
$config['mapCssPath'] = 'plugins/UserCountryMap/stylesheets/map.css';
$view->config = Common::json_encode($config);
$view->config = json_encode($config);
$view->noData = empty($config['visitsSummary']['nb_visits']);
$countriesByIso = array();
$regionDataProvider = StaticContainer::get('Piwik\Intl\Data\Provider\RegionDataProvider');
$countries = array_keys($regionDataProvider->getCountryList());
foreach ($countries AS $country) {
$countriesByIso[strtoupper($country)] = Piwik::translate('Intl_Country_'.strtoupper($country));
}
$view->countriesByIso = $countriesByIso;
$view->continents = array(
'AF' => \Piwik\Plugins\UserCountry\continentTranslate('afr'),
'AS' => \Piwik\Plugins\UserCountry\continentTranslate('asi'),
'EU' => \Piwik\Plugins\UserCountry\continentTranslate('eur'),
'NA' => \Piwik\Plugins\UserCountry\continentTranslate('amn'),
'OC' => \Piwik\Plugins\UserCountry\continentTranslate('oce'),
'SA' => \Piwik\Plugins\UserCountry\continentTranslate('ams')
);
return $view->render();
}
@ -135,19 +170,19 @@ class Controller extends \Piwik\Plugin\Controller
// some translations
$locale = array(
'nb_actions' => Piwik::translate('VisitsSummary_NbActionsDescription'),
'local_time' => Piwik::translate('VisitTime_ColumnLocalTime'),
'from' => Piwik::translate('General_FromReferrer'),
'seconds' => Piwik::translate('UserCountryMap_Seconds'),
'seconds_ago' => Piwik::translate('UserCountryMap_SecondsAgo'),
'minutes' => Piwik::translate('UserCountryMap_Minutes'),
'minutes_ago' => Piwik::translate('UserCountryMap_MinutesAgo'),
'hours' => Piwik::translate('UserCountryMap_Hours'),
'hours_ago' => Piwik::translate('UserCountryMap_HoursAgo'),
'days_ago' => Piwik::translate('UserCountryMap_DaysAgo'),
'actions' => Piwik::translate('VisitsSummary_NbPageviewsDescription'),
'searches' => Piwik::translate('UserCountryMap_Searches'),
'goal_conversions' => Piwik::translate('UserCountryMap_GoalConversions'),
'nb_actions' => $this->translator->translate('VisitsSummary_NbActionsDescription'),
'local_time' => $this->translator->translate('VisitTime_ColumnLocalTime'),
'from' => $this->translator->translate('General_FromReferrer'),
'seconds' => $this->translator->translate('Intl_Seconds'),
'seconds_ago' => $this->translator->translate('UserCountryMap_SecondsAgo'),
'minutes' => $this->translator->translate('Intl_Minutes'),
'minutes_ago' => $this->translator->translate('UserCountryMap_MinutesAgo'),
'hours' => $this->translator->translate('Intl_Hours'),
'hours_ago' => $this->translator->translate('UserCountryMap_HoursAgo'),
'days_ago' => $this->translator->translate('UserCountryMap_DaysAgo'),
'actions' => $this->translator->translate('VisitsSummary_NbPageviewsDescription'),
'searches' => $this->translator->translate('UserCountryMap_Searches'),
'goal_conversions' => $this->translator->translate('UserCountryMap_GoalConversions'),
);
$segment = $segmentOverride ? : Request::getRawSegmentFromRequest() ? : '';
@ -190,22 +225,27 @@ class Controller extends \Piwik\Plugin\Controller
$params['format'] = 'json';
$params['showRawMetrics'] = 1;
if (empty($params['segment'])) {
$segment = \Piwik\API\Request::getRawSegmentFromRequest();
$segment = Request::getRawSegmentFromRequest();
if (!empty($segment)) {
$params['segment'] = urldecode($segment);
$params['segment'] = $segment;
}
}
if ($encode) {
$params = Common::json_encode($params);
if (!empty($params['segment'])) {
$params['segment'] = urldecode($params['segment']);
}
if ($encode) {
$params = json_encode($params);
}
return $params;
}
private function checkUserCountryPluginEnabled()
{
if (!\Piwik\Plugin\Manager::getInstance()->isPluginActivated('UserCountry')) {
throw new Exception(Piwik::translate('General_Required', 'Plugin UserCountry'));
throw new Exception($this->translator->translate('General_Required', 'Plugin UserCountry'));
}
}
@ -220,16 +260,21 @@ class Controller extends \Piwik\Plugin\Controller
. '&token_auth=' . $token_auth
. '&filter_limit=-1'
);
$metaData = $request->process();
$metaData = unserialize($request->process());
$metrics = array();
foreach ($metaData[0]['metrics'] as $id => $val) {
if (Common::getRequestVar('period') == 'day' || $id != 'nb_uniq_visitors') {
$metrics[] = array($id, $val);
if (!empty($metaData[0]['metrics']) && is_array($metaData[0]['metrics'])) {
foreach ($metaData[0]['metrics'] as $id => $val) {
// todo: should use SettingsPiwik::isUniqueVisitorsEnabled ?
if (Common::getRequestVar('period') == 'day' || $id != 'nb_uniq_visitors') {
$metrics[] = array($id, $val);
}
}
}
foreach ($metaData[0]['processedMetrics'] as $id => $val) {
$metrics[] = array($id, $val);
if (!empty($metaData[0]['processedMetrics']) && is_array($metaData[0]['processedMetrics'])) {
foreach ($metaData[0]['processedMetrics'] as $id => $val) {
$metrics[] = array($id, $val);
}
}
return $metrics;
}

View file

@ -0,0 +1,24 @@
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\UserCountryMap;
use Piwik\Menu\MenuReporting;
use Piwik\Plugin\Manager as PluginManager;
class Menu extends \Piwik\Plugin\Menu
{
public function configureReportingMenu(MenuReporting $menu)
{
if (PluginManager::getInstance()->isPluginActivated('UserCountry')) {
$menu->addVisitorsItem('UserCountryMap_RealTimeMap',
$this->urlForAction('realtimeWorldMap'),
$order = 70);
}
}
}

View file

@ -1,6 +1,6 @@
<?php
/**
* Piwik - Open source web analytics
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
@ -9,66 +9,54 @@
namespace Piwik\Plugins\UserCountryMap;
use Piwik\FrontController;
use Piwik\Menu\MenuMain;
use Piwik\Piwik;
use Piwik\Version;
use Piwik\WidgetsList;
use Piwik\Plugin\Manager as PluginManager;
/**
*/
class UserCountryMap extends \Piwik\Plugin
{
/**
* @see Piwik\Plugin::getInformation
*/
public function getInformation()
{
return array(
'name' => 'User Country Map',
'description' => 'This plugin provides the widgets Visitor Map and Real-time Map. Note: Requires the UserCountry plugin enabled.',
'authors' => array(array('name' => 'Piwik', 'homepage' => 'http://piwik.org/')),
'version' => Version::VERSION,
'license' => 'GPL v3+',
'license_homepage' => 'http://www.gnu.org/licenses/gpl.html'
);
}
public function postLoad()
{
WidgetsList::add('General_Visitors', Piwik::translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
Piwik::addAction('Template.leftColumnUserCountry', array('Piwik\Plugins\UserCountryMap\UserCountryMap', 'insertMapInLocationReport'));
}
static public function insertMapInLocationReport(&$out)
public static function insertMapInLocationReport(&$out)
{
$out = '<h2>' . Piwik::translate('UserCountryMap_VisitorMap') . '</h2>';
$out .= FrontController::getInstance()->fetchDispatch('UserCountryMap', 'visitorMap');
}
public function getListHooksRegistered()
public function registerEvents()
{
$hooks = array(
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'Menu.Reporting.addItems' => 'addMenu'
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
'Platform.initialized' => array(
'after' => true,
'function' => 'registerWidgets'
)
);
return $hooks;
}
public function addMenu()
public function registerWidgets()
{
MenuMain::getInstance()->add('General_Visitors', 'UserCountryMap_RealTimeMap',
array('module' => 'UserCountryMap', 'action' => 'realtimeWorldMap'), true, $order = 70);
if (PluginManager::getInstance()->isPluginActivated('UserCountry')) {
WidgetsList::add('General_Visitors', Piwik::translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap');
WidgetsList::add('Live!', Piwik::translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap');
}
}
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = "libs/bower_components/visibilityjs/lib/visibility.core.js";
$jsFiles[] = "plugins/UserCountryMap/javascripts/vendor/raphael.min.js";
$jsFiles[] = "plugins/UserCountryMap/javascripts/vendor/jquery.qtip.min.js";
$jsFiles[] = "plugins/UserCountryMap/javascripts/vendor/kartograph.min.js";
$jsFiles[] = "plugins/UserCountryMap/javascripts/vendor/chroma.min.js";
$jsFiles[] = "libs/bower_components/chroma-js/chroma.min.js";
$jsFiles[] = "plugins/UserCountryMap/javascripts/visitor-map.js";
$jsFiles[] = "plugins/UserCountryMap/javascripts/realtime-map.js";
}
@ -78,4 +66,11 @@ class UserCountryMap extends \Piwik\Plugin
$stylesheets[] = "plugins/UserCountryMap/stylesheets/visitor-map.less";
$stylesheets[] = "plugins/UserCountryMap/stylesheets/realtime-map.less";
}
public function getClientSideTranslationKeys(&$translationKeys)
{
$translationKeys[] = 'UserCountryMap_WithUnknownRegion';
$translationKeys[] = 'UserCountryMap_WithUnknownCity';
$translationKeys[] = 'General_UserId';
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

After

Width:  |  Height:  |  Size: 1 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 296 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 270 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Before After
Before After

View file

@ -1,5 +1,5 @@
/*!
* Piwik - Web Analytics
* Piwik - free/libre analytics platform
*
* Real time visitors map
* Using Kartograph.js http://kartograph.org/
@ -51,17 +51,20 @@
$('.RealTimeMap_map', $element).attr('id', this.uniqueId);
// create the map
this.map = Kartograph.map('#' + this.uniqueId);
this.map = $K.map('#' + this.uniqueId);
$element.focus();
},
_initStandaloneMap: function () {
$('.top_controls').hide();
$('.Menu--dashboard').on('piwikSwitchPage', function (event, item) {
var clickedMenuIsNotMap = ($(item).attr('href').indexOf('module=UserCountryMap&action=realtimeWorldMap') == -1);
$('#periodString').hide();
initTopControls();
$('#secondNavBar').on('piwikSwitchPage', function (event, item) {
var href = $(item).attr('href');
var clickedMenuIsNotMap = !href || (href.indexOf('module=UserCountryMap&action=realtimeWorldMap') == -1);
if (clickedMenuIsNotMap) {
$('.top_controls').show();
$('#periodString').show();
initTopControls();
}
});
$('.realTimeMap_overlay').css('top', '0px');
@ -99,7 +102,7 @@
colorManager = piwik.ColorManager,
colors = colorManager.getColors('realtime-map', ['white-bg', 'white-fill', 'black-bg', 'black-fill', 'visit-stroke',
'website-referrer-color', 'direct-referrer-color', 'search-referrer-color',
'live-widget-highlight', 'live-widget-unhighlight', 'symbol-animate-fill']),
'live-widget-highlight', 'live-widget-unhighlight', 'symbol-animate-fill', 'region-stroke-color']),
currentTheme = 'white',
colorTheme = {
white: {
@ -142,7 +145,7 @@
'visitLocalTime', 'city', 'country', 'referrerType', 'referrerName',
'referrerTypeName', 'browserIcon', 'operatingSystemIcon',
'countryFlag', 'idVisit', 'actionDetails', 'continentCode',
'actions', 'searches', 'goalConversions', 'visitorId'].join(','),
'actions', 'searches', 'goalConversions', 'visitorId', 'userId'].join(','),
minTimestamp: firstRun ? -1 : lastTimestamp
});
}
@ -214,6 +217,8 @@
return '<h3>' + (r.city ? r.city + ' / ' : '') + r.country + '</h3>' +
// icons
ico(r.countryFlag) + ico(r.browserIcon) + ico(r.operatingSystemIcon) + '<br/>' +
// User ID
(r.userId ? _pk_translate('General_UserId') + ':&nbsp;' + r.userId + '<br/>' : '') +
// last action
(ad && ad.length && ad[ad.length - 1].pageTitle ? '<em>' + ad[ad.length - 1].pageTitle + '</em><br/>' : '') +
// time of visit
@ -357,7 +362,7 @@
*/
function gotNewReport(report) {
// if the map has been destroyed, do nothing
if (!self.map) {
if (!self.map || !self.$element.length || !$.contains(document, self.$element[0])) {
return;
}
@ -374,7 +379,7 @@
if (firstRun) { // if we run this the first time, we initialiize the map symbols
visitSymbols = map.addSymbols({
data: [],
type: Kartograph.Bubble,
type: $K.Bubble,
/*title: function(d) {
return visitRadius(d) > 15 && d.actions > 1 ? d.actions : '';
},
@ -476,6 +481,8 @@
if (firstRun && lastVisits.length) {
// zoom changed, use cached report data
gotNewReport(lastVisits.slice());
} else if (Visibility.hidden()) {
nextReqTimer = setTimeout(refreshVisits, config.liveRefreshAfterMs);
} else {
// request API for new data
$('.realTimeMap_overlay img').show();
@ -490,7 +497,7 @@
*/
function initMap() {
$('#widgetRealTimeMapliveMap .loadingPiwik, .RealTimeMap .loadingPiwik').hide();
map.addLayer('countries', {
map.addLayer(currentMap.length == 3 ? 'context' : 'countries', {
styles: {
fill: colorTheme[currentTheme].fill,
stroke: colorTheme[currentTheme].bg,
@ -498,7 +505,9 @@
},
click: function (d, p, evt) {
evt.stopPropagation();
if (currentMap != 'world') { // zoom out if zoomed in
if (currentMap.length == 2){ // zoom to country
updateMap(d.iso);
} else if (currentMap != 'world') { // zoom out if zoomed in
updateMap('world');
} else { // or zoom to continent view otherwise
updateMap(UserCountryMap.ISO3toCONT[d.iso]);
@ -509,7 +518,13 @@
return d.name;
}
});
if (currentMap.length == 3){
map.addLayer('regions', {
styles: {
stroke: colors['region-stroke-color']
}
});
}
var lastVisitId = -1,
lastReport = [];
refreshVisits(true);
@ -539,7 +554,7 @@
storeSettings();
}
updateMap(location.hash && (location.hash == '#world' || location.hash.match(/^#[A-Z][A-Z]$/)) ? location.hash.substr(1) : 'world'); // TODO: restore last state
updateMap(location.hash && (location.hash == '#world' || location.hash.match(/^#[A-Z]{2,3}$/)) ? location.hash.substr(1) : 'world'); // TODO: restore last state
// clicking on map background zooms out
$('.RealTimeMap_map', this.$element).off('click').click(function () {
@ -637,4 +652,4 @@
});
}());
}());

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,5 +1,5 @@
/*!
* Piwik - Web Analytics
* Piwik - free/libre analytics platform
*
* Visitors Map with zoom in continents / countries. Cities + Region view.
* Using Kartograph.js http://kartograph.org/
@ -77,7 +77,7 @@
}
var mapContainer = $$('.UserCountryMap_map').get(0),
map = self.map = Kartograph.map(mapContainer),
map = self.map = $K.map(mapContainer),
main = $$('.UserCountryMap_container'),
worldTotalVisits = 0,
width = main.width(),
@ -96,7 +96,9 @@
apiModule: module,
apiAction: action,
filter_limit: -1,
limit: -1
limit: -1,
format_metrics: 0,
showRawMetrics: 1
});
if (countryFilter) {
$.extend(params, {
@ -152,13 +154,21 @@
//
function formatValueForTooltips(data, metric, id) {
var val = data[metric] % 1 === 0 || Number(data[metric]) != data[metric] ? data[metric] : data[metric].toFixed(1),
v = _[metric].replace('%s', '<strong>' + val + '</strong>');
var val = data[metric] % 1 === 0 || Number(data[metric]) != data[metric] ? data[metric] : data[metric].toFixed(1);
if (metric == 'bounce_rate') {
val = NumberFormatter.formatPercent(val);
} else if (metric == 'avg_time_on_site') {
val = new Date(0, 0, 0, val / 3600, val % 3600 / 60, val % 60)
.toTimeString()
.replace(/.*(\d{2}:\d{2}:\d{2}).*/, "$1");
} else {
val = NumberFormatter.formatNumber(val);
}
var v = _[metric].replace('%s', '<strong>' + val + '</strong>');
if (val == 1 && metric == 'nb_visits') v = _.one_visit;
function avgTime(d) { return d['sum_visit_length'] / d['nb_visits']; }
if (metric.substr(0, 3) == 'nb_' && metric != 'nb_actions_per_visit') {
var total;
if (id.length == 3) total = UserCountryMap.countriesByIso[id][metric];
@ -187,7 +197,14 @@
function addLegendItem(val, first) {
var d = $('<div>'), r = $('<div>'), l = $('<div>'),
metric = $$('.userCountryMapSelectMetrics').val(),
v = formatNumber(Math.round(val)) + (metric == 'avg_time_on_site' ? first ? ' sec' : 's' : '');
v = formatNumber(Math.round(val));
if (metric == 'avg_time_on_site') {
v += first ? ' sec' : 's';
} else if (metric == 'bounce_rate') {
v += '%';
}
d.css({ width: 17, height: 17, float: 'left', background: colscale(val) });
l.css({ 'margin-left': 20, 'line-height': '20px', 'text-align': 'right' }).html(v);
r.css({ clear: 'both', height: 19 });
@ -195,7 +212,7 @@
$('.UserCountryMap-legend .content').append(r);
}
var stats, values = [], id = self.lastSelected, c;
var stats, values = [], id = self.lastSelected, c, showLegend;
$.each(rows, function (i, r) {
if (!$.isFunction(filter) || filter(r)) {
@ -205,12 +222,15 @@
});
stats = minmax(values);
showLegend = values.length > 0;
if (stats.min == stats.max) {
colscale = function () { return chroma.hex(oneCountryColor); };
if (choropleth) {
$('.UserCountryMap-legend .content').html('').show();
addLegendItem(stats.min, true);
if (showLegend) {
addLegendItem(stats.min, true);
}
}
return colscale;
}
@ -231,7 +251,7 @@
}
// a good place to update the legend, isn't it?
if (choropleth) {
if (choropleth && showLegend) {
$('.UserCountryMap-legend .content').html('').show();
var itemExists = {};
$.each(chroma.limits(values, 'k', 3), function (i, v) {
@ -247,10 +267,11 @@
return colscale;
}
function formatPercentage(val) {
if (val < 0.001) return '< 0.1%';
return Math.round(1000 * val) / 10 + '%';
if (val < 0.001) {
return '< ' + NumberFormatter.formatPercent(0.1);
}
return NumberFormatter.formatPercent(Math.round(1000 * val) / 10);
}
/*
@ -334,7 +355,6 @@
$('.UserCountryMap-tooltip').hide();
}
/*
* updateState, called whenever the view changes
*/
@ -520,7 +540,14 @@
return UserCountryMap.countriesByIso[pd.iso] === undefined;
},
tooltips: function (pd) {
return '<h3>' + pd.name + '</h3>' + _.no_visit;
var countryName = pd.name;
for (var iso in self.config.countryNames) {
if (UserCountryMap.ISO2toISO3[iso.toUpperCase()] == pd.iso) {
countryName = self.config.countryNames[iso];
break;
}
}
return '<h3>' + countryName + '</h3>' + _.no_visit;
}
});
@ -561,7 +588,6 @@
});
}
/*
* updateMap is called by renderCountryMap() and renderWorldMap()
*/
@ -595,10 +621,6 @@
function quantify(d, metric) {
if (!metric) metric = $$('.userCountryMapSelectMetrics').val();
switch (metric) {
case 'avg_time_on_site':
return d.sum_visit_length / d.nb_visits;
case 'bounce_rate':
return d.bounce_count / d.nb_visits;
default:
return d[metric];
}
@ -637,7 +659,7 @@
$.each(groups, function (g_id, group) {
var apv = group.nb_actions / group.nb_visits,
ats = group.sum_visit_length / group.nb_visits,
br = (group.bounce_count * 100 / group.bounce_count);
br = group.bounce_count / group.nb_visits;
group['nb_actions_per_visit'] = apv;
group['avg_time_on_site'] = new Date(0, 0, 0, ats / 3600, ats % 3600 / 60, ats % 60).toLocaleTimeString();
group['bounce_rate'] = (br % 1 !== 0 ? br.toFixed(1) : br) + "%";
@ -646,7 +668,7 @@
return groupBy ? groups : groups.X;
}
function displayUnlocatableCount(unlocated, total) {
function displayUnlocatableCount(unlocated, total, regionOrCity) {
$('.unlocated-stats').html(
$('.unlocated-stats').data('tpl')
.replace('%s', unlocated)
@ -654,6 +676,21 @@
.replace('%c', UserCountryMap.countriesByIso[self.lastSelected].name)
);
$('.UserCountryMap-info-btn').show();
var zoomTitle = '';
if (regionOrCity == 'region') {
zoomTitle = ' ' + _pk_translate('UserCountryMap_WithUnknownRegion', [unlocated]);
} else if (regionOrCity == 'city') {
zoomTitle = ' ' + _pk_translate('UserCountryMap_WithUnknownCity', [unlocated]);
}
if (unlocated && zoomTitle) {
if ($('.map-stats .unlocatableCount').length) {
$('.map-stats .unlocatableCount').html(zoomTitle);
} else {
$('.map-stats').append('<small class="unlocatableCount">' + zoomTitle + '</small>');
}
}
}
/*
@ -677,6 +714,7 @@
// load data from Piwik API
ajax(_reportParams('UserCountry', 'getRegion', UserCountryMap.countriesByIso[iso].iso2))
.done(function (data) {
convertBounceRatesToPercents(data);
loadingComplete();
@ -727,7 +765,7 @@
$.each(regionDict, function (key, region) {
if (regionExistsInMap(key)) unlocated -= region.nb_visits;
});
displayUnlocatableCount(unlocated, totalCountryVisits);
displayUnlocatableCount(unlocated, totalCountryVisits, 'region');
// create color scale
colscale = getColorScale(regionDict, 'curMetric', null, true);
@ -799,13 +837,15 @@
*/
function updateCitySymbols() {
// color regions in white as background for symbols
if (map.getLayer('regions')) map.getLayer('regions').style('fill', invisibleRegionBackgroundColor);
var layerName = self.mode != "region" ? "regions2" : "regions";
if (map.getLayer(layerName)) map.getLayer(layerName).style('fill', invisibleRegionBackgroundColor);
indicateLoading();
// get visits per city from API
ajax(_reportParams('UserCountry', 'getCity', UserCountryMap.countriesByIso[iso].iso2))
.done(function (data) {
convertBounceRatesToPercents(data);
loadingComplete();
@ -823,7 +863,7 @@
}));
});
displayUnlocatableCount(unlocated, totalCountryVisits);
displayUnlocatableCount(unlocated, totalCountryVisits, 'city');
// sort by current metric
cities.sort(function (a, b) { return b.curMetric - a.curMetric; });
@ -854,7 +894,7 @@
var is_rate = metric.substr(0, 3) != 'nb_' || metric == 'nb_actions_per_visit';
var citySymbols = map.addSymbols({
type: Kartograph.LabeledBubble,
type: $K.LabeledBubble,
data: cities,
clustering: 'noverlap',
clusteringOpts: {
@ -942,7 +982,6 @@
});
}
_updateMap(iso + '.svg', function () {
// add background
@ -1099,6 +1138,8 @@
// now load the metrics for all countries
ajax(_reportParams('UserCountry', 'getCountry'))
.done(function (report) {
convertBounceRatesToPercents(report);
var metrics = $$('.userCountryMapSelectMetrics option');
var countryData = [], countrySelect = $$('.userCountryMapSelectCountry'),
countriesByIso = {};
@ -1148,7 +1189,9 @@
// populate country select
$.each(countryData, function (i, country) {
countrySelect.append('<option value="' + country.iso + '">' + country.name + '</option>');
if (!!country.iso) {
countrySelect.append('<option value="' + country.iso + '">' + country.name + '</option>');
}
});
initUserInterface();
@ -1198,20 +1241,33 @@
$$('.widgetUserCountryMapvisitorMap .widgetName span').remove();
$$('.widgetUserCountryMapvisitorMap .widgetName').append('<span class="map-title"></span>');
// converts bounce rate quotients to numeric percents, eg, .12 => 12
function convertBounceRatesToPercents(report) {
$.each(report.reportData, function (i, row) {
if (row['bounce_rate']) {
row['bounce_rate'] = parseFloat(row['bounce_rate']) * 100;
}
});
}
},
/*
* resizes the map
*/
resize: function () {
var ratio, w, h,
map = this.map,
maxHeight = $(window).height() - (this.theWidget && this.theWidget.isMaximised ? 150 : 79);
map = this.map;
ratio = map.viewAB.width / map.viewAB.height;
w = map.container.width();
h = w / ratio;
h = Math.min(maxHeight, h);
// special handling for widgetize mode
if (!this.theWidget && map.container.parents('.widget').length) {
var maxHeight = $(window).height() - ($('html').height() - map.container.height());
h = Math.min(maxHeight, h);
}
map.container.height(h - 2);
map.resize(w, h);
@ -1231,7 +1287,6 @@
}());
/*
* Some static data used both by VisitorMap and RealtimeMap
*/

View file

@ -0,0 +1,5 @@
{
"UserCountryMap": {
"map": "خريطة"
}
}

View file

@ -0,0 +1,5 @@
{
"UserCountryMap": {
"map": "карта"
}
}

View file

@ -0,0 +1,22 @@
{
"UserCountryMap": {
"AndNOthers": "и %s други",
"Cities": "Градове",
"Countries": "Държави",
"DaysAgo": "преди %s дни",
"GoalConversions": "%s достигнати цели",
"HoursAgo": "преди %s часа",
"map": "карта",
"MinutesAgo": "преди %s минути",
"None": "Няма",
"NoVisit": "Няма посещения",
"RealTimeMap": "Карта на посетителите в реално време",
"Regions": "Региони",
"Searches": "%s търсения",
"SecondsAgo": "преди %s секунди",
"ShowingVisits": "Последни посещения базирани на географско местоположение",
"Unlocated": "<b>%s<\/b> %p посещения от %c вашето местоположение не може да бъде открито.",
"VisitorMap": "Карта на посетителите",
"WorldWide": "По целия свят"
}
}

View file

@ -0,0 +1,5 @@
{
"UserCountryMap": {
"map": "mapa"
}
}

View file

@ -0,0 +1,25 @@
{
"UserCountryMap": {
"PluginDescription": "Tento modul poskytuje widgety Mapa návštěvníků a Real-time Mapa. Poznámka: Vyžaduje povolený UserCountry plugin.",
"AndNOthers": "a %s dalších",
"Cities": "Města",
"Countries": "Země",
"DaysAgo": "před %s dny",
"GoalConversions": "%s konverzí cíle",
"HoursAgo": "před %s hodinami",
"map": "mapa",
"MinutesAgo": "před %s minutami",
"None": "Žádní",
"NoVisit": "Žádná návštěva",
"RealTimeMap": "Mapa v reálném čase",
"Regions": "Regiony",
"Searches": "%s vyhledávání",
"SecondsAgo": "před %s sekundami",
"ShowingVisits": "Geolokované návštěvy posledních",
"Unlocated": "<b>%s<\/b> %p z návštěv z %c nebylo možné geolokovat.",
"VisitorMap": "Mapa návštěvníků",
"WorldWide": "Celosvětová",
"WithUnknownRegion": "%s s neznámým regionem",
"WithUnknownCity": "%s s neznámým městem"
}
}

View file

@ -0,0 +1,24 @@
{
"UserCountryMap": {
"AndNOthers": "og %s andre",
"Cities": "Byer",
"Countries": "Lande",
"DaysAgo": "%s dage siden",
"GoalConversions": "%s målkonverteringer",
"HoursAgo": "%s timer siden",
"map": "kort",
"MinutesAgo": "%s minutter siden",
"None": "Ingen",
"NoVisit": "Ingen besøg",
"RealTimeMap": "Tidstro kort",
"Regions": "Regioner",
"Searches": "%s søgninger",
"SecondsAgo": "%s sekunder siden",
"ShowingVisits": "Geografisk placeret besøg af sidste",
"Unlocated": "<b>%s<\/b> besøg %p fra %c kunne ikke placeres geografisk.",
"VisitorMap": "Besøgerkort",
"WorldWide": "Hele verden",
"WithUnknownRegion": "%s med ukendt region",
"WithUnknownCity": "%s med ukendt by"
}
}

View file

@ -0,0 +1,25 @@
{
"UserCountryMap": {
"PluginDescription": "Dieses Plugin stellt die Widgets Besucherkarte sowie Besucherkarte in Echtzeit bereit. Hinweis: Das Plugin UserCountry muss aktiviert sein.",
"AndNOthers": "und %s andere",
"Cities": "Städte",
"Countries": "Länder",
"DaysAgo": "vor %s Tagen",
"GoalConversions": "%s Ziel-Konversionen",
"HoursAgo": "vor %s Stunden",
"map": "Karte",
"MinutesAgo": "vor %s Minuten",
"None": "Keine",
"NoVisit": "Keine Besuche",
"RealTimeMap": "Besucherkarte in Echtzeit",
"Regions": "Regionen",
"Searches": "%s Suchen",
"SecondsAgo": "vor %s Sekunden",
"ShowingVisits": "Lokalisierte Besuche der letzten",
"Unlocated": "<b>%s<\/b> %p der Besuche von %c konnten nicht lokalisiert werden.",
"VisitorMap": "Besucherkarte",
"WorldWide": "Weltweit",
"WithUnknownRegion": "%s mit unbekannter Region",
"WithUnknownCity": "%s mit unbekannter Stadt"
}
}

View file

@ -0,0 +1,25 @@
{
"UserCountryMap": {
"PluginDescription": "Το πρόσθετο αυτό παρέχει το γραφικό συστατικό Χάρτης Επισκεπτών και τον Χάρτη Σε Πραγματικό Χρόνο. Σημείωση: Απαιτεί να είναι ενεργοποιημένο το πρόσθετο UserCountry.",
"AndNOthers": "και %s άλλοι",
"Cities": "Πόλεις",
"Countries": "Χώρες",
"DaysAgo": "πριν %s ημέρες",
"GoalConversions": "%s μετατροπές στόχων",
"HoursAgo": "πριν %s ώρες",
"map": "χάρτης",
"MinutesAgo": "πριν %s λεπτά",
"None": "Κανένα",
"NoVisit": "Δεν υπάρχουν επισκέψεις",
"RealTimeMap": "Χάρτης σε πραγματικό χρόνο",
"Regions": "Περιοχές",
"Searches": "%s αναζητήσεις",
"SecondsAgo": "πριν %s δευτερόλεπτα",
"ShowingVisits": "Επισκέψεις με γεωτοποθεσία στα τελευταία",
"Unlocated": "<b>%s<\/b> %p από τις επισκέψεις από %c δεν ήταν δυνατόν να χαρακτηριστούν με γεωτοποθεσία.",
"VisitorMap": "Χάρτης Επισκεπτών",
"WorldWide": "Παγκοσμίως",
"WithUnknownRegion": "%s με άγνωστη περιοχή",
"WithUnknownCity": "%s με άγνωστη πόλη"
}
}

View file

@ -0,0 +1,25 @@
{
"UserCountryMap": {
"PluginDescription": "This plugin provides the widgets Visitor Map and Real-time Map. Note: Requires the UserCountry plugin enabled.",
"AndNOthers": "and %s others",
"Cities": "Cities",
"Countries": "Countries",
"DaysAgo": "%s days ago",
"GoalConversions": "%s goal conversions",
"HoursAgo": "%s hours ago",
"map": "map",
"MinutesAgo": "%s minutes ago",
"None": "None",
"NoVisit": "No visit",
"RealTimeMap": "Real-time Map",
"Regions": "Regions",
"Searches": "%s searches",
"SecondsAgo": "%s seconds ago",
"ShowingVisits": "Geo-located visits of last",
"Unlocated": "<b>%s<\/b> %p of the visits from %c couldn't be geo located.",
"VisitorMap": "Visitor Map",
"WorldWide": "World-Wide",
"WithUnknownRegion": "%s with unknown region",
"WithUnknownCity": "%s with unknown city"
}
}

View file

@ -0,0 +1,25 @@
{
"UserCountryMap": {
"PluginDescription": "Este complemento suministra los reproductores Mapa de visitante y Mapa tiempo-real. Nota: Requiere el complemento UserCountry habilitado.",
"AndNOthers": "y %s otros",
"Cities": "Ciudades",
"Countries": "Países",
"DaysAgo": "%s días atrás",
"GoalConversions": "%s conversiones de objetivo",
"HoursAgo": "%s horas atrás",
"map": "mapa",
"MinutesAgo": "Hace %s minutos",
"None": "Ninguno",
"NoVisit": "Sin visitas",
"RealTimeMap": "Mapa en Tiempo real",
"Regions": "Regiones",
"Searches": "%s búsquedas",
"SecondsAgo": "Hace %s segundos",
"ShowingVisits": "Visitas geolocalizadas desde la última vez",
"Unlocated": "<b>%s<\/b> %p de las visitas desde %c no pudieron ser geolocalizadas.",
"VisitorMap": "Mapa de visitantes",
"WorldWide": "Global",
"WithUnknownRegion": "%s con región desconocida",
"WithUnknownCity": "%s con ciudad desconocida"
}
}

Some files were not shown because too many files have changed in this diff Show more