update Piwik to version 2.16 (fixes #91)
This commit is contained in:
parent
296343bf3b
commit
d885a4baa9
5833 changed files with 418860 additions and 226988 deletions
|
|
@ -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
|
||||
|
|
@ -8,14 +8,11 @@
|
|||
*/
|
||||
namespace Piwik\Plugins\Dashboard;
|
||||
|
||||
use Exception;
|
||||
use Piwik\Common;
|
||||
use Piwik\Container\StaticContainer;
|
||||
use Piwik\Db;
|
||||
use Piwik\DbHelper;
|
||||
use Piwik\Menu\MenuMain;
|
||||
use Piwik\Menu\MenuTop;
|
||||
use Piwik\Piwik;
|
||||
use Piwik\Site;
|
||||
use Piwik\Plugin;
|
||||
use Piwik\WidgetsList;
|
||||
|
||||
/**
|
||||
|
|
@ -23,16 +20,14 @@ use Piwik\WidgetsList;
|
|||
class Dashboard extends \Piwik\Plugin
|
||||
{
|
||||
/**
|
||||
* @see Piwik\Plugin::getListHooksRegistered
|
||||
* @see Piwik\Plugin::registerEvents
|
||||
*/
|
||||
public function getListHooksRegistered()
|
||||
public function registerEvents()
|
||||
{
|
||||
return array(
|
||||
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
|
||||
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
|
||||
'UsersManager.deleteUser' => 'deleteDashboardLayout',
|
||||
'Menu.Reporting.addItems' => 'addMenus',
|
||||
'Menu.Top.addItems' => 'addTopMenu',
|
||||
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys'
|
||||
);
|
||||
}
|
||||
|
|
@ -48,10 +43,7 @@ class Dashboard extends \Piwik\Plugin
|
|||
*/
|
||||
public function getLayoutForUser($login, $idDashboard)
|
||||
{
|
||||
$paramsBind = array($login, $idDashboard);
|
||||
$query = sprintf('SELECT layout FROM %s WHERE login = ? AND iddashboard = ?',
|
||||
Common::prefixTable('user_dashboard'));
|
||||
$return = Db::fetchAll($query, $paramsBind);
|
||||
$return = $this->getModel()->getLayoutForUser($login, $idDashboard);
|
||||
|
||||
if (count($return) == 0) {
|
||||
return false;
|
||||
|
|
@ -60,16 +52,29 @@ class Dashboard extends \Piwik\Plugin
|
|||
return $return[0]['layout'];
|
||||
}
|
||||
|
||||
private function getModel()
|
||||
{
|
||||
return new Model();
|
||||
}
|
||||
|
||||
public function getDefaultLayout()
|
||||
{
|
||||
$defaultLayout = $this->getLayoutForUser('', 1);
|
||||
|
||||
if (empty($defaultLayout)) {
|
||||
$topWidget = '';
|
||||
|
||||
$advertising = StaticContainer::get('Piwik\PiwikPro\Advertising');
|
||||
if ($advertising->arePiwikProAdsEnabled() && Plugin\Manager::getInstance()->isPluginActivated('PiwikPro')) {
|
||||
$topWidget .= '{"uniqueId":"widgetPiwikPropromoPiwikPro",'
|
||||
. '"parameters":{"module":"PiwikPro","action":"promoPiwikPro"}},';
|
||||
}
|
||||
|
||||
if (Piwik::hasUserSuperUserAccess()) {
|
||||
$topWidget = '{"uniqueId":"widgetCoreHomegetDonateForm",'
|
||||
$topWidget .= '{"uniqueId":"widgetCoreHomegetDonateForm",'
|
||||
. '"parameters":{"module":"CoreHome","action":"getDonateForm"}},';
|
||||
} else {
|
||||
$topWidget = '{"uniqueId":"widgetCoreHomegetPromoVideo",'
|
||||
$topWidget .= '{"uniqueId":"widgetCoreHomegetPromoVideo",'
|
||||
. '"parameters":{"module":"CoreHome","action":"getPromoVideo"}},';
|
||||
}
|
||||
|
||||
|
|
@ -81,19 +86,30 @@ class Dashboard extends \Piwik\Plugin
|
|||
],
|
||||
[
|
||||
' . $topWidget . '
|
||||
{"uniqueId":"widgetReferrersgetKeywords","parameters":{"module":"Referrers","action":"getKeywords"}},
|
||||
{"uniqueId":"widgetReferrersgetWebsites","parameters":{"module":"Referrers","action":"getWebsites"}}
|
||||
{"uniqueId":"widgetReferrersgetWebsites","parameters":{"module":"Referrers","action":"getWebsites"}},
|
||||
{"uniqueId":"widgetVisitTimegetVisitInformationPerServerTime","parameters":{"module":"VisitTime","action":"getVisitInformationPerServerTime"}}
|
||||
],
|
||||
[
|
||||
{"uniqueId":"widgetUserCountryMapvisitorMap","parameters":{"module":"UserCountryMap","action":"visitorMap"}},
|
||||
{"uniqueId":"widgetUserSettingsgetBrowser","parameters":{"module":"UserSettings","action":"getBrowser"}},
|
||||
{"uniqueId":"widgetDevicesDetectiongetBrowsers","parameters":{"module":"DevicesDetection","action":"getBrowsers"}},
|
||||
{"uniqueId":"widgetReferrersgetSearchEngines","parameters":{"module":"Referrers","action":"getSearchEngines"}},
|
||||
{"uniqueId":"widgetVisitTimegetVisitInformationPerServerTime","parameters":{"module":"VisitTime","action":"getVisitInformationPerServerTime"}},
|
||||
{"uniqueId":"widgetExampleRssWidgetrssPiwik","parameters":{"module":"ExampleRssWidget","action":"rssPiwik"}}
|
||||
]
|
||||
]';
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows other plugins to modify the default dashboard layout.
|
||||
*
|
||||
* @param string &$defaultLayout JSON encoded string of the default dashboard layout. Contains an
|
||||
* array of columns where each column is an array of widgets. Each
|
||||
* widget is an associative array w/ the following elements:
|
||||
*
|
||||
* * **uniqueId**: The widget's unique ID.
|
||||
* * **parameters**: The array of query parameters that should be used to get this widget's report.
|
||||
*/
|
||||
Piwik::postEvent("Dashboard.changeDefaultDashboardLayout", array(&$defaultLayout));
|
||||
|
||||
$defaultLayout = $this->removeDisabledPluginFromLayout($defaultLayout);
|
||||
|
||||
return $defaultLayout;
|
||||
|
|
@ -101,12 +117,10 @@ class Dashboard extends \Piwik\Plugin
|
|||
|
||||
public function getAllDashboards($login)
|
||||
{
|
||||
$dashboards = Db::fetchAll('SELECT iddashboard, name, layout
|
||||
FROM ' . Common::prefixTable('user_dashboard') .
|
||||
' WHERE login = ? ORDER BY iddashboard', array($login));
|
||||
$dashboards = $this->getModel()->getAllDashboardsForUser($login);
|
||||
|
||||
$nameless = 1;
|
||||
foreach ($dashboards AS &$dashboard) {
|
||||
foreach ($dashboards as &$dashboard) {
|
||||
|
||||
if (empty($dashboard['name'])) {
|
||||
$dashboard['name'] = Piwik::translate('Dashboard_DashboardOf', $login);
|
||||
|
|
@ -188,43 +202,12 @@ class Dashboard extends \Piwik\Plugin
|
|||
$layout = str_replace("\\\"", "\"", $layout);
|
||||
$layout = str_replace("\n", "", $layout);
|
||||
|
||||
return Common::json_decode($layout, $assoc = false);
|
||||
return json_decode($layout, $assoc = false);
|
||||
}
|
||||
|
||||
public function encodeLayout($layout)
|
||||
{
|
||||
return Common::json_encode($layout);
|
||||
}
|
||||
|
||||
public function addMenus()
|
||||
{
|
||||
MenuMain::getInstance()->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5);
|
||||
|
||||
if (!Piwik::isUserIsAnonymous()) {
|
||||
$login = Piwik::getCurrentUserLogin();
|
||||
|
||||
$dashboards = $this->getAllDashboards($login);
|
||||
|
||||
$pos = 0;
|
||||
foreach ($dashboards as $dashboard) {
|
||||
MenuMain::getInstance()->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos);
|
||||
$pos++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function addTopMenu()
|
||||
{
|
||||
$tooltip = false;
|
||||
try {
|
||||
$idSite = Common::getRequestVar('idSite');
|
||||
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
|
||||
} catch (Exception $ex) {
|
||||
// if no idSite parameter, show no tooltip
|
||||
}
|
||||
|
||||
$urlParams = array('module' => 'CoreHome', 'action' => 'index');
|
||||
MenuTop::addEntry('Dashboard_Dashboard', $urlParams, true, 1, $isHTML = false, $tooltip);
|
||||
return json_encode($layout);
|
||||
}
|
||||
|
||||
public function getJsFiles(&$jsFiles)
|
||||
|
|
@ -240,27 +223,22 @@ class Dashboard extends \Piwik\Plugin
|
|||
{
|
||||
$stylesheets[] = "plugins/CoreHome/stylesheets/dataTable.less";
|
||||
$stylesheets[] = "plugins/Dashboard/stylesheets/dashboard.less";
|
||||
$stylesheets[] = "plugins/Dashboard/stylesheets/widget.less";
|
||||
}
|
||||
|
||||
public function deleteDashboardLayout($userLogin)
|
||||
{
|
||||
Db::query('DELETE FROM ' . Common::prefixTable('user_dashboard') . ' WHERE login = ?', array($userLogin));
|
||||
$this->getModel()->deleteAllLayoutsForUser($userLogin);
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
$dashboard = "login VARCHAR( 100 ) NOT NULL ,
|
||||
iddashboard INT NOT NULL ,
|
||||
name VARCHAR( 100 ) NULL DEFAULT NULL ,
|
||||
layout TEXT NOT NULL,
|
||||
PRIMARY KEY ( login , iddashboard )";
|
||||
|
||||
DbHelper::createTable('user_dashboard', $dashboard);
|
||||
Model::install();
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
Db::dropTables(Common::prefixTable('user_dashboard'));
|
||||
Model::uninstall();
|
||||
}
|
||||
|
||||
public function getClientSideTranslationKeys(&$translationKeys)
|
||||
|
|
@ -272,6 +250,8 @@ class Dashboard extends \Piwik\Plugin
|
|||
$translationKeys[] = 'Dashboard_LoadingWidget';
|
||||
$translationKeys[] = 'Dashboard_WidgetNotFound';
|
||||
$translationKeys[] = 'Dashboard_DashboardCopied';
|
||||
$translationKeys[] = 'Dashboard_Dashboard';
|
||||
$translationKeys[] = 'Dashboard_RemoveDefaultDashboardNotPossible';
|
||||
$translationKeys[] = 'General_Close';
|
||||
$translationKeys[] = 'General_Refresh';
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue