Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas ZILLIOX <thomas@zilliox.me>2013-08-05 13:38:24 +0400
committerThomas ZILLIOX <thomas@zilliox.me>2013-08-05 13:38:24 +0400
commitafcd488b37af164f28ec5b320eca5547ebd60ec9 (patch)
treea559c4dbfbd0b7c742cfce915e789e2c5cc82acc /plugins/Dashboard
parent9edf8c65fecd9b61679b7ca4d917d382c698e12f (diff)
parent86850ebd9c5a8ab41c367d0c8084ce87bccb87ef (diff)
Merge from master
Diffstat (limited to 'plugins/Dashboard')
-rw-r--r--plugins/Dashboard/API.php4
-rw-r--r--plugins/Dashboard/Controller.php92
-rw-r--r--plugins/Dashboard/Dashboard.php36
3 files changed, 74 insertions, 58 deletions
diff --git a/plugins/Dashboard/API.php b/plugins/Dashboard/API.php
index 59ae8b9ae1..dd87979739 100644
--- a/plugins/Dashboard/API.php
+++ b/plugins/Dashboard/API.php
@@ -7,6 +7,8 @@
* @category Piwik_Plugins
* @package Piwik_Dashboard
*/
+use Piwik\Piwik;
+use Piwik\WidgetsList;
/**
@@ -154,7 +156,7 @@ class Piwik_Dashboard_API
$module = $widget->parameters->module;
$action = $widget->parameters->action;
- return Piwik_IsWidgetDefined($module, $action);
+ return WidgetsList::isDefined($module, $action);
}
private function widgetIsNotHidden($widget)
diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php
index ec63d82e4a..7ffe0dc79e 100644
--- a/plugins/Dashboard/Controller.php
+++ b/plugins/Dashboard/Controller.php
@@ -7,13 +7,21 @@
* @category Piwik_Plugins
* @package Piwik_Dashboard
*/
+use Piwik\DataTable\Renderer\Json;
+use Piwik\Piwik;
+use Piwik\Common;
+use Piwik\Controller;
+use Piwik\Session\SessionNamespace;
+use Piwik\View;
+use Piwik\Db;
+use Piwik\WidgetsList;
/**
* Dashboard Controller
*
* @package Piwik_Dashboard
*/
-class Piwik_Dashboard_Controller extends Piwik_Controller
+class Piwik_Dashboard_Controller extends Controller
{
/**
* @var Piwik_Dashboard
@@ -29,13 +37,13 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
protected function _getDashboardView($template)
{
- $view = new Piwik_View($template);
+ $view = new View($template);
$this->setGeneralVariablesView($view);
- $view->availableWidgets = Piwik_Common::json_encode(Piwik_GetWidgetsList());
+ $view->availableWidgets = Common::json_encode(WidgetsList::get());
$view->availableLayouts = $this->getAvailableLayouts();
- $view->dashboardId = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
+ $view->dashboardId = Common::getRequestVar('idDashboard', 1, 'int');
$view->dashboardLayout = $this->getLayout($view->dashboardId);
return $view;
@@ -64,15 +72,15 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
{
$this->checkTokenInUrl();
- Piwik_DataTable_Renderer_Json::sendHeaderJSON();
- echo Piwik_Common::json_encode(Piwik_GetWidgetsList());
+ Json::sendHeaderJSON();
+ echo Common::json_encode(WidgetsList::get());
}
public function getDashboardLayout()
{
$this->checkTokenInUrl();
- $idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
+ $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
$layout = $this->getLayout($idDashboard);
@@ -86,9 +94,9 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
{
$this->checkTokenInUrl();
$layout = $this->dashboard->getDefaultLayout();
- $idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
+ $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
if (Piwik::isUserIsAnonymous()) {
- $session = new Piwik_Session_Namespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Piwik_Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
@@ -107,8 +115,8 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
{
$paramsBind = array($login, $idDashboard, $layout, $layout);
$query = sprintf('INSERT INTO %s (login, iddashboard, layout) VALUES (?,?,?) ON DUPLICATE KEY UPDATE layout=?',
- Piwik_Common::prefixTable('user_dashboard'));
- Piwik_Query($query, $paramsBind);
+ Common::prefixTable('user_dashboard'));
+ Db::query($query, $paramsBind);
}
/**
@@ -122,8 +130,8 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
{
$paramsBind = array($name, $login, $idDashboard);
$query = sprintf('UPDATE %s SET name = ? WHERE login = ? AND iddashboard = ?',
- Piwik_Common::prefixTable('user_dashboard'));
- Piwik_Query($query, $paramsBind);
+ Common::prefixTable('user_dashboard'));
+ Db::query($query, $paramsBind);
}
/**
@@ -137,13 +145,13 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
return;
}
- $idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
+ $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
// first layout can't be removed
if ($idDashboard != 1) {
$query = sprintf('DELETE FROM %s WHERE iddashboard = ? AND login = ?',
- Piwik_Common::prefixTable('user_dashboard'));
- Piwik_Query($query, array($idDashboard, Piwik::getCurrentUserLogin()));
+ Common::prefixTable('user_dashboard'));
+ Db::query($query, array($idDashboard, Piwik::getCurrentUserLogin()));
}
}
@@ -155,7 +163,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
$this->checkTokenInUrl();
if (Piwik::isUserIsAnonymous()) {
- Piwik_DataTable_Renderer_Json::sendHeaderJSON();
+ Json::sendHeaderJSON();
echo '[]';
return;
@@ -164,8 +172,8 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
$login = Piwik::getCurrentUserLogin();
$dashboards = $this->dashboard->getAllDashboards($login);
- Piwik_DataTable_Renderer_Json::sendHeaderJSON();
- echo Piwik_Common::json_encode($dashboards);
+ Json::sendHeaderJSON();
+ echo Common::json_encode($dashboards);
}
/**
@@ -183,8 +191,8 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
$user = Piwik::getCurrentUserLogin();
$nextId = $this->getNextIdDashboard($user);
- $name = urldecode(Piwik_Common::getRequestVar('name', '', 'string'));
- $type = urldecode(Piwik_Common::getRequestVar('type', 'default', 'string'));
+ $name = urldecode(Common::getRequestVar('name', '', 'string'));
+ $type = urldecode(Common::getRequestVar('type', 'default', 'string'));
$layout = '{}';
if ($type == 'default') {
@@ -192,18 +200,18 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
}
$query = sprintf('INSERT INTO %s (login, iddashboard, name, layout) VALUES (?, ?, ?, ?)',
- Piwik_Common::prefixTable('user_dashboard'));
- Piwik_Query($query, array($user, $nextId, $name, $layout));
+ Common::prefixTable('user_dashboard'));
+ Db::query($query, array($user, $nextId, $name, $layout));
- Piwik_DataTable_Renderer_Json::sendHeaderJSON();
- echo Piwik_Common::json_encode($nextId);
+ Json::sendHeaderJSON();
+ echo Common::json_encode($nextId);
}
private function getNextIdDashboard($login)
{
$nextIdQuery = sprintf('SELECT MAX(iddashboard)+1 FROM %s WHERE login = ?',
- Piwik_Common::prefixTable('user_dashboard'));
- $nextId = Piwik_FetchOne($nextIdQuery, array($login));
+ Common::prefixTable('user_dashboard'));
+ $nextId = Db::fetchOne($nextIdQuery, array($login));
if (empty($nextId)) {
$nextId = 1;
@@ -221,20 +229,20 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
return;
}
$login = Piwik::getCurrentUserLogin();
- $name = urldecode(Piwik_Common::getRequestVar('name', '', 'string'));
- $user = urldecode(Piwik_Common::getRequestVar('user', '', 'string'));
- $idDashboard = Piwik_Common::getRequestVar('dashboardId', 0, 'int');
+ $name = urldecode(Common::getRequestVar('name', '', 'string'));
+ $user = urldecode(Common::getRequestVar('user', '', 'string'));
+ $idDashboard = Common::getRequestVar('dashboardId', 0, 'int');
$layout = $this->dashboard->getLayoutForUser($login, $idDashboard);
if ($layout !== false) {
$nextId = $this->getNextIdDashboard($user);
$query = sprintf('INSERT INTO %s (login, iddashboard, name, layout) VALUES (?, ?, ?, ?)',
- Piwik_Common::prefixTable('user_dashboard'));
- Piwik_Query($query, array($user, $nextId, $name, $layout));
+ Common::prefixTable('user_dashboard'));
+ Db::query($query, array($user, $nextId, $name, $layout));
- Piwik_DataTable_Renderer_Json::sendHeaderJSON();
- echo Piwik_Common::json_encode($nextId);
+ Json::sendHeaderJSON();
+ echo Common::json_encode($nextId);
return;
}
}
@@ -248,11 +256,11 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
{
$this->checkTokenInUrl();
- $layout = Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('layout'));
- $idDashboard = Piwik_Common::getRequestVar('idDashboard', 1, 'int');
- $name = Piwik_Common::getRequestVar('name', '', 'string');
+ $layout = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
+ $idDashboard = Common::getRequestVar('idDashboard', 1, 'int');
+ $name = Common::getRequestVar('name', '', 'string');
if (Piwik::isUserIsAnonymous()) {
- $session = new Piwik_Session_Namespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Piwik_Dashboard");
$session->dashboardLayout = $layout;
$session->setExpirationSeconds(1800);
} else {
@@ -271,11 +279,11 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
$this->checkTokenInUrl();
if (Piwik::isUserIsSuperUser()) {
- $layout = Piwik_Common::unsanitizeInputValue(Piwik_Common::getRequestVar('layout'));
+ $layout = Common::unsanitizeInputValue(Common::getRequestVar('layout'));
$paramsBind = array('', '1', $layout, $layout);
$query = sprintf('INSERT INTO %s (login, iddashboard, layout) VALUES (?,?,?) ON DUPLICATE KEY UPDATE layout=?',
- Piwik_Common::prefixTable('user_dashboard'));
- Piwik_Query($query, $paramsBind);
+ Common::prefixTable('user_dashboard'));
+ Db::query($query, $paramsBind);
}
}
@@ -290,7 +298,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller
{
if (Piwik::isUserIsAnonymous()) {
- $session = new Piwik_Session_Namespace("Piwik_Dashboard");
+ $session = new SessionNamespace("Piwik_Dashboard");
if (!isset($session->dashboardLayout)) {
return $this->dashboard->getDefaultLayout();
diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php
index d8909fbf01..13d25ee9cb 100644
--- a/plugins/Dashboard/Dashboard.php
+++ b/plugins/Dashboard/Dashboard.php
@@ -8,11 +8,17 @@
* @category Piwik_Plugins
* @package Piwik_Dashboard
*/
+use Piwik\Piwik;
+use Piwik\Common;
+use Piwik\Plugin;
+use Piwik\Site;
+use Piwik\Db;
+use Piwik\WidgetsList;
/**
* @package Piwik_Dashboard
*/
-class Piwik_Dashboard extends Piwik_Plugin
+class Piwik_Dashboard extends Plugin
{
/**
* @see Piwik_Plugin::getListHooksRegistered
@@ -41,8 +47,8 @@ class Piwik_Dashboard extends Piwik_Plugin
{
$paramsBind = array($login, $idDashboard);
$query = sprintf('SELECT layout FROM %s WHERE login = ? AND iddashboard = ?',
- Piwik_Common::prefixTable('user_dashboard'));
- $return = Piwik_FetchAll($query, $paramsBind);
+ Common::prefixTable('user_dashboard'));
+ $return = Db::fetchAll($query, $paramsBind);
if (count($return) == 0) {
return false;
@@ -92,8 +98,8 @@ class Piwik_Dashboard extends Piwik_Plugin
public function getAllDashboards($login)
{
- $dashboards = Piwik_FetchAll('SELECT iddashboard, name, layout
- FROM ' . Piwik_Common::prefixTable('user_dashboard') .
+ $dashboards = Db::fetchAll('SELECT iddashboard, name, layout
+ FROM ' . Common::prefixTable('user_dashboard') .
' WHERE login = ? ORDER BY iddashboard', array($login));
$nameless = 1;
@@ -108,7 +114,7 @@ class Piwik_Dashboard extends Piwik_Plugin
$nameless++;
}
- $dashboard['name'] = Piwik_Common::unsanitizeInputValue($dashboard['name']);
+ $dashboard['name'] = Common::unsanitizeInputValue($dashboard['name']);
$layout = '[]';
if (!empty($dashboard['layout'])) {
@@ -157,7 +163,7 @@ class Piwik_Dashboard extends Piwik_Plugin
if (isset($widget->parameters->module)) {
$controllerName = $widget->parameters->module;
$controllerAction = $widget->parameters->action;
- if (!Piwik_IsWidgetDefined($controllerName, $controllerAction)) {
+ if (!WidgetsList::isDefined($controllerName, $controllerAction)) {
unset($row[$widgetId]);
}
} else {
@@ -179,12 +185,12 @@ class Piwik_Dashboard extends Piwik_Plugin
$layout = str_replace("\\\"", "\"", $layout);
$layout = str_replace("\n", "", $layout);
- return Piwik_Common::json_decode($layout, $assoc = false);
+ return Common::json_decode($layout, $assoc = false);
}
public function encodeLayout($layout)
{
- return Piwik_Common::json_encode($layout);
+ return Common::json_encode($layout);
}
public function addMenus()
@@ -209,8 +215,8 @@ class Piwik_Dashboard extends Piwik_Plugin
{
$tooltip = false;
try {
- $idSite = Piwik_Common::getRequestVar('idSite');
- $tooltip = Piwik_Translate('Dashboard_TopLinkTooltip', Piwik_Site::getNameFor($idSite));
+ $idSite = Common::getRequestVar('idSite');
+ $tooltip = Piwik_Translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
} catch (Exception $ex) {
// if no idSite parameter, show no tooltip
}
@@ -236,21 +242,21 @@ class Piwik_Dashboard extends Piwik_Plugin
public function deleteDashboardLayout($userLogin)
{
- Piwik_Query('DELETE FROM ' . Piwik_Common::prefixTable('user_dashboard') . ' WHERE login = ?', array($userLogin));
+ Db::query('DELETE FROM ' . Common::prefixTable('user_dashboard') . ' WHERE login = ?', array($userLogin));
}
public function install()
{
// we catch the exception
try {
- $sql = "CREATE TABLE " . Piwik_Common::prefixTable('user_dashboard') . " (
+ $sql = "CREATE TABLE " . Common::prefixTable('user_dashboard') . " (
login VARCHAR( 100 ) NOT NULL ,
iddashboard INT NOT NULL ,
name VARCHAR( 100 ) NULL DEFAULT NULL ,
layout TEXT NOT NULL,
PRIMARY KEY ( login , iddashboard )
) DEFAULT CHARSET=utf8 ";
- Piwik_Exec($sql);
+ Db::exec($sql);
} catch (Exception $e) {
// mysql code error 1050:table already exists
// see bug #153 http://dev.piwik.org/trac/ticket/153
@@ -262,6 +268,6 @@ class Piwik_Dashboard extends Piwik_Plugin
public function uninstall()
{
- Piwik_DropTables(Piwik_Common::prefixTable('user_dashboard'));
+ Db::dropTables(Common::prefixTable('user_dashboard'));
}
}