Skip to content
Extraits de code Groupes Projets
Valider 8a0fcbb4 rédigé par BeezyT's avatar BeezyT
Parcourir les fichiers

refs #2465 Insight

 * links to the current url get a bubble as well
 * limit for the number of pages loaded from the API can be configured
 * ready for translation
 * url normalizer doesn't remove the hash part anymore (which corresponds to the latest behavior of the tracker)

git-svn-id: http://dev.piwik.org/svn/trunk@7405 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent be0df121
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -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'
);
......@@ -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)
......
......@@ -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 = '&nbsp;&nbsp;';
// 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 = '&nbsp;&nbsp;';
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 */
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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';
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter