diff --git a/config/global.ini.php b/config/global.ini.php index f5caf0c81605ca668e701fa5959a1ea847320830..697b918407397645a4184dc75df6ee2cf0473f9c 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -311,6 +311,10 @@ api_service_url = http://api.piwik.org ; eg. $period=range&date=previous10 becomes $period=day&date=previous10. Use this setting to override the $period value. graphs_default_period_to_plot_when_period_range = day +; The Insight plugin shows the Top X following pages, Top X downloads and Top X outlinks which followed +; a view of the current page. The value X can be set here. +insight_limit = 300 + [Tracker] ; Piwik uses first party cookies by default. If set to 1, ; the visit ID cookie will be set on the Piwik server domain as well diff --git a/lang/en.php b/lang/en.php index 04c8318f1217b22fa041c0756988fcc3e57900a6..558b87b6ef24755d5f61f63d17289e369b077f5d 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1809,5 +1809,9 @@ And thank you for using Piwik!', 'Insight_MainMetrics' => 'Main metrics', 'Insight_NoData' => 'There is no data for this page during the selected period.', 'Insight_OpenFullScreen' => 'Go full screen', - 'Insight_CloseFullScreen' => 'Close full screen' + 'Insight_CloseFullScreen' => 'Close full screen', + 'Insight_OneClick' => '1 click', + 'Insight_Clicks' => '%s clicks', + 'Insight_ClicksFromXLinks' => '%1$s clicks from one of %2$s links', + 'Insight_Link' => 'Link' ); diff --git a/plugins/Insight/API.php b/plugins/Insight/API.php index 1c904a2516f7fb98ac98efd17a89634893ebabf2..eb2c9eb5d7014554cf7358e626295af244e1e352 100644 --- a/plugins/Insight/API.php +++ b/plugins/Insight/API.php @@ -35,7 +35,12 @@ class Piwik_Insight_API { $this->authenticate($idSite); - $translations = array(); + $translations = array( + 'oneClick' => 'Insight_OneClick', + 'clicks' => 'Insight_Clicks', + 'clicksFromXLinks' => 'Insight_ClicksFromXLinks', + 'link' => 'Insight_Link' + ); return array_map('Piwik_Translate', $translations); } @@ -66,9 +71,9 @@ class Piwik_Insight_API try { - // TODO find a good value for $limitBeforeGrouping - add config option? + $limitBeforeGrouping = Piwik_Config::getInstance()->General['insight_limit']; $transitionsReport = Piwik_Transitions_API::getInstance()->getTransitionsForAction( - $url, $type = 'url', $idSite, $period, $date, $segment, $limitBeforeGrouping = 100, + $url, $type = 'url', $idSite, $period, $date, $segment, $limitBeforeGrouping, $part = 'followingActions', $returnNormalizedUrls = true); } catch(Exception $e) diff --git a/plugins/Insight/client/followingpages.js b/plugins/Insight/client/followingpages.js index d85d985f07a02eacf869f948b9c574ad1937b2f5..5373bf274b8b133f98654f9ddda6cadb7e734ca1 100644 --- a/plugins/Insight/client/followingpages.js +++ b/plugins/Insight/client/followingpages.js @@ -57,8 +57,8 @@ var Piwik_Insight_FollowingPages = (function() { var totalClicks = 0; for (var i = 0; i < followingPages.length; i++) { var page = followingPages[i]; - // downloads and outlinks still have the prefix - // TODO investigate whether it would be better to use Piwik_Insight_UrlNormalizer.normalize + // though the following pages are returned without the prefix, downloads + // and outlinks still have it. page.label = Piwik_Insight_UrlNormalizer.removeUrlPrefix(page.label); totalClicks += followingPages[i].referrals; } @@ -223,14 +223,20 @@ var Piwik_Insight_FollowingPages = (function() { highlightElements[1].height(height + 4).css({top: offset.top - 2, left: offset.left + width}).show(); highlightElements[2].height(height + 4).css({top: offset.top - 2, left: offset.left - 2}).show(); - var padding = ' '; - // TODO translate - var text = data.referrals + ' clicks'; var numLinks = linksOnPage[linkUrl].length; + var text; if (numLinks > 1) { - text += ' from ' + numLinks + ' links'; + text = Piwik_Insight_Translations.get('clicksFromXLinks') + .replace(/%1\$s/, data.referrals) + .replace(/%2\$s/, numLinks); + } else if (data.referrals == 1) { + text = Piwik_Insight_Translations.get('oneClick'); + } else { + text = Piwik_Insight_Translations.get('clicks') + .replace(/%s/, data.referrals); } - + + var padding = ' '; highlightElements[3].html(padding + text + padding).css({ minWidth: (width + 4) + 'px', top: offset.top + height, @@ -243,8 +249,8 @@ var Piwik_Insight_FollowingPages = (function() { tag.data('piwik-highlighted', true); } - // TODO translate - linkTag.data('piwik-hideNotification', Piwik_Insight_Client.notification('Link: ' + linkUrl)); + linkTag.data('piwik-hideNotification', Piwik_Insight_Client.notification( + Piwik_Insight_Translations.get('link') + ': ' + linkUrl)); } /** Remove highlight from link */ diff --git a/plugins/Insight/client/urlnormalizer.js b/plugins/Insight/client/urlnormalizer.js index 01904eafa476765c70836841845aeafa8f32e35f..fcdf386c6316030e40f43565d66cef137377089d 100644 --- a/plugins/Insight/client/urlnormalizer.js +++ b/plugins/Insight/client/urlnormalizer.js @@ -162,12 +162,6 @@ var Piwik_Insight_UrlNormalizer = (function() { } } - // remove #... - var pos; - if ((pos = url.indexOf('#')) != -1) { - url = url.substring(0, pos); - } - // replace multiple / with a single / url = url.replace(/\/\/+/g, '/'); @@ -194,6 +188,7 @@ var Piwik_Insight_UrlNormalizer = (function() { url = url.replace(regEx, ''); } url = url.replace(/\?&/, '?'); + url = url.replace(/\?#/, '#'); url = url.replace(/\?$/, ''); return url; diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index 1810cf5b17f8dcec7009437f3cae6b4bdfce67d8..4d1a0aea8b6ebf6f25027b4efdae9960c4e31aa4 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -92,8 +92,9 @@ class Piwik_Transitions_API } if ($parts == 'all' || in_array('followingActions', $partsArray)) { + $includeLoops = $parts != 'all' && !in_array('internalReferrers', $partsArray); $this->addFollowingActions($transitionsArchiving, $archiveProcessing, $report, $idaction, - $actionType, $limitBeforeGrouping); + $actionType, $limitBeforeGrouping, $includeLoops); } if ($parts == 'all' || in_array('externalReferrers', $partsArray)) { @@ -205,12 +206,13 @@ class Piwik_Transitions_API * @param $idaction * @param string $actionType * @param $limitBeforeGrouping + * @param boolean $includeLoops */ private function addFollowingActions($transitionsArchiving, $archiveProcessing, &$report, - $idaction, $actionType, $limitBeforeGrouping) { + $idaction, $actionType, $limitBeforeGrouping, $includeLoops=false) { $data = $transitionsArchiving->queryFollowingActions( - $idaction, $actionType, $archiveProcessing, $limitBeforeGrouping); + $idaction, $actionType, $archiveProcessing, $limitBeforeGrouping, $includeLoops); foreach ($data as $tableName => $table) { diff --git a/plugins/Transitions/Transitions.php b/plugins/Transitions/Transitions.php index 6a2e6cc1cd25586b3142a7931090ca876869ea5f..6b7cea5349987b7232dc8f9a3701cefe89a1a241 100644 --- a/plugins/Transitions/Transitions.php +++ b/plugins/Transitions/Transitions.php @@ -285,10 +285,11 @@ class Piwik_Transitions extends Piwik_Plugin * @param $actionType * @param Piwik_ArchiveProcessing_Day $archiveProcessing * @param $limitBeforeGrouping + * @param $includeLoops * @return array(followingPages:Piwik_DataTable, outlinks:Piwik_DataTable, downloads:Piwik_DataTable) */ public function queryFollowingActions($idaction, $actionType, Piwik_ArchiveProcessing_Day $archiveProcessing, - $limitBeforeGrouping = false) + $limitBeforeGrouping = false, $includeLoops = false) { $types = array(); @@ -348,9 +349,11 @@ class Piwik_Transitions extends Piwik_Plugin $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($types)); $type = $this->getColumnTypeSuffix($actionType); - $where = 'log_link_visit_action.idaction_'.$type.'_ref = '.intval($idaction).' AND ' - . '(log_link_visit_action.idaction_'.$type.' IS NULL OR ' - . 'log_link_visit_action.idaction_'.$type.' != '.intval($idaction).')'; + $where = 'log_link_visit_action.idaction_'.$type.'_ref = '.intval($idaction); + if (!$includeLoops) { + $where .= ' AND (log_link_visit_action.idaction_'.$type.' IS NULL OR ' + . 'log_link_visit_action.idaction_'.$type.' != '.intval($idaction).')'; + } $orderBy = '`'.Piwik_Archive::INDEX_NB_ACTIONS.'` DESC';