diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2013-10-02 06:31:06 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2013-10-02 06:31:06 +0400 |
commit | f185beba0491c1f72f84d71d9c69cb11d75b0a6d (patch) | |
tree | e4fa41ce7896eaf8f46b567c7aed2461131749d4 | |
parent | cc422d3f666e4b4b87037499ee8b27609d1481b5 (diff) |
refs #4134 renamed some more hooks and removed some not used and not needed hooks
51 files changed, 602 insertions, 62 deletions
diff --git a/core/Common.php b/core/Common.php index fa5b401510..622dc9df40 100644 --- a/core/Common.php +++ b/core/Common.php @@ -770,12 +770,6 @@ class Common */ public static function getCountry($lang, $enableLanguageToCountryGuess, $ip) { - $country = null; - Piwik_PostEvent('Request.getCountry', array(&$country, $ip)); - if (!empty($country)) { - return strtolower($country); - } - if (empty($lang) || strlen($lang) < 2 || $lang == 'xx') { return 'xx'; } diff --git a/core/Controller.php b/core/Controller.php index 0e01851eee..7e04c46e47 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -634,8 +634,6 @@ abstract class Controller $defaultWebsiteId = $defaultReport; } - Piwik_PostEvent('User.getDefaultWebsiteId', array(&$defaultWebsiteId)); - if ($defaultWebsiteId) { return $defaultWebsiteId; } diff --git a/core/Menu/Admin.php b/core/Menu/Admin.php index ef89c42c4f..c706d8c8b6 100644 --- a/core/Menu/Admin.php +++ b/core/Menu/Admin.php @@ -32,14 +32,14 @@ class Admin extends MenuAbstract } /** - * Triggers the AdminMenu.addMenuEntries hook and returns the menu. + * Triggers the Menu.Admin.addItems hook and returns the menu. * * @return Array */ public function get() { if (!$this->menu) { - Piwik_PostEvent('AdminMenu.addMenuEntries'); + Piwik_PostEvent('Menu.Admin.addItems'); } return parent::get(); } diff --git a/core/Menu/Main.php b/core/Menu/Main.php index fbaaf55337..8732400975 100644 --- a/core/Menu/Main.php +++ b/core/Menu/Main.php @@ -51,7 +51,7 @@ class Main extends MenuAbstract } /** - * Triggers the Menu.addMenuEntries hook and returns the menu. + * Triggers the Menu.Reporting.addItems hook and returns the menu. * * @return Array */ @@ -59,7 +59,7 @@ class Main extends MenuAbstract { // We trigger the Event only once! if (!$this->menu) { - Piwik_PostEvent('Menu.addMenuEntries'); + Piwik_PostEvent('Menu.Reporting.addItems'); } return parent::get(); } diff --git a/core/Menu/Top.php b/core/Menu/Top.php index c4e70ca1bd..31c8fbb86a 100644 --- a/core/Menu/Top.php +++ b/core/Menu/Top.php @@ -52,14 +52,14 @@ class Top extends MenuAbstract } /** - * Triggers the TopMenu.addMenuEntries hook and returns the menu. + * Triggers the Menu.Top.addItems hook and returns the menu. * * @return Array */ public function get() { if (!$this->menu) { - Piwik_PostEvent('TopMenu.addMenuEntries'); + Piwik_PostEvent('Menu.Top.addItems'); } return parent::get(); } diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index f40e346298..85388222a8 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -909,14 +909,7 @@ class Visit implements Tracker\VisitInterface */ protected function newAction() { - $action = null; - Piwik_PostEvent('Tracker.createNewAction', array(&$action)); - - if (is_null($action)) { - $action = new Action($this->request); - } elseif (!($action instanceof ActionInterface)) { - throw new Exception("The Action object set in the plugin must implement the interface ActionInterface"); - } + $action = new Action($this->request); return $action; } diff --git a/plugins/API/API.php b/plugins/API/API.php index c4b8179e9a..060a003fe5 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -649,7 +649,7 @@ class Plugin extends \Piwik\Plugin { return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'TopMenu.addMenuEntries' => 'addTopMenu', + 'Menu.Top.addItems' => 'addTopMenu', ); } diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index bf78c166ea..779593f52f 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -57,7 +57,7 @@ class Actions extends \Piwik\Plugin 'ArchiveProcessing_Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenus', + 'Menu.Reporting.addItems' => 'addMenus', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php index b15d970cd5..01b80aa85b 100644 --- a/plugins/CoreAdminHome/CoreAdminHome.php +++ b/plugins/CoreAdminHome/CoreAdminHome.php @@ -32,7 +32,7 @@ class CoreAdminHome extends \Piwik\Plugin return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks', ); } diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php index 1ef77a962c..02b239e9dd 100644 --- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php +++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php @@ -26,7 +26,7 @@ class CorePluginsAdmin extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks', diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php index fe7871d4c0..7f8dd16edf 100644 --- a/plugins/CustomVariables/CustomVariables.php +++ b/plugins/CustomVariables/CustomVariables.php @@ -36,7 +36,7 @@ class CustomVariables extends \Piwik\Plugin 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenus', + 'Menu.Reporting.addItems' => 'addMenus', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php index aeb11e7d9b..7f7fc0301d 100644 --- a/plugins/DBStats/DBStats.php +++ b/plugins/DBStats/DBStats.php @@ -32,7 +32,7 @@ class DBStats extends \Piwik\Plugin { return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', ); diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index c94b3e6df5..20ac92a9dc 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -31,8 +31,8 @@ class Dashboard extends \Piwik\Plugin 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'UsersManager.deleteUser' => 'deleteDashboardLayout', - 'Menu.addMenuEntries' => 'addMenus', - 'TopMenu.addMenuEntries' => 'addTopMenu', + 'Menu.Reporting.addItems' => 'addMenus', + 'Menu.Top.addItems' => 'addTopMenu', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); } diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index 11d99e87a9..08942539c1 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -63,7 +63,7 @@ class DevicesDetection extends \Piwik\Plugin return array( 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', 'Tracker.newVisitorInformation' => 'parseMobileVisitData', 'WidgetsList.addWidgets' => 'addWidgets', 'API.getReportMetadata' => 'getReportMetadata', diff --git a/plugins/ExampleUI/ExampleUI.php b/plugins/ExampleUI/ExampleUI.php index 08f0e66dff..97cf9f2bc2 100644 --- a/plugins/ExampleUI/ExampleUI.php +++ b/plugins/ExampleUI/ExampleUI.php @@ -33,7 +33,7 @@ class ExampleUI extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'Menu.addMenuEntries' => 'addMenus', + 'Menu.Reporting.addItems' => 'addMenus', ); return $hooks; } diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php index 629df7e83f..e48b416c37 100644 --- a/plugins/Feedback/Feedback.php +++ b/plugins/Feedback/Feedback.php @@ -24,10 +24,10 @@ class Feedback extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'TopMenu.addMenuEntries' => 'addTopMenu', - 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' + 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', + 'AssetManager.getJavaScriptFiles' => 'getJsFiles', + 'Menu.Top.addItems' => 'addTopMenu', + 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); } diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index 31172a444c..18e89766c7 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -96,7 +96,7 @@ class Goals extends \Piwik\Plugin 'API.getReportMetadata.end' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenus', + 'Menu.Reporting.addItems' => 'addMenus', 'SitesManager.deleteSite.end' => 'deleteSiteGoals', 'Goals.getReportsWithGoalMetrics' => 'getActualReportsWithGoalMetrics', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php index 95bae08344..0c37aa5170 100644 --- a/plugins/Installation/Installation.php +++ b/plugins/Installation/Installation.php @@ -30,7 +30,7 @@ class Installation extends \Piwik\Plugin $hooks = array( 'Config.NoConfigurationFile' => 'dispatch', 'Config.badConfigurationFile' => 'dispatch', - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', ); return $hooks; diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 0ee99134ea..f9b7a3ed00 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -35,7 +35,7 @@ class LanguagesManager extends \Piwik\Plugin return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'TopMenu.addMenuEntries' => 'showLanguagesSelector', + 'Menu.Top.addItems' => 'showLanguagesSelector', 'User.getLanguage' => 'getLanguageToLoad', 'UsersManager.deleteUser' => 'deleteUserLanguage', 'Template.topBar' => 'addLanguagesManagerToOtherTopBar', diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index 470d731249..2161b0f9a7 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -45,7 +45,7 @@ class Live extends \Piwik\Plugin 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'WidgetsList.addWidgets' => 'addWidget', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', ); diff --git a/plugins/LiveTab/API.php b/plugins/LiveTab/API.php new file mode 100644 index 0000000000..7401527846 --- /dev/null +++ b/plugins/LiveTab/API.php @@ -0,0 +1,100 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * @category Piwik_Plugins + * @package Piwik_LiveTab + */ + +namespace Piwik\Plugins\LiveTab; + +use Piwik\Piwik; + +/** + * @package Piwik_LiveTab + */ +class API +{ + /** + * @var API + */ + static private $instance = null; + + /** + * @return API + */ + static public function getInstance() + { + if (null == self::$instance) { + self::$instance = new self; + } + + return self::$instance; + } + + public function setSettings($metric, $lastMinutes, $refreshInterval) + { + // TODO add login as parameter + Piwik::checkUserHasSomeViewAccess(); + + if (!$this->isAllowedMetric($metric)) { + throw new \Exception(Piwik_TranslateException('LiveTab_InvalidMetric')); + } + + $lastMinutes = (int) $lastMinutes; + $refreshInterval = (int) $refreshInterval; + + $login = Piwik::getCurrentUserLogin(); + + $model = new Model($login); + $model->setSettings($metric, $lastMinutes, $refreshInterval); + } + + public function getSettings() + { + // TODO add login as parameter + + Piwik::checkUserHasSomeViewAccess(); + + $login = Piwik::getCurrentUserLogin(); + + $model = new Model($login); + $settings = $model->getSettings(); + + if (empty($settings)) { + return $this->getDefaultSettings(); + } + + return array( + 'metric' => $settings['metric'], + 'lastMinutes' => $settings['last_minutes'], + 'refreshInterval' => $settings['refresh_interval'] + ); + } + + public function getAvailableMetrics() + { + return array( + 'visits' => Piwik_Translate('General_ColumnNbVisits'), + 'actions' => Piwik_Translate('General_ColumnNbActions'), + 'visitsConverted' => Piwik_Translate('Goals_GoalConversions'), + 'visitors' => Piwik_Translate('General_ColumnNbUniqVisitors') + ); + } + + private function getDefaultSettings() + { + return array( + 'metric' => LiveTab::$defaultMetricToDisplay, + 'lastMinutes' => LiveTab::$defaultLastMinutes, + 'refreshInterval' => LiveTab::$defaultRefreshInterval + ); + } + + private function isAllowedMetric($metric) + { + return in_array($metric, array_keys($this->getAvailableMetrics())); + } +} diff --git a/plugins/LiveTab/Controller.php b/plugins/LiveTab/Controller.php new file mode 100644 index 0000000000..6a7daa1c4e --- /dev/null +++ b/plugins/LiveTab/Controller.php @@ -0,0 +1,42 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik_Plugins + * @package Piwik_LiveTab + */ + +namespace Piwik\Plugins\LiveTab; + +use Piwik\Controller\Admin; +use Piwik\Piwik; +use Piwik\View; + +/** + * + * @package Piwik_LiveTab + */ +class Controller extends Admin +{ + public function index() + { + Piwik::checkUserIsNotAnonymous(); + + $view = new View('@LiveTab/index'); + + $api = new API(); + $settings = $api->getSettings(); + + $view->metricToDisplay = $settings['metric']; + $view->lastMinutes = $settings['lastMinutes']; + $view->refreshInterval = $settings['refreshInterval']; + $view->availableMetrics = $api->getAvailableMetrics(); + + $this->setBasicVariablesView($view); + + echo $view->render(); + } +} diff --git a/plugins/LiveTab/LiveTab.php b/plugins/LiveTab/LiveTab.php new file mode 100644 index 0000000000..7b4604becf --- /dev/null +++ b/plugins/LiveTab/LiveTab.php @@ -0,0 +1,53 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik_Plugins + * @package Piwik_LiveTab + */ + +namespace Piwik\Plugins\LiveTab; + +use Piwik\Piwik; +use Piwik\Plugin; + +/** + * + * @package Piwik_LiveTab + */ +class LiveTab extends Plugin +{ + public static $defaultRefreshInterval = 60; + public static $defaultLastMinutes = 30; + public static $defaultMetricToDisplay = 'visits'; + + /** + * @see Piwik_Plugin::getListHooksRegistered + */ + public function getListHooksRegistered() + { + return array( + 'AssetManager.getJsFiles' => 'getJsFiles', + 'AdminMenu.add' => 'addMenu', + ); + } + + public function getJsFiles(&$jsFiles) + { + $jsFiles[] = 'plugins/LiveTab/javascripts/api.js'; + $jsFiles[] = 'plugins/LiveTab/javascripts/liveTab.js'; + $jsFiles[] = 'plugins/LiveTab/javascripts/liveTabAdmin.js'; + } + + public function addMenu() + { + Piwik_AddAdminMenu( + 'LiveTab_SettingsMenu', + array('module' => 'LiveTab', 'action' => 'index'), + true + ); + } +} diff --git a/plugins/LiveTab/Model.php b/plugins/LiveTab/Model.php new file mode 100644 index 0000000000..7befe582df --- /dev/null +++ b/plugins/LiveTab/Model.php @@ -0,0 +1,56 @@ +<?php +/** + * Piwik - Open source web analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + * + * @category Piwik_Plugins + * @package Piwik_LiveTab + */ + +namespace Piwik\Plugins\LiveTab; + +use Piwik\Piwik; +use Piwik\Common; +use Piwik\Db; + +/** + * + * @package Piwik_LiveTab + */ +class Model +{ + private $login; + + public function __construct($login) + { + $this->login = $login; + } + + public function getSettings() + { + $settings = Piwik_GetOption($this->getKey()); + + if (empty($settings)) { + return array(); + } + + return (array) unserialize($settings); + } + + public function setSettings($metric, $lastMinutes, $refreshIntervalInMinutes) + { + $setting = array( + 'metric' => $metric, + 'last_minutes' => $lastMinutes, + 'refresh_interval' => $refreshIntervalInMinutes); + + Piwik_SetOption($this->getKey(), serialize($setting), 1); + } + + private function getKey() + { + return 'LiveTab-settings-' . $this->login; + } +} diff --git a/plugins/LiveTab/README.md b/plugins/LiveTab/README.md new file mode 100644 index 0000000000..f04cf7379d --- /dev/null +++ b/plugins/LiveTab/README.md @@ -0,0 +1,41 @@ +# Piwik LiveTab Plugin + +## Description + +This is a plugin for the Open Source Web Analytics platform [Piwik](http://piwik.org). It allows you to keep an eye on the number of live visitors in the browser tab. It displays the number of visits, actions, unique visitors or converted goals in the last X minutes in the browser tab. The number will be updated every minute. + +For better and faster readability the value will be shortened when greater than 1000. For instance to 3.12K or 3.43M. + +![Screenshot](https://raw.github.com/tsteur/piwik-livetab-plugin/master/screenshots/Browser_Tab.png) + +## Installation + +See http://piwik.org/faq/plugins/#faq_21 + +## FAQ + +__Is it possible to configure the displayed metric?__ +Yes, you can choose between Visits, Actions, Converted Visits and Visitors. + +__Is it possible to configure the displayed metric per user?__ +Yes, this is also possible. Each user can configure the plugin differently. + + +## Changelog + +__1.0.2__ +* Compatible with Piwik 2.0 + +__1.0.0__ +* Initial release + +## License + +GPL v3 or later + +## Support + +Please direct any feedback to: + +* https://github.com/tsteur/piwik-livetab-plugin/issues +* https://www.twitter.com/tsteur diff --git a/plugins/LiveTab/javascripts/api.js b/plugins/LiveTab/javascripts/api.js new file mode 100644 index 0000000000..bf802da6a3 --- /dev/null +++ b/plugins/LiveTab/javascripts/api.js @@ -0,0 +1,37 @@ +/*! + * Piwik - Web Analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +var LiveTabApi = LiveTabApi || (function () { + + function setSettings() + { + } + + function getSettings(onSuccess) + { + var ajaxRequest = new ajaxHelper(); + ajaxRequest.addParams({ + module: 'API', + method: 'LiveTab.getSettings', + format: 'JSON' + }, 'get'); + ajaxRequest.setCallback( + function (response) { + if (!response || !response[0]) { + + return; + } + + onSuccess(response[0]); + } + ); + ajaxRequest.send(false); + } + + return {setSettings: setSettings, + getSettings: getSettings}; +})();
\ No newline at end of file diff --git a/plugins/LiveTab/javascripts/liveTab.js b/plugins/LiveTab/javascripts/liveTab.js new file mode 100644 index 0000000000..9e4428ed94 --- /dev/null +++ b/plugins/LiveTab/javascripts/liveTab.js @@ -0,0 +1,70 @@ +/*! + * Piwik - Web Analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +$(document).ready(function () { + + // TODO make it customizable + var NUM_LAST_MINUTES = 30; + var METRIC_TO_SHOW = 'visits'; + var REFRESH_INTERVAL_SECONDS = 60; + + LiveTabApi.getSettings(function (settings) { + NUM_LAST_MINUTES = settings.lastMinutes; + METRIC_TO_SHOW = settings.metric; + REFRESH_INTERVAL_SECONDS = settings.refreshInterval; + updateTitle(); + }); + + var originalTitle = $('title').text(); + + function makeSeconds(seconds) + { + return seconds * 1000; + } + + function shortenNumber (value) { + if (!value) { + return 0; + } + + var suffix = ['', 'K', 'M', 'B', 'T']; + + var index = 0; + while (value > 1000 && index < suffix.length - 1) { + index++; + value = (value / 1000).toFixed(2) + } + + return (value) + suffix[index]; + } + + function updateTitle() + { + var ajaxRequest = new ajaxHelper(); + ajaxRequest.addParams({ + module: 'API', + method: 'Live.getCounters', + lastMinutes: NUM_LAST_MINUTES, + format: 'JSON' + }, 'get'); + ajaxRequest.setCallback( + function (response) { + if (!response || !response[0]) { + + return; + } + + var value = shortenNumber(response[0][METRIC_TO_SHOW]); + + $('title').text(value + ' - ' + originalTitle); + + setTimeout(updateTitle, makeSeconds(REFRESH_INTERVAL_SECONDS)); + } + ); + ajaxRequest.send(false); + } +});
\ No newline at end of file diff --git a/plugins/LiveTab/javascripts/liveTabAdmin.js b/plugins/LiveTab/javascripts/liveTabAdmin.js new file mode 100644 index 0000000000..f2e809e854 --- /dev/null +++ b/plugins/LiveTab/javascripts/liveTabAdmin.js @@ -0,0 +1,51 @@ +/*! + * Piwik - Web Analytics + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +$(document).ready(function () { + + $submit = $('#liveTabSubmit'); + + if (!$submit) { + return; + } + + $submit.click(updateLiveTabSettings); + + function getSettings() + { + return { + metric: $('#metricToDisplay option:selected').val(), + lastMinutes: $('#lastMinutes').val(), + refreshInterval: $('#refreshInterval').val() + }; + } + + function getErrorElement() + { + return $('#ajaxErrorLiveTab'); + } + + function getLoadingElement() + { + return $('#ajaxLoadingLiveTab'); + } + + function updateLiveTabSettings() + { + var ajaxHandler = new ajaxHelper(); + ajaxHandler.addParams({ + module: 'API', + format: 'json', + method: 'LiveTab.setSettings' + }, 'GET'); + ajaxHandler.addParams(getSettings(), 'POST'); + ajaxHandler.redirectOnSuccess(); + ajaxHandler.setLoadingElement(getLoadingElement()); + ajaxHandler.setErrorElement(getErrorElement()); + ajaxHandler.send(true); + } +});
\ No newline at end of file diff --git a/plugins/LiveTab/lang/en.php b/plugins/LiveTab/lang/en.php new file mode 100644 index 0000000000..24af86f5fc --- /dev/null +++ b/plugins/LiveTab/lang/en.php @@ -0,0 +1,12 @@ +<?php +$translations = array( + 'LiveTab_SettingsMenu' => 'LiveTab Settings', + 'LiveTab_Settings' => 'LiveTab Settings', + 'LiveTab_RefreshInterval' => 'Refresh interval', + 'LiveTab_MetricToDisplay' => 'Metric to display', + 'LiveTab_LastMinutes' => 'Last minutes', + 'LiveTab_DefaultDisplayMetric' => 'Visits', + 'LiveTab_DefaultLastMinutes' => 30, + 'LiveTab_DefaultRefreshInterval' => 60, + 'LiveTab_InvalidMetric' => 'The given metric is not available.' +);
\ No newline at end of file diff --git a/plugins/LiveTab/plugin.json b/plugins/LiveTab/plugin.json new file mode 100644 index 0000000000..f2055ca1ed --- /dev/null +++ b/plugins/LiveTab/plugin.json @@ -0,0 +1,20 @@ +{ + "name": "LiveTab", + "description": "Keep an eye on the number of live visitors in the browser tab. It displays the number of visitors in the last 30 minutes in the browser tab.", + "version": "1.0.3", + "keywords": ["live", "tab"], + "homepage": "http://piwik.org", + "license": "GPL-3.0+", + "has_translation": true, + "donate": { + "paypal": "thomas.steur@googlemail.com", + "flattr": "https://flattr.com/profile/steurth" + }, + "authors": [ + { + "name": "Thomas Steur", + "email": "thomas@piwik.org", + "homepage": "http://piwik.org" + } + ] +} diff --git a/plugins/LiveTab/screenshots/Browser_Tab.png b/plugins/LiveTab/screenshots/Browser_Tab.png Binary files differnew file mode 100644 index 0000000000..86c75a2c17 --- /dev/null +++ b/plugins/LiveTab/screenshots/Browser_Tab.png diff --git a/plugins/LiveTab/templates/index.twig b/plugins/LiveTab/templates/index.twig new file mode 100644 index 0000000000..b82dc6a401 --- /dev/null +++ b/plugins/LiveTab/templates/index.twig @@ -0,0 +1,74 @@ +{% extends 'admin.twig' %} + +{% block content %} + + <h2>{{ 'LiveTab_Settings'|translate }}</h2> + + {% import 'macros.twig' as piwik %} + {% import 'ajaxMacros.twig' as ajax %} + {{ ajax.errorDiv('ajaxErrorLiveTab') }} + {{ ajax.loadingDiv('ajaxLoadingLiveTab') }} + + <table class="adminTable" style='width:620px;'> + <tr> + <td style='width:400px'>{{ 'LiveTab_MetricToDisplay'|translate }}</td> + <td style='width:220px'> + <fieldset> + <label> + <select id='metricToDisplay'> + {% for metric, metricName in availableMetrics %} + <option value='{{ metric }}' + {% if metricToDisplay==metric %} selected='selected' {% endif %} + > + {{ metricName }} + </option> + {% endfor %} + </select> + <br/> + <span class='form-description'> + ({{ 'General_Default'|translate }}) {{ 'LiveTab_DefaultDisplayMetric'|translate }} + </span> + + </label> + </fieldset> + </td> + </tr> + <tr> + <td>{{ 'LiveTab_LastMinutes'|translate }}</td> + <td> + <fieldset> + <label> + + {{ 'General_NMinutes'|translate("<input size='3' value='" ~ lastMinutes ~ "' id='lastMinutes' />")|raw }} + + <br/> + <span class='form-description'> + ({{ 'General_Default'|translate }}) {{ 'LiveTab_DefaultLastMinutes'|translate }} + </span> + + </label> + </fieldset> + </td> + </tr> + <tr> + <td>{{ 'LiveTab_RefreshInterval'|translate }}</td> + <td> + <fieldset> + <label> + + {{ 'General_NSeconds'|translate("<input size='3' value='" ~ refreshInterval ~ "' id='refreshInterval' />")|raw }} + + <br/> + <span class='form-description'> + ({{ 'General_Default'|translate }}) {{ 'LiveTab_DefaultRefreshInterval'|translate }} + </span> + + </label> + </fieldset> + </td> + </tr> + </table> + + <input type="submit" value="{{ 'General_Save'|translate }}" id="liveTabSubmit" class="submit"/> + +{% endblock %} diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php index a2d6626151..4d447e7f12 100644 --- a/plugins/MobileMessaging/MobileMessaging.php +++ b/plugins/MobileMessaging/MobileMessaging.php @@ -67,7 +67,7 @@ class MobileMessaging extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'PDFReports.getReportParameters' => 'getReportParameters', diff --git a/plugins/MultiSites/MultiSites.php b/plugins/MultiSites/MultiSites.php index e8a37d762c..0e08ac8cc8 100644 --- a/plugins/MultiSites/MultiSites.php +++ b/plugins/MultiSites/MultiSites.php @@ -34,7 +34,7 @@ class MultiSites extends \Piwik\Plugin return array( 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'TopMenu.addMenuEntries' => 'addTopMenu', + 'Menu.Top.addItems' => 'addTopMenu', 'API.getReportMetadata' => 'getReportMetadata', ); } diff --git a/plugins/PDFReports/PDFReports.php b/plugins/PDFReports/PDFReports.php index 569068151c..8768107b7b 100644 --- a/plugins/PDFReports/PDFReports.php +++ b/plugins/PDFReports/PDFReports.php @@ -78,7 +78,7 @@ class PDFReports extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'TopMenu.addMenuEntries' => 'addTopMenu', + 'Menu.Top.addItems' => 'addTopMenu', 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'PDFReports.getReportParameters' => 'getReportParameters', diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php index 72d71e21e5..5831ccd0f0 100644 --- a/plugins/PrivacyManager/PrivacyManager.php +++ b/plugins/PrivacyManager/PrivacyManager.php @@ -69,7 +69,7 @@ class PrivacyManager extends \Piwik\Plugin { return array( 'AssetManager.getJavaScriptFiles' => 'getJsFiles', - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'TaskScheduler.getScheduledTasks' => 'getScheduledTasks', ); } diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 10205685b2..77ce6ea7a1 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -35,7 +35,7 @@ class Provider extends \Piwik\Plugin 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'Tracker.newVisitorInformation' => 'logProviderInfo', 'WidgetsList.addWidgets' => 'addWidget', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', diff --git a/plugins/Referers/Archiver.php b/plugins/Referers/Archiver.php index aa8d7bbf45..5959a849fb 100644 --- a/plugins/Referers/Archiver.php +++ b/plugins/Referers/Archiver.php @@ -57,7 +57,6 @@ class Archiver extends PluginsArchiver $query = $this->getLogAggregator()->queryConversionsByDimension(array("referer_type", "referer_name", "referer_keyword")); $this->aggregateFromConversions($query); - Piwik_PostEvent('Referrers.archiveDay', $this); $this->recordDayReports(); } diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php index 3c809b0b6f..5ee8ebf364 100644 --- a/plugins/Referers/Referers.php +++ b/plugins/Referers/Referers.php @@ -34,7 +34,7 @@ class Referers extends \Piwik\Plugin 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenus', + 'Menu.Reporting.addItems' => 'addMenus', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', diff --git a/plugins/SecurityInfo b/plugins/SecurityInfo -Subproject 22333f8dbc9b7ce3a3f003e8d0b657705d188cc +Subproject c7b9a64a58910c1bea64f4eb3870de74142f81e diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php index 0de72da0ce..0671890c2a 100644 --- a/plugins/SitesManager/SitesManager.php +++ b/plugins/SitesManager/SitesManager.php @@ -30,7 +30,7 @@ class SitesManager extends \Piwik\Plugin return array( 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'Site.getSiteAttributes' => 'recordWebsiteDataInCache', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', ); diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 8b00e06c5f..53e9ce380d 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -42,8 +42,8 @@ class UserCountry extends \Piwik\Plugin 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenu', - 'AdminMenu.addMenuEntries' => 'addAdminMenu', + 'Menu.Reporting.addItems' => 'addMenu', + 'Menu.Admin.addItems' => 'addAdminMenu', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php index 44b0fd361e..61e24df047 100644 --- a/plugins/UserCountryMap/UserCountryMap.php +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -56,7 +56,7 @@ class UserCountryMap extends \Piwik\Plugin $hooks = array( 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', ); return $hooks; } diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index be46e42853..aae94c2cbf 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -167,7 +167,7 @@ class UserSettings extends \Piwik\Plugin 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php index 30446bca65..3193315e1e 100644 --- a/plugins/UsersManager/UsersManager.php +++ b/plugins/UsersManager/UsersManager.php @@ -31,7 +31,7 @@ class UsersManager extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'AdminMenu.addMenuEntries' => 'addMenu', + 'Menu.Admin.addItems' => 'addMenu', 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'SitesManager.deleteSite.end' => 'deleteSite', diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index 3425c80b1a..4054636767 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -24,9 +24,9 @@ class VisitFrequency extends \Piwik\Plugin public function getListHooksRegistered() { $hooks = array( - 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenu', - 'API.getReportMetadata' => 'getReportMetadata', + 'WidgetsList.addWidgets' => 'addWidgets', + 'Menu.Reporting.addItems' => 'addMenu', + 'API.getReportMetadata' => 'getReportMetadata', ); return $hooks; } diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index 73eb50329d..161c1edd3e 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -33,7 +33,7 @@ class VisitTime extends \Piwik\Plugin 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', 'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics', 'API.getReportMetadata' => 'getReportMetadata', 'API.getSegmentsMetadata' => 'getSegmentsMetadata', diff --git a/plugins/VisitorGenerator b/plugins/VisitorGenerator -Subproject 850a32c73c713df26525e87c28db5d4873815b5 +Subproject 58a69c541f2d777cebe6d91eb1aa20ea5e8efd5 diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index dc83bdb871..81f2079552 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -31,7 +31,7 @@ class VisitorInterest extends \Piwik\Plugin 'ArchiveProcessor.Day.compute' => 'archiveDay', 'ArchiveProcessor.Period.compute' => 'archivePeriod', 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenu', + 'Menu.Reporting.addItems' => 'addMenu', 'API.getReportMetadata' => 'getReportMetadata', 'Visualization.getReportDisplayProperties' => 'getReportDisplayProperties', ); diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index 263453088d..aa9522bb50 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -28,9 +28,9 @@ class VisitsSummary extends \Piwik\Plugin public function getListHooksRegistered() { return array( - 'API.getReportMetadata' => 'getReportMetadata', - 'WidgetsList.addWidgets' => 'addWidgets', - 'Menu.addMenuEntries' => 'addMenu', + 'API.getReportMetadata' => 'getReportMetadata', + 'WidgetsList.addWidgets' => 'addWidgets', + 'Menu.Reporting.addItems' => 'addMenu', ); } diff --git a/plugins/Widgetize/Widgetize.php b/plugins/Widgetize/Widgetize.php index d64a3472fa..06e54d15a8 100644 --- a/plugins/Widgetize/Widgetize.php +++ b/plugins/Widgetize/Widgetize.php @@ -26,7 +26,7 @@ class Widgetize extends \Piwik\Plugin return array( 'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', - 'TopMenu.addMenuEntries' => 'addTopMenu', + 'Menu.Top.addItems' => 'addTopMenu', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys' ); } |