From b6f1a8b0d2284ff896b5caa8a8975a1c4482bed3 Mon Sep 17 00:00:00 2001 From: BeezyT <timo@ezdesign.de> Date: Fri, 9 Nov 2012 13:34:35 +0000 Subject: [PATCH] refs #2465 * renaming menu item to "Page Overlay", putting it under Actions * config option to disable framed mode altogether (can be used when websites contain frame busters) * fixed error for anonymous user * loading message in framed mode git-svn-id: http://dev.piwik.org/svn/trunk@7419 59fd770c-687e-43c8-a1e3-f5a4ff64c105 --- config/global.ini.php | 4 ++++ lang/en.php | 6 ++++-- plugins/Insight/API.php | 8 +++++++- plugins/Insight/Controller.php | 7 ++++++- plugins/Insight/Insight.php | 2 +- plugins/Insight/templates/index.css | 15 +++++++++++++++ plugins/Insight/templates/index.tpl | 6 ++++++ plugins/Insight/templates/index_noframe.tpl | 13 +++++++++++++ plugins/Insight/templates/insight.js | 11 ++++++----- 9 files changed, 62 insertions(+), 10 deletions(-) create mode 100644 plugins/Insight/templates/index_noframe.tpl diff --git a/config/global.ini.php b/config/global.ini.php index 697b918407..7e1f7d5457 100644 --- a/config/global.ini.php +++ b/config/global.ini.php @@ -315,6 +315,10 @@ graphs_default_period_to_plot_when_period_range = day ; a view of the current page. The value X can be set here. insight_limit = 300 +; With this option, you can disable the framed mode of the Insight plugin. If set to 1, the Insight session +; will be started in a new tab instead of the iframe. +insight_disable_framed_mode = 0 + [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 e03b5b9bcb..57e723a84e 100644 --- a/lang/en.php +++ b/lang/en.php @@ -1804,7 +1804,7 @@ And thank you for using Piwik!', 'Transitions_NoDataForAction' => 'There\'s no data for %s', 'Transitions_NoDataForActionDetails' => 'Either the action had no pageviews during the period %s or it is invalid.', 'Transitions_ErrorBack' => 'Go back to the previous action', - 'Insight_Insight' => 'Insight', + 'Insight_Insight' => 'Page Overlay', 'Insight_Page' => 'Page', 'Insight_MainMetrics' => 'Main metrics', 'Insight_NoData' => 'There is no data for this page during the selected period.', @@ -1815,5 +1815,7 @@ And thank you for using Piwik!', 'Insight_ClicksFromXLinks' => '%1$s clicks from one of %2$s links', 'Insight_Link' => 'Link', 'Insight_OpenNewTab' => 'Open in new tab', - 'Insight_RedirectUrlError' => 'You are attempting to open Insight for the URL "%s". %s None of the URLs from the Piwik settings matches the link. Please add the domain there.' + 'Insight_RedirectUrlError' => 'You are attempting to open Insight for the URL "%s". %s None of the URLs from the Piwik settings matches the link. Please add the domain there.', + 'Insight_Domain' => 'Domain', + 'Insight_NoFrameModeText' => 'The page overlay session will be launched in a new tab. %s If opening the tab doesn\'t work automatically, please %sclick here%s.' ); diff --git a/plugins/Insight/API.php b/plugins/Insight/API.php index 9517b75367..d48a7e69be 100644 --- a/plugins/Insight/API.php +++ b/plugins/Insight/API.php @@ -56,7 +56,13 @@ class Piwik_Insight_API $sitesManager = Piwik_SitesManager_API::getInstance(); $site = $sitesManager->getSiteFromId($idSite); - return Piwik_SitesManager::getTrackerExcludedQueryParameters($site); + try { + return Piwik_SitesManager::getTrackerExcludedQueryParameters($site); + } catch(Exception $e) { + // an exception is thrown when the user has no admin access. + // in this case, we don't handle excluded parameters. + return array(); + } } /** diff --git a/plugins/Insight/Controller.php b/plugins/Insight/Controller.php index 325f01deb3..d35c87eeb7 100644 --- a/plugins/Insight/Controller.php +++ b/plugins/Insight/Controller.php @@ -18,7 +18,12 @@ class Piwik_Insight_Controller extends Piwik_Controller { Piwik::checkUserHasViewAccess($this->idSite); - $view = Piwik_View::factory('index'); + $template = 'index'; + if (Piwik_Config::getInstance()->General['insight_disable_framed_mode']) { + $template = 'index_noframe'; + } + + $view = Piwik_View::factory($template); $view->idSite = $this->idSite; $view->date = Piwik_Common::getRequestVar('date', 'today'); $view->period = Piwik_Common::getRequestVar('period', 'day'); diff --git a/plugins/Insight/Insight.php b/plugins/Insight/Insight.php index 2b0f1e2abd..1e36fd3e87 100644 --- a/plugins/Insight/Insight.php +++ b/plugins/Insight/Insight.php @@ -45,7 +45,7 @@ class Piwik_Insight extends Piwik_Plugin public function addMenu() { - Piwik_AddMenu('General_Visitors', 'Insight_Insight', + Piwik_AddMenu('Actions_Actions', 'Insight_Insight', array('module' => 'Insight', 'action' => 'index'), $display = true, $order = 60); } diff --git a/plugins/Insight/templates/index.css b/plugins/Insight/templates/index.css index 92eefd7def..eaa114f84a 100644 --- a/plugins/Insight/templates/index.css +++ b/plugins/Insight/templates/index.css @@ -34,6 +34,17 @@ padding: 0; } +#Insight_Loading { + background: url(../../../themes/default/images/loading-blue.gif) no-repeat center 10px; + float: left; + width: 190px; + position: relative; + clear: left; + padding-top: 35px; + text-align: center; + display: none; +} + #Insight_Sidebar { float: left; width: 200px; @@ -126,4 +137,8 @@ h2.Insight_MainMetrics { body .piwik-tooltip.Insight_Tooltip { font-size: 11px; padding: 3px 5px 3px 6px; +} + +#Insight_NoFrame { + padding: 20px 0 40px 2px } \ No newline at end of file diff --git a/plugins/Insight/templates/index.tpl b/plugins/Insight/templates/index.tpl index 217aa2fbdf..b85547a403 100644 --- a/plugins/Insight/templates/index.tpl +++ b/plugins/Insight/templates/index.tpl @@ -5,6 +5,8 @@ <div id="Insight_Sidebar"></div> + <div id="Insight_Loading">{'General_Loading_js'|translate|escape:'html'}</div> + <div id="Insight_Main"> <iframe id="Insight_Iframe" @@ -17,4 +19,8 @@ <script type="text/javascript"> Piwik_Insight.init(); + + Piwik_Insight_Translations = {literal}{{/literal} + domain: "{'Insight_Domain'|translate|escape:'html'}" + {literal}}{/literal}; </script> \ No newline at end of file diff --git a/plugins/Insight/templates/index_noframe.tpl b/plugins/Insight/templates/index_noframe.tpl new file mode 100644 index 0000000000..3f8c45c311 --- /dev/null +++ b/plugins/Insight/templates/index_noframe.tpl @@ -0,0 +1,13 @@ + +<div id="Insight_NoFrame"> + + {capture name="link"}index.php?module=Insight&action=startInsightSession&idsite={$idSite}&period={$period}&date={$date}{/capture} + {capture name="linkTag"}<a id="Insight_Link" href="{$smarty.capture.link}" target="_blank">{/capture} + + {'Insight_NoFrameModeText'|translate|escape:'html'|sprintf:'<br />':$smarty.capture.linkTag:'</a>'} + + <script type="text/javascript"> + window.open('{$smarty.capture.link}', '_newtab'); + </script> + +</div> \ No newline at end of file diff --git a/plugins/Insight/templates/insight.js b/plugins/Insight/templates/insight.js index 5437d1863e..408030cfc3 100644 --- a/plugins/Insight/templates/insight.js +++ b/plugins/Insight/templates/insight.js @@ -1,6 +1,6 @@ var Piwik_Insight = (function() { - var $container, $iframe, $sidebar, $main, $location; + var $container, $iframe, $sidebar, $main, $location, $loading; var isFullScreen = false; @@ -10,8 +10,7 @@ var Piwik_Insight = (function() { function loadSidebar(currentUrl) { $sidebar.hide(); $location.html(' '); - - // TODO show loading message + $loading.show(); iframeDomain = currentUrl.match(/http(s)?:\/\/(www\.)?([^\/]*)/i)[3]; @@ -27,16 +26,17 @@ var Piwik_Insight = (function() { $responseLocation.remove(); $location.find('span').hover(function() { - // TODO translate if (iframeDomain) { // use addBreakpointsToUrl because it also encoded html entities - Piwik_Tooltip.show('<b>Domain:</b> ' + piwikHelper.addBreakpointsToUrl(iframeDomain), 'Insight_Tooltip'); + Piwik_Tooltip.show('<b>' + Piwik_Insight_Translations.domain + ':</b> ' + + piwikHelper.addBreakpointsToUrl(iframeDomain), 'Insight_Tooltip'); } }, function() { Piwik_Tooltip.hide(); }); $sidebar.empty().append($response).show(); + $loading.hide(); var $fullScreen = $sidebar.find('a.Insight_FullScreen'); $fullScreen.click(function() { @@ -84,6 +84,7 @@ var Piwik_Insight = (function() { $sidebar = $('#Insight_Sidebar'); $location = $('#Insight_Location'); $main = $('#Insight_Main'); + $loading = $('#Insight_Loading'); adjustHeight(); -- GitLab