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
path: root/core
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
commit5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch)
tree5f30daf7bc14373fb1bbd0504ce11a771dafc02f /core
parentae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff)
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'core')
-rw-r--r--core/API/DataTableGenericFilter.php5
-rw-r--r--core/API/DataTableManipulator.php21
-rw-r--r--core/API/DataTableManipulator/Flattener.php7
-rw-r--r--core/API/DataTableManipulator/LabelFilter.php16
-rw-r--r--core/API/DocumentationGenerator.php32
-rw-r--r--core/API/Proxy.php59
-rw-r--r--core/API/Request.php31
-rw-r--r--core/API/ResponseBuilder.php25
-rw-r--r--core/Access.php14
-rw-r--r--core/ArchiveProcessor/Day.php10
-rw-r--r--core/AssetManager.php21
-rw-r--r--core/CacheFile.php7
-rw-r--r--core/Common.php19
-rw-r--r--core/Controller.php89
-rw-r--r--core/Controller/Admin.php25
-rw-r--r--core/Cookie.php4
-rw-r--r--core/DataAccess/ArchiveSelector.php16
-rw-r--r--core/DataAccess/ArchiveTableCreator.php16
-rw-r--r--core/DataAccess/ArchiveWriter.php16
-rw-r--r--core/DataAccess/LogAggregator.php8
-rw-r--r--core/DataArray.php16
-rw-r--r--core/DataTable/Filter/MetadataCallbackReplace.php1
-rw-r--r--core/DataTable/Renderer.php2
-rw-r--r--core/DataTable/Renderer/Rss.php4
-rw-r--r--core/Db.php (renamed from core/PluginsFunctions/Sql.php)350
-rw-r--r--core/Db/Adapter.php8
-rw-r--r--core/Db/Adapter/Mysqli.php3
-rw-r--r--core/Db/Adapter/Pdo/Mssql.php21
-rw-r--r--core/Db/Adapter/Pdo/Mysql.php12
-rw-r--r--core/Db/Adapter/Pdo/Pgsql.php9
-rw-r--r--core/Db/AdapterInterface.php (renamed from core/Db/Adapter/Interface.php)6
-rw-r--r--core/Db/Schema.php15
-rw-r--r--core/Db/Schema/Myisam.php25
-rw-r--r--core/Db/SchemaInterface.php (renamed from core/Db/Schema/Interface.php)4
-rw-r--r--core/ExceptionHandler.php3
-rw-r--r--core/FrontController.php64
-rw-r--r--core/HTMLPurifier.php50
-rw-r--r--core/Http.php58
-rw-r--r--core/IP.php301
-rw-r--r--core/JqplotDataGenerator.php63
-rw-r--r--core/JqplotDataGenerator/Evolution.php24
-rw-r--r--core/Log.php109
-rw-r--r--core/Log/APICall.php20
-rw-r--r--core/Log/Error.php25
-rw-r--r--core/Log/Exception.php21
-rw-r--r--core/Log/Formatter.php62
-rw-r--r--core/Log/Message.php88
-rw-r--r--core/Mail.php12
-rw-r--r--core/Menu/Admin.php92
-rw-r--r--core/Menu/Main.php70
-rw-r--r--core/Menu/MenuAbstract.php (renamed from core/Menu/Abstract.php)23
-rw-r--r--core/Menu/Top.php48
-rw-r--r--core/Nonce.php13
-rw-r--r--core/Option.php42
-rw-r--r--core/Piwik.php137
-rw-r--r--core/Plugin.php2
-rw-r--r--core/Plugin/Config.php4
-rw-r--r--core/Plugin/MetadataLoader.php4
-rw-r--r--core/PluginsManager.php18
-rw-r--r--core/ProxyHeaders.php4
-rw-r--r--core/QuickForm2.php15
-rw-r--r--core/RankingQuery.php12
-rw-r--r--core/ReportRenderer.php20
-rw-r--r--core/ReportRenderer/Html.php38
-rw-r--r--core/ReportRenderer/Pdf.php37
-rw-r--r--core/ScheduledTask.php18
-rw-r--r--core/ScheduledTime.php15
-rw-r--r--core/ScheduledTime/Daily.php5
-rw-r--r--core/ScheduledTime/Hourly.php5
-rw-r--r--core/ScheduledTime/Monthly.php5
-rw-r--r--core/ScheduledTime/Weekly.php5
-rw-r--r--core/Session.php10
-rw-r--r--core/Session/Namespace.php2
-rw-r--r--core/Session/SaveHandler/DbTable.php2
-rw-r--r--core/TCPDF.php6
-rw-r--r--core/TaskScheduler.php18
-rw-r--r--core/Timer.php4
-rw-r--r--core/Tracker.php80
-rw-r--r--core/Tracker/Action.php17
-rw-r--r--core/Tracker/Cache.php12
-rw-r--r--core/Tracker/Db.php9
-rw-r--r--core/Tracker/Db/Exception.php2
-rw-r--r--core/Tracker/Db/Mysqli.php2
-rw-r--r--core/Tracker/Db/Pdo/Mysql.php2
-rw-r--r--core/Tracker/Db/Pdo/Pgsql.php2
-rw-r--r--core/Tracker/GoalManager.php19
-rw-r--r--core/Tracker/IgnoreCookie.php11
-rw-r--r--core/Tracker/Referer.php2
-rw-r--r--core/Tracker/Request.php23
-rw-r--r--core/Tracker/Visit.php40
-rw-r--r--core/Tracker/VisitExcluded.php7
-rw-r--r--core/TranslationWriter.php5
-rw-r--r--core/Twig.php36
-rw-r--r--core/Unzip.php10
-rwxr-xr-xcore/Unzip/Gzip.php2
-rw-r--r--core/Unzip/Interface.php2
-rw-r--r--core/Unzip/PclZip.php2
-rwxr-xr-xcore/Unzip/Tar.php2
-rw-r--r--core/Unzip/ZipArchive.php2
-rw-r--r--core/UpdateCheck.php19
-rw-r--r--core/Updater.php18
-rw-r--r--core/Updates.php7
-rw-r--r--core/Updates/0.2.10.php4
-rw-r--r--core/Updates/0.2.12.php4
-rw-r--r--core/Updates/0.2.13.php4
-rw-r--r--core/Updates/0.2.24.php4
-rw-r--r--core/Updates/0.2.27.php4
-rw-r--r--core/Updates/0.2.32.php4
-rw-r--r--core/Updates/0.2.33.php4
-rw-r--r--core/Updates/0.2.34.php3
-rw-r--r--core/Updates/0.2.35.php4
-rw-r--r--core/Updates/0.2.37.php4
-rw-r--r--core/Updates/0.4.1.php4
-rw-r--r--core/Updates/0.4.2.php4
-rw-r--r--core/Updates/0.4.4.php3
-rw-r--r--core/Updates/0.4.php4
-rw-r--r--core/Updates/0.5.4.php4
-rw-r--r--core/Updates/0.5.5.php4
-rw-r--r--core/Updates/0.5.php4
-rw-r--r--core/Updates/0.6-rc1.php4
-rw-r--r--core/Updates/0.6.2.php3
-rw-r--r--core/Updates/0.6.3.php4
-rw-r--r--core/Updates/0.7.php4
-rw-r--r--core/Updates/0.9.1.php4
-rw-r--r--core/Updates/1.1.php3
-rwxr-xr-xcore/Updates/1.10-b4.php3
-rwxr-xr-xcore/Updates/1.10.1.php3
-rwxr-xr-xcore/Updates/1.10.2-b1.php4
-rw-r--r--core/Updates/1.10.2-b2.php4
-rw-r--r--core/Updates/1.11-b1.php3
-rw-r--r--core/Updates/1.12-b1.php4
-rw-r--r--core/Updates/1.12-b15.php3
-rw-r--r--core/Updates/1.12-b16.php4
-rw-r--r--core/Updates/1.2-rc1.php4
-rw-r--r--core/Updates/1.2-rc2.php3
-rw-r--r--core/Updates/1.2.3.php4
-rw-r--r--core/Updates/1.2.5-rc1.php4
-rw-r--r--core/Updates/1.2.5-rc7.php4
-rw-r--r--core/Updates/1.4-rc1.php4
-rw-r--r--core/Updates/1.4-rc2.php4
-rw-r--r--core/Updates/1.5-b1.php4
-rw-r--r--core/Updates/1.5-b2.php4
-rw-r--r--core/Updates/1.5-b3.php4
-rw-r--r--core/Updates/1.5-b4.php4
-rw-r--r--core/Updates/1.5-b5.php4
-rw-r--r--core/Updates/1.5-rc6.php3
-rw-r--r--core/Updates/1.6-b1.php4
-rw-r--r--core/Updates/1.6-rc1.php3
-rw-r--r--core/Updates/1.7-b1.php4
-rw-r--r--core/Updates/1.7.2-rc5.php4
-rwxr-xr-xcore/Updates/1.7.2-rc7.php8
-rw-r--r--core/Updates/1.8.3-b1.php10
-rw-r--r--core/Updates/1.8.4-b1.php4
-rwxr-xr-xcore/Updates/1.9-b16.php4
-rwxr-xr-xcore/Updates/1.9-b19.php4
-rwxr-xr-xcore/Updates/1.9-b9.php4
-rw-r--r--core/Updates/1.9.1-b2.php4
-rwxr-xr-xcore/Updates/1.9.3-b10.php3
-rw-r--r--core/Updates/1.9.3-b3.php3
-rwxr-xr-xcore/Updates/1.9.3-b8.php4
-rw-r--r--core/Url.php18
-rw-r--r--core/Version.php4
-rw-r--r--core/View.php41
-rw-r--r--core/View/Interface.php2
-rw-r--r--core/View/ReportsByDimension.php9
-rw-r--r--core/ViewDataTable.php131
-rw-r--r--core/ViewDataTable/Cloud.php8
-rw-r--r--core/ViewDataTable/GenerateGraphHTML.php16
-rw-r--r--core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php5
-rw-r--r--core/ViewDataTable/GenerateGraphHTML/ChartPie.php2
-rw-r--r--core/ViewDataTable/GenerateGraphHTML/ChartVerticalBar.php2
-rw-r--r--core/ViewDataTable/HtmlTable.php14
-rw-r--r--core/ViewDataTable/HtmlTable/AllColumns.php5
-rw-r--r--core/ViewDataTable/HtmlTable/Goals.php2
-rw-r--r--core/ViewDataTable/Sparkline.php5
-rw-r--r--core/WidgetsList.php (renamed from core/PluginsFunctions/WidgetsList.php)46
-rw-r--r--core/functions.php259
177 files changed, 1878 insertions, 1744 deletions
diff --git a/core/API/DataTableGenericFilter.php b/core/API/DataTableGenericFilter.php
index fec5bb7e94..111453520c 100644
--- a/core/API/DataTableGenericFilter.php
+++ b/core/API/DataTableGenericFilter.php
@@ -8,6 +8,9 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API;
+
+use Exception;
use Piwik\Common;
use Piwik\DataTable;
use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
@@ -16,7 +19,7 @@ use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal;
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_DataTableGenericFilter
+class DataTableGenericFilter
{
private static $genericFiltersInfo = null;
diff --git a/core/API/DataTableManipulator.php b/core/API/DataTableManipulator.php
index 03541cf4ff..1fce679f95 100644
--- a/core/API/DataTableManipulator.php
+++ b/core/API/DataTableManipulator.php
@@ -8,15 +8,21 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API;
+
+use Exception;
use Piwik\DataTable\Row;
use Piwik\Period\Range;
use Piwik\DataTable;
+use Piwik_API_API;
+use Piwik\API\Proxy;
+use Piwik\API\ResponseBuilder;
/**
* Base class for manipulating data tables.
* It provides generic mechanisms like iteration and loading subtables.
*
- * The manipulators are used in Piwik_API_ResponseBuilder and are triggered by
+ * The manipulators are used in ResponseBuilder and are triggered by
* API parameters. They are not filters because they don't work on the pre-
* fetched nested data tables. Instead, they load subtables using this base
* class. This way, they can only load the tables they really need instead
@@ -27,7 +33,7 @@ use Piwik\DataTable;
* @package Piwik
* @subpackage Piwik_API
*/
-abstract class Piwik_API_DataTableManipulator
+abstract class DataTableManipulator
{
protected $apiModule;
protected $apiMethod;
@@ -92,7 +98,7 @@ abstract class Piwik_API_DataTableManipulator
* Load the subtable for a row.
* Returns null if none is found.
*
- * @param DataTable $dataTable
+ * @param DataTable $dataTable
* @param Row $row
*
* @return DataTable
@@ -114,7 +120,7 @@ abstract class Piwik_API_DataTableManipulator
if ($dataTable) {
$period = $dataTable->metadata['period'];
if ($period instanceof Range) {
- $request['date'] = $period->getDateStart().','.$period->getDateEnd();
+ $request['date'] = $period->getDateStart() . ',' . $period->getDateEnd();
} else {
$request['date'] = $period->getDateStart()->toString();
}
@@ -132,8 +138,8 @@ abstract class Piwik_API_DataTableManipulator
// run it on the flattened table.
unset($request['filter_pattern_recursive']);
- $dataTable = Piwik_API_Proxy::getInstance()->call($class, $method, $request);
- $response = new Piwik_API_ResponseBuilder($format = 'original', $request);
+ $dataTable = Proxy::getInstance()->call($class, $method, $request);
+ $response = new ResponseBuilder($format = 'original', $request);
$dataTable = $response->getResponse($dataTable);
if (method_exists($dataTable, 'applyQueuedFilters')) {
$dataTable->applyQueuedFilters();
@@ -144,7 +150,7 @@ abstract class Piwik_API_DataTableManipulator
/**
* In this method, subclasses can clean up the request array for loading subtables
- * in order to make Piwik_API_ResponseBuilder behave correctly (e.g. not trigger the
+ * in order to make ResponseBuilder behave correctly (e.g. not trigger the
* manipulator again).
*
* @param $request
@@ -169,5 +175,4 @@ abstract class Piwik_API_DataTableManipulator
}
return $this->apiMethodForSubtable;
}
-
}
diff --git a/core/API/DataTableManipulator/Flattener.php b/core/API/DataTableManipulator/Flattener.php
index 6ccae47fdd..ab9127d338 100644
--- a/core/API/DataTableManipulator/Flattener.php
+++ b/core/API/DataTableManipulator/Flattener.php
@@ -8,8 +8,11 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API\DataTableManipulator;
+
use Piwik\DataTable;
use Piwik\DataTable\Row;
+use Piwik\API\DataTableManipulator;
/**
* This class is responsible for flattening data tables.
@@ -20,7 +23,7 @@ use Piwik\DataTable\Row;
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_DataTableManipulator_Flattener extends Piwik_API_DataTableManipulator
+class Flattener extends DataTableManipulator
{
private $includeAggregateRows = false;
@@ -66,7 +69,7 @@ class Piwik_API_DataTableManipulator_Flattener extends Piwik_API_DataTableManipu
if ($this->includeAggregateRows) {
$dataTable->applyQueuedFilters();
}
-
+
$newDataTable = $dataTable->getEmptyClone($keepFilters = false);
foreach ($dataTable->getRows() as $row) {
$this->flattenRow($row, $newDataTable);
diff --git a/core/API/DataTableManipulator/LabelFilter.php b/core/API/DataTableManipulator/LabelFilter.php
index 56ccd4366e..f8eb91ec6f 100644
--- a/core/API/DataTableManipulator/LabelFilter.php
+++ b/core/API/DataTableManipulator/LabelFilter.php
@@ -8,9 +8,13 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API\DataTableManipulator;
+
use Piwik\Common;
use Piwik\DataTable;
use Piwik\DataTable\Row;
+use Piwik\API\DataTableManipulator;
+use false;
/**
* This class is responsible for handling the label parameter that can be
@@ -23,7 +27,7 @@ use Piwik\DataTable\Row;
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_DataTableManipulator_LabelFilter extends Piwik_API_DataTableManipulator
+class LabelFilter extends DataTableManipulator
{
const SEPARATOR_RECURSIVE_LABEL = '>';
@@ -96,7 +100,7 @@ class Piwik_API_DataTableManipulator_LabelFilter extends Piwik_API_DataTableMani
}
/**
- * Clean up request for Piwik_API_ResponseBuilder to behave correctly
+ * Clean up request for ResponseBuilder to behave correctly
*
* @param $request
*/
@@ -108,7 +112,7 @@ class Piwik_API_DataTableManipulator_LabelFilter extends Piwik_API_DataTableMani
/**
* Use variations of the label to make it easier to specify the desired label
*
- * Note: The HTML Encoded version must be tried first, since in Piwik_API_ResponseBuilder the $label is unsanitized
+ * Note: The HTML Encoded version must be tried first, since in ResponseBuilder the $label is unsanitized
* via Common::unsanitizeLabelParameter.
*
* @param string $label
@@ -117,19 +121,19 @@ class Piwik_API_DataTableManipulator_LabelFilter extends Piwik_API_DataTableMani
private function getLabelVariations($label)
{
static $pageTitleReports = array('getPageTitles', 'getEntryPageTitles', 'getExitPageTitles');
-
+
$variations = array();
$label = urldecode($label);
$label = trim($label);
- $sanitizedLabel = Common::sanitizeInputValue( $label );
+ $sanitizedLabel = Common::sanitizeInputValue($label);
$variations[] = $sanitizedLabel;
if ($this->apiModule == 'Actions'
&& in_array($this->apiMethod, $pageTitleReports)
) {
// special case: the Actions.getPageTitles report prefixes some labels with a blank.
- // the blank might be passed by the user but is removed in Piwik_API_Request::getRequestArrayFromString.
+ // the blank might be passed by the user but is removed in Request::getRequestArrayFromString.
$variations[] = ' ' . $sanitizedLabel;
$variations[] = ' ' . $label;
}
diff --git a/core/API/DocumentationGenerator.php b/core/API/DocumentationGenerator.php
index e928409dfa..8c2b0ca37a 100644
--- a/core/API/DocumentationGenerator.php
+++ b/core/API/DocumentationGenerator.php
@@ -8,14 +8,20 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\API\Proxy;
+use Piwik_API_Proxy_NoDefaultValue;
+use Piwik_Url;
/**
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_DocumentationGenerator
+class DocumentationGenerator
{
protected $modulesToHide = array('CoreAdminHome', 'DBStats');
protected $countPluginsLoaded = 0;
@@ -29,7 +35,7 @@ class Piwik_API_DocumentationGenerator
foreach ($plugins as $plugin) {
$plugin = Common::unprefixClass($plugin);
try {
- Piwik_API_Proxy::getInstance()->registerClass('Piwik_' . $plugin . '_API');
+ Proxy::getInstance()->registerClass('Piwik_' . $plugin . '_API');
} catch (Exception $e) {
}
}
@@ -57,8 +63,8 @@ class Piwik_API_DocumentationGenerator
'date' => Common::getRequestVar('date', 'today', 'string')
);
- foreach (Piwik_API_Proxy::getInstance()->getMetadata() as $class => $info) {
- $moduleName = Piwik_API_Proxy::getInstance()->getModuleNameFromClassName($class);
+ foreach (Proxy::getInstance()->getMetadata() as $class => $info) {
+ $moduleName = Proxy::getInstance()->getModuleNameFromClassName($class);
if (in_array($moduleName, $this->modulesToHide)) {
continue;
}
@@ -87,9 +93,9 @@ class Piwik_API_DocumentationGenerator
}
$exampleUrl = $prefixUrls . $exampleUrl;
$str .= " [ Example in
- <a target=_blank href='$exampleUrl&format=xml$token_auth'>XML</a>,
- <a target=_blank href='$exampleUrl&format=JSON$token_auth'>Json</a>,
- <a target=_blank href='$exampleUrl&format=Tsv$token_auth&translateColumnNames=1'>Tsv (Excel)</a>
+ <a target=_blank href='$exampleUrl&format=xml$token_auth'>XML</a>,
+ <a target=_blank href='$exampleUrl&format=JSON$token_auth'>Json</a>,
+ <a target=_blank href='$exampleUrl&format=Tsv$token_auth&translateColumnNames=1'>Tsv (Excel)</a>
$lastNUrls
]";
} else {
@@ -104,7 +110,7 @@ class Piwik_API_DocumentationGenerator
}
$str = "<h2 id='topApiRef' name='topApiRef'>Quick access to APIs</h2>
- $toc
+ $toc
$str";
return $str;
}
@@ -129,7 +135,7 @@ class Piwik_API_DocumentationGenerator
'languageCode' => 'fr',
'url' => 'http://forum.piwik.org/',
- 'pageUrl' => 'http://forum.piwik.org/',
+ 'pageUrl' => 'http://forum.piwik.org/',
'apiModule' => 'UserCountry',
'apiAction' => 'getCountry',
'lastMinutes' => '30',
@@ -165,7 +171,7 @@ class Piwik_API_DocumentationGenerator
}
// we try to give an URL example to call the API
- $aParameters = Piwik_API_Proxy::getInstance()->getParametersList($class, $methodName);
+ $aParameters = Proxy::getInstance()->getParametersList($class, $methodName);
// Kindly force some known generic parameters to appear in the final list
// the parameter 'format' can be set to all API methods (used in tests)
// the parameter 'hideIdSubDatable' is used for integration tests only
@@ -189,7 +195,7 @@ class Piwik_API_DocumentationGenerator
$aParameters['showColumns'] = false;
$aParameters['filter_pattern_recursive'] = false;
- $moduleName = Piwik_API_Proxy::getInstance()->getModuleNameFromClassName($class);
+ $moduleName = Proxy::getInstance()->getModuleNameFromClassName($class);
$aParameters = array_merge(array('module' => 'API', 'method' => $moduleName . '.' . $methodName), $aParameters);
foreach ($aParameters as $nameVariable => &$defaultValue) {
@@ -204,7 +210,6 @@ class Piwik_API_DocumentationGenerator
return '?' . Piwik_Url::getQueryStringFromParameters($aParameters);
}
-
/**
* Returns the methods $class.$name parameters (and default value if provided) as a string.
*
@@ -214,7 +219,7 @@ class Piwik_API_DocumentationGenerator
*/
public function getParametersString($class, $name)
{
- $aParameters = Piwik_API_Proxy::getInstance()->getParametersList($class, $name);
+ $aParameters = Proxy::getInstance()->getParametersList($class, $name);
$asParameters = array();
foreach ($aParameters as $nameVariable => $defaultValue) {
// Do not show API parameters starting with _
@@ -235,5 +240,4 @@ class Piwik_API_DocumentationGenerator
$sParameters = implode(", ", $asParameters);
return "($sParameters)";
}
-
}
diff --git a/core/API/Proxy.php b/core/API/Proxy.php
index 08810ab396..8579e4a13a 100644
--- a/core/API/Proxy.php
+++ b/core/API/Proxy.php
@@ -8,17 +8,14 @@
* @category Piwik
* @package Piwik
*/
-use Piwik\Common;
-/**
- * To differentiate between "no value" and default value of null
- *
- * @package Piwik
- * @subpackage Piwik_API
- */
-class Piwik_API_Proxy_NoDefaultValue
-{
-}
+namespace Piwik\API;
+use Exception;
+use Piwik\Common;
+use Piwik\Timer;
+use ReflectionClass;
+use ReflectionMethod;
+use Zend_Registry;
/**
* Proxy is a singleton that has the knowledge of every method available, their parameters
@@ -31,7 +28,7 @@ class Piwik_API_Proxy_NoDefaultValue
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_Proxy
+class Proxy
{
// array of already registered plugins names
protected $alreadyRegistered = array();
@@ -44,7 +41,7 @@ class Piwik_API_Proxy
/**
* Singleton instance
- * @var self|null
+ * @var \Piwik\API\Proxy|null
*/
static private $instance = null;
@@ -59,14 +56,14 @@ class Piwik_API_Proxy
/**
* Singleton, returns instance
*
- * @return Piwik_API_Proxy
+ * @return \Piwik\API\Proxy
*/
static public function getInstance()
{
- if (self::$instance == null) {
- self::$instance = new self;
+ if (\Piwik\API\self::$instance == null) {
+ \Piwik\API\self::$instance = new \Piwik\API\self;
}
- return self::$instance;
+ return \Piwik\API\self::$instance;
}
/**
@@ -154,7 +151,7 @@ class Piwik_API_Proxy
* @param array $parametersRequest The parameters pairs (name=>value)
*
* @return mixed|null
- * @throws Exception|Access_NoAccessException
+ * @throws Exception|\Piwik\NoAccessException
*/
public function call($className, $methodName, $parametersRequest)
{
@@ -183,7 +180,7 @@ class Piwik_API_Proxy
$finalParameters = $this->getRequestParametersArray($parameterNamesDefaultValues, $parametersRequest);
// start the timer
- $timer = new Piwik_Timer();
+ $timer = new Timer();
// call the method
$returnedValue = call_user_func_array(array($object, $methodName), $finalParameters);
@@ -192,12 +189,12 @@ class Piwik_API_Proxy
if (substr($className, 0, 6) == 'Piwik_' && substr($className, -4) == '_API') {
$pluginName = substr($className, 6, -4);
Piwik_PostEvent('API.Proxy.processReturnValue', array(
- &$returnedValue,
- array('className' => $className,
- 'module' => $pluginName,
- 'action' => $methodName,
- 'parameters' => &$parametersRequest)
- ));
+ &$returnedValue,
+ array('className' => $className,
+ 'module' => $pluginName,
+ 'action' => $methodName,
+ 'parameters' => &$parametersRequest)
+ ));
}
// Restore the request
@@ -285,7 +282,7 @@ class Piwik_API_Proxy
} else {
try {
- if( $name == 'segment' && !empty($parametersRequest['segment'])) {
+ if ($name == 'segment' && !empty($parametersRequest['segment'])) {
// segment parameter is an exception: we do not want to sanitize user input or it would break the segment encoding
$requestValue = ($parametersRequest['segment']);
} else {
@@ -318,7 +315,7 @@ class Piwik_API_Proxy
*/
private function includeApiFile($fileName)
{
- $module = self::getModuleNameFromClassName($fileName);
+ $module = \Piwik\API\self::getModuleNameFromClassName($fileName);
$path = PIWIK_INCLUDE_PATH . '/plugins/' . $module . '/API.php';
if (is_readable($path)) {
@@ -410,3 +407,13 @@ class Piwik_API_Proxy
}
}
}
+
+/**
+ * To differentiate between "no value" and default value of null
+ *
+ * @package Piwik
+ * @subpackage Piwik_API
+ */
+class Piwik_API_Proxy_NoDefaultValue
+{
+}
diff --git a/core/API/Request.php b/core/API/Request.php
index 7a7569e59c..168da13ac3 100644
--- a/core/API/Request.php
+++ b/core/API/Request.php
@@ -8,10 +8,18 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API;
+
+use Exception;
+use Piwik\API\DataTableGenericFilter;
+use Piwik\API\Proxy;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Access;
use Piwik\DataTable;
+use Piwik\Url;
+use Piwik\API\ResponseBuilder;
+use Piwik_FrontController_PluginDeactivatedException;
/**
* An API request is the object used to make a call to the API and get the result.
@@ -23,7 +31,7 @@ use Piwik\DataTable;
* (see examples in the documentation http://piwik.org/docs/analytics-api)
*
* Example:
- * $request = new Piwik_API_Request('
+ * $request = new Request('
* method=UserSettings.getWideScreen
* &idSite=1
* &date=yesterday
@@ -39,7 +47,7 @@ use Piwik\DataTable;
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_Request
+class Request
{
protected $request = null;
@@ -54,7 +62,7 @@ class Piwik_API_Request
$defaultRequest = $_GET + $_POST;
$requestRaw = self::getRequestParametersGET();
- if(!empty($requestRaw['segment'])) {
+ if (!empty($requestRaw['segment'])) {
$defaultRequest['segment'] = $requestRaw['segment'];
}
@@ -74,7 +82,6 @@ class Piwik_API_Request
$requestParsed = Common::getArrayFromQueryString($request);
$requestArray = $requestParsed + $defaultRequest;
-
}
foreach ($requestArray as &$element) {
@@ -130,7 +137,7 @@ class Piwik_API_Request
$outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $this->request));
// create the response
- $response = new Piwik_API_ResponseBuilder($outputFormat, $this->request);
+ $response = new ResponseBuilder($outputFormat, $this->request);
try {
// read parameters
@@ -146,7 +153,7 @@ class Piwik_API_Request
self::reloadAuthUsingTokenAuth($this->request);
// call the method
- $returnedValue = Piwik_API_Proxy::getInstance()->call($moduleClass, $method, $this->request);
+ $returnedValue = Proxy::getInstance()->call($moduleClass, $method, $this->request);
$toReturn = $response->getResponse($returnedValue, $module, $method);
} catch (Exception $e) {
@@ -207,7 +214,7 @@ class Piwik_API_Request
$params = $paramOverride + $params;
// process request
- $request = new Piwik_API_Request($params);
+ $request = new Request($params);
return $request->process();
}
@@ -216,16 +223,16 @@ class Piwik_API_Request
*/
public static function getRequestParametersGET()
{
- if(empty($_SERVER['QUERY_STRING'])) {
+ if (empty($_SERVER['QUERY_STRING'])) {
return array();
}
$GET = Common::getArrayFromQueryString($_SERVER['QUERY_STRING']);
return $GET;
}
-
+
/**
* Returns the current URL without generic filter query parameters.
- *
+ *
* @param array $params Query parameter values to override in the new URL.
* @return string
*/
@@ -233,7 +240,7 @@ class Piwik_API_Request
{
// unset all filter query params so the related report will show up in its default state,
// unless the filter param was in $queryParams
- $genericFiltersInfo = Piwik_API_DataTableGenericFilter::getGenericFiltersInformation();
+ $genericFiltersInfo = DataTableGenericFilter::getGenericFiltersInformation();
foreach ($genericFiltersInfo as $filter) {
foreach ($filter as $queryParamName => $queryParamInfo) {
if (!isset($params[$queryParamName])) {
@@ -242,6 +249,6 @@ class Piwik_API_Request
}
}
- return Piwik_Url::getCurrentQueryStringWithParametersModified($params);
+ return Url::getCurrentQueryStringWithParametersModified($params);
}
}
diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php
index c9bc6eec91..512339ee62 100644
--- a/core/API/ResponseBuilder.php
+++ b/core/API/ResponseBuilder.php
@@ -8,6 +8,12 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\API;
+
+use Exception;
+use Piwik\API\DataTableManipulator\Flattener;
+use Piwik\API\DataTableManipulator\LabelFilter;
+use Piwik\API\DataTableGenericFilter;
use Piwik\DataTable\Renderer\Json;
use Piwik\DataTable\Simple;
use Piwik\DataTable\Renderer;
@@ -19,7 +25,7 @@ use Piwik\DataTable;
* @package Piwik
* @subpackage Piwik_API
*/
-class Piwik_API_ResponseBuilder
+class ResponseBuilder
{
const DISPLAY_BACKTRACE_DEBUG = false;
@@ -141,7 +147,6 @@ class Piwik_API_ResponseBuilder
return $renderer->renderException();
}
-
/**
* @param Exception $e
* @return Exception
@@ -149,11 +154,11 @@ class Piwik_API_ResponseBuilder
protected function decorateExceptionWithDebugTrace(Exception $e)
{
// If we are in tests, show full backtrace
- if( defined('PIWIK_PATH_TEST_TO_ROOT')) {
- if(self::DISPLAY_BACKTRACE_DEBUG) {
+ if (defined('PIWIK_PATH_TEST_TO_ROOT')) {
+ if (self::DISPLAY_BACKTRACE_DEBUG) {
$message = $e->getMessage() . " in \n " . $e->getFile() . ":" . $e->getLine() . " \n " . $e->getTraceAsString();
} else {
- $message = $e->getMessage() . "\n \n --> To temporarily debug this error further, set const DISPLAY_BACKTRACE_DEBUG=true; in " . basename(__FILE__) ;
+ $message = $e->getMessage() . "\n \n --> To temporarily debug this error further, set const DISPLAY_BACKTRACE_DEBUG=true; in " . basename(__FILE__);
}
return new Exception($message);
}
@@ -287,7 +292,7 @@ class Piwik_API_ResponseBuilder
{
// if requested, flatten nested tables
if (Common::getRequestVar('flat', '0', 'string', $this->request) == '1') {
- $flattener = new Piwik_API_DataTableManipulator_Flattener($this->apiModule, $this->apiMethod, $this->request);
+ $flattener = new Flattener($this->apiModule, $this->apiMethod, $this->request);
if (Common::getRequestVar('include_aggregate_rows', '0', 'string', $this->request) == '1') {
$flattener->includeAggregateRows();
}
@@ -296,7 +301,7 @@ class Piwik_API_ResponseBuilder
// if the flag disable_generic_filters is defined we skip the generic filters
if (0 == Common::getRequestVar('disable_generic_filters', '0', 'string', $this->request)) {
- $genericFilter = new Piwik_API_DataTableGenericFilter($this->request);
+ $genericFilter = new DataTableGenericFilter($this->request);
$genericFilter->filter($datatable);
}
@@ -321,7 +326,7 @@ class Piwik_API_ResponseBuilder
if (!empty($label)) {
$addLabelIndex = Common::getRequestVar('labelFilterAddLabelIndex', 0, 'int', $this->request) == 1;
- $filter = new Piwik_API_DataTableManipulator_LabelFilter($this->apiModule, $this->apiMethod, $this->request);
+ $filter = new LabelFilter($this->apiModule, $this->apiMethod, $this->request);
$datatable = $filter->filter($label, $datatable, $addLabelIndex);
}
return $this->getRenderedDataTable($datatable);
@@ -478,7 +483,7 @@ class Piwik_API_ResponseBuilder
* Returns the value for the label query parameter which can be either a string
* (ie, label=...) or array (ie, label[]=...).
*
- * @param array $request
+ * @param array $request
* @return array
*/
static public function getLabelFromRequest($request)
@@ -497,7 +502,7 @@ class Piwik_API_ResponseBuilder
static public function unsanitizeLabelParameter($label)
{
- // this is needed because Piwik_API_Proxy uses Common::getRequestVar which in turn
+ // this is needed because Proxy uses Common::getRequestVar which in turn
// uses Common::sanitizeInputValue. This causes the > that separates recursive labels
// to become &gt; and we need to undo that here.
$label = Common::unsanitizeInputValues($label);
diff --git a/core/Access.php b/core/Access.php
index ab92cf97c1..a53cd52d1b 100644
--- a/core/Access.php
+++ b/core/Access.php
@@ -186,7 +186,7 @@ class Access
public function getRawSitesWithSomeViewAccess($login)
{
- return Piwik_FetchAll(self::getSqlAccessSite("access, t2.idsite"), $login);
+ return Db::fetchAll(self::getSqlAccessSite("access, t2.idsite"), $login);
}
/**
@@ -331,7 +331,7 @@ class Access
/**
* Throws an exception if the user is not the SuperUser
*
- * @throws Access_NoAccessException
+ * @throws \Piwik\NoAccessException
*/
public function checkUserIsSuperUser()
{
@@ -343,7 +343,7 @@ class Access
/**
* If the user doesn't have an ADMIN access for at least one website, throws an exception
*
- * @throws Access_NoAccessException
+ * @throws \Piwik\NoAccessException
*/
public function checkUserHasSomeAdminAccess()
{
@@ -359,7 +359,7 @@ class Access
/**
* If the user doesn't have any view permission, throw exception
*
- * @throws Access_NoAccessException
+ * @throws \Piwik\NoAccessException
*/
public function checkUserHasSomeViewAccess()
{
@@ -377,7 +377,7 @@ class Access
* If the user doesn't have ADMIN access for at least one website of the list, we throw an exception.
*
* @param int|array $idSites List of ID sites to check
- * @throws Access_NoAccessException If for any of the websites the user doesn't have an ADMIN access
+ * @throws \Piwik\NoAccessException If for any of the websites the user doesn't have an ADMIN access
*/
public function checkUserHasAdminAccess($idSites)
{
@@ -398,7 +398,7 @@ class Access
* If the user doesn't have VIEW or ADMIN access for at least one website of the list, we throw an exception.
*
* @param int|array|string $idSites List of ID sites to check (integer, array of integers, string comma separated list of integers)
- * @throws Access_NoAccessException If for any of the websites the user doesn't have an VIEW or ADMIN access
+ * @throws \Piwik\NoAccessException If for any of the websites the user doesn't have an VIEW or ADMIN access
*/
public function checkUserHasViewAccess($idSites)
{
@@ -417,7 +417,7 @@ class Access
/**
* @param int|array|string $idSites
* @return array
- * @throws Access_NoAccessException
+ * @throws \Piwik\NoAccessException
*/
protected function getIdSites($idSites)
{
diff --git a/core/ArchiveProcessor/Day.php b/core/ArchiveProcessor/Day.php
index ba8fbb3ae6..244936b73f 100644
--- a/core/ArchiveProcessor/Day.php
+++ b/core/ArchiveProcessor/Day.php
@@ -11,7 +11,7 @@
namespace Piwik\ArchiveProcessor;
use Piwik\Metrics;
use Piwik\ArchiveProcessor;
-use Piwik_DataArray;
+use Piwik\DataArray;
use Piwik\DataTable;
/**
@@ -23,10 +23,10 @@ class Day extends ArchiveProcessor
{
/**
* Converts the given array to a datatable
- * @param Piwik_DataArray $array
+ * @param DataArray $array
* @return \Piwik\DataTable
*/
- static public function getDataTableFromDataArray(Piwik_DataArray $array)
+ static public function getDataTableFromDataArray(DataArray $array)
{
$dataArray = $array->getDataArray();
$dataArrayTwoLevels = $array->getDataArrayWithTwoLevels();
@@ -62,7 +62,7 @@ class Day extends ArchiveProcessor
* Mac OS 15 36 ...
*
* @param string $dimension Table log_visit field name to be use to compute common stats
- * @return Piwik_DataArray
+ * @return DataArray
*/
public function getMetricsForDimension($dimension)
{
@@ -73,7 +73,7 @@ class Day extends ArchiveProcessor
$dimension = array("label" => reset($dimension));
}
$query = $this->getLogAggregator()->queryVisitsByDimension($dimension);
- $metrics = new Piwik_DataArray();
+ $metrics = new DataArray();
while ($row = $query->fetch()) {
$metrics->sumMetricsVisits($row["label"], $row);
}
diff --git a/core/AssetManager.php b/core/AssetManager.php
index f175bc5c41..3f701e02b7 100644
--- a/core/AssetManager.php
+++ b/core/AssetManager.php
@@ -8,9 +8,15 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
+use JSMin;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Version;
+use lessc;
/**
* @see libs/jsmin/jsmin.php
@@ -18,7 +24,7 @@ use Piwik\Common;
require_once PIWIK_INCLUDE_PATH . '/libs/jsmin/jsmin.php';
/**
- * Piwik_AssetManager is the class used to manage the inclusion of UI assets:
+ * AssetManager is the class used to manage the inclusion of UI assets:
* JavaScript and CSS files.
*
* It performs the following actions:
@@ -35,7 +41,7 @@ require_once PIWIK_INCLUDE_PATH . '/libs/jsmin/jsmin.php';
*
* @package Piwik
*/
-class Piwik_AssetManager
+class AssetManager
{
const MERGED_CSS_FILE = "asset_manager_global_css.css";
const MERGED_JS_FILE = "asset_manager_global_js.js";
@@ -82,7 +88,7 @@ class Piwik_AssetManager
public static function generateAssetsCacheBuster()
{
$pluginList = md5(implode(",", \Piwik\PluginsManager::getInstance()->getLoadedPluginsName()));
- $cacheBuster = md5(Common::getSalt() . $pluginList . PHP_VERSION . Piwik_Version::VERSION);
+ $cacheBuster = md5(Common::getSalt() . $pluginList . PHP_VERSION . Version::VERSION);
return $cacheBuster;
}
@@ -133,7 +139,8 @@ class Piwik_AssetManager
$firstLine = fgets($f);
fclose($f);
if (!empty($firstLine)
- && trim($firstLine) == trim($firstLineCompileHash)) {
+ && trim($firstLine) == trim($firstLineCompileHash)
+ ) {
return;
}
// Some CSS file in the merge, has changed since last merged asset was generated
@@ -145,9 +152,9 @@ class Piwik_AssetManager
Piwik_PostEvent('AssetManager.filterMergedCss', array(&$mergedContent));
$mergedContent =
- $firstLineCompileHash . "\n"
- . "/* Piwik CSS file is compiled with Less. You may be interested in writing a custom Theme for Piwik! */\n"
- . $mergedContent;
+ $firstLineCompileHash . "\n"
+ . "/* Piwik CSS file is compiled with Less. You may be interested in writing a custom Theme for Piwik! */\n"
+ . $mergedContent;
self::writeAssetToFile($mergedContent, self::MERGED_CSS_FILE);
}
diff --git a/core/CacheFile.php b/core/CacheFile.php
index 7458588dc3..addb926d6c 100644
--- a/core/CacheFile.php
+++ b/core/CacheFile.php
@@ -8,6 +8,9 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
@@ -21,7 +24,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_CacheFile
+class CacheFile
{
/**
* @var string
@@ -39,7 +42,7 @@ class Piwik_CacheFile
/**
* @param string $directory directory to use
- * @param int $timeToLiveInSeconds TTL
+ * @param int $timeToLiveInSeconds TTL
*/
public function __construct($directory, $timeToLiveInSeconds = 300)
{
diff --git a/core/Common.php b/core/Common.php
index da6e8892b5..4f40424c95 100644
--- a/core/Common.php
+++ b/core/Common.php
@@ -1,9 +1,18 @@
<?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
+ * @package Piwik
+ */
namespace Piwik;
use Exception;
-use Piwik_IP;
-use Piwik_Tracker;
+use Piwik\IP;
+use Piwik\Tracker;
use Piwik_Tracker_Cache;
use Piwik_UserCountry_LocationProvider_Default;
@@ -753,10 +762,10 @@ class Common
*/
public static function convertVisitorIdToBin($id)
{
- if (strlen($id) !== Piwik_Tracker::LENGTH_HEX_ID_STRING
+ if (strlen($id) !== Tracker::LENGTH_HEX_ID_STRING
|| @bin2hex(self::hex2bin($id)) != $id
) {
- throw new Exception("visitorId is expected to be a " . Piwik_Tracker::LENGTH_HEX_ID_STRING . " hex char string");
+ throw new Exception("visitorId is expected to be a " . Tracker::LENGTH_HEX_ID_STRING . " hex char string");
}
return self::hex2bin($id);
}
@@ -778,7 +787,7 @@ class Common
*/
public static function long2ip($ip)
{
- return Piwik_IP::long2ip($ip);
+ return IP::long2ip($ip);
}
/**
diff --git a/core/Controller.php b/core/Controller.php
index 0d6aa3ec64..344dee8616 100644
--- a/core/Controller.php
+++ b/core/Controller.php
@@ -8,6 +8,9 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\DataTable\Filter\CalculateEvolutionFilter;
use Piwik\Period;
@@ -18,7 +21,18 @@ use Piwik\Common;
use Piwik\Access;
use Piwik\Date;
use Piwik\Site;
-
+use Piwik_API_API;
+use Piwik\API\Request;
+use Piwik\FrontController;
+use Piwik_LanguagesManager;
+use Piwik_SitesManager_API;
+use Piwik\Url;
+use Piwik_UsersManager_API;
+use Piwik\View;
+use Piwik\ViewDataTable;
+use Piwik_ViewDataTable_GenerateGraphHTML_ChartEvolution;
+use Zend_Registry;
+use false;
/**
* Parent class of all plugins Controllers (located in /plugins/PluginName/Controller.php
@@ -26,7 +40,7 @@ use Piwik\Site;
*
* @package Piwik
*/
-abstract class Piwik_Controller
+abstract class Controller
{
/**
* Plugin name, eg. Referers
@@ -139,21 +153,21 @@ abstract class Piwik_Controller
* - echo the output of the rendering if fetch = false
* - returns the output of the rendering if fetch = true
*
- * @param Piwik_ViewDataTable $view view object to use
+ * @param ViewDataTable $view view object to use
* @param bool $fetch indicates whether to output or return the content
* @return string|void
*/
- protected function renderView(Piwik_ViewDataTable $view, $fetch = false)
+ protected function renderView(ViewDataTable $view, $fetch = false)
{
Piwik_PostEvent('Controller.renderView', array(
- $this,
- array('view' => $view,
- 'controllerName' => $view->getCurrentControllerName(),
- 'controllerAction' => $view->getCurrentControllerAction(),
- 'apiMethodToRequestDataTable' => $view->getApiMethodToRequestDataTable(),
- 'controllerActionCalledWhenRequestSubTable' => $view->getControllerActionCalledWhenRequestSubTable(),
- )
- ));
+ $this,
+ array('view' => $view,
+ 'controllerName' => $view->getCurrentControllerName(),
+ 'controllerAction' => $view->getCurrentControllerAction(),
+ 'apiMethodToRequestDataTable' => $view->getApiMethodToRequestDataTable(),
+ 'controllerActionCalledWhenRequestSubTable' => $view->getControllerActionCalledWhenRequestSubTable(),
+ )
+ ));
$view->main();
@@ -175,7 +189,7 @@ abstract class Piwik_Controller
*/
protected function getLastUnitGraph($currentModuleName, $currentControllerAction, $apiMethod)
{
- $view = Piwik_ViewDataTable::factory('graphEvolution');
+ $view = ViewDataTable::factory('graphEvolution');
$view->init($currentModuleName, $currentControllerAction, $apiMethod);
return $view;
}
@@ -256,7 +270,7 @@ abstract class Piwik_Controller
* - period: day, week, month, year
*
* @param array $paramsToSet array( 'date' => 'last50', 'viewDataTable' =>'sparkline' )
- * @throws Access_NoAccessException
+ * @throws \Piwik\NoAccessException
* @return array
*/
protected function getGraphParamsModified($paramsToSet = array())
@@ -282,7 +296,7 @@ abstract class Piwik_Controller
}
if (is_null($this->site)) {
- throw new Access_NoAccessException("Website not initialized, check that you are logged in and/or using the correct token_auth.");
+ throw new \Piwik\NoAccessException("Website not initialized, check that you are logged in and/or using the correct token_auth.");
}
$paramDate = self::getDateRangeRelativeToEndDate($period, $range, $endDate, $this->site);
@@ -312,8 +326,8 @@ abstract class Piwik_Controller
* Returns a numeric value from the API.
* Works only for API methods that originally returns numeric values (there is no cast here)
*
- * @param string $methodToCall Name of method to call, eg. Referers.getNumberOfDistinctSearchEngines
- * @param bool|string $date A custom date to use when getting the value. If false, the 'date' query
+ * @param string $methodToCall Name of method to call, eg. Referers.getNumberOfDistinctSearchEngines
+ * @param bool|string $date A custom date to use when getting the value. If false, the 'date' query
* parameter is used.
*
* @return int|float
@@ -322,14 +336,14 @@ abstract class Piwik_Controller
{
$params = $date === false ? array() : array('date' => $date);
- $return = Piwik_API_Request::processRequest($methodToCall, $params);
+ $return = Request::processRequest($methodToCall, $params);
$columns = $return->getFirstRow()->getColumns();
return reset($columns);
}
/**
* Returns the current URL to use in a img src=X to display a sparkline.
- * $action must be the name of a Controller method that requests data using the Piwik_ViewDataTable::factory
+ * $action must be the name of a Controller method that requests data using the ViewDataTable::factory
* It will automatically build a sparkline by setting the viewDataTable=sparkline parameter in the URL.
* It will also computes automatically the 'date' for the 'last30' days/weeks/etc.
*
@@ -351,7 +365,7 @@ abstract class Piwik_Controller
$value = rawurlencode(implode(',', $value));
}
}
- $url = Piwik_Url::getCurrentQueryStringWithParametersModified($params);
+ $url = Url::getCurrentQueryStringWithParametersModified($params);
return $url;
}
@@ -359,7 +373,7 @@ abstract class Piwik_Controller
* Sets the first date available in the calendar
*
* @param Date $minDate
- * @param Piwik_View $view
+ * @param View $view
* @return void
*/
protected function setMinDateView(Date $minDate, $view)
@@ -373,7 +387,7 @@ abstract class Piwik_Controller
* Sets "today" in the calendar. Today does not always mean "UTC" today, eg. for websites in UTC+12.
*
* @param Date $maxDate
- * @param Piwik_View $view
+ * @param View $view
* @return void
*/
protected function setMaxDateView(Date $maxDate, $view)
@@ -388,7 +402,7 @@ abstract class Piwik_Controller
* various templates and Javascript.
* If any error happens, displays the login screen
*
- * @param Piwik_View $view
+ * @param View $view
* @throws Exception
* @return void
*/
@@ -454,7 +468,7 @@ abstract class Piwik_Controller
/**
* Set the minimal variables in the view object
*
- * @param Piwik_View $view
+ * @param View $view
*/
protected function setBasicVariablesView($view)
{
@@ -488,7 +502,7 @@ abstract class Piwik_Controller
public static function setHostValidationVariablesView($view)
{
// check if host is valid
- $view->isValidHost = Piwik_Url::isValidHost();
+ $view->isValidHost = Url::isValidHost();
if (!$view->isValidHost) {
// invalid host, so display warning to user
$validHost = Config::getInstance()->General['trusted_hosts'][0];
@@ -501,14 +515,14 @@ abstract class Piwik_Controller
$mailToUrl = "mailto:$superUserEmail?subject=$emailSubject&body=$emailBody";
$mailLinkStart = "<a href=\"$mailToUrl\">";
- $invalidUrl = Piwik_Url::getCurrentUrlWithoutQueryString($checkIfTrusted = false);
- $validUrl = Piwik_Url::getCurrentScheme() . '://' . $validHost
- . Piwik_Url::getCurrentScriptName();
+ $invalidUrl = Url::getCurrentUrlWithoutQueryString($checkIfTrusted = false);
+ $validUrl = Url::getCurrentScheme() . '://' . $validHost
+ . Url::getCurrentScriptName();
$invalidUrl = Common::sanitizeInputValue($invalidUrl);
$validUrl = Common::sanitizeInputValue($validUrl);
$changeTrustedHostsUrl = "index.php"
- . Piwik_Url::getCurrentQueryStringWithParametersModified(array(
+ . Url::getCurrentQueryStringWithParametersModified(array(
'module' => 'CoreAdminHome',
'action' => 'generalSettings'
))
@@ -551,7 +565,7 @@ abstract class Piwik_Controller
/**
* Sets general period variables (available periods, current period, period labels) used by templates
*
- * @param Piwik_View $view
+ * @param View $view
* @throws Exception
* @return void
*/
@@ -589,7 +603,7 @@ abstract class Piwik_Controller
* Set metrics variables (displayed metrics, available metrics) used by template
* Handles the server-side of the metrics picker
*
- * @param Piwik_View|Piwik_ViewDataTable $view
+ * @param View|ViewDataTable $view
* @param string $defaultMetricDay name of the default metric for period=day
* @param string $defaultMetric name of the default metric for other periods
* @param array $metricsForDay metrics that are only available for period=day
@@ -597,7 +611,7 @@ abstract class Piwik_Controller
* @param bool $labelDisplayed add 'label' to columns to display?
* @return void
*/
- protected function setMetricsVariablesView(Piwik_ViewDataTable $view, $defaultMetricDay = 'nb_uniq_visitors',
+ protected function setMetricsVariablesView(ViewDataTable $view, $defaultMetricDay = 'nb_uniq_visitors',
$defaultMetric = 'nb_visits', $metricsForDay = array('nb_uniq_visitors'),
$metricsForAllPeriods = array('nb_visits', 'nb_actions'), $labelDisplayed = true)
{
@@ -642,7 +656,7 @@ abstract class Piwik_Controller
}
$parametersString = '';
if (!empty($parameters)) {
- $parametersString = '&' . Piwik_Url::getQueryStringFromParameters($parameters);
+ $parametersString = '&' . Url::getQueryStringFromParameters($parameters);
}
if ($websiteId) {
@@ -670,11 +684,10 @@ abstract class Piwik_Controller
Piwik_ExitWithMessage($errorMessage, false, true);
}
- Piwik_FrontController::getInstance()->dispatch(Piwik::getLoginPluginName(), false);
+ FrontController::getInstance()->dispatch(Piwik::getLoginPluginName(), false);
exit;
}
-
/**
* Returns default website that Piwik should load
*
@@ -753,13 +766,13 @@ abstract class Piwik_Controller
* within the site. The token should never appear in the browser's
* address bar.
*
- * @throws Access_NoAccessException if token doesn't match
+ * @throws \Piwik\NoAccessException if token doesn't match
* @return void
*/
protected function checkTokenInUrl()
{
if (Common::getRequestVar('token_auth', false) != Piwik::getCurrentUserTokenAuth()) {
- throw new Access_NoAccessException(Piwik_TranslateException('General_ExceptionInvalidToken'));
+ throw new \Piwik\NoAccessException(Piwik_TranslateException('General_ExceptionInvalidToken'));
}
}
@@ -779,7 +792,6 @@ abstract class Piwik_Controller
}
}
-
/**
* Returns the pretty date representation
*
@@ -792,7 +804,6 @@ abstract class Piwik_Controller
return self::getCalendarPrettyDate(Period::factory($period, Date::factory($date)));
}
-
/**
* Calculates the evolution from one value to another and returns HTML displaying
* the evolution percent. The HTML includes an up/down arrow and is colored red, black or
diff --git a/core/Controller/Admin.php b/core/Controller/Admin.php
index a6c58b46a6..be4bcd2741 100644
--- a/core/Controller/Admin.php
+++ b/core/Controller/Admin.php
@@ -8,21 +8,26 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Controller;
+
use Piwik\Config;
use Piwik\Piwik;
+use Piwik\Controller;
+use Piwik\View;
+use Piwik\Url;
/**
* Parent class of all plugins Controllers with admin functions
*
* @package Piwik
*/
-abstract class Piwik_Controller_Admin extends Piwik_Controller
+abstract class Admin extends Controller
{
/**
* Set the minimal variables in the view object
* Extended by some admin view specific variables
*
- * @param Piwik_View $view
+ * @param View $view
*/
protected function setBasicVariablesView($view)
{
@@ -31,12 +36,12 @@ abstract class Piwik_Controller_Admin extends Piwik_Controller
self::setBasicVariablesAdminView($view);
}
- static public function displayWarningIfConfigFileNotWritable(Piwik_View $view )
+ static public function displayWarningIfConfigFileNotWritable(View $view)
{
$view->configFileNotWritable = !Config::getInstance()->isFileWritable();
}
- static public function setBasicVariablesAdminView(Piwik_View $view)
+ static public function setBasicVariablesAdminView(View $view)
{
$statsEnabled = Config::getInstance()->Tracker['record_statistics'];
if ($statsEnabled == "0") {
@@ -44,7 +49,7 @@ abstract class Piwik_Controller_Admin extends Piwik_Controller
}
$view->topMenu = Piwik_GetTopMenu();
- $view->currentAdminMenuName = Piwik_GetCurrentAdminMenuName();
+ $view->currentAdminMenuName = \Piwik\Menu\Admin::getInstance()->getCurrentAdminMenuName();
$view->enableFrames = Config::getInstance()->General['enable_framed_settings'];
if (!$view->enableFrames) {
@@ -59,21 +64,21 @@ abstract class Piwik_Controller_Admin extends Piwik_Controller
// for cannot find installed plugin warning
$missingPlugins = \Piwik\PluginsManager::getInstance()->getMissingPlugins();
if (!empty($missingPlugins)) {
- $pluginsLink = Piwik_Url::getCurrentQueryStringWithParametersModified(array(
- 'module' => 'CorePluginsAdmin', 'action' => 'index'
- ));
+ $pluginsLink = Url::getCurrentQueryStringWithParametersModified(array(
+ 'module' => 'CorePluginsAdmin', 'action' => 'index'
+ ));
$view->missingPluginsWarning = Piwik_Translate('CoreAdminHome_MissingPluginsWarning', array(
'<strong>' . implode('</strong>,&nbsp;<strong>', $missingPlugins) . '</strong>',
'<a href="' . $pluginsLink . '"/>',
'</a>'
));
}
-
+
self::checkPhpVersion($view);
$view->menu = Piwik_GetAdminMenu();
}
-
+
/**
* Check if the current PHP version is >= 5.3. If not, a warning is displayed
* to the user.
diff --git a/core/Cookie.php b/core/Cookie.php
index 24bd7c8ba2..84246569af 100644
--- a/core/Cookie.php
+++ b/core/Cookie.php
@@ -8,6 +8,8 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Common;
/**
@@ -18,7 +20,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_Cookie
+class Cookie
{
/**
* Don't create a cookie bigger than 1k
diff --git a/core/DataAccess/ArchiveSelector.php b/core/DataAccess/ArchiveSelector.php
index 8ed467ba90..b261e78fc3 100644
--- a/core/DataAccess/ArchiveSelector.php
+++ b/core/DataAccess/ArchiveSelector.php
@@ -72,7 +72,7 @@ class ArchiveSelector
OR name = '" . self::NB_VISITS_CONVERTED_RECORD_LOOKED_UP . "')
$timeStampWhere
ORDER BY idarchive DESC";
- $results = Piwik_FetchAll($sqlQuery, $bindSQL);
+ $results = Db::fetchAll($sqlQuery, $bindSQL);
if (empty($results)) {
return false;
}
@@ -185,7 +185,7 @@ class ArchiveSelector
$sql = sprintf($getArchiveIdsSql, $table, $dateCondition);
// get the archive IDs
- foreach (Piwik_FetchAll($sql, $bind) as $row) {
+ foreach (Db::fetchAll($sql, $bind) as $row) {
$archiveName = $row['name'];
//FIXMEA duplicate with Archive.php
@@ -246,7 +246,7 @@ class ArchiveSelector
$table = ArchiveTableCreator::getBlobTable($date);
}
$sql = sprintf($getValuesSql, $table, implode(',', $ids));
- $dataRows = Piwik_FetchAll($sql, $bind);
+ $dataRows = Db::fetchAll($sql, $bind);
foreach ($dataRows as $row) {
$rows[] = $row;
}
@@ -305,10 +305,10 @@ class ArchiveSelector
$yesterday = Date::factory('yesterday')->getDateTime();
$bind = array(Piwik::$idPeriods['range'], $yesterday);
$numericTable = ArchiveTableCreator::getNumericTable($date);
- Piwik_Query(sprintf($query, $numericTable), $bind);
+ Db::query(sprintf($query, $numericTable), $bind);
Piwik::log("Purging Custom Range archives: done [ purged archives older than $yesterday from $numericTable / blob ]");
try {
- Piwik_Query(sprintf($query, ArchiveTableCreator::getBlobTable($date)), $bind);
+ Db::query(sprintf($query, ArchiveTableCreator::getBlobTable($date)), $bind);
} catch (Exception $e) {
// Individual blob tables could be missing
}
@@ -318,9 +318,9 @@ class ArchiveSelector
{
$query = "DELETE FROM %s WHERE idarchive IN (" . implode(',', $idArchivesToDelete) . ")";
- Piwik_Query(sprintf($query, ArchiveTableCreator::getNumericTable($date)));
+ Db::query(sprintf($query, ArchiveTableCreator::getNumericTable($date)));
try {
- Piwik_Query(sprintf($query, ArchiveTableCreator::getBlobTable($date)));
+ Db::query(sprintf($query, ArchiveTableCreator::getBlobTable($date)));
} catch (Exception $e) {
// Individual blob tables could be missing
}
@@ -335,7 +335,7 @@ class ArchiveSelector
AND ts_archived < ?)
OR value = " . ArchiveProcessor::DONE_ERROR . ")";
- $result = Piwik_FetchAll($query, array($purgeArchivesOlderThan));
+ $result = Db::fetchAll($query, array($purgeArchivesOlderThan));
$idArchivesToDelete = array();
if (!empty($result)) {
foreach ($result as $row) {
diff --git a/core/DataAccess/ArchiveTableCreator.php b/core/DataAccess/ArchiveTableCreator.php
index 9b2fb6797d..cb70f49b35 100644
--- a/core/DataAccess/ArchiveTableCreator.php
+++ b/core/DataAccess/ArchiveTableCreator.php
@@ -1,12 +1,4 @@
<?php
-namespace Piwik\DataAccess;
-
-use Exception;
-use Piwik\Piwik;
-use Piwik\Common;
-use Piwik\Date;
-use Zend_Registry;
-
/**
* Piwik - Open source web analytics
*
@@ -17,6 +9,14 @@ use Zend_Registry;
* @package Piwik
*/
+namespace Piwik\DataAccess;
+
+use Exception;
+use Piwik\Piwik;
+use Piwik\Common;
+use Piwik\Date;
+use Zend_Registry;
+
class ArchiveTableCreator
{
const NUMERIC_TABLE = "numeric";
diff --git a/core/DataAccess/ArchiveWriter.php b/core/DataAccess/ArchiveWriter.php
index ef04212b74..8296c0f438 100644
--- a/core/DataAccess/ArchiveWriter.php
+++ b/core/DataAccess/ArchiveWriter.php
@@ -13,13 +13,13 @@ namespace Piwik\DataAccess;
use Exception;
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
+use Piwik\Db;
use Piwik\DataAccess\ArchiveTableCreator;
use Piwik\Period;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\ArchiveProcessor;
use Piwik\Segment;
-use Zend_Registry;
/**
* This class is used to create a new Archive.
@@ -69,7 +69,7 @@ class ArchiveWriter
protected function acquireLock()
{
$lockName = $this->getArchiveProcessorLockName();
- $result = Piwik_GetDbLock($lockName, $maxRetries = 30);
+ $result = Db::getDbLock($lockName, $maxRetries = 30);
if (!$result) {
Piwik::log("SELECT GET_LOCK failed to acquire lock. Proceeding anyway.");
}
@@ -86,12 +86,12 @@ class ArchiveWriter
$numericTable = $this->getTableNumeric();
$idSite = $this->idSite;
- $db = Zend_Registry::get('db');
+ $db = \Zend_Registry::get('db');
$locked = self::PREFIX_SQL_LOCK . Common::generateUniqId();
$date = date("Y-m-d H:i:s");
$dbLockName = "allocateNewArchiveId.$numericTable";
- if (Piwik_GetDbLock($dbLockName, $maxRetries = 30) === false) {
+ if (Db::getDbLock($dbLockName, $maxRetries = 30) === false) {
throw new Exception("allocateNewArchiveId: Cannot get named lock for table $numericTable.");
}
$insertSql = "INSERT INTO $numericTable "
@@ -105,7 +105,7 @@ class ArchiveWriter
0 "
. " FROM $numericTable as tb1";
$db->exec($insertSql);
- Piwik_ReleaseDbLock($dbLockName);
+ Db::releaseDbLock($dbLockName);
$selectIdSql = "SELECT idarchive FROM $numericTable WHERE name = ? LIMIT 1";
$id = $db->fetchOne($selectIdSql, $locked);
return $id;
@@ -147,7 +147,7 @@ class ArchiveWriter
protected function deletePreviousArchiveStatus()
{
- Piwik_Query("DELETE FROM " . $this->getTableNumeric() . "
+ Db::query("DELETE FROM " . $this->getTableNumeric() . "
WHERE idarchive = ? AND (name = '" . $this->doneFlag . "' OR name LIKE '" . self::PREFIX_SQL_LOCK . "%')",
array($this->getIdArchive())
);
@@ -165,7 +165,7 @@ class ArchiveWriter
protected function releaseArchiveProcessorLock()
{
$lockName = $this->getArchiveProcessorLockName();
- return Piwik_ReleaseDbLock($lockName);
+ return Db::releaseDbLock($lockName);
}
public function insertBulkRecords($records)
@@ -224,7 +224,7 @@ class ArchiveWriter
$bindSql = $this->getInsertRecordBind();
$bindSql[] = $name;
$bindSql[] = $value;
- Piwik_Query($query, $bindSql);
+ Db::query($query, $bindSql);
return true;
}
diff --git a/core/DataAccess/LogAggregator.php b/core/DataAccess/LogAggregator.php
index 72e94e8b70..f1b38c7d4e 100644
--- a/core/DataAccess/LogAggregator.php
+++ b/core/DataAccess/LogAggregator.php
@@ -16,7 +16,7 @@ use Piwik\Metrics;
use Piwik\Date;
use Piwik\Segment;
use Piwik\Site;
-use Piwik_RankingQuery;
+use Piwik\RankingQuery;
use Piwik_Tracker_GoalManager;
use Zend_Registry;
@@ -128,9 +128,9 @@ class LogAggregator
* @param array $additionalSelects Additional SELECT clause
* @param bool|array $metrics Set this if you want to limit the columns that are returned.
* The possible values in the array are Metrics::INDEX_*.
- * @param bool|Piwik_RankingQuery $rankingQuery
+ * @param bool|\Piwik\RankingQuery $rankingQuery
* A pre-configured ranking query instance that is used to limit the result.
- * If set, the return value is the array returned by Piwik_RankingQuery::execute().
+ * If set, the return value is the array returned by RankingQuery::execute().
*
* @return mixed
*/
@@ -347,7 +347,7 @@ class LogAggregator
* @param array|bool $additionalSelects additional select clause
* @param bool|array $metrics Set this if you want to limit the columns that are returned.
* The possible values in the array are Metrics::INDEX_*.
- * @param Piwik_RankingQuery $rankingQuery pre-configured ranking query instance
+ * @param \Piwik\RankingQuery $rankingQuery pre-configured ranking query instance
* @param bool|string $joinLogActionOnColumn column from log_link_visit_action that
* log_action should be joined on.
* can be an array to join multiple times.
diff --git a/core/DataArray.php b/core/DataArray.php
index 58d9d159f4..e9971997d2 100644
--- a/core/DataArray.php
+++ b/core/DataArray.php
@@ -8,7 +8,11 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Metrics;
+use Piwik_Tracker_GoalManager;
/**
* The DataArray is a data structure used to aggregate datasets,
@@ -17,7 +21,7 @@ use Piwik\Metrics;
*
*/
-class Piwik_DataArray
+class DataArray
{
protected $data = array();
protected $dataTwoLevels = array();
@@ -198,16 +202,16 @@ class Piwik_DataArray
* @param $row
* @throws Exception if the the data row contains non numeric values
*/
- public function sumMetrics( $label, $row)
+ public function sumMetrics($label, $row)
{
- foreach($row as $columnName => $columnValue) {
- if(empty($columnValue)) {
+ foreach ($row as $columnName => $columnValue) {
+ if (empty($columnValue)) {
continue;
}
- if(empty($this->data[$label][$columnName])) {
+ if (empty($this->data[$label][$columnName])) {
$this->data[$label][$columnName] = 0;
}
- if(!is_numeric($columnValue)) {
+ if (!is_numeric($columnValue)) {
throw new Exception("DataArray->sumMetricsPivot expects rows of numeric values, non numeric found: " . var_export($columnValue, true) . " for column $columnName");
}
$this->data[$label][$columnName] += $columnValue;
diff --git a/core/DataTable/Filter/MetadataCallbackReplace.php b/core/DataTable/Filter/MetadataCallbackReplace.php
index 32051c1e6f..affbc6f4ab 100644
--- a/core/DataTable/Filter/MetadataCallbackReplace.php
+++ b/core/DataTable/Filter/MetadataCallbackReplace.php
@@ -13,7 +13,6 @@ namespace Piwik\DataTable\Filter;
use Piwik\DataTable;
use Piwik\DataTable\Filter\ColumnCallbackReplace;
use Piwik\DataTable\Row;
-use false;
/**
* Replace a metadata value with a new value resulting
diff --git a/core/DataTable/Renderer.php b/core/DataTable/Renderer.php
index 88f3f9ff37..bdec4b87ca 100644
--- a/core/DataTable/Renderer.php
+++ b/core/DataTable/Renderer.php
@@ -299,7 +299,7 @@ abstract class Renderer
$this->apiMetaData = false;
}
- $api = Piwik_API_API::getInstance();
+ $api = \Piwik_API_API::getInstance();
$meta = $api->getMetadata($this->idSite, $apiModule, $apiAction);
if (is_array($meta[0])) {
$meta = $meta[0];
diff --git a/core/DataTable/Renderer/Rss.php b/core/DataTable/Renderer/Rss.php
index 2b131d25df..3061ddbc67 100644
--- a/core/DataTable/Renderer/Rss.php
+++ b/core/DataTable/Renderer/Rss.php
@@ -15,7 +15,7 @@ use Piwik\Common;
use Piwik\DataTable\Renderer;
use Piwik\Date;
use Piwik\DataTable;
-use Piwik_Url;
+use Piwik\Url;
/**
* RSS Feed.
@@ -69,7 +69,7 @@ class Rss extends Renderer
$idSite = Common::getRequestVar('idSite', 1, 'int');
$period = Common::getRequestVar('period');
- $piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName()
+ $piwikUrl = Url::getCurrentUrlWithoutFileName()
. "?module=CoreHome&action=index&idSite=" . $idSite . "&period=" . $period;
$out = "";
$moreRecentFirst = array_reverse($table->getArray(), true);
diff --git a/core/PluginsFunctions/Sql.php b/core/Db.php
index 2a0d3665ba..d73b5c65f6 100644
--- a/core/PluginsFunctions/Sql.php
+++ b/core/Db.php
@@ -8,25 +8,27 @@
* @category Piwik
* @package PluginsFunctions
*/
+namespace Piwik;
use Piwik\Config;
+use Piwik\Tracker;
/**
* SQL wrapper
*
* @package PluginsFunctions
*/
-class Piwik_Sql
+class Db
{
/**
* Returns the database adapter to use
*
- * @return Piwik_Tracker_Db|Piwik_Db_Adapter_Interface
+ * @return Piwik_Tracker_Db|AdapterInterface
*/
static private function getDb()
{
$db = null;
if (!empty($GLOBALS['PIWIK_TRACKER_MODE'])) {
- $db = Piwik_Tracker::getDatabase();
+ $db = Tracker::getDatabase();
}
if ($db === null) {
$db = Zend_Registry::get('db');
@@ -37,7 +39,7 @@ class Piwik_Sql
/**
* Executes an unprepared SQL query on the DB. Recommended for DDL statements, e.g., CREATE/DROP/ALTER.
* The return result is DBMS-specific. For MySQLI, it returns the number of rows affected. For PDO, it returns the Zend_Db_Statement object
- * If you want to fetch data from the DB you should use the function Piwik_FetchAll()
+ * If you want to fetch data from the DB you should use the function Db::fetchAll()
*
* @param string $sql SQL Query
* @return integer|Zend_Db_Statement
@@ -54,7 +56,7 @@ class Piwik_Sql
/**
* Executes a SQL query on the DB and returns the Zend_Db_Statement object
- * If you want to fetch data from the DB you should use the function Piwik_FetchAll()
+ * If you want to fetch data from the DB you should use the function Db::fetchAll()
*
* See also http://framework.zend.com/manual/en/zend.db.statement.html
*
@@ -162,7 +164,7 @@ class Piwik_Sql
// filter out all InnoDB tables
$nonInnoDbTables = array();
- foreach (Piwik_FetchAll("SHOW TABLE STATUS") as $row) {
+ foreach (Db::fetchAll("SHOW TABLE STATUS") as $row) {
if (strtolower($row['Engine']) != 'innodb'
&& in_array($row['Name'], $tables)
) {
@@ -234,18 +236,22 @@ class Piwik_Sql
* Performs a SELECT on a table one chunk at a time and returns the first
* fetched value.
*
- * @param string $sql The SQL to perform. The last two conditions of the WHERE
- * expression must be as follows: 'id >= ? AND id < ?' where
- * 'id' is the int id of the table. If $step < 0, the condition
- * should be 'id <= ? AND id > ?'.
- * @param int $first The minimum ID to loop from.
- * @param int $last The maximum ID to loop to.
- * @param int $step The maximum number of rows to scan in each smaller SELECT.
- * @param array $params parameters to bind in the query, array( param1 => value1, param2 => value2)
+ * This function will break up a SELECT into several smaller SELECTs and
+ * should be used when performing a SELECT that can take a long time to finish.
+ * Using several smaller SELECTs will ensure that the table will not be locked
+ * for too long.
*
- * @return array
+ * @param string $sql The SQL to perform. The last two conditions of the WHERE
+ * expression must be as follows: 'id >= ? AND id < ?' where
+ * 'id' is the int id of the table.
+ * @param int $first The minimum ID to loop from.
+ * @param int $last The maximum ID to loop to.
+ * @param int $step The maximum number of rows to scan in each smaller SELECT.
+ * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
+ *
+ * @return string
*/
- static public function segmentedFetchFirst($sql, $first, $last, $step, $params)
+ static public function segmentedFetchFirst($sql, $first, $last, $step, $params = array())
{
$result = false;
if ($step > 0) {
@@ -264,17 +270,23 @@ class Piwik_Sql
* Performs a SELECT on a table one chunk at a time and returns an array
* of every fetched value.
*
- * @param string $sql The SQL to perform. The last two conditions of the WHERE
- * expression must be as follows: 'id >= ? AND id < ?' where
- * 'id' is the int id of the table.
- * @param int $first The minimum ID to loop from.
- * @param int $last The maximum ID to loop to.
- * @param int $step The maximum number of rows to scan in each smaller SELECT.
- * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
+ * This function will break up a SELECT into several smaller SELECTs and
+ * should be used when performing a SELECT that can take a long time to finish.
+ * Using several smaller SELECTs will ensure that the table will not be locked
+ * for too long.
+ *
+ *
+ * @param string $sql The SQL to perform. The last two conditions of the WHERE
+ * expression must be as follows: 'id >= ? AND id < ?' where
+ * 'id' is the int id of the table.
+ * @param int $first The minimum ID to loop from.
+ * @param int $last The maximum ID to loop to.
+ * @param int $step The maximum number of rows to scan in each smaller SELECT.
+ * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
*
* @return array
*/
- static public function segmentedFetchOne($sql, $first, $last, $step, $params)
+ static public function segmentedFetchOne($sql, $first, $last, $step, $params = array())
{
$result = array();
if ($step > 0) {
@@ -333,7 +345,7 @@ class Piwik_Sql
*
* @return array
*/
- static public function segmentedQuery($sql, $first, $last, $step, $params)
+ static public function segmentedQuery($sql, $first, $last, $step, $params = array())
{
if ($step > 0) {
for ($i = $first; $i <= $last; $i += $step) {
@@ -391,291 +403,3 @@ class Piwik_Sql
return $db->fetchOne($sql, array($lockName)) == '1';
}
}
-
-/**
- * Executes an unprepared SQL query on the DB. Recommended for DDL statements, e.g., CREATE/DROP/ALTER.
- * The return result is DBMS-specific. For MySQLI, it returns the number of rows affected. For PDO, it returns the Zend_Db_Statement object
- * If you want to fetch data from the DB you should use the function Piwik_FetchAll()
- *
- * @see Piwik_Sql::exec
- *
- * @param string $sqlQuery SQL Query
- * @return integer|Zend_Db_Statement
- */
-function Piwik_Exec($sqlQuery)
-{
- return Piwik_Sql::exec($sqlQuery);
-}
-
-/**
- * Executes a SQL query on the DB and returns the Zend_Db_Statement object
- * If you want to fetch data from the DB you should use the function Piwik_FetchAll()
- *
- * See also http://framework.zend.com/manual/en/zend.db.statement.html
- *
- * @see Piwik_Sql::query
- *
- * @param string $sqlQuery SQL Query
- * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
- * @return Zend_Db_Statement
- */
-function Piwik_Query($sqlQuery, $parameters = array())
-{
- return Piwik_Sql::query($sqlQuery, $parameters);
-}
-
-/**
- * Executes the SQL Query and fetches all the rows from the database query
- *
- * @see Piwik_Sql::fetchAll
- *
- * @param string $sqlQuery SQL Query
- * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
- * @return array (one row in the array per row fetched in the DB)
- */
-function Piwik_FetchAll($sqlQuery, $parameters = array())
-{
- return Piwik_Sql::fetchAll($sqlQuery, $parameters);
-}
-
-/**
- * Fetches first row of result from the database query
- *
- * @see Piwik_Sql::fetchRow
- *
- * @param string $sqlQuery SQL Query
- * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
- * @return array
- */
-function Piwik_FetchRow($sqlQuery, $parameters = array())
-{
- return Piwik_Sql::fetchRow($sqlQuery, $parameters);
-}
-
-/**
- * Fetches first column of first row of result from the database query
- *
- * @see Piwik_Sql::fetchOne
- *
- * @param string $sqlQuery SQL Query
- * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
- * @return string
- */
-function Piwik_FetchOne($sqlQuery, $parameters = array())
-{
- return Piwik_Sql::fetchOne($sqlQuery, $parameters);
-}
-
-/**
- * Fetches result from the database query as an array of associative arrays.
- *
- * @param string $sqlQuery
- * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
- * @return array
- */
-function Piwik_FetchAssoc($sqlQuery, $parameters = array())
-{
- return Piwik_Sql::fetchAssoc($sqlQuery, $parameters);
-}
-
-/**
- * Deletes all desired rows in a table, while using a limit. This function will execute a
- * DELETE query until there are no more rows to delete.
- *
- * @see Piwik_Sql::deleteAllRows
- *
- * @param string $table The name of the table to delete from. Must be prefixed.
- * @param string $where The where clause of the query. Must include the WHERE keyword.
- * @param int $maxRowsPerQuery The maximum number of rows to delete per DELETE query.
- * @param array $parameters Parameters to bind in the query.
- * @return int The total number of rows deleted.
- */
-function Piwik_DeleteAllRows($table, $where, $maxRowsPerQuery, $parameters = array())
-{
- return Piwik_Sql::deleteAllRows($table, $where, $maxRowsPerQuery, $parameters);
-}
-
-/**
- * Runs an OPTIMIZE TABLE query on the supplied table or tables. The table names must be prefixed.
- *
- * @see Piwik_Sql::optimizeTables
- *
- * @param string|array $tables The name of the table to optimize or an array of tables to optimize.
- * @return Zend_Db_Statement
- */
-function Piwik_OptimizeTables($tables)
-{
- return Piwik_Sql::optimizeTables($tables);
-}
-
-/**
- * Drops the supplied table or tables. The table names must be prefixed.
- *
- * @see Piwik_Sql::dropTables
- *
- * @param string|array $tables The name of the table to drop or an array of table names to drop.
- * @return Zend_Db_Statement
- */
-function Piwik_DropTables($tables)
-{
- return Piwik_Sql::dropTables($tables);
-}
-
-/**
- * Locks the supplied table or tables. The table names must be prefixed.
- *
- * @see Piwik_Sql::lockTables
- *
- * @param string|array $tablesToRead The table or tables to obtain 'read' locks on.
- * @param string|array $tablesToWrite The table or tables to obtain 'write' locks on.
- * @return Zend_Db_Statement
- */
-function Piwik_LockTables($tablesToRead, $tablesToWrite = array())
-{
- return Piwik_Sql::lockTables($tablesToRead, $tablesToWrite);
-}
-
-/**
- * Releases all table locks.
- *
- * @see Piwik_Sql::unlockAllTables
- *
- * @return Zend_Db_Statement
- */
-function Piwik_UnlockAllTables()
-{
- return Piwik_Sql::unlockAllTables();
-}
-
-/**
- * Performs a SELECT on a table one chunk at a time and returns the first
- * fetched value.
- *
- * This function will break up a SELECT into several smaller SELECTs and
- * should be used when performing a SELECT that can take a long time to finish.
- * Using several smaller SELECTs will ensure that the table will not be locked
- * for too long.
- *
- * @see Piwik_Sql::segmentedFetchFirst
- *
- * @param string $sql The SQL to perform. The last two conditions of the WHERE
- * expression must be as follows: 'id >= ? AND id < ?' where
- * 'id' is the int id of the table.
- * @param int $first The minimum ID to loop from.
- * @param int $last The maximum ID to loop to.
- * @param int $step The maximum number of rows to scan in each smaller SELECT.
- * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
- *
- * @return string
- */
-function Piwik_SegmentedFetchFirst($sql, $first, $last, $step, $params = array())
-{
- return Piwik_Sql::segmentedFetchFirst($sql, $first, $last, $step, $params);
-}
-
-/**
- * Performs a SELECT on a table one chunk at a time and returns an array
- * of every fetched value.
- *
- * This function will break up a SELECT into several smaller SELECTs and
- * should be used when performing a SELECT that can take a long time to finish.
- * Using several smaller SELECTs will ensure that the table will not be locked
- * for too long.
- *
- * @see Piwik_Sql::segmentedFetchFirst
- *
- * @param string $sql The SQL to perform. The last two conditions of the WHERE
- * expression must be as follows: 'id >= ? AND id < ?' where
- * 'id' is the int id of the table.
- * @param int $first The minimum ID to loop from.
- * @param int $last The maximum ID to loop to.
- * @param int $step The maximum number of rows to scan in each smaller SELECT.
- * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
- *
- * @return array
- */
-function Piwik_SegmentedFetchOne($sql, $first, $last, $step, $params = array())
-{
- return Piwik_Sql::segmentedFetchOne($sql, $first, $last, $step, $params);
-}
-
-/**
- * Performs a SELECT on a table one chunk at a time and returns an array
- * of every fetched row.
- *
- * This function will break up a SELECT into several smaller SELECTs and
- * should be used when performing a SELECT that can take a long time to finish.
- * Using several smaller SELECTs will ensure that the table will not be locked
- * for too long.
- *
- * @see Piwik_Sql::segmentedFetchFirst
- *
- * @param string $sql The SQL to perform. The last two conditions of the WHERE
- * expression must be as follows: 'id >= ? AND id < ?' where
- * 'id' is the int id of the table.
- * @param int $first The minimum ID to loop from.
- * @param int $last The maximum ID to loop to.
- * @param int $step The maximum number of rows to scan in each smaller SELECT.
- * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
- *
- * @return array
- */
-function Piwik_SegmentedFetchAll($sql, $first, $last, $step, $params = array())
-{
- return Piwik_Sql::segmentedFetchAll($sql, $first, $last, $step, $params);
-}
-
-/**
- * Performs a query on a table one chunk at a time and returns an array of
- * every fetched row.
- *
- * This function will break up a non-SELECT query (like an INSERT, UPDATE, or
- * DELETE) into smaller queries and should be used when performing an operation
- * that can take a long time to finish. Using several small queries will ensure
- * that the table will not be locked for too long.
- *
- * @see Piwik_Sql::segmentedQuery
- *
- * @param string $sql The SQL to perform. The last two conditions of the WHERE
- * expression must be as follows: 'id >= ? AND id < ?' where
- * 'id' is the int id of the table.
- * @param int $first The minimum ID to loop from.
- * @param int $last The maximum ID to loop to.
- * @param int $step The maximum number of rows to scan in each smaller query.
- * @param array $params Parameters to bind in the query, array( param1 => value1, param2 => value2)
- *
- * @return array
- */
-function Piwik_SegmentedQuery($sql, $first, $last, $step, $params = array())
-{
- return Piwik_Sql::segmentedQuery($sql, $first, $last, $step, $params);
-}
-
-/**
- * Attempts to get a named lock. This function uses a timeout of 1s, but will
- * retry a set number of time.
- *
- * @see Piwik_Sql::getDbLock
- *
- * @param string $lockName The lock name.
- * @param int $maxRetries The max number of times to retry.
- * @return bool true if the lock was obtained, false if otherwise.
- */
-function Piwik_GetDbLock($lockName, $maxRetries = 30)
-{
- return Piwik_Sql::getDbLock($lockName, $maxRetries);
-}
-
-/**
- * Releases a named lock.
- *
- * @see Piwik_Sql::releaseDbLock
- *
- * @param string $lockName The lock name.
- * @return bool true if the lock was released, false if otherwise.
- */
-function Piwik_ReleaseDbLock($lockName)
-{
- return Piwik_Sql::releaseDbLock($lockName);
-}
-
diff --git a/core/Db/Adapter.php b/core/Db/Adapter.php
index db9214b82a..e818866802 100644
--- a/core/Db/Adapter.php
+++ b/core/Db/Adapter.php
@@ -8,13 +8,17 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Db;
+
+use Piwik\Db\AdapterInterface;
use Piwik\Loader;
+use Zend_Db_Table;
/**
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Adapter
+class Adapter
{
/**
* Create adapter
@@ -22,7 +26,7 @@ class Piwik_Db_Adapter
* @param string $adapterName database adapter name
* @param array $dbInfos database connection info
* @param bool $connect
- * @return Piwik_Db_Adapter_Interface
+ * @return AdapterInterface
*/
public static function factory($adapterName, & $dbInfos, $connect = true)
{
diff --git a/core/Db/Adapter/Mysqli.php b/core/Db/Adapter/Mysqli.php
index 38495a2357..db923dbf99 100644
--- a/core/Db/Adapter/Mysqli.php
+++ b/core/Db/Adapter/Mysqli.php
@@ -9,12 +9,13 @@
* @package Piwik
*/
use Piwik\Config;
+use Piwik\Db\AdapterInterface;
/**
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Adapter_Mysqli extends Zend_Db_Adapter_Mysqli implements Piwik_Db_Adapter_Interface
+class Piwik_Db_Adapter_Mysqli extends Zend_Db_Adapter_Mysqli implements AdapterInterface
{
/**
* Constructor
diff --git a/core/Db/Adapter/Pdo/Mssql.php b/core/Db/Adapter/Pdo/Mssql.php
index 458a99fcc5..c77797b6c1 100644
--- a/core/Db/Adapter/Pdo/Mssql.php
+++ b/core/Db/Adapter/Pdo/Mssql.php
@@ -8,13 +8,23 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Db\Adapter\Pdo;
+
+use Exception;
+use PDO;
+use PDOException;
use Piwik\Config;
+use Piwik\Db\Adapter\AdapterInterface;
+use Zend_Db;
+use Zend_Db_Adapter_Exception;
+use Zend_Db_Adapter_Pdo_Mssql;
+use Zend_Db_Profiler;
/**
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_Adapter_Interface
+class Mssql extends Zend_Db_Adapter_Pdo_Mssql implements AdapterInterface
{
/**
* Returns connection handle
@@ -38,7 +48,7 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A
/**
* @see Zend_Db_Adapter_Exception
*/
- throw new Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
+ throw new \Zend_Db_Adapter_Exception('The PDO extension is required for this adapter but the extension is not loaded');
}
// check the PDO driver is available
@@ -46,7 +56,7 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A
/**
* @see Zend_Db_Adapter_Exception
*/
- throw new Zend_Db_Adapter_Exception('The ' . $this->_pdoType . ' driver is not currently installed');
+ throw new \Zend_Db_Adapter_Exception('The ' . $this->_pdoType . ' driver is not currently installed');
}
// create PDO connection
@@ -71,7 +81,6 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A
$this->_connection = new PDO("sqlsrv:$serverName", $uid, $pwd, array('Database' => $database));
-
if ($this->_connection === false) {
die(self::FormatErrors(sqlsrv_errors()));
}
@@ -91,7 +100,6 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A
$this->_connection->setAttribute(PDO::ATTR_CASE, $this->_caseFolding);
$this->_connection->setAttribute(PDO::SQLSRV_ENCODING_UTF8, true);
-
// always use exceptions.
$this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -100,7 +108,7 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A
/**
* @see Zend_Db_Adapter_Exception
*/
- throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
+ throw new \Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
}
}
@@ -134,7 +142,6 @@ class Piwik_Db_Pdo_Mssql extends Zend_Db_Adapter_Pdo_Mssql implements Piwik_Db_A
if (version_compare($serverVersion, $requiredVersion) === -1) {
throw new Exception(Piwik_TranslateException('General_ExceptionDatabaseVersion', array('MSSQL', $serverVersion, $requiredVersion)));
}
-
}
/**
diff --git a/core/Db/Adapter/Pdo/Mysql.php b/core/Db/Adapter/Pdo/Mysql.php
index c2ad0ea2d8..37dae1bee8 100644
--- a/core/Db/Adapter/Pdo/Mysql.php
+++ b/core/Db/Adapter/Pdo/Mysql.php
@@ -8,13 +8,23 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Db\Adapter\Pdo;
+
+use Exception;
+use PDO;
+use PDOException;
use Piwik\Config;
+use Piwik\Db\Adapter\AdapterInterface;
+use Zend_Config;
+use Zend_Db_Adapter_Pdo_Mysql;
+use Zend_Db_Select;
+use Zend_Db_Statement_Interface;
/**
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Adapter_Pdo_Mysql extends Zend_Db_Adapter_Pdo_Mysql implements Piwik_Db_Adapter_Interface
+class Mysql extends Zend_Db_Adapter_Pdo_Mysql implements AdapterInterface
{
/**
* Constructor
diff --git a/core/Db/Adapter/Pdo/Pgsql.php b/core/Db/Adapter/Pdo/Pgsql.php
index f4e68dfde9..16baba2543 100644
--- a/core/Db/Adapter/Pdo/Pgsql.php
+++ b/core/Db/Adapter/Pdo/Pgsql.php
@@ -8,13 +8,20 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Db\Adapter\Pdo;
+
+use Exception;
+use PDO;
+use PDOException;
use Piwik\Config;
+use Piwik\Db\Adapter\AdapterInterface;
+use Zend_Db_Adapter_Pdo_Pgsql;
/**
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Adapter_Pdo_Pgsql extends Zend_Db_Adapter_Pdo_Pgsql implements Piwik_Db_Adapter_Interface
+class Pgsql extends Zend_Db_Adapter_Pdo_Pgsql implements AdapterInterface
{
/**
* Reset the configuration variables in this adapter.
diff --git a/core/Db/Adapter/Interface.php b/core/Db/AdapterInterface.php
index bd81c0834d..e13a99769b 100644
--- a/core/Db/Adapter/Interface.php
+++ b/core/Db/AdapterInterface.php
@@ -9,11 +9,15 @@
* @package Piwik
*/
+namespace Piwik\Db;
+
+use Exception;
+
/**
* @package Piwik
* @subpackage Piwik_Db
*/
-interface Piwik_Db_Adapter_Interface
+interface AdapterInterface
{
/**
* Reset the configuration variables in this adapter.
diff --git a/core/Db/Schema.php b/core/Db/Schema.php
index fed20dfe28..261860c6a1 100644
--- a/core/Db/Schema.php
+++ b/core/Db/Schema.php
@@ -8,7 +8,10 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Db;
+
use Piwik\Config;
+use Piwik\Db\Schema\SchemaInterface;
/**
* Schema abstraction
@@ -18,12 +21,12 @@ use Piwik\Config;
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Schema
+class Schema
{
/**
* Singleton instance
*
- * @var Piwik_Db_Schema
+ * @var \Piwik\Db\Schema
*/
static private $instance = null;
@@ -35,9 +38,9 @@ class Piwik_Db_Schema
private $schema = null;
/**
- * Returns the singleton Piwik_Db_Schema
+ * Returns the singleton Schema
*
- * @return Piwik_Db_Schema
+ * @return \Piwik\Db\Schema
*/
static public function getInstance()
{
@@ -145,9 +148,9 @@ class Piwik_Db_Schema
}
/**
- * Returns an instance that subclasses Piwik_Db_Schema
+ * Returns an instance that subclasses Schema
*
- * @return Piwik_Db_Schema_Interface
+ * @return \Piwik\Db\Schema\SchemaInterface
*/
private function getSchema()
{
diff --git a/core/Db/Schema/Myisam.php b/core/Db/Schema/Myisam.php
index 274e6f82e0..8a6ae12e07 100644
--- a/core/Db/Schema/Myisam.php
+++ b/core/Db/Schema/Myisam.php
@@ -8,10 +8,15 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Db\Schema;
+
+use Exception;
use Piwik\Config;
+use Piwik\Db\Schema\SchemaInterface;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
+use Zend_Registry;
/**
* MySQL schema
@@ -19,7 +24,7 @@ use Piwik\Date;
* @package Piwik
* @subpackage Piwik_Db
*/
-class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
+class Myisam implements SchemaInterface
{
/**
* Is this MySQL storage engine available?
@@ -92,7 +97,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
excluded_ips TEXT NOT NULL,
excluded_parameters TEXT NOT NULL,
excluded_user_agents TEXT NOT NULL,
- `group` VARCHAR(250) NOT NULL,
+ `group` VARCHAR(250) NOT NULL,
keep_url_fragment TINYINT NOT NULL DEFAULT 0,
PRIMARY KEY(idsite)
) DEFAULT CHARSET=utf8
@@ -197,7 +202,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
visit_total_searches SMALLINT(5) UNSIGNED NOT NULL,
visit_total_time SMALLINT(5) UNSIGNED NOT NULL,
visit_goal_converted TINYINT(1) NOT NULL,
- visit_goal_buyer TINYINT(1) NOT NULL,
+ visit_goal_buyer TINYINT(1) NOT NULL,
referer_type TINYINT(1) UNSIGNED NULL,
referer_name VARCHAR(70) NULL,
referer_url TEXT NOT NULL,
@@ -247,7 +252,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
server_time DATETIME NOT NULL,
idvisit INTEGER(10) UNSIGNED NOT NULL,
idorder varchar(100) NOT NULL,
-
+
idaction_sku INTEGER(10) UNSIGNED NOT NULL,
idaction_name INTEGER(10) UNSIGNED NOT NULL,
idaction_category INTEGER(10) UNSIGNED NOT NULL,
@@ -258,7 +263,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
price FLOAT NOT NULL,
quantity INTEGER(10) UNSIGNED NOT NULL,
deleted TINYINT(1) UNSIGNED NOT NULL,
-
+
PRIMARY KEY(idvisit, idorder, idaction_sku),
INDEX index_idsite_servertime ( idsite, server_time )
) DEFAULT CHARSET=utf8
@@ -287,7 +292,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
url text NOT NULL,
idgoal int(10) NOT NULL,
buster int unsigned NOT NULL,
-
+
idorder varchar(100) default NULL,
items SMALLINT UNSIGNED DEFAULT NULL,
revenue float default NULL,
@@ -295,7 +300,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
revenue_tax float default NULL,
revenue_shipping float default NULL,
revenue_discount float default NULL,
-
+
custom_var_k1 VARCHAR(200) DEFAULT NULL,
custom_var_v1 VARCHAR(200) DEFAULT NULL,
custom_var_k2 VARCHAR(200) DEFAULT NULL,
@@ -493,7 +498,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
if (is_null($dbName)) {
$dbName = Config::getInstance()->database['dbname'];
}
- Piwik_Exec("CREATE DATABASE IF NOT EXISTS " . $dbName . " DEFAULT CHARACTER SET utf8");
+ Db::exec("CREATE DATABASE IF NOT EXISTS " . $dbName . " DEFAULT CHARACTER SET utf8");
}
/**
@@ -502,7 +507,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
public function dropDatabase()
{
$dbName = Config::getInstance()->database['dbname'];
- Piwik_Exec("DROP DATABASE IF EXISTS " . $dbName);
+ Db::exec("DROP DATABASE IF EXISTS " . $dbName);
}
/**
@@ -546,7 +551,7 @@ class Piwik_Db_Schema_Myisam implements Piwik_Db_Schema_Interface
{
$tablesAlreadyInstalled = $this->getTablesInstalled($forceReload = true);
foreach ($tablesAlreadyInstalled as $table) {
- Piwik_Query("TRUNCATE `$table`");
+ Db::query("TRUNCATE `$table`");
}
}
diff --git a/core/Db/Schema/Interface.php b/core/Db/SchemaInterface.php
index a56f79eb03..c8ad0eb340 100644
--- a/core/Db/Schema/Interface.php
+++ b/core/Db/SchemaInterface.php
@@ -9,13 +9,15 @@
* @package Piwik
*/
+namespace Piwik\Db;
+
/**
* Database schema interface
*
* @package Piwik
* @subpackage Piwik_Db
*/
-interface Piwik_Db_Schema_Interface
+interface SchemaInterface
{
/**
* Is this schema available?
diff --git a/core/ExceptionHandler.php b/core/ExceptionHandler.php
index c06bc3d5af..5b21d59e6e 100644
--- a/core/ExceptionHandler.php
+++ b/core/ExceptionHandler.php
@@ -9,6 +9,7 @@
* @package Piwik
*/
use Piwik\Piwik;
+use Piwik\FrontController;
/**
* Exception handler used to display nicely exceptions in Piwik
@@ -22,7 +23,7 @@ function Piwik_ExceptionHandler(Exception $exception)
Zend_Registry::get('logger_exception')->logEvent($exception);
} catch (Exception $e) {
- if (Piwik_FrontController::shouldRethrowException()) {
+ if (FrontController::shouldRethrowException()) {
throw $exception;
}
diff --git a/core/FrontController.php b/core/FrontController.php
index 9d777ed4b6..1acd18820f 100644
--- a/core/FrontController.php
+++ b/core/FrontController.php
@@ -8,20 +8,16 @@
* @category Piwik
* @package Piwik
*/
-use Piwik\Config;
-use Piwik\Piwik;
-use Piwik\Common;
-use Piwik\Access;
-use Piwik\Translate;
-/**
- * @see core/PluginsManager.php
- * @see core/Translate.php
- * @see core/Option.php
- */
-require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php';
-require_once PIWIK_INCLUDE_PATH . '/core/Translate.php';
-require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
+namespace Piwik;
+use \Piwik\NoAccessException;
+use Exception;
+use Piwik\API\Request;
+use Piwik\API\ResponseBuilder;
+use Piwik\Session;
+use Piwik\Timer;
+use Piwik\Url;
+use Zend_Registry;
/**
* Front controller.
@@ -31,9 +27,9 @@ require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
* For a detailed explanation, see the documentation on http://piwik.org/docs/plugins/framework-overview
*
* @package Piwik
- * @subpackage Piwik_FrontController
+ * @subpackage FrontController
*/
-class Piwik_FrontController
+class FrontController
{
/**
* Set to false and the Front Controller will not dispatch the request
@@ -47,7 +43,7 @@ class Piwik_FrontController
/**
* returns singleton
*
- * @return Piwik_FrontController
+ * @return \Piwik\FrontController
*/
public static function getInstance()
{
@@ -83,10 +79,10 @@ class Piwik_FrontController
$action = Common::getRequestVar('action', false);
}
- if (!Piwik_Session::isFileBasedSessions()
+ if (!Session::isFileBasedSessions()
&& ($module !== 'API' || ($action && $action !== 'index'))
) {
- Piwik_Session::start();
+ Session::start();
}
if (is_null($parameters)) {
@@ -128,7 +124,7 @@ class Piwik_FrontController
try {
return call_user_func_array(array($params[0], $params[1]), $params[2]);
- } catch (Access_NoAccessException $e) {
+ } catch (\Piwik\NoAccessException $e) {
Piwik_PostEvent('FrontController.NoAccessException', array($e), $pending = true);
} catch (Exception $e) {
$debugTrace = $e->getTraceAsString();
@@ -190,7 +186,7 @@ class Piwik_FrontController
*
* @return Exception
*/
- protected function createConfigObject()
+ public function createConfigObject()
{
$exceptionToThrow = false;
try {
@@ -221,9 +217,8 @@ class Piwik_FrontController
}
$initialized = true;
-
try {
- Zend_Registry::set('timer', new Piwik_Timer);
+ Zend_Registry::set('timer', new Timer);
$directoriesToCheck = array(
'/tmp/',
@@ -240,8 +235,8 @@ class Piwik_FrontController
$exceptionToThrow = $this->createConfigObject();
- if (Piwik_Session::isFileBasedSessions()) {
- Piwik_Session::start();
+ if (Session::isFileBasedSessions()) {
+ Session::start();
}
$this->handleMaintenanceMode();
@@ -256,7 +251,6 @@ class Piwik_FrontController
throw $exceptionToThrow;
}
-
try {
Piwik::createDatabaseObject();
} catch (Exception $e) {
@@ -267,7 +261,7 @@ class Piwik_FrontController
throw $e;
}
- Piwik::createLogObject();
+ \Piwik\Log::make();
// Init the Access object, so that eg. core/Updates/* can enforce Super User and use some APIs
Access::getInstance();
@@ -286,16 +280,16 @@ class Piwik_FrontController
$authAdapter = Zend_Registry::get('auth');
} catch (Exception $e) {
throw new Exception("Authentication object cannot be found in the Registry. Maybe the Login plugin is not activated?
- <br />You can activate the plugin by adding:<br />
- <code>Plugins[] = Login</code><br />
- under the <code>[Plugins]</code> section in your config/config.ini.php");
+ <br />You can activate the plugin by adding:<br />
+ <code>Plugins[] = Login</code><br />
+ under the <code>[Plugins]</code> section in your config/config.ini.php");
}
Access::getInstance()->reloadAccess($authAdapter);
// Force the auth to use the token_auth if specified, so that embed dashboard
// and all other non widgetized controller methods works fine
if (($token_auth = Common::getRequestVar('token_auth', false, 'string')) !== false) {
- Piwik_API_Request::reloadAuthUsingTokenAuth();
+ Request::reloadAuthUsingTokenAuth();
}
Piwik::raiseMemoryLimitIfNecessary();
@@ -334,7 +328,7 @@ class Piwik_FrontController
if (empty($format)) {
throw $exception;
}
- $response = new Piwik_API_ResponseBuilder($format);
+ $response = new ResponseBuilder($format);
echo $response->getResponseException($exception);
exit;
}
@@ -349,18 +343,19 @@ class Piwik_FrontController
&& !(Common::getRequestVar('module', '') == 'CoreAdminHome'
&& Common::getRequestVar('action', '') == 'optOut')
) {
- $url = Piwik_Url::getCurrentUrl();
+ $url = Url::getCurrentUrl();
$url = str_replace("http://", "https://", $url);
- Piwik_Url::redirectToUrl($url);
+ Url::redirectToUrl($url);
}
}
}
+
/**
* Exception thrown when the requested plugin is not activated in the config file
*
* @package Piwik
- * @subpackage Piwik_FrontController
+ * @subpackage FrontController
*/
class Piwik_FrontController_PluginDeactivatedException extends Exception
{
@@ -370,3 +365,4 @@ class Piwik_FrontController_PluginDeactivatedException extends Exception
}
}
+
diff --git a/core/HTMLPurifier.php b/core/HTMLPurifier.php
deleted file mode 100644
index 33095f2f52..0000000000
--- a/core/HTMLPurifier.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?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
- * @package Piwik
- */
-
-/**
- * HTML Purifier class wrapper.
- *
- * @package Piwik
- */
-class Piwik_HTMLPurifier
-{
- private static $instance = null;
-
- /**
- * Returns the singleton HTMLPurifier or a mock object
- *
- * @return HTMLPurifier|Piwik_HTMLPurifier
- */
- public static function getInstance()
- {
- if (self::$instance == null) {
- if (file_exists(PIWIK_INCLUDE_PATH . '/libs/HTMLPurifier.php')) {
- if (!class_exists('HTMLPurifier_Bootstrap', false)) {
- HTMLPurifier_Bootstrap::registerAutoload();
- }
-
- $config = HTMLPurifier_Config::createDefault();
- $config->set('Cache.SerializerPath', PIWIK_USER_PATH . '/tmp/purifier');
-
- self::$instance = new HTMLPurifier($config);
- } else {
- $c = __CLASS__;
- self::$instance = new $c();
- }
- }
- return self::$instance;
- }
-
- public function purify($html, $config = null)
- {
- return $html;
- }
-}
diff --git a/core/Http.php b/core/Http.php
index de30bf3b2f..df00fce2a1 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -8,9 +8,14 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\IP;
+use Piwik\Version;
/**
* Server-side http client to retrieve content from remote servers, and optionally save to a local file.
@@ -18,7 +23,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_Http
+class Http
{
/**
* Get "best" available transport method for sendHttpRequest() calls.
@@ -55,16 +60,16 @@ class Piwik_Http
* If no $destinationPath is specified, the trimmed response (without header) is returned as a string.
* If a $destinationPath is specified, the response (without header) is saved to a file.
*
- * @param string $aUrl
- * @param int $timeout
- * @param string $userAgent
- * @param string $destinationPath
- * @param int $followDepth
- * @param bool $acceptLanguage
+ * @param string $aUrl
+ * @param int $timeout
+ * @param string $userAgent
+ * @param string $destinationPath
+ * @param int $followDepth
+ * @param bool $acceptLanguage
* @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
* Doesn't work w/ fopen method.
- * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
- * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
+ * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
+ * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
*
* @throws Exception
* @return bool true (or string) on success; false on HTTP response error code (1xx or 4xx)
@@ -88,19 +93,19 @@ class Piwik_Http
/**
* Sends http request using the specified transport method
*
- * @param string $method
- * @param string $aUrl
- * @param int $timeout
- * @param string $userAgent
- * @param string $destinationPath
- * @param resource $file
- * @param int $followDepth
+ * @param string $method
+ * @param string $aUrl
+ * @param int $timeout
+ * @param string $userAgent
+ * @param string $destinationPath
+ * @param resource $file
+ * @param int $followDepth
* @param bool|string $acceptLanguage Accept-language header
- * @param bool $acceptInvalidSslCertificate Only used with $method == 'curl'. If set to true (NOT recommended!) the SSL certificate will not be checked
- * @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
+ * @param bool $acceptInvalidSslCertificate Only used with $method == 'curl'. If set to true (NOT recommended!) the SSL certificate will not be checked
+ * @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
* Doesn't work w/ fopen method.
- * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
- * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
+ * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
+ * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
*
* @throws Exception
* @return bool true (or string/array) on success; false on HTTP response error code (1xx or 4xx)
@@ -130,7 +135,7 @@ class Piwik_Http
// Piwik services behave like a proxy, so we should act like one.
$xff = 'X-Forwarded-For: '
. (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] . ',' : '')
- . Piwik_IP::getIpFromHeader();
+ . IP::getIpFromHeader();
if (empty($userAgent)) {
$userAgent = self::getUserAgent();
@@ -138,7 +143,7 @@ class Piwik_Http
$via = 'Via: '
. (isset($_SERVER['HTTP_VIA']) && !empty($_SERVER['HTTP_VIA']) ? $_SERVER['HTTP_VIA'] . ', ' : '')
- . Piwik_Version::VERSION . ' '
+ . Version::VERSION . ' '
. ($userAgent ? " ($userAgent)" : '');
// range header
@@ -450,7 +455,6 @@ class Piwik_Http
@curl_setopt_array($ch, $curl_options);
self::configCurlCertificate($ch);
-
/*
* as of php 5.2.0, CURLOPT_FOLLOWLOCATION can't be set if
* in safe_mode or open_basedir is set
@@ -540,7 +544,7 @@ class Piwik_Http
*
* @param string $url The url to download from.
* @param string $outputPath The path to the file to save/append to.
- * @param bool $isContinuation True if this is the continuation of a download,
+ * @param bool $isContinuation True if this is the continuation of a download,
* or if we're starting a fresh one.
*
* @throws Exception
@@ -560,7 +564,7 @@ class Piwik_Http
// if we're starting a download, get the expected file size & save as an option
$downloadOption = $outputPath . '_expectedDownloadSize';
if (!$isContinuation) {
- $expectedFileSizeResult = Piwik_Http::sendHttpRequest(
+ $expectedFileSizeResult = Http::sendHttpRequest(
$url,
$timeout = 300,
$userAgent = null,
@@ -601,7 +605,7 @@ class Piwik_Http
}
// download a chunk of the file
- $result = Piwik_Http::sendHttpRequest(
+ $result = Http::sendHttpRequest(
$url,
$timeout = 300,
$userAgent = null,
@@ -650,7 +654,7 @@ class Piwik_Http
{
return !empty($_SERVER['HTTP_USER_AGENT'])
? $_SERVER['HTTP_USER_AGENT']
- : 'Piwik/' . Piwik_Version::VERSION;
+ : 'Piwik/' . Version::VERSION;
}
/**
diff --git a/core/IP.php b/core/IP.php
index 2fa60ca33d..e1fecf600d 100644
--- a/core/IP.php
+++ b/core/IP.php
@@ -9,31 +9,11 @@
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Config;
use Piwik\Common;
-
-if (Common::isWindows() || !function_exists('inet_ntop')) {
- function _inet_ntop($in_addr)
- {
- return php_compat_inet_ntop($in_addr);
- }
-} else {
- function _inet_ntop($in_addr)
- {
- return inet_ntop($in_addr);
- }
-}
-if (Common::isWindows() || !function_exists('inet_pton')) {
- function _inet_pton($address)
- {
- return php_compat_inet_pton($address);
- }
-} else {
- function _inet_pton($address)
- {
- return inet_pton($address);
- }
-}
+use false;
/**
* Handling IP addresses (both IPv4 and IPv6).
@@ -52,7 +32,7 @@ if (Common::isWindows() || !function_exists('inet_pton')) {
*
* @package Piwik
*/
-class Piwik_IP
+class IP
{
const MAPPED_IPv4_START = '::ffff:';
@@ -134,7 +114,7 @@ class Piwik_IP
}
// single IP
- if (($ip = @_inet_pton($ipRangeString)) === false)
+ if (($ip = @self::_inet_pton($ipRangeString)) === false)
return false;
$maxbits = Common::strlen($ip) * 8;
@@ -157,7 +137,7 @@ class Piwik_IP
public static function P2N($ipString)
{
// use @inet_pton() because it throws an exception and E_WARNING on invalid input
- $ip = @_inet_pton($ipString);
+ $ip = @self::_inet_pton($ipString);
return $ip === false ? "\x00\x00\x00\x00" : $ip;
}
@@ -172,7 +152,7 @@ class Piwik_IP
public static function N2P($ip)
{
// use @inet_ntop() because it throws an exception and E_WARNING on invalid input
- $ipStr = @_inet_ntop($ip);
+ $ipStr = @self::_inet_ntop($ip);
return $ipStr === false ? '0.0.0.0' : $ipStr;
}
@@ -293,7 +273,7 @@ class Piwik_IP
$bits = substr($ipRange, $pos + 1);
$range = substr($ipRange, 0, $pos);
- $high = $low = @_inet_pton($range);
+ $high = $low = @self::_inet_pton($range);
if ($low === false) {
return false;
}
@@ -435,7 +415,6 @@ class Piwik_IP
/**
* Get hostname for a given IP address
*
- * @todo Remove in 2.0?
* @param string $ipStr Human-readable IP address
* @return string Hostname or unmodified $ipStr if failure
*/
@@ -446,154 +425,172 @@ class Piwik_IP
$host = strtolower(@gethostbyaddr($ipStr));
return $host === '' ? $ipStr : $host;
}
-}
-/**
- * Converts a packed internet address to a human readable representation
- *
- * @link http://php.net/inet_ntop
- *
- * @param string $in_addr 32-bit IPv4 or 128-bit IPv6 address
- * @return string|false string representation of address or false on failure
- */
-function php_compat_inet_ntop($in_addr)
-{
- $r = bin2hex($in_addr);
-
- switch (Common::strlen($in_addr)) {
- case 4:
- // IPv4 address
- $prefix = '';
- break;
-
- case 16:
- // IPv4-mapped address
- if (substr_compare($r, '00000000000000000000ffff', 0, 24) === 0) {
- $prefix = '::ffff:';
- $r = substr($r, 24);
- break;
- }
+ static private function _inet_ntop($in_addr)
+ {
+ if (Common::isWindows() || !function_exists('inet_ntop')) {
+ return self::php_compat_inet_ntop($in_addr);
+ } else {
+ return inet_ntop($in_addr);
+ }
+ }
- // IPv4-compat address
- if (substr_compare($r, '000000000000000000000000', 0, 24) === 0 &&
- substr_compare($r, '0000', 24, 4) !== 0
- ) {
- $prefix = '::';
- $r = substr($r, 24);
+ static private function _inet_pton($address)
+ {
+ if (Common::isWindows() || !function_exists('inet_pton')) {
+ return self::php_compat_inet_pton($address);
+ } else {
+ return inet_pton($address);
+ }
+ }
+
+ /**
+ * Converts a packed internet address to a human readable representation
+ *
+ * @link http://php.net/inet_ntop
+ *
+ * @param string $in_addr 32-bit IPv4 or 128-bit IPv6 address
+ * @return string|false string representation of address or false on failure
+ */
+ static public function php_compat_inet_ntop($in_addr)
+ {
+ $r = bin2hex($in_addr);
+
+ switch (Common::strlen($in_addr)) {
+ case 4:
+ // IPv4 address
+ $prefix = '';
break;
- }
- $r = str_split($r, 4);
- $r = implode(':', $r);
-
- // compress leading zeros
- $r = preg_replace(
- '/(^|:)0{1,3}/',
- '$1',
- $r
- );
-
- // compress longest (and leftmost) consecutive groups of zeros
- if (preg_match_all('/(?:^|:)(0(:|$))+/D', $r, $matches)) {
- $longestMatch = 0;
- foreach ($matches[0] as $aMatch) {
- if (strlen($aMatch) > strlen($longestMatch)) {
- $longestMatch = $aMatch;
- }
+ case 16:
+ // IPv4-mapped address
+ if (substr_compare($r, '00000000000000000000ffff', 0, 24) === 0) {
+ $prefix = '::ffff:';
+ $r = substr($r, 24);
+ break;
}
- $r = substr_replace($r, '::', strpos($r, $longestMatch), strlen($longestMatch));
- }
- return $r;
+ // IPv4-compat address
+ if (substr_compare($r, '000000000000000000000000', 0, 24) === 0 &&
+ substr_compare($r, '0000', 24, 4) !== 0
+ ) {
+ $prefix = '::';
+ $r = substr($r, 24);
+ break;
+ }
- default:
- return false;
- }
+ $r = str_split($r, 4);
+ $r = implode(':', $r);
+
+ // compress leading zeros
+ $r = preg_replace(
+ '/(^|:)0{1,3}/',
+ '$1',
+ $r
+ );
+
+ // compress longest (and leftmost) consecutive groups of zeros
+ if (preg_match_all('/(?:^|:)(0(:|$))+/D', $r, $matches)) {
+ $longestMatch = 0;
+ foreach ($matches[0] as $aMatch) {
+ if (strlen($aMatch) > strlen($longestMatch)) {
+ $longestMatch = $aMatch;
+ }
+ }
+ $r = substr_replace($r, '::', strpos($r, $longestMatch), strlen($longestMatch));
+ }
- $r = str_split($r, 2);
- $r = array_map('hexdec', $r);
- $r = implode('.', $r);
- return $prefix . $r;
-}
+ return $r;
-/**
- * Converts a human readable IP address to its packed in_addr representation
- *
- * @link http://php.net/inet_pton
- *
- * @param string $address a human readable IPv4 or IPv6 address
- * @return string in_addr representation or false on failure
- */
-function php_compat_inet_pton($address)
-{
- // IPv4 (or IPv4-compat, or IPv4-mapped)
- if (preg_match('/(^|:)([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/iD', $address, $matches)) {
- for ($i = count($matches); $i-- > 2;) {
- if ($matches[$i] > 255 ||
- ($matches[$i][0] == '0' && strlen($matches[$i]) > 1)
- ) {
+ default:
return false;
- }
}
- if (empty($matches[1])) {
- $r = ip2long($address);
- if ($r === false) {
- return false;
+ $r = str_split($r, 2);
+ $r = array_map('hexdec', $r);
+ $r = implode('.', $r);
+ return $prefix . $r;
+ }
+
+ /**
+ * Converts a human readable IP address to its packed in_addr representation
+ *
+ * @link http://php.net/inet_pton
+ *
+ * @param string $address a human readable IPv4 or IPv6 address
+ * @return string in_addr representation or false on failure
+ */
+ static public function php_compat_inet_pton($address)
+ {
+ // IPv4 (or IPv4-compat, or IPv4-mapped)
+ if (preg_match('/(^|:)([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/iD', $address, $matches)) {
+ for ($i = count($matches); $i-- > 2;) {
+ if ($matches[$i] > 255 ||
+ ($matches[$i][0] == '0' && strlen($matches[$i]) > 1)
+ ) {
+ return false;
+ }
}
- return pack('N', $r);
- }
+ if (empty($matches[1])) {
+ $r = ip2long($address);
+ if ($r === false) {
+ return false;
+ }
- $suffix = sprintf("%02x%02x:%02x%02x", $matches[2], $matches[3], $matches[4], $matches[5]);
- $address = substr_replace($address, $matches[1] . $suffix, strrpos($address, $matches[0]));
- }
+ return pack('N', $r);
+ }
- // IPv6
- if (strpos($address, ':') === false ||
- strspn($address, '01234567890abcdefABCDEF:') !== strlen($address)
- ) {
- return false;
- }
+ $suffix = sprintf("%02x%02x:%02x%02x", $matches[2], $matches[3], $matches[4], $matches[5]);
+ $address = substr_replace($address, $matches[1] . $suffix, strrpos($address, $matches[0]));
+ }
- if (substr($address, 0, 2) == '::') {
- $address = '0' . $address;
- }
+ // IPv6
+ if (strpos($address, ':') === false ||
+ strspn($address, '01234567890abcdefABCDEF:') !== strlen($address)
+ ) {
+ return false;
+ }
- if (substr($address, -2) == '::') {
- $address .= '0';
- }
+ if (substr($address, 0, 2) == '::') {
+ $address = '0' . $address;
+ }
- $r = explode(':', $address);
- $count = count($r);
+ if (substr($address, -2) == '::') {
+ $address .= '0';
+ }
- // grouped zeros
- if (strpos($address, '::') !== false
- && $count < 8
- ) {
- $zeroGroup = array_search('', $r, 1);
+ $r = explode(':', $address);
+ $count = count($r);
- // we're replacing this cell, so we splice (8 - $count + 1) cells containing '0'
- array_splice($r, $zeroGroup, 1, array_fill(0, 9 - $count, '0'));
- }
+ // grouped zeros
+ if (strpos($address, '::') !== false
+ && $count < 8
+ ) {
+ $zeroGroup = array_search('', $r, 1);
- // guard against excessive ':' or '::'
- if ($count > 8 ||
- array_search('', $r, 1) !== false
- ) {
- return false;
- }
+ // we're replacing this cell, so we splice (8 - $count + 1) cells containing '0'
+ array_splice($r, $zeroGroup, 1, array_fill(0, 9 - $count, '0'));
+ }
- // leading zeros
- foreach ($r as $v) {
- if (strlen(ltrim($v, '0')) > 4) {
+ // guard against excessive ':' or '::'
+ if ($count > 8 ||
+ array_search('', $r, 1) !== false
+ ) {
return false;
}
- }
- $r = array_map('hexdec', $r);
- array_unshift($r, 'n*');
- $r = call_user_func_array('pack', $r);
+ // leading zeros
+ foreach ($r as $v) {
+ if (strlen(ltrim($v, '0')) > 4) {
+ return false;
+ }
+ }
- return $r;
+ $r = array_map('hexdec', $r);
+ array_unshift($r, 'n*');
+ $r = call_user_func_array('pack', $r);
+
+ return $r;
+ }
}
diff --git a/core/JqplotDataGenerator.php b/core/JqplotDataGenerator.php
index 4ae3c493b2..76d48f5f19 100644
--- a/core/JqplotDataGenerator.php
+++ b/core/JqplotDataGenerator.php
@@ -9,57 +9,64 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Common;
+use Piwik\JqplotDataGenerator\Evolution;
use Piwik\Metrics;
use Piwik\DataTable;
+use Piwik_Visualization;
+use Piwik_Visualization_Chart_Pie;
+use Piwik_Visualization_Chart_VerticalBar;
/**
* Generates JSON data used to configure and populate JQPlot graphs.
- *
+ *
* Supports pie graphs, bar graphs and time serieses (aka, evolution graphs).
*/
-class Piwik_JqplotDataGenerator
+class JqplotDataGenerator
{
/**
* View properties. @see Piwik_ViewDataTable for more info.
- *
+ *
* @var array
*/
protected $properties;
-
+
/**
* This object does most of the work in generating the JQPlot JSON data.
- *
+ *
* @var Piwik_Visualization
*/
protected $visualization;
-
+
/**
* Creates a new JqplotDataGenerator instance for a graph type and view properties.
- *
+ *
* @param string $type 'pie', 'bar', or 'evolution'
* @param array $properties The view properties.
- * @return Piwik_JqplotDataGenerator
+ * @return \Piwik\JqplotDataGenerator
*/
public static function factory($type, $properties)
{
switch ($type) {
case 'evolution':
- return new Piwik_JqplotDataGenerator_Evolution($properties);
+ return new Evolution($properties);
case 'pie':
$visualization = new Piwik_Visualization_Chart_Pie();
- return new Piwik_JqplotDataGenerator($visualization, $properties);
+ return new JqplotDataGenerator($visualization, $properties);
case 'bar':
$visualization = new Piwik_Visualization_Chart_VerticalBar();
- return new Piwik_JqplotDataGenerator($visualization, $properties);
+ return new JqplotDataGenerator($visualization, $properties);
default:
throw new Exception("Unknown JqplotDataGenerator type '$type'.");
}
}
-
+
/**
* Constructor.
- *
+ *
* @param Piwik_Visualization $visualization
* @param array $properties
*/
@@ -68,10 +75,10 @@ class Piwik_JqplotDataGenerator
$this->visualization = $visualization;
$this->properties = $properties;
}
-
+
/**
* Generates JSON graph data and returns it.
- *
+ *
* @param DataTable|DataTable\Map $dataTable
* @return string
*/
@@ -80,9 +87,9 @@ class Piwik_JqplotDataGenerator
if (!empty($this->properties['graph_limit'])) {
$offsetStartSummary = $this->properties['graph_limit'] - 1;
$sortColumn = !empty($this->properties['filter_sort_column'])
- ? $this->properties['filter_sort_column']
- : Metrics::INDEX_NB_VISITS;
-
+ ? $this->properties['filter_sort_column']
+ : Metrics::INDEX_NB_VISITS;
+
$dataTable->filter(
'AddSummaryRow', array($offsetStartSummary, Piwik_Translate('General_Others'), $sortColumn));
}
@@ -93,12 +100,12 @@ class Piwik_JqplotDataGenerator
if (!empty($this->properties['add_total_row'])) {
$dataTable->queueFilter('AddSummaryRow', array(0, Piwik_Translate('General_Total'), null, false));
}
-
+
$this->initChartObjectData($dataTable);
}
-
+
$this->visualization->customizeChartProperties();
-
+
return $this->visualization->render();
}
@@ -110,7 +117,7 @@ class Piwik_JqplotDataGenerator
$dataTable->filter('ColumnCallbackReplace', array('label', 'urldecode'));
$xLabels = $dataTable->getColumn('label');
-
+
$columnNames = $this->properties['columns_to_display'];
if (($labelColumnIndex = array_search('label', $columnNames)) !== false) {
unset($columnNames[$labelColumnIndex]);
@@ -119,10 +126,10 @@ class Piwik_JqplotDataGenerator
$columnNameToTranslation = $columnNameToValue = array();
foreach ($columnNames as $columnName) {
$columnNameToTranslation[$columnName] = @$this->properties['translations'][$columnName];
-
+
$columnNameToValue[$columnName] = $dataTable->getColumn($columnName);
}
-
+
$visualization = $this->visualization;
$visualization->setAxisXLabels($xLabels);
$visualization->setAxisYValues($columnNameToValue);
@@ -151,20 +158,20 @@ class Piwik_JqplotDataGenerator
$unit = $this->properties['y_axis_unit'];
}
}
-
+
// the bar charts contain the labels a first series
// this series has to be removed from the units
if ($this->visualization instanceof Piwik_Visualization_Chart_VerticalBar) {
array_shift($units);
}
-
+
return $units;
}
private function deriveUnitsFromRequestedColumnNames()
{
$idSite = Common::getRequestVar('idSite', null, 'int');
-
+
$units = array();
foreach ($this->properties['columns_to_display'] as $columnName) {
$derivedUnit = Metrics::getUnit($columnName, $idSite);
@@ -190,7 +197,7 @@ class Piwik_JqplotDataGenerator
'displayed' => in_array($column, $this->properties['columns_to_display'])
);
}
-
+
$this->visualization->setSelectableColumns(
$selectableColumns, $this->properties['allow_multi_select_series_picker']);
}
diff --git a/core/JqplotDataGenerator/Evolution.php b/core/JqplotDataGenerator/Evolution.php
index 47c85f0724..218b0da890 100644
--- a/core/JqplotDataGenerator/Evolution.php
+++ b/core/JqplotDataGenerator/Evolution.php
@@ -8,17 +8,23 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\JqplotDataGenerator;
+
use Piwik\Piwik;
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\ViewDataTable;
+use Piwik\Url;
+use Piwik\JqplotDataGenerator;
+use Piwik_Visualization_Chart_Evolution;
/**
* Generates JQPlot JSON data/config for evolution graphs.
*/
-class Piwik_JqplotDataGenerator_Evolution extends Piwik_JqplotDataGenerator
+class Evolution extends JqplotDataGenerator
{
protected $rowPickerConfig = array();
-
+
/**
* Constructor.
*/
@@ -89,7 +95,7 @@ class Piwik_JqplotDataGenerator_Evolution extends Piwik_JqplotDataGenerator
$yAxisLabelToValueCleaned[$yAxisLabel][] = $columnValue;
}
}
-
+
$visualization = $this->visualization;
$visualization->setAxisXLabels($xLabels);
$visualization->setAxisYValues($yAxisLabelToValueCleaned);
@@ -113,14 +119,14 @@ class Piwik_JqplotDataGenerator_Evolution extends Piwik_JqplotDataGenerator
'idSite' => $idSite,
'period' => $period->getLabel(),
'date' => $dateInUrl->toString(),
- 'segment' => Piwik_ViewDataTable::getRawSegmentFromRequest()
+ 'segment' => ViewDataTable::getRawSegmentFromRequest()
);
$hash = '';
if (!empty($queryStringAsHash)) {
- $hash = '#' . Piwik_Url::getQueryStringFromParameters($queryStringAsHash + $parameters);
+ $hash = '#' . Url::getQueryStringFromParameters($queryStringAsHash + $parameters);
}
$link = 'index.php?' .
- Piwik_Url::getQueryStringFromParameters(array(
+ Url::getQueryStringFromParameters(array(
'module' => 'CoreHome',
'action' => 'index',
) + $parameters)
@@ -131,7 +137,7 @@ class Piwik_JqplotDataGenerator_Evolution extends Piwik_JqplotDataGenerator
}
$this->addSeriesPickerToView();
-
+
// configure the row picker
if ($this->properties['row_picker_mach_rows_by'] !== false) {
$visualization->setSelectableRows(array_values($this->rowPickerConfig));
@@ -204,12 +210,12 @@ class Piwik_JqplotDataGenerator_Evolution extends Piwik_JqplotDataGenerator
*/
private function getQueryStringAsHash()
{
- $queryString = Piwik_Url::getArrayFromCurrentQueryString();
+ $queryString = Url::getArrayFromCurrentQueryString();
$piwikParameters = array('idSite', 'date', 'period', 'XDEBUG_SESSION_START', 'KEY');
foreach ($piwikParameters as $parameter) {
unset($queryString[$parameter]);
}
- if (Piwik_IsMenuUrlFound($queryString)) {
+ if (Piwik_Menu_Main::getInstance()->isUrlFound($queryString)) {
return $queryString;
}
return false;
diff --git a/core/Log.php b/core/Log.php
index 2228ec9dae..18fe490f13 100644
--- a/core/Log.php
+++ b/core/Log.php
@@ -8,17 +8,23 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
use Piwik\Config;
use Piwik\Common;
+use Piwik\Log\Exception;
+use Piwik\Log\Error;
+use Piwik\Log\APICall;
+use Piwik\Log\Message;
+
/**
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
* @see Zend_Log, libs/Zend/Log.php
* @link http://framework.zend.com/manual/en/zend.log.html
*/
-abstract class Piwik_Log extends Zend_Log
+abstract class Log extends \Zend_Log
{
protected $logToDatabaseTableName = null;
protected $logToDatabaseColumnMapping = null;
@@ -52,20 +58,20 @@ abstract class Piwik_Log extends Zend_Log
function addWriteToFile()
{
Common::mkdir(dirname($this->logToFileFilename));
- $writerFile = new Zend_Log_Writer_Stream($this->logToFileFilename);
+ $writerFile = new \Zend_Log_Writer_Stream($this->logToFileFilename);
$writerFile->setFormatter($this->fileFormatter);
$this->addWriter($writerFile);
}
function addWriteToNull()
{
- $this->addWriter(new Zend_Log_Writer_Null);
+ $this->addWriter(new \Zend_Log_Writer_Null);
}
function addWriteToDatabase()
{
- $writerDb = new Zend_Log_Writer_Db(
- Zend_Registry::get('db'),
+ $writerDb = new \Zend_Log_Writer_Db(
+ \Zend_Registry::get('db'),
$this->logToDatabaseTableName,
$this->logToDatabaseColumnMapping);
@@ -74,7 +80,7 @@ abstract class Piwik_Log extends Zend_Log
function addWriteToScreen()
{
- $writerScreen = new Zend_Log_Writer_Stream('php://output');
+ $writerScreen = new \Zend_Log_Writer_Stream('php://output');
$writerScreen->setFormatter($this->screenFormatter);
$this->addWriter($writerScreen);
}
@@ -96,7 +102,7 @@ abstract class Piwik_Log extends Zend_Log
{
// sanity checks
if (empty($this->_writers)) {
- throw new Zend_Log_Exception('No writers were added');
+ throw new \Zend_Log_Exception('No writers were added');
}
$event['timestamp'] = date('Y-m-d H:i:s');
@@ -139,56 +145,55 @@ abstract class Piwik_Log extends Zend_Log
}
}
-}
-/**
- *
- * @package Piwik
- * @subpackage Piwik_Log
- */
-class Piwik_Log_Formatter_FileFormatter implements Zend_Log_Formatter_Interface
-{
/**
- * Formats data into a single line to be written by the writer.
- *
- * @param array $event event data
- * @return string formatted line to write to the log
+ * Create log object
+ * @throws Exception
*/
- public function format($event)
+ static public function make()
{
- foreach ($event as &$value) {
- $value = str_replace("\n", '\n', $value);
- $value = '"' . $value . '"';
+ $configAPI = Config::getInstance()->log;
+
+ $aLoggers = array(
+ 'logger_api_call' => new APICall,
+ 'logger_exception' => new Exception,
+ 'logger_error' => new Error,
+ 'logger_message' => new Message,
+ );
+
+ foreach ($configAPI as $loggerType => $aRecordTo) {
+ if (isset($aLoggers[$loggerType])) {
+ $logger = $aLoggers[$loggerType];
+
+ foreach ($aRecordTo as $recordTo) {
+ switch ($recordTo) {
+ case 'screen':
+ $logger->addWriteToScreen();
+ break;
+
+ case 'database':
+ $logger->addWriteToDatabase();
+ break;
+
+ case 'file':
+ $logger->addWriteToFile();
+ break;
+
+ default:
+ throw new Exception("'$recordTo' is not a valid Log type. Valid logger types are: screen, database, file.");
+ break;
+ }
+ }
+ }
}
- $ts = $event['timestamp'];
- unset($event['timestamp']);
- return $ts . ' ' . implode(" ", $event) . "\n";
- }
-}
-
-/**
- *
- * @package Piwik
- * @subpackage Piwik_Log
- */
-class Piwik_Log_Formatter_ScreenFormatter implements Zend_Log_Formatter_Interface
-{
- function formatEvent($event)
- {
- // no injection in error messages, backtrace when displayed on screen
- return array_map(array('Piwik\Common', 'sanitizeInputValue'), $event);
- }
- function format($string)
- {
- return self::getFormattedString($string);
- }
-
- static public function getFormattedString($string)
- {
- if (!Common::isPhpCliMode()) {
- @header('Content-Type: text/html; charset=utf-8');
+ foreach ($aLoggers as $loggerType => $logger) {
+ if ($logger->getWritersCount() == 0) {
+ $logger->addWriteToNull();
+ }
+ \Zend_Registry::set($loggerType, $logger);
}
- return $string;
}
+
}
+
diff --git a/core/Log/APICall.php b/core/Log/APICall.php
index 07e5bb25ff..39398b92ba 100644
--- a/core/Log/APICall.php
+++ b/core/Log/APICall.php
@@ -8,14 +8,18 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Log;
+
+use Piwik\IP;
+use Piwik\Log;
/**
* Class used to log all the API Calls information (class / method / parameters / returned value / time spent)
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_APICall extends Piwik_Log
+class APICall extends Log
{
const ID = 'logger_api_call';
@@ -36,8 +40,8 @@ class Piwik_Log_APICall extends Piwik_Log
'timestamp' => 'timestamp',
'returned_value' => 'returned_value'
);
- $screenFormatter = new Piwik_Log_APICall_Formatter_ScreenFormatter();
- $fileFormatter = new Piwik_Log_Formatter_FileFormatter();
+ $screenFormatter = new APICall_Formatter_ScreenFormatter();
+ $fileFormatter = new Formatter_FileFormatter();
parent::__construct($logToFileFilename,
$fileFormatter,
@@ -45,7 +49,7 @@ class Piwik_Log_APICall extends Piwik_Log
$logToDatabaseTableName,
$logToDatabaseColumnMapping);
- $this->setEventItem('caller_ip', Piwik_IP::P2N(Piwik_IP::getIpFromHeader()));
+ $this->setEventItem('caller_ip', IP::P2N(IP::getIpFromHeader()));
}
/**
@@ -67,7 +71,7 @@ class Piwik_Log_APICall extends Piwik_Log
$event['parameter_values'] = serialize($parameterValues);
$event['execution_time'] = $executionTime;
$event['returned_value'] = is_array($returnedValue) ? serialize($returnedValue) : $returnedValue;
- parent::log($event, Piwik_Log::INFO, null);
+ parent::log($event, Log::INFO, null);
}
}
@@ -75,9 +79,9 @@ class Piwik_Log_APICall extends Piwik_Log
* Class used to format the API Call log on the screen.
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_APICall_Formatter_ScreenFormatter extends Piwik_Log_Formatter_ScreenFormatter
+class APICall_Formatter_ScreenFormatter extends Formatter_ScreenFormatter
{
/**
* Formats data into a single line to be written by the writer.
diff --git a/core/Log/Error.php b/core/Log/Error.php
index bd54c8e6f0..609227080e 100644
--- a/core/Log/Error.php
+++ b/core/Log/Error.php
@@ -8,14 +8,17 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Log;
+use Piwik\Log;
+use Zend_Log_Writer_Stream;
/**
* Class used to log an error event.
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_Error extends Piwik_Log
+class Error extends Log
{
const ID = 'logger_error';
@@ -34,8 +37,8 @@ class Piwik_Log_Error extends Piwik_Log
'errfile' => 'errfile',
'backtrace' => 'backtrace'
);
- $screenFormatter = new Piwik_Log_Error_Formatter_ScreenFormatter();
- $fileFormatter = new Piwik_Log_Formatter_FileFormatter();
+ $screenFormatter = new Error_Formatter_ScreenFormatter();
+ $fileFormatter = new Formatter_FileFormatter();
parent::__construct($logToFileFilename,
$fileFormatter,
$screenFormatter,
@@ -49,7 +52,7 @@ class Piwik_Log_Error extends Piwik_Log
function addWriteToScreen()
{
parent::addWriteToScreen();
- $writerScreen = new Zend_Log_Writer_Stream('php://stderr');
+ $writerScreen = new \Zend_Log_Writer_Stream('php://stderr');
$writerScreen->setFormatter($this->screenFormatter);
$this->addWriter($writerScreen);
}
@@ -72,7 +75,7 @@ class Piwik_Log_Error extends Piwik_Log
$event['errline'] = $errline;
$event['backtrace'] = $backtrace;
- parent::log($event, Piwik_Log::ERR, null);
+ parent::log($event, Log::ERR, null);
}
}
@@ -80,9 +83,9 @@ class Piwik_Log_Error extends Piwik_Log
* Format an error event to be displayed on the screen.
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_Error_Formatter_ScreenFormatter extends Piwik_Log_Formatter_ScreenFormatter
+class Error_Formatter_ScreenFormatter extends Formatter_ScreenFormatter
{
/**
* Formats data into a single line to be written by the writer.
@@ -108,9 +111,9 @@ class Piwik_Log_Error_Formatter_ScreenFormatter extends Piwik_Log_Formatter_Scre
// is there any other case where the errno is zero at this point?
if ($errno == 0) return '';
$strReturned .= "\n<div style='word-wrap: break-word; border: 3px solid red; padding:4px; width:70%; background-color:#FFFF96;'>
- <strong>There is an error. Please report the message (Piwik " . (class_exists('Piwik_Version') ? Piwik_Version::VERSION : '') . ")
- and full backtrace in the <a href='?module=Proxy&action=redirect&url=http://forum.piwik.org' target='_blank'>Piwik forums</a> (please do a Search first as it might have been reported already!).<br /><br/>
- ";
+ <strong>There is an error. Please report the message (Piwik " . (class_exists('Piwik\Version') ? Piwik_Version::VERSION : '') . ")
+ and full backtrace in the <a href='?module=Proxy&action=redirect&url=http://forum.piwik.org' target='_blank'>Piwik forums</a> (please do a Search first as it might have been reported already!).<br /><br/>
+ ";
switch ($errno) {
case E_ERROR:
$strReturned .= "Error";
diff --git a/core/Log/Exception.php b/core/Log/Exception.php
index b71479e575..2e7bb34bb4 100644
--- a/core/Log/Exception.php
+++ b/core/Log/Exception.php
@@ -8,16 +8,19 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Log;
+
use Piwik\Common;
+use Piwik\Log;
/**
* Class used to log an exception event.
* Displays the exception with a user friendly error message, suggests to get support from piwik.org
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_Exception extends Piwik_Log
+class Exception extends Log
{
const ID = 'logger_exception';
@@ -36,8 +39,8 @@ class Piwik_Log_Exception extends Piwik_Log
'errfile' => 'errfile',
'backtrace' => 'backtrace'
);
- $screenFormatter = new Piwik_Log_Exception_Formatter_ScreenFormatter();
- $fileFormatter = new Piwik_Log_Formatter_FileFormatter();
+ $screenFormatter = new Exception_Formatter_ScreenFormatter();
+ $fileFormatter = new Formatter_FileFormatter();
parent::__construct($logToFileFilename,
$fileFormatter,
@@ -52,7 +55,7 @@ class Piwik_Log_Exception extends Piwik_Log
function addWriteToScreen()
{
parent::addWriteToScreen();
- $writerScreen = new Zend_Log_Writer_Stream('php://stderr');
+ $writerScreen = new \Zend_Log_Writer_Stream('php://stderr');
$writerScreen->setFormatter($this->screenFormatter);
$this->addWriter($writerScreen);
}
@@ -71,7 +74,7 @@ class Piwik_Log_Exception extends Piwik_Log
$event['errline'] = $exception->getLine();
$event['backtrace'] = $exception->getTraceAsString();
- parent::log($event, Piwik_Log::CRIT, null);
+ parent::log($event, Log::CRIT, null);
}
}
@@ -79,9 +82,9 @@ class Piwik_Log_Exception extends Piwik_Log
* Format an exception event to be displayed on the screen.
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_Exception_Formatter_ScreenFormatter extends Piwik_Log_Formatter_ScreenFormatter
+class Exception_Formatter_ScreenFormatter extends Formatter_ScreenFormatter
{
/**
* Formats data into a single line to be written by the writer.
@@ -96,7 +99,7 @@ class Piwik_Log_Exception_Formatter_ScreenFormatter extends Piwik_Log_Formatter_
$outputFormat = strtolower(Common::getRequestVar('format', 'html', 'string'));
$response = new Piwik_API_ResponseBuilder($outputFormat);
- $message = $response->getResponseException(new Exception($errstr));
+ $message = $response->getResponseException(new \Exception($errstr));
return parent::format($message);
}
}
diff --git a/core/Log/Formatter.php b/core/Log/Formatter.php
new file mode 100644
index 0000000000..3fa7c3d803
--- /dev/null
+++ b/core/Log/Formatter.php
@@ -0,0 +1,62 @@
+<?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
+ * @package Piwik
+ */
+namespace Piwik\Log;
+
+/**
+ * @package Piwik
+ * @subpackage Log
+ */
+class Formatter_FileFormatter implements \Zend_Log_Formatter_Interface
+{
+ /**
+ * Formats data into a single line to be written by the writer.
+ *
+ * @param array $event event data
+ * @return string formatted line to write to the log
+ */
+ public function format($event)
+ {
+ foreach ($event as &$value) {
+ $value = str_replace("\n", '\n', $value);
+ $value = '"' . $value . '"';
+ }
+ $ts = $event['timestamp'];
+ unset($event['timestamp']);
+ return $ts . ' ' . implode(" ", $event) . "\n";
+ }
+}
+
+/**
+ *
+ * @package Piwik
+ * @subpackage Log
+ */
+class Formatter_ScreenFormatter implements \Zend_Log_Formatter_Interface
+{
+ function formatEvent($event)
+ {
+ // no injection in error messages, backtrace when displayed on screen
+ return array_map(array('Piwik\Common', 'sanitizeInputValue'), $event);
+ }
+
+ function format($string)
+ {
+ return self::getFormattedString($string);
+ }
+
+ static public function getFormattedString($string)
+ {
+ if (!Common::isPhpCliMode()) {
+ @header('Content-Type: text/html; charset=utf-8');
+ }
+ return $string;
+ }
+} \ No newline at end of file
diff --git a/core/Log/Message.php b/core/Log/Message.php
index eb200a3b68..26acec5348 100644
--- a/core/Log/Message.php
+++ b/core/Log/Message.php
@@ -8,16 +8,55 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik\Log;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Log;
+
+/**
+ * Format a standard message event to be displayed on the screen.
+ * The message can be a PHP array or a string.
+ *
+ * @package Piwik
+ * @subpackage Log
+ */
+class Message_Formatter_ScreenFormatter extends Formatter_ScreenFormatter
+{
+ /**
+ * Formats data into a single line to be written by the writer.
+ *
+ * @param array $event event data
+ * @return string formatted line to write to the log
+ */
+ public function format($event)
+ {
+ if (is_array($event['message'])) {
+ $message = "<pre>" . var_export($event['message'], true) . "</pre>";
+ } else {
+ $message = $event['message'];
+ }
+ if (!Common::isPhpCliMode()) {
+ $message .= "<br/>";
+ }
+ $message .= "\n";
+
+ $memory = '';
+ // Hacky: let's hide the memory usage in CLI to hide from the archive.php output
+ if (!Common::isPhpCliMode()) {
+ $memory = '[' . Piwik::getMemoryUsage() . '] ';
+ }
+ $message = '[' . $event['timestamp'] . '] [' . $event['requestKey'] . '] ' . $memory . $message;
+ return parent::format($message);
+ }
+}
/**
* Class used to log a standard message event.
*
* @package Piwik
- * @subpackage Piwik_Log
+ * @subpackage Log
*/
-class Piwik_Log_Message extends Piwik_Log
+class Message extends Log
{
const ID = 'logger_message';
@@ -32,8 +71,8 @@ class Piwik_Log_Message extends Piwik_Log
'message' => 'message',
'timestamp' => 'timestamp'
);
- $screenFormatter = new Piwik_Log_Message_Formatter_ScreenFormatter();
- $fileFormatter = new Piwik_Log_Formatter_FileFormatter();
+ $screenFormatter = new Log\Message_Formatter_ScreenFormatter();
+ $fileFormatter = new Formatter_FileFormatter();
parent::__construct($logToFileFilename,
$fileFormatter,
@@ -51,43 +90,6 @@ class Piwik_Log_Message extends Piwik_Log
{
$event = array();
$event['message'] = $message;
- parent::log($event, Piwik_Log::INFO, null);
+ parent::log($event, Log::INFO, null);
}
-}
-
-/**
- * Format a standard message event to be displayed on the screen.
- * The message can be a PHP array or a string.
- *
- * @package Piwik
- * @subpackage Piwik_Log
- */
-class Piwik_Log_Message_Formatter_ScreenFormatter extends Piwik_Log_Formatter_ScreenFormatter
-{
- /**
- * Formats data into a single line to be written by the writer.
- *
- * @param array $event event data
- * @return string formatted line to write to the log
- */
- public function format($event)
- {
- if (is_array($event['message'])) {
- $message = "<pre>" . var_export($event['message'], true) . "</pre>";
- } else {
- $message = $event['message'];
- }
- if (!Common::isPhpCliMode()) {
- $message .= "<br/>";
- }
- $message .= "\n";
-
- $memory = '';
- // Hacky: let's hide the memory usage in CLI to hide from the archive.php output
- if (!Common::isPhpCliMode()) {
- $memory = '[' . Piwik::getMemoryUsage() . '] ';
- }
- $message = '[' . $event['timestamp'] . '] [' . $event['requestKey'] . '] ' . $memory . $message;
- return parent::format($message);
- }
-}
+} \ No newline at end of file
diff --git a/core/Mail.php b/core/Mail.php
index d9f917e464..1ffbc5d2e4 100644
--- a/core/Mail.php
+++ b/core/Mail.php
@@ -8,8 +8,12 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Config;
use Piwik\Piwik;
+use Piwik\Url;
+use Zend_Mail;
/**
* Class for sending mails, for more information see:
@@ -18,7 +22,7 @@ use Piwik\Piwik;
* @see Zend_Mail, libs/Zend/Mail.php
* @link http://framework.zend.com/manual/en/zend.mail.html
*/
-class Piwik_Mail extends Zend_Mail
+class Mail extends Zend_Mail
{
/**
* Default charset utf-8
@@ -41,7 +45,7 @@ class Piwik_Mail extends Zend_Mail
public function setFrom($email, $name = null)
{
$hostname = Config::getInstance()->mail['defaultHostnameIfEmpty'];
- $piwikHost = Piwik_Url::getCurrentHost($hostname);
+ $piwikHost = Url::getCurrentHost($hostname);
// If known Piwik URL, use it instead of "localhost"
$piwikUrl = Piwik::getPiwikUrl();
@@ -77,8 +81,8 @@ class Piwik_Mail extends Zend_Mail
if (!empty($mailConfig['encryption']))
$smtpConfig['ssl'] = $mailConfig['encryption'];
- $tr = new Zend_Mail_Transport_Smtp($mailConfig['host'], $smtpConfig);
- Piwik_Mail::setDefaultTransport($tr);
+ $tr = new \Zend_Mail_Transport_Smtp($mailConfig['host'], $smtpConfig);
+ Mail::setDefaultTransport($tr);
ini_set("smtp_port", $mailConfig['port']);
}
}
diff --git a/core/Menu/Admin.php b/core/Menu/Admin.php
index 7af69b3255..aa8fee720a 100644
--- a/core/Menu/Admin.php
+++ b/core/Menu/Admin.php
@@ -8,17 +8,20 @@
* @category Piwik
* @package Piwik_Menu
*/
+namespace Piwik\Menu;
+
+use Piwik\Menu\MenuAbstract;
use Piwik\Piwik;
/**
* @package Piwik_Menu
*/
-class Piwik_Menu_Admin extends Piwik_Menu_Abstract
+class Admin extends MenuAbstract
{
static private $instance = null;
/**
- * @return Piwik_Menu_Admin
+ * @return \Piwik\Menu\Admin
*/
static public function getInstance()
{
@@ -40,75 +43,28 @@ class Piwik_Menu_Admin extends Piwik_Menu_Abstract
}
return parent::get();
}
-}
-/**
- * Returns the current AdminMenu name
- *
- * @return boolean
- */
-function Piwik_GetCurrentAdminMenuName()
-{
- $menu = Piwik_GetAdminMenu();
- $currentModule = Piwik::getModule();
- $currentAction = Piwik::getAction();
- foreach ($menu as $name => $submenu) {
- foreach ($submenu as $subMenuName => $parameters) {
- if (strpos($subMenuName, '_') !== 0 &&
- $parameters['_url']['module'] == $currentModule
- && $parameters['_url']['action'] == $currentAction
- ) {
- return $subMenuName;
+ /**
+ * Returns the current AdminMenu name
+ *
+ * @return boolean
+ */
+ function getCurrentAdminMenuName()
+ {
+ $menu = Piwik_GetAdminMenu();
+ $currentModule = Piwik::getModule();
+ $currentAction = Piwik::getAction();
+ foreach ($menu as $name => $submenu) {
+ foreach ($submenu as $subMenuName => $parameters) {
+ if (strpos($subMenuName, '_') !== 0 &&
+ $parameters['_url']['module'] == $currentModule
+ && $parameters['_url']['action'] == $currentAction
+ ) {
+ return $subMenuName;
+ }
}
}
+ return false;
}
- return false;
-}
-
-/**
- * Returns the AdminMenu
- *
- * @return Array
- */
-function Piwik_GetAdminMenu()
-{
- return Piwik_Menu_Admin::getInstance()->get();
}
-/**
- * Adds a new AdminMenu entry.
- *
- * @param string $adminMenuName
- * @param string $url
- * @param boolean $displayedForCurrentUser
- * @param int $order
- */
-function Piwik_AddAdminMenu($adminMenuName, $url, $displayedForCurrentUser = true, $order = 10)
-{
- Piwik_Menu_Admin::getInstance()->add('General_Settings', $adminMenuName, $url, $displayedForCurrentUser, $order);
-}
-
-/**
- * Adds a new AdminMenu entry with a submenu.
- *
- * @param string $adminMenuName
- * @param string $adminSubMenuName
- * @param string $url
- * @param boolean $displayedForCurrentUser
- * @param int $order
- */
-function Piwik_AddAdminSubMenu($adminMenuName, $adminSubMenuName, $url, $displayedForCurrentUser = true, $order = 10)
-{
- Piwik_Menu_Admin::getInstance()->add($adminMenuName, $adminSubMenuName, $url, $displayedForCurrentUser, $order);
-}
-
-/**
- * Renames an AdminMenu entry.
- *
- * @param string $adminMenuOriginal
- * @param string $adminMenuRenamed
- */
-function Piwik_RenameAdminMenuEntry($adminMenuOriginal, $adminMenuRenamed)
-{
- Piwik_Menu_Admin::getInstance()->rename($adminMenuOriginal, null, $adminMenuRenamed, null);
-}
diff --git a/core/Menu/Main.php b/core/Menu/Main.php
index fa21883a30..105ac9cd66 100644
--- a/core/Menu/Main.php
+++ b/core/Menu/Main.php
@@ -8,16 +8,19 @@
* @category Piwik
* @package Piwik_Menu
*/
+namespace Piwik\Menu;
+
+use Piwik\Menu\MenuAbstract;
/**
* @package Piwik_Menu
*/
-class Piwik_Menu_Main extends Piwik_Menu_Abstract
+class Main extends MenuAbstract
{
static private $instance = null;
/**
- * @return Piwik_Menu_Abstract
+ * @return MenuAbstract
*/
static public function getInstance()
{
@@ -35,7 +38,7 @@ class Piwik_Menu_Main extends Piwik_Menu_Abstract
*/
public function isUrlFound($url)
{
- $menu = Piwik_Menu_Main::getInstance()->get();
+ $menu = Main::getInstance()->get();
foreach ($menu as $mainMenuName => $subMenus) {
foreach ($subMenus as $subMenuName => $menuUrl) {
@@ -60,66 +63,5 @@ class Piwik_Menu_Main extends Piwik_Menu_Abstract
}
return parent::get();
}
-
-}
-
-/**
- * Checks if an entry uses the URL $url.
- *
- * @param string $url
- * @return boolean
- */
-function Piwik_IsMenuUrlFound($url)
-{
- return Piwik_Menu_Main::getInstance()->isUrlFound($url);
}
-/**
- * Returns the MainMenu as array.
- *
- * @return array
- */
-function Piwik_GetMenu()
-{
- return Piwik_Menu_Main::getInstance()->get();
-}
-
-/**
- * Adds a new entry to the MainMenu.
- *
- * @param string $mainMenuName
- * @param string $subMenuName
- * @param string $url
- * @param boolean $displayedForCurrentUser
- * @param int $order
- */
-function Piwik_AddMenu($mainMenuName, $subMenuName, $url, $displayedForCurrentUser = true, $order = 10)
-{
- Piwik_Menu_Main::getInstance()->add($mainMenuName, $subMenuName, $url, $displayedForCurrentUser, $order);
-}
-
-/**
- * Renames a menu entry.
- *
- * @param string $mainMenuOriginal
- * @param string $subMenuOriginal
- * @param string $mainMenuRenamed
- * @param string $subMenuRenamed
- */
-function Piwik_RenameMenuEntry($mainMenuOriginal, $subMenuOriginal,
- $mainMenuRenamed, $subMenuRenamed)
-{
- Piwik_Menu_Main::getInstance()->rename($mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed);
-}
-
-/**
- * Edits the URL of a menu entry.
- *
- * @param string $mainMenuToEdit
- * @param string $subMenuToEdit
- * @param string $newUrl
- */
-function Piwik_EditMenuUrl($mainMenuToEdit, $subMenuToEdit, $newUrl)
-{
- Piwik_Menu_Main::getInstance()->editUrl($mainMenuToEdit, $subMenuToEdit, $newUrl);
-}
diff --git a/core/Menu/Abstract.php b/core/Menu/MenuAbstract.php
index 14574847bf..5bb4adb39c 100644
--- a/core/Menu/Abstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -8,12 +8,15 @@
* @category Piwik
* @package Piwik_Menu
*/
+namespace Piwik\Menu;
+
use Piwik\Common;
+use Piwik_SitesManager_API;
/**
* @package Piwik_Menu
*/
-abstract class Piwik_Menu_Abstract
+abstract class MenuAbstract
{
protected $menu = null;
@@ -45,11 +48,11 @@ abstract class Piwik_Menu_Abstract
/**
* Adds a new entry to the menu.
*
- * @param string $menuName
- * @param string $subMenuName
- * @param string $url
- * @param bool $displayedForCurrentUser
- * @param int $order
+ * @param string $menuName
+ * @param string $subMenuName
+ * @param string $url
+ * @param bool $displayedForCurrentUser
+ * @param int $order
* @param bool|string $tooltip Tooltip to display.
*/
public function add($menuName, $subMenuName, $url, $displayedForCurrentUser, $order = 50, $tooltip = false)
@@ -74,10 +77,10 @@ abstract class Piwik_Menu_Abstract
/**
* Builds a single menu item
*
- * @param string $menuName
- * @param string $subMenuName
- * @param string $url
- * @param int $order
+ * @param string $menuName
+ * @param string $subMenuName
+ * @param string $url
+ * @param int $order
* @param bool|string $tooltip Tooltip to display.
*/
private function buildMenuItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false)
diff --git a/core/Menu/Top.php b/core/Menu/Top.php
index b3438c906c..b646eb89a9 100644
--- a/core/Menu/Top.php
+++ b/core/Menu/Top.php
@@ -8,16 +8,19 @@
* @category Piwik
* @package Piwik_Menu
*/
+namespace Piwik\Menu;
+
+use Piwik\Menu\MenuAbstract;
/**
* @package Piwik_Menu
*/
-class Piwik_Menu_Top extends Piwik_Menu_Abstract
+class Top extends MenuAbstract
{
static private $instance = null;
/**
- * @return Piwik_Menu_Top
+ * @return \Piwik\Menu\Top
*/
static public function getInstance()
{
@@ -61,44 +64,3 @@ class Piwik_Menu_Top extends Piwik_Menu_Abstract
return parent::get();
}
}
-
-/**
- * Returns the TopMenu as an array.
- *
- * @return array
- */
-function Piwik_GetTopMenu()
-{
- return Piwik_Menu_Top::getInstance()->get();
-}
-
-/**
- * Adds a new entry to the TopMenu.
- *
- * @param string $topMenuName
- * @param string $data
- * @param boolean $displayedForCurrentUser
- * @param int $order
- * @param bool $isHTML
- * @param bool|string $tooltip Tooltip to display.
- */
-function Piwik_AddTopMenu($topMenuName, $data, $displayedForCurrentUser = true, $order = 10, $isHTML = false,
- $tooltip = false)
-{
- if ($isHTML) {
- Piwik_Menu_Top::getInstance()->addHtml($topMenuName, $data, $displayedForCurrentUser, $order, $tooltip);
- } else {
- Piwik_Menu_Top::getInstance()->add($topMenuName, null, $data, $displayedForCurrentUser, $order, $tooltip);
- }
-}
-
-/**
- * Renames a entry of the TopMenu
- *
- * @param string $topMenuOriginal
- * @param string $topMenuRenamed
- */
-function Piwik_RenameTopMenuEntry($topMenuOriginal, $topMenuRenamed)
-{
- Piwik_Menu_Top::getInstance()->rename($topMenuOriginal, null, $topMenuRenamed, null);
-}
diff --git a/core/Nonce.php b/core/Nonce.php
index 23e447f949..ff6a97227b 100644
--- a/core/Nonce.php
+++ b/core/Nonce.php
@@ -8,7 +8,12 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Common;
+use Piwik_Session_Namespace;
+use Piwik\Url;
+use false;
/**
* Nonce class.
@@ -23,7 +28,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_Nonce
+class Nonce
{
/**
* Generate nonce
@@ -68,8 +73,8 @@ class Piwik_Nonce
}
// validate referer
- $referer = Piwik_Url::getReferer();
- if (!empty($referer) && !Piwik_Url::isLocalUrl($referer)) {
+ $referer = Url::getReferer();
+ if (!empty($referer) && !Url::isLocalUrl($referer)) {
return false;
}
@@ -117,7 +122,7 @@ class Piwik_Nonce
*/
static public function getAcceptableOrigins()
{
- $host = Piwik_Url::getCurrentHost(null);
+ $host = Url::getCurrentHost(null);
$port = '';
// parse host:port
diff --git a/core/Option.php b/core/Option.php
index 11f541bd55..653363bfc1 100644
--- a/core/Option.php
+++ b/core/Option.php
@@ -8,17 +8,18 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
use Piwik\Common;
/**
- * Piwik_Option provides a very simple mechanism to save/retrieve key-values pair
+ * Option provides a very simple mechanism to save/retrieve key-values pair
* from the database (persistent key-value datastore).
*
* This is useful to save Piwik-wide preferences, configuration values.
*
* @package Piwik
*/
-class Piwik_Option
+class Option
{
/**
* @var array
@@ -32,14 +33,14 @@ class Piwik_Option
/**
* Singleton instance
- * @var self
+ * @var \Piwik\Option
*/
static private $instance = null;
/**
* Returns Singleton instance
*
- * @return Piwik_Option
+ * @return \Piwik\Option
*/
static public function getInstance()
{
@@ -68,7 +69,7 @@ class Piwik_Option
if (isset($this->all[$name])) {
return $this->all[$name];
}
- $value = Piwik_FetchOne('SELECT option_value ' .
+ $value = Db::fetchOne('SELECT option_value ' .
'FROM `' . Common::prefixTable('option') . '`' .
'WHERE option_name = ?', $name);
if ($value === false) {
@@ -88,7 +89,7 @@ class Piwik_Option
public function set($name, $value, $autoLoad = 0)
{
$autoLoad = (int)$autoLoad;
- Piwik_Query('INSERT INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' .
+ Db::query('INSERT INTO `' . Common::prefixTable('option') . '` (option_name, option_value, autoload) ' .
' VALUES (?, ?, ?) ' .
' ON DUPLICATE KEY UPDATE option_value = ?',
array($name, $value, $autoLoad, $value));
@@ -111,7 +112,7 @@ class Piwik_Option
$bind[] = $value;
}
- Piwik_Query($sql, $bind);
+ Db::query($sql, $bind);
$this->clearCache();
}
@@ -133,7 +134,7 @@ class Piwik_Option
$bind[] = $value;
}
- Piwik_Query($sql, $bind);
+ Db::query($sql, $bind);
$this->clearCache();
}
@@ -149,7 +150,7 @@ class Piwik_Option
return;
}
- $all = Piwik_FetchAll('SELECT option_value, option_name
+ $all = Db::fetchAll('SELECT option_value, option_name
FROM `' . Common::prefixTable('option') . '`
WHERE autoload = 1');
foreach ($all as $option) {
@@ -171,26 +172,3 @@ class Piwik_Option
$this->all = array();
}
}
-
-/**
- * Returns the option value for the requested option $name
- *
- * @param string $name Key
- * @return string|false Value or false, if not found
- */
-function Piwik_GetOption($name)
-{
- return Piwik_Option::getInstance()->get($name);
-}
-
-/**
- * Sets the option value in the database
- *
- * @param string $name
- * @param string $value
- * @param int $autoLoad if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
- */
-function Piwik_SetOption($name, $value, $autoLoad = 0)
-{
- Piwik_Option::getInstance()->set($name, $value, $autoLoad);
-}
diff --git a/core/Piwik.php b/core/Piwik.php
index 5edff85b19..97ad1c97bb 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -11,28 +11,22 @@
namespace Piwik;
use Exception;
-use Piwik\Config;
use Piwik\Access;
-use Access_NoAccessException;
-use Piwik_AssetManager;
+use Piwik\AssetManager;
use Piwik\Common;
-use Piwik_Db_Adapter;
-use Piwik_Db_Schema;
-use Piwik_Log_APICall;
-use Piwik_Log_Error;
-use Piwik_Log_Exception;
-use Piwik_Log_Formatter_ScreenFormatter;
-use Piwik_Log_Message;
+use Piwik\Config;
use Piwik\Plugin;
-use Piwik_Session;
use Piwik\Site;
-use Piwik_Tracker;
+use Piwik\Db\Adapter;
+use Piwik\Db\Schema;
+use Piwik\Session;
+use Piwik\Tracker;
use Piwik_Tracker_Cache;
use Piwik_Tracker_Db;
use Piwik_Tracker_GoalManager;
-use Piwik_Url;
+use Piwik\Url;
use Piwik_UsersManager_API;
-use Piwik_View;
+use Piwik\View;
use Zend_Registry;
/**
@@ -127,7 +121,7 @@ class Piwik
*/
static public function uninstall()
{
- Piwik_Db_Schema::getInstance()->dropTables();
+ Schema::getInstance()->dropTables();
}
/**
@@ -140,7 +134,7 @@ class Piwik
static public function isInstalled()
{
try {
- return Piwik_Db_Schema::getInstance()->hasTables();
+ return Schema::getInstance()->hasTables();
} catch (Exception $e) {
return false;
}
@@ -152,8 +146,8 @@ class Piwik
*/
static public function deleteAllCacheOnUpdate()
{
- Piwik_AssetManager::removeMergedAssets();
- Piwik_View::clearCompiledTemplates();
+ AssetManager::removeMergedAssets();
+ View::clearCompiledTemplates();
Piwik_Tracker_Cache::deleteTrackerCache();
}
@@ -190,7 +184,7 @@ class Piwik
return $url;
}
- $currentUrl = Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName());
+ $currentUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
if (empty($url)
// if URL changes, always update the cache
@@ -211,7 +205,7 @@ class Piwik
*/
static public function isHttps()
{
- return Piwik_Url::getCurrentScheme() === 'https';
+ return Url::getCurrentScheme() === 'https';
}
/**
@@ -1060,7 +1054,7 @@ class Piwik
"<p><img src='plugins/Zeitgeist/images/error_medium.png' style='vertical-align:middle; float:left;padding:20 20 20 20' />" .
$message .
"</p></div>";
- print(Piwik_Log_Formatter_ScreenFormatter::getFormattedString($output));
+ print(\Piwik\Log\Formatter_ScreenFormatter::getFormattedString($output));
exit;
}
@@ -1115,7 +1109,7 @@ class Piwik
}
if (is_null($db)) {
- $db = Piwik_Tracker::getDatabase();
+ $db = Tracker::getDatabase();
}
$tableName = Common::prefixTable('log_profiling');
@@ -1524,7 +1518,7 @@ class Piwik
'Free Web Analytics',
'Analytics Platform',
);
- $id = abs(intval(md5(Piwik_Url::getCurrentHost())));
+ $id = abs(intval(md5(Url::getCurrentHost())));
$title = $titles[$id % count($titles)];
return $title;
}
@@ -1647,7 +1641,7 @@ class Piwik
* Check that current user is either the specified user or the superuser
*
* @param string $theUser
- * @throws Access_NoAccessException if the user is neither the super user nor the user $theUser
+ * @throws \Piwik\NoAccessException if the user is neither the super user nor the user $theUser
*/
static public function checkUserIsSuperUserOrTheUser($theUser)
{
@@ -1656,8 +1650,8 @@ class Piwik
// or to the super user
Piwik::checkUserIsSuperUser();
}
- } catch (Access_NoAccessException $e) {
- throw new Access_NoAccessException(Piwik_Translate('General_ExceptionCheckUserIsSuperUserOrTheUser', array($theUser)));
+ } catch (\Piwik\NoAccessException $e) {
+ throw new \Piwik\NoAccessException(Piwik_Translate('General_ExceptionCheckUserIsSuperUserOrTheUser', array($theUser)));
}
}
@@ -1689,7 +1683,7 @@ class Piwik
/**
* Checks if user is not the anonymous user.
*
- * @throws Access_NoAccessException if user is anonymous.
+ * @throws \Piwik\NoAccessException if user is anonymous.
*/
static public function checkUserIsNotAnonymous()
{
@@ -1901,11 +1895,11 @@ class Piwik
*/
static public function redirectToModule($newModule, $newAction = '', $parameters = array())
{
- $newUrl = 'index.php' . Piwik_Url::getCurrentQueryStringWithParametersModified(
+ $newUrl = 'index.php' . Url::getCurrentQueryStringWithParametersModified(
array('module' => $newModule, 'action' => $newAction)
+ $parameters
);
- Piwik_Url::redirectToUrl($newUrl);
+ Url::redirectToUrl($newUrl);
}
/*
@@ -1932,7 +1926,7 @@ class Piwik
Piwik_PostEvent('Reporting.createDatabase', array(&$db));
if (is_null($db)) {
$adapter = $dbInfos['adapter'];
- $db = @Piwik_Db_Adapter::factory($adapter, $dbInfos);
+ $db = @Adapter::factory($adapter, $dbInfos);
}
Zend_Registry::set('db', $db);
}
@@ -1972,55 +1966,6 @@ class Piwik
* Global log object
*/
- /**
- * Create log object
- * @throws Exception
- */
- static public function createLogObject()
- {
- $configAPI = Config::getInstance()->log;
-
- $aLoggers = array(
- 'logger_api_call' => new Piwik_Log_APICall,
- 'logger_exception' => new Piwik_Log_Exception,
- 'logger_error' => new Piwik_Log_Error,
- 'logger_message' => new Piwik_Log_Message,
- );
-
- foreach ($configAPI as $loggerType => $aRecordTo) {
- if (isset($aLoggers[$loggerType])) {
- $logger = $aLoggers[$loggerType];
-
- foreach ($aRecordTo as $recordTo) {
- switch ($recordTo) {
- case 'screen':
- $logger->addWriteToScreen();
- break;
-
- case 'database':
- $logger->addWriteToDatabase();
- break;
-
- case 'file':
- $logger->addWriteToFile();
- break;
-
- default:
- throw new Exception("'$recordTo' is not a valid Log type. Valid logger types are: screen, database, file.");
- break;
- }
- }
- }
- }
-
- foreach ($aLoggers as $loggerType => $logger) {
- if ($logger->getWritersCount() == 0) {
- $logger->addWriteToNull();
- }
- Zend_Registry::set($loggerType, $logger);
- }
- }
-
/*
* User input validation
*/
@@ -2119,7 +2064,7 @@ class Piwik
*/
static public function isAvailable()
{
- return Piwik_Db_Schema::getInstance()->isAvailable();
+ return Schema::getInstance()->isAvailable();
}
/**
@@ -2130,7 +2075,7 @@ class Piwik
*/
static public function getTableCreateSql($tableName)
{
- return Piwik_Db_Schema::getInstance()->getTableCreateSql($tableName);
+ return Schema::getInstance()->getTableCreateSql($tableName);
}
/**
@@ -2140,7 +2085,7 @@ class Piwik
*/
static public function getTablesCreateSql()
{
- return Piwik_Db_Schema::getInstance()->getTablesCreateSql();
+ return Schema::getInstance()->getTablesCreateSql();
}
/**
@@ -2150,7 +2095,7 @@ class Piwik
*/
static public function createDatabase($dbName = null)
{
- Piwik_Db_Schema::getInstance()->createDatabase($dbName);
+ Schema::getInstance()->createDatabase($dbName);
}
/**
@@ -2158,7 +2103,7 @@ class Piwik
*/
static public function dropDatabase()
{
- Piwik_Db_Schema::getInstance()->dropDatabase();
+ Schema::getInstance()->dropDatabase();
}
/**
@@ -2166,7 +2111,7 @@ class Piwik
*/
static public function createTables()
{
- Piwik_Db_Schema::getInstance()->createTables();
+ Schema::getInstance()->createTables();
}
/**
@@ -2174,7 +2119,7 @@ class Piwik
*/
static public function createAnonymousUser()
{
- Piwik_Db_Schema::getInstance()->createAnonymousUser();
+ Schema::getInstance()->createAnonymousUser();
}
/**
@@ -2182,7 +2127,7 @@ class Piwik
*/
static public function truncateAllTables()
{
- Piwik_Db_Schema::getInstance()->truncateAllTables();
+ Schema::getInstance()->truncateAllTables();
}
/**
@@ -2192,7 +2137,7 @@ class Piwik
*/
static public function dropTables($doNotDelete = array())
{
- Piwik_Db_Schema::getInstance()->dropTables($doNotDelete);
+ Schema::getInstance()->dropTables($doNotDelete);
}
/**
@@ -2203,7 +2148,7 @@ class Piwik
*/
static public function getTablesNames()
{
- return Piwik_Db_Schema::getInstance()->getTablesNames();
+ return Schema::getInstance()->getTablesNames();
}
/**
@@ -2214,7 +2159,7 @@ class Piwik
*/
static public function getTablesInstalled($forceReload = true)
{
- return Piwik_Db_Schema::getInstance()->getTablesInstalled($forceReload);
+ return Schema::getInstance()->getTablesInstalled($forceReload);
}
/**
@@ -2286,7 +2231,7 @@ class Piwik
try {
$queryStart = 'LOAD DATA ' . $keyword . 'INFILE ';
$sql = $queryStart . $query;
- $result = @Piwik_Exec($sql);
+ $result = @Db::exec($sql);
if (empty($result) || $result < 0) {
continue;
}
@@ -2322,7 +2267,7 @@ class Piwik
*/
static public function tableInsertBatch($tableName, $fields, $values, $throwException = false)
{
- $filePath = PIWIK_USER_PATH . '/' . Piwik_AssetManager::MERGED_FILE_DIR . $tableName . '-' . Common::generateUniqId() . '.csv';
+ $filePath = PIWIK_USER_PATH . '/' . AssetManager::MERGED_FILE_DIR . $tableName . '-' . Common::generateUniqId() . '.csv';
if (Zend_Registry::get('db')->hasBulkLoader()) {
try {
@@ -2388,7 +2333,7 @@ class Piwik
INTO " . $tableName . "
$fieldList
VALUES (" . Common::getSqlStringFieldsArray($row) . ")";
- Piwik_Query($query, $row);
+ Db::query($query, $row);
}
}
@@ -2410,8 +2355,8 @@ class Piwik
{
if (is_null(self::$lockPrivilegeGranted)) {
try {
- Piwik_LockTables(Common::prefixTable('log_visit'));
- Piwik_UnlockAllTables();
+ Db::lockTables(Common::prefixTable('log_visit'));
+ Db::unlockAllTables();
self::$lockPrivilegeGranted = true;
} catch (Exception $ex) {
@@ -2493,7 +2438,7 @@ class Piwik
*/
public static function checkIfFileSystemIsNFS()
{
- $sessionsPath = Piwik_Session::getSessionsDirectory();
+ $sessionsPath = Session::getSessionsDirectory();
// this command will display details for the filesystem that holds the $sessionsPath
// path, but only if its type is NFS. if not NFS, df will return one or less lines
diff --git a/core/Plugin.php b/core/Plugin.php
index 06aa0534ec..578d38c5f5 100644
--- a/core/Plugin.php
+++ b/core/Plugin.php
@@ -64,7 +64,7 @@ class Plugin
* - 'homepage' => string // plugin homepage URL
* - 'license' => string // plugin license
* - 'license_homepage' => string // license homepage URL
- * - 'version' => string // plugin version number; examples and 3rd party plugins must not use Piwik_Version::VERSION; 3rd party plugins must increment the version number with each plugin release
+ * - 'version' => string // plugin version number; examples and 3rd party plugins must not use Version::VERSION; 3rd party plugins must increment the version number with each plugin release
* - 'theme' => bool // Whether this plugin is a theme (a theme is a plugin, but a plugin is not necessarily a theme)
*
* @return array
diff --git a/core/Plugin/Config.php b/core/Plugin/Config.php
index 2b41f23d5a..cb4ecd42e5 100644
--- a/core/Plugin/Config.php
+++ b/core/Plugin/Config.php
@@ -9,12 +9,14 @@
* @package Piwik
*/
+namespace Piwik\Plugin;
+
/**
* Read / write local plugin-specific configuration
*
* @package Piwik
*/
-class Piwik_Plugin_Config
+class Config
{
private $pluginName;
private $configFileName;
diff --git a/core/Plugin/MetadataLoader.php b/core/Plugin/MetadataLoader.php
index 335442f31c..5400fde01d 100644
--- a/core/Plugin/MetadataLoader.php
+++ b/core/Plugin/MetadataLoader.php
@@ -12,7 +12,7 @@ namespace Piwik\Plugin;
use Exception;
use Piwik\Common;
-use Piwik_Version;
+use Piwik\Version;
/**
* @see core/Version.php
@@ -73,7 +73,7 @@ class MetadataLoader
'author_homepage' => 'http://piwik.org/',
'license' => 'GPL v3 or later',
'license_homepage' => 'http://www.gnu.org/licenses/gpl.html',
- 'version' => Piwik_Version::VERSION,
+ 'version' => Version::VERSION,
'theme' => false,
);
}
diff --git a/core/PluginsManager.php b/core/PluginsManager.php
index 4660a37cd2..f11698f202 100644
--- a/core/PluginsManager.php
+++ b/core/PluginsManager.php
@@ -18,21 +18,6 @@ use Piwik\EventDispatcher;
use Piwik\Translate;
use Piwik\Plugin\MetadataLoader;
-/**
- * @see core/Menu/Abstract.php
- * @see core/Menu/Main.php
- * @see core/Menu/Admin.php
- * @see core/Menu/Top.php
- * @see core/PluginsFunctions/WidgetsList.php
- * @see core/PluginsFunctions/Sql.php
- * @see core/EventDispatcher.php
- */
-require_once PIWIK_INCLUDE_PATH . '/core/Menu/Abstract.php';
-require_once PIWIK_INCLUDE_PATH . '/core/Menu/Main.php';
-require_once PIWIK_INCLUDE_PATH . '/core/Menu/Admin.php';
-require_once PIWIK_INCLUDE_PATH . '/core/Menu/Top.php';
-require_once PIWIK_INCLUDE_PATH . '/core/PluginsFunctions/WidgetsList.php';
-require_once PIWIK_INCLUDE_PATH . '/core/PluginsFunctions/Sql.php';
require_once PIWIK_INCLUDE_PATH . '/core/EventDispatcher.php';
/**
@@ -535,7 +520,7 @@ class PluginsManager
*/
public function unloadPlugin($plugin)
{
- if (!($plugin instanceof Piwik_Plugin)) {
+ if (!($plugin instanceof Plugin)) {
$oPlugin = $this->loadPlugin($plugin);
if ($oPlugin === null) {
unset($this->loadedPlugins[$plugin]);
@@ -719,7 +704,6 @@ class PluginsManager
}
}
-namespace Piwik;
/**
* @package Piwik
* @subpackage PluginsManager
diff --git a/core/ProxyHeaders.php b/core/ProxyHeaders.php
index 5b18bcfbc3..07d9c9f883 100644
--- a/core/ProxyHeaders.php
+++ b/core/ProxyHeaders.php
@@ -8,6 +8,8 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Common;
/**
@@ -15,7 +17,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_ProxyHeaders
+class ProxyHeaders
{
/**
* Get protocol information, with the exception of HTTPS
diff --git a/core/QuickForm2.php b/core/QuickForm2.php
index a41f2e5eb9..23f0690e45 100644
--- a/core/QuickForm2.php
+++ b/core/QuickForm2.php
@@ -9,8 +9,17 @@
* @package Piwik
*/
+namespace Piwik;
+
+use HTML_QuickForm2;
+use HTML_QuickForm2_InvalidArgumentException;
+use HTML_QuickForm2_Node;
+use HTML_QuickForm2_NotFoundException;
+use HTML_QuickForm2_Renderer;
+use Piwik\Url;
+
/**
- * Parent class for forms to be included in Smarty
+ * Manages forms displayed in Twig
*
* For an example, @see Piwik_Login_FormLogin
*
@@ -18,14 +27,14 @@
* @see HTML_QuickForm2, libs/HTML/QuickForm2.php
* @link http://pear.php.net/package/HTML_QuickForm2/
*/
-abstract class Piwik_QuickForm2 extends HTML_QuickForm2
+abstract class QuickForm2 extends HTML_QuickForm2
{
protected $a_formElements = array();
function __construct($id, $method = 'post', $attributes = null, $trackSubmit = false)
{
if (!isset($attributes['action'])) {
- $attributes['action'] = Piwik_Url::getCurrentQueryString();
+ $attributes['action'] = Url::getCurrentQueryString();
}
if (!isset($attributes['name'])) {
$attributes['name'] = $id;
diff --git a/core/RankingQuery.php b/core/RankingQuery.php
index 147f58e1bf..e72d76f193 100644
--- a/core/RankingQuery.php
+++ b/core/RankingQuery.php
@@ -9,6 +9,10 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
+
/**
* The ranking query class wraps an arbitrary SQL query with more SQL that limits
* the number of results while grouping the rest to "Others" and allows for some
@@ -18,7 +22,7 @@
* The general use case looks like this:
*
* // limit to 500 rows + "Others"
- * $rankingQuery = new Piwik_RankingQuery(500);
+ * $rankingQuery = new RankingQuery(500);
*
* // idaction_url will be "Others" in the row that contains the aggregated rest
* $rankingQuery->addLabelColumn('idaction_url');
@@ -38,7 +42,7 @@
*
* @package Piwik
*/
-class Piwik_RankingQuery
+class RankingQuery
{
/**
@@ -205,7 +209,7 @@ class Piwik_RankingQuery
public function execute($innerQuery, $bind = array())
{
$query = $this->generateQuery($innerQuery);
- $data = Piwik_FetchAll($query, $bind);
+ $data = Db::fetchAll($query, $bind);
if ($this->columnToMarkExcludedRows !== false) {
// split the result into the regular result and the rows with special treatment
@@ -285,7 +289,6 @@ class Piwik_RankingQuery
} else {
$additionalColumnsAggregatedString .= ', `' . $additionalColumn . '`';
}
-
}
// initialize the counters
@@ -359,5 +362,4 @@ class Piwik_RankingQuery
END
";
}
-
}
diff --git a/core/ReportRenderer.php b/core/ReportRenderer.php
index 7d43bf4856..7f8e959c74 100644
--- a/core/ReportRenderer.php
+++ b/core/ReportRenderer.php
@@ -8,20 +8,25 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\DataTable\Simple;
use Piwik\DataTable\Row;
use Piwik\Piwik;
use Piwik\DataTable;
use Piwik\Loader;
+use Piwik\API\Request;
+use Piwik_ImageGraph_API;
/**
* A Report Renderer produces user friendly renderings of any given Piwik report.
* All new Renderers must be copied in ReportRenderer and added to the $availableReportRenderers.
*
* @package Piwik
- * @subpackage Piwik_ReportRenderer
+ * @subpackage ReportRenderer
*/
-abstract class Piwik_ReportRenderer
+abstract class ReportRenderer
{
const DEFAULT_REPORT_FONT = 'dejavusans';
const REPORT_TEXT_COLOR = "68,68,68";
@@ -44,7 +49,7 @@ abstract class Piwik_ReportRenderer
*
* @throws exception If the renderer is unknown
* @param string $rendererType
- * @return Piwik_ReportRenderer
+ * @return \Piwik\ReportRenderer
*/
static public function factory($rendererType)
{
@@ -108,8 +113,8 @@ abstract class Piwik_ReportRenderer
* @param string $reportTitle
* @param string $prettyDate formatted date
* @param string $description
- * @param array $reportMetadata metadata for all reports
- * @param array $segment segment applied to all reports
+ * @param array $reportMetadata metadata for all reports
+ * @param array $segment segment applied to all reports
*/
abstract public function renderFrontPage($reportTitle, $prettyDate, $description, $reportMetadata, $segment);
@@ -168,7 +173,7 @@ abstract class Piwik_ReportRenderer
protected static function sendToBrowser($filename, $extension, $contentType, $content)
{
- $filename = Piwik_ReportRenderer::appendExtension($filename, $extension);
+ $filename = ReportRenderer::appendExtension($filename, $extension);
Piwik::overrideCacheControlHeaders();
header('Content-Description: File Transfer');
@@ -237,7 +242,7 @@ abstract class Piwik_ReportRenderer
'&height=' . $height .
($segment != null ? '&segment=' . urlencode($segment['definition']) : '');
- $request = new Piwik_API_Request($requestGraph);
+ $request = new Request($requestGraph);
try {
$imageGraph = $request->process();
@@ -250,7 +255,6 @@ abstract class Piwik_ReportRenderer
imagedestroy($imageGraph);
return $imageGraphData;
-
} catch (Exception $e) {
throw new Exception("ImageGraph API returned an error: " . $e->getMessage() . "\n");
}
diff --git a/core/ReportRenderer/Html.php b/core/ReportRenderer/Html.php
index 0f72de2aaf..e1d30734c4 100644
--- a/core/ReportRenderer/Html.php
+++ b/core/ReportRenderer/Html.php
@@ -6,16 +6,20 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
- * @package Piwik_ReportRenderer
+ * @package ReportRenderer
*/
-use Piwik\Piwik;
+namespace Piwik\ReportRenderer;
+use Piwik\Piwik;
+use Piwik\View;
+use Piwik\ReportRenderer;
+use Piwik_API_API;
/**
*
- * @package Piwik_ReportRenderer
+ * @package ReportRenderer
*/
-class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer
+class Html extends ReportRenderer
{
const IMAGE_GRAPH_WIDTH = 700;
const IMAGE_GRAPH_HEIGHT = 200;
@@ -53,21 +57,21 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer
{
$this->epilogue();
- return Piwik_ReportRenderer::writeFile($filename, self::HTML_FILE_EXTENSION, $this->rendering);
+ return ReportRenderer::writeFile($filename, self::HTML_FILE_EXTENSION, $this->rendering);
}
public function sendToBrowserDownload($filename)
{
$this->epilogue();
- Piwik_ReportRenderer::sendToBrowser($filename, self::HTML_FILE_EXTENSION, self::HTML_CONTENT_TYPE, $this->rendering);
+ ReportRenderer::sendToBrowser($filename, self::HTML_FILE_EXTENSION, self::HTML_CONTENT_TYPE, $this->rendering);
}
public function sendToBrowserInline($filename)
{
$this->epilogue();
- Piwik_ReportRenderer::inlineToBrowser(self::HTML_CONTENT_TYPE, $this->rendering);
+ ReportRenderer::inlineToBrowser(self::HTML_CONTENT_TYPE, $this->rendering);
}
public function getRenderedReport()
@@ -79,13 +83,13 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer
private function epilogue()
{
- $view = new Piwik_View('@CoreHome/ReportRenderer/_htmlReportFooter');
+ $view = new View('@CoreHome/ReportRenderer/_htmlReportFooter');
$this->rendering .= $view->render();
}
public function renderFrontPage($reportTitle, $prettyDate, $description, $reportMetadata, $segment)
{
- $frontPageView = new Piwik_View('@CoreHome/ReportRenderer/_htmlReportHeader');
+ $frontPageView = new View('@CoreHome/ReportRenderer/_htmlReportHeader');
$this->assignCommonParameters($frontPageView);
// todo rename 'websiteName' to 'reportTitle' once branch twig is merged
@@ -104,15 +108,15 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer
$this->rendering .= $frontPageView->render();
}
- private function assignCommonParameters(Piwik_View $view)
+ private function assignCommonParameters(View $view)
{
- $view->assign("reportTitleTextColor", Piwik_ReportRenderer::REPORT_TITLE_TEXT_COLOR);
+ $view->assign("reportTitleTextColor", ReportRenderer::REPORT_TITLE_TEXT_COLOR);
$view->assign("reportTitleTextSize", self::REPORT_TITLE_TEXT_SIZE);
- $view->assign("reportTextColor", Piwik_ReportRenderer::REPORT_TEXT_COLOR);
- $view->assign("tableHeaderBgColor", Piwik_ReportRenderer::TABLE_HEADER_BG_COLOR);
- $view->assign("tableHeaderTextColor", Piwik_ReportRenderer::TABLE_HEADER_TEXT_COLOR);
- $view->assign("tableCellBorderColor", Piwik_ReportRenderer::TABLE_CELL_BORDER_COLOR);
- $view->assign("tableBgColor", Piwik_ReportRenderer::TABLE_BG_COLOR);
+ $view->assign("reportTextColor", ReportRenderer::REPORT_TEXT_COLOR);
+ $view->assign("tableHeaderBgColor", ReportRenderer::TABLE_HEADER_BG_COLOR);
+ $view->assign("tableHeaderTextColor", ReportRenderer::TABLE_HEADER_TEXT_COLOR);
+ $view->assign("tableCellBorderColor", ReportRenderer::TABLE_CELL_BORDER_COLOR);
+ $view->assign("tableBgColor", ReportRenderer::TABLE_BG_COLOR);
$view->assign("reportTableHeaderTextSize", self::REPORT_TABLE_HEADER_TEXT_SIZE);
$view->assign("reportTableRowTextSize", self::REPORT_TABLE_ROW_TEXT_SIZE);
$view->assign("reportBackToTopTextSize", self::REPORT_BACK_TO_TOP_TEXT_SIZE);
@@ -122,7 +126,7 @@ class Piwik_ReportRenderer_Html extends Piwik_ReportRenderer
public function renderReport($processedReport)
{
- $reportView = new Piwik_View('@CoreHome/ReportRenderer/_htmlReportBody');
+ $reportView = new View('@CoreHome/ReportRenderer/_htmlReportBody');
$this->assignCommonParameters($reportView);
$reportMetadata = $processedReport['metadata'];
diff --git a/core/ReportRenderer/Pdf.php b/core/ReportRenderer/Pdf.php
index 7e7e6069f0..192a7f9133 100644
--- a/core/ReportRenderer/Pdf.php
+++ b/core/ReportRenderer/Pdf.php
@@ -6,9 +6,14 @@
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
* @category Piwik
- * @package Piwik_ReportRenderer
+ * @package ReportRenderer
*/
+namespace Piwik\ReportRenderer;
+
use Piwik\Common;
+use Piwik\TCPDF;
+use Piwik\ReportRenderer;
+use Piwik_API_API;
/**
* @see libs/tcpdf
@@ -19,9 +24,9 @@ require_once PIWIK_INCLUDE_PATH . '/core/TCPDF.php';
/**
*
- * @package Piwik_ReportRenderer
+ * @package ReportRenderer
*/
-class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer
+class Pdf extends ReportRenderer
{
const IMAGE_GRAPH_WIDTH_LANDSCAPE = 1050;
const IMAGE_GRAPH_WIDTH_PORTRAIT = 760;
@@ -71,19 +76,19 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer
private $reportColumns;
private $reportRowsMetadata;
private $currentPage = 0;
- private $reportFont = Piwik_ReportRenderer::DEFAULT_REPORT_FONT;
+ private $reportFont = ReportRenderer::DEFAULT_REPORT_FONT;
private $TCPDF;
private $orientation = self::PORTRAIT;
public function __construct()
{
- $this->TCPDF = new Piwik_TCPDF();
- $this->headerTextColor = preg_split("/,/", Piwik_ReportRenderer::REPORT_TITLE_TEXT_COLOR);
- $this->reportTextColor = preg_split("/,/", Piwik_ReportRenderer::REPORT_TEXT_COLOR);
- $this->tableHeaderBackgroundColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_HEADER_BG_COLOR);
- $this->tableHeaderTextColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_HEADER_TEXT_COLOR);
- $this->tableCellBorderColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_CELL_BORDER_COLOR);
- $this->tableBackgroundColor = preg_split("/,/", Piwik_ReportRenderer::TABLE_BG_COLOR);
+ $this->TCPDF = new TCPDF();
+ $this->headerTextColor = preg_split("/,/", ReportRenderer::REPORT_TITLE_TEXT_COLOR);
+ $this->reportTextColor = preg_split("/,/", ReportRenderer::REPORT_TEXT_COLOR);
+ $this->tableHeaderBackgroundColor = preg_split("/,/", ReportRenderer::TABLE_HEADER_BG_COLOR);
+ $this->tableHeaderTextColor = preg_split("/,/", ReportRenderer::TABLE_HEADER_TEXT_COLOR);
+ $this->tableCellBorderColor = preg_split("/,/", ReportRenderer::TABLE_CELL_BORDER_COLOR);
+ $this->tableBackgroundColor = preg_split("/,/", ReportRenderer::TABLE_BG_COLOR);
}
public function setLocale($locale)
@@ -111,7 +116,7 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer
case 'en':
default:
- $reportFont = Piwik_ReportRenderer::DEFAULT_REPORT_FONT;
+ $reportFont = ReportRenderer::DEFAULT_REPORT_FONT;
break;
}
$this->reportFont = $reportFont;
@@ -119,8 +124,8 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer
public function sendToDisk($filename)
{
- $filename = Piwik_ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
- $outputFilename = Piwik_ReportRenderer::getOutputPath($filename);
+ $filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
+ $outputFilename = ReportRenderer::getOutputPath($filename);
$this->TCPDF->Output($outputFilename, 'F');
@@ -129,13 +134,13 @@ class Piwik_ReportRenderer_Pdf extends Piwik_ReportRenderer
public function sendToBrowserDownload($filename)
{
- $filename = Piwik_ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
+ $filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
$this->TCPDF->Output($filename, 'D');
}
public function sendToBrowserInline($filename)
{
- $filename = Piwik_ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
+ $filename = ReportRenderer::appendExtension($filename, self::PDF_CONTENT_TYPE);
$this->TCPDF->Output($filename, 'I');
}
diff --git a/core/ScheduledTask.php b/core/ScheduledTask.php
index 585d793b91..8d9c368c54 100644
--- a/core/ScheduledTask.php
+++ b/core/ScheduledTask.php
@@ -9,13 +9,18 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
+use Piwik\ScheduledTime;
+
/**
- * Piwik_ScheduledTask is used by the task scheduler and by plugins to configure runnable tasks.
+ * ScheduledTask is used by the task scheduler and by plugins to configure runnable tasks.
*
* @package Piwik
- * @subpackage Piwik_ScheduledTask
+ * @subpackage ScheduledTask
*/
-class Piwik_ScheduledTask
+class ScheduledTask
{
const LOWEST_PRIORITY = 12;
const LOW_PRIORITY = 9;
@@ -49,7 +54,7 @@ class Piwik_ScheduledTask
/**
* The scheduled time policy
- * @var Piwik_ScheduledTime
+ * @var ScheduledTime
*/
var $scheduledTime;
@@ -110,10 +115,9 @@ class Piwik_ScheduledTask
return $this->methodParameter;
}
-
/**
* Return scheduled time
- * @return Piwik_ScheduledTime
+ * @return ScheduledTime
*/
public function getScheduledTime()
{
@@ -131,7 +135,7 @@ class Piwik_ScheduledTask
/**
* Return the task priority. The priority will be an integer whose value is
- * between Piwik_ScheduledTask::HIGH_PRIORITY and Piwik_ScheduledTask::LOW_PRIORITY.
+ * between ScheduledTask::HIGH_PRIORITY and ScheduledTask::LOW_PRIORITY.
*
* @return int
*/
diff --git a/core/ScheduledTime.php b/core/ScheduledTime.php
index 1db44c1643..b0c6b8b224 100644
--- a/core/ScheduledTime.php
+++ b/core/ScheduledTime.php
@@ -9,15 +9,22 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
+use Piwik_ScheduledTime_Daily;
+use Piwik_ScheduledTime_Monthly;
+use Piwik_ScheduledTime_Weekly;
+
/**
- * The Piwik_ScheduledTime abstract class is used as a base class for different types of scheduling intervals.
- * Piwik_ScheduledTime subclasses are used to schedule tasks within Piwik.
+ * The ScheduledTime abstract class is used as a base class for different types of scheduling intervals.
+ * ScheduledTime subclasses are used to schedule tasks within Piwik.
*
* @see Piwik_ScheduledTask
* @package Piwik
- * @subpackage Piwik_ScheduledTime
+ * @subpackage ScheduledTime
*/
-abstract class Piwik_ScheduledTime
+abstract class ScheduledTime
{
const PERIOD_NEVER = 'never';
const PERIOD_DAY = 'day';
diff --git a/core/ScheduledTime/Daily.php b/core/ScheduledTime/Daily.php
index 46efdd0ddf..1783ddb160 100644
--- a/core/ScheduledTime/Daily.php
+++ b/core/ScheduledTime/Daily.php
@@ -8,15 +8,16 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\ScheduledTime;
/**
* Piwik_ScheduledTime_Daily class is used to schedule tasks every day.
*
* @see Piwik_ScheduledTask
* @package Piwik
- * @subpackage Piwik_ScheduledTime
+ * @subpackage ScheduledTime
*/
-class Piwik_ScheduledTime_Daily extends Piwik_ScheduledTime
+class Piwik_ScheduledTime_Daily extends ScheduledTime
{
public function getRescheduledTime()
{
diff --git a/core/ScheduledTime/Hourly.php b/core/ScheduledTime/Hourly.php
index fa5a4a3230..142ce95868 100644
--- a/core/ScheduledTime/Hourly.php
+++ b/core/ScheduledTime/Hourly.php
@@ -8,15 +8,16 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\ScheduledTime;
/**
* Piwik_ScheduledTime_Hourly class is used to schedule tasks every hour.
*
* @see Piwik_ScheduledTask
* @package Piwik
- * @subpackage Piwik_ScheduledTime
+ * @subpackage ScheduledTime
*/
-class Piwik_ScheduledTime_Hourly extends Piwik_ScheduledTime
+class Piwik_ScheduledTime_Hourly extends ScheduledTime
{
public function getRescheduledTime()
{
diff --git a/core/ScheduledTime/Monthly.php b/core/ScheduledTime/Monthly.php
index e09777a23a..c3e4d759da 100644
--- a/core/ScheduledTime/Monthly.php
+++ b/core/ScheduledTime/Monthly.php
@@ -8,15 +8,16 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\ScheduledTime;
/**
* Piwik_ScheduledTime_Monthly class is used to schedule tasks every month.
*
* @see Piwik_ScheduledTask
* @package Piwik
- * @subpackage Piwik_ScheduledTime
+ * @subpackage ScheduledTime
*/
-class Piwik_ScheduledTime_Monthly extends Piwik_ScheduledTime
+class Piwik_ScheduledTime_Monthly extends ScheduledTime
{
/**
* Day of the week for scheduled time.
diff --git a/core/ScheduledTime/Weekly.php b/core/ScheduledTime/Weekly.php
index d47cf53350..af8a78214f 100644
--- a/core/ScheduledTime/Weekly.php
+++ b/core/ScheduledTime/Weekly.php
@@ -8,15 +8,16 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\ScheduledTime;
/**
* Piwik_ScheduledTime_Weekly class is used to schedule tasks every week.
*
* @see Piwik_ScheduledTask
* @package Piwik
- * @subpackage Piwik_ScheduledTime
+ * @subpackage ScheduledTime
*/
-class Piwik_ScheduledTime_Weekly extends Piwik_ScheduledTime
+class Piwik_ScheduledTime_Weekly extends ScheduledTime
{
public function getRescheduledTime()
diff --git a/core/Session.php b/core/Session.php
index 1db8458cb7..dcbd327562 100644
--- a/core/Session.php
+++ b/core/Session.php
@@ -8,17 +8,23 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik_Session_SaveHandler_DbTable;
+use Zend_Registry;
+use Zend_Session;
/**
* Session initialization.
*
* @package Piwik
- * @subpackage Piwik_Session
+ * @subpackage Session
*/
-class Piwik_Session extends Zend_Session
+class Session extends Zend_Session
{
protected static $sessionStarted = false;
diff --git a/core/Session/Namespace.php b/core/Session/Namespace.php
index f2fb04b131..d46ca799d7 100644
--- a/core/Session/Namespace.php
+++ b/core/Session/Namespace.php
@@ -14,7 +14,7 @@ use Piwik\Common;
* Session namespace.
*
* @package Piwik
- * @subpackage Piwik_Session
+ * @subpackage Session
*/
class Piwik_Session_Namespace extends Zend_Session_Namespace
{
diff --git a/core/Session/SaveHandler/DbTable.php b/core/Session/SaveHandler/DbTable.php
index df00a920ea..a8bedd44ef 100644
--- a/core/Session/SaveHandler/DbTable.php
+++ b/core/Session/SaveHandler/DbTable.php
@@ -13,7 +13,7 @@
* Database-backed session save handler
*
* @package Piwik
- * @subpackage Piwik_Session
+ * @subpackage Session
*/
class Piwik_Session_SaveHandler_DbTable implements Zend_Session_SaveHandler_Interface
{
diff --git a/core/TCPDF.php b/core/TCPDF.php
index 2be9e09ad9..ab0e3d2a54 100644
--- a/core/TCPDF.php
+++ b/core/TCPDF.php
@@ -9,6 +9,10 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
+
/**
* @see libs/tcpdf/tcpdf.php
*/
@@ -19,7 +23,7 @@ require_once PIWIK_INCLUDE_PATH . '/libs/tcpdf/tcpdf.php';
*
* @package Piwik
*/
-class Piwik_TCPDF extends TCPDF
+class TCPDF extends \TCPDF
{
protected $footerContent = null;
protected $currentPageNo = null;
diff --git a/core/TaskScheduler.php b/core/TaskScheduler.php
index aa39e703de..a102e55252 100644
--- a/core/TaskScheduler.php
+++ b/core/TaskScheduler.php
@@ -10,10 +10,16 @@
*/
// When set to true, all scheduled tasks will be triggered in all requests (careful!)
+namespace Piwik;
+
+use Exception;
+use Piwik\ScheduledTask;
+use Piwik\Timer;
+
define('DEBUG_FORCE_SCHEDULED_TASKS', false);
/**
- * Piwik_TaskScheduler is the class used to manage the execution of periodicaly planned task.
+ * TaskScheduler is the class used to manage the execution of periodicaly planned task.
*
* It performs the following actions :
* - Identifies tasks of Piwik
@@ -22,7 +28,7 @@ define('DEBUG_FORCE_SCHEDULED_TASKS', false);
* @package Piwik
*/
-class Piwik_TaskScheduler
+class TaskScheduler
{
const GET_TASKS_EVENT = "TaskScheduler.getScheduledTasks";
const TIMETABLE_OPTION_STRING = "TaskScheduler.timetable";
@@ -56,8 +62,8 @@ class Piwik_TaskScheduler
// for every priority level, starting with the highest and concluding with the lowest
$executionResults = array();
- for ($priority = Piwik_ScheduledTask::HIGHEST_PRIORITY;
- $priority <= Piwik_ScheduledTask::LOWEST_PRIORITY;
+ for ($priority = ScheduledTask::HIGHEST_PRIORITY;
+ $priority <= ScheduledTask::LOWEST_PRIORITY;
++$priority) {
// loop through each task
foreach ($tasks as $task) {
@@ -105,7 +111,7 @@ class Piwik_TaskScheduler
// get the array where rescheduled timetables are stored
$timetable = self::getTimetableFromOptionTable();
- $taskName = Piwik_ScheduledTask::getTaskName($className, $methodName, $methodParameter);
+ $taskName = ScheduledTask::getTaskName($className, $methodName, $methodParameter);
return self::taskHasBeenScheduledOnce($taskName, $timetable) ? $timetable[$taskName] : false;
}
@@ -167,7 +173,7 @@ class Piwik_TaskScheduler
static private function executeTask($task)
{
try {
- $timer = new Piwik_Timer();
+ $timer = new Timer();
call_user_func(array($task->getObjectInstance(), $task->getMethodName()), $task->getMethodParameter());
$message = $timer->__toString();
} catch (Exception $e) {
diff --git a/core/Timer.php b/core/Timer.php
index 236787db67..d3f1e29d79 100644
--- a/core/Timer.php
+++ b/core/Timer.php
@@ -8,13 +8,15 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Piwik;
/**
*
* @package Piwik
*/
-class Piwik_Timer
+class Timer
{
private $timerStart;
private $memoryStart;
diff --git a/core/Tracker.php b/core/Tracker.php
index a5fb093b95..aca7ee28eb 100644
--- a/core/Tracker.php
+++ b/core/Tracker.php
@@ -8,11 +8,25 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
use Piwik\Access;
use Piwik\Translate;
+use Piwik\TaskScheduler;
+use Piwik_Tracker_Cache;
+use Piwik_Tracker_Db;
+use Piwik_Tracker_Db_Exception;
+use Piwik_Tracker_Db_Mysqli;
+use Piwik_Tracker_Db_Pdo_Mysql;
+use Piwik_Tracker_Request;
+use Piwik_Tracker_Visit;
+use Piwik_Tracker_Visit_Excluded;
+use Piwik_Tracker_Visit_Interface;
+use Zend_Registry;
/**
* Class used by the logging script piwik.php called by the javascript tag.
@@ -22,9 +36,9 @@ use Piwik\Translate;
* We try to include as little files as possible (no dependency on 3rd party modules).
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
-class Piwik_Tracker
+class Tracker
{
protected $stateValid = self::STATE_NOTHING_TO_NOTICE;
/**
@@ -126,13 +140,12 @@ class Piwik_Tracker
{
return self::$pluginsToLoad;
}
+
static public function setPluginsToLoad($plugins)
{
self::$pluginsToLoad = $plugins;
}
-
-
/**
* Update Tracker config
*
@@ -245,17 +258,16 @@ class Piwik_Tracker
++$this->countOfLoggedRequests;
}
-
// run scheduled task
try {
if (!$isAuthenticated // Do not run schedule task if we are importing logs or doing custom tracking (as it could slow down)
- && $this->shouldRunScheduledTasks()) {
+ && $this->shouldRunScheduledTasks()
+ ) {
self::runScheduledTasks();
}
} catch (Exception $e) {
$this->exitWithException($e);
}
-
} else {
$this->handleEmptyRequest(new Piwik_Tracker_Request($_GET + $_POST));
}
@@ -316,7 +328,7 @@ class Piwik_Tracker
// we ensure English translations at least are loaded
Translate::getInstance()->loadEnglishTranslation();
- $resultTasks = Piwik_TaskScheduler::runTasks();
+ $resultTasks = TaskScheduler::runTasks();
// restore original user privilege
Piwik::setUserIsSuperUser($isSuperUser);
@@ -343,10 +355,10 @@ class Piwik_Tracker
self::$initTrackerMode = true;
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
-
+
$access = Access::getInstance();
$config = Config::getInstance();
-
+
try {
$db = Zend_Registry::get('db');
} catch (Exception $e) {
@@ -355,9 +367,9 @@ class Piwik_Tracker
$pluginsManager = \Piwik\PluginsManager::getInstance();
$pluginsToLoad = Config::getInstance()->Plugins['Plugins'];
- $pluginsForcedNotToLoad = Piwik_Tracker::getPluginsNotToLoad();
+ $pluginsForcedNotToLoad = Tracker::getPluginsNotToLoad();
$pluginsToLoad = array_diff($pluginsToLoad, $pluginsForcedNotToLoad);
- $pluginsToLoad = array_merge($pluginsToLoad, Piwik_Tracker::getPluginsToLoad());
+ $pluginsToLoad = array_merge($pluginsToLoad, Tracker::getPluginsToLoad());
$pluginsManager->loadPlugins($pluginsToLoad);
}
}
@@ -375,7 +387,7 @@ class Piwik_Tracker
$result = array('succeeded' => $this->countOfLoggedRequests);
// send error when in debug mode or when authenticated (which happens when doing log importing,
if ((isset($GLOBALS['PIWIK_TRACKER_DEBUG']) && $GLOBALS['PIWIK_TRACKER_DEBUG']) || $authenticated) {
- $result['error'] = Piwik_Tracker_GetErrorMessage($e);
+ $result['error'] = $this->getMessageFromException($e);
}
echo Common::json_encode($result);
exit;
@@ -387,11 +399,11 @@ class Piwik_Tracker
$footerPage = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Zeitgeist/templates/simpleLayoutFooter.tpl');
$headerPage = str_replace('{$HTML_TITLE}', 'Piwik &rsaquo; Error', $headerPage);
- echo $headerPage . '<p>' . Piwik_Tracker_GetErrorMessage($e) . '</p>' . $trailer . $footerPage;
+ echo $headerPage . '<p>' . $this->getMessageFromException($e) . '</p>' . $trailer . $footerPage;
} // If not debug, but running authenticated (eg. during log import) then we display raw errors
elseif ($authenticated) {
Common::sendHeader('Content-Type: text/html; charset=utf-8');
- echo Piwik_Tracker_GetErrorMessage($e);
+ echo $this->getMessageFromException($e);
} else {
$this->outputTransparentGif();
}
@@ -491,7 +503,7 @@ class Piwik_Tracker
Piwik_PostEvent('Tracker.getDatabaseConfig', array(&$configDb));
- $db = Piwik_Tracker::factory($configDb);
+ $db = Tracker::factory($configDb);
$db->connect();
return $db;
@@ -597,7 +609,7 @@ class Piwik_Tracker
if (!empty($disableProvider)
&& $request->isAuthenticated()
) {
- Piwik_Tracker::setPluginsNotToLoad(array('Provider'));
+ Tracker::setPluginsNotToLoad(array('Provider'));
}
try {
@@ -649,7 +661,7 @@ class Piwik_Tracker
*/
protected function handleTrackingApi(Piwik_Tracker_Request $request)
{
- if(!$request->isAuthenticated()) {
+ if (!$request->isAuthenticated()) {
return;
}
@@ -738,23 +750,23 @@ class Piwik_Tracker
self::setPluginsNotToLoad($pluginsDisabled);
// we load 'DevicesDetection' in tests only (disabled by default)
- self::setPluginsToLoad( array('DevicesDetection') );
+ self::setPluginsToLoad(array('DevicesDetection'));
}
-}
-/**
- * Gets the error message to output when a tracking request fails.
- *
- * @param Exception $e
- * @return string
- */
-function Piwik_Tracker_GetErrorMessage($e)
-{
- // Note: duplicated from FormDatabaseSetup.isAccessDenied
- // Avoid leaking the username/db name when access denied
- if ($e->getCode() == 1044 || $e->getCode() == 42000) {
- return "Error while connecting to the Piwik database - please check your credentials in config/config.ini.php file";
- } else {
- return $e->getMessage();
+ /**
+ * Gets the error message to output when a tracking request fails.
+ *
+ * @param Exception $e
+ * @return string
+ */
+ private function getMessageFromException($e)
+ {
+ // Note: duplicated from FormDatabaseSetup.isAccessDenied
+ // Avoid leaking the username/db name when access denied
+ if ($e->getCode() == 1044 || $e->getCode() == 42000) {
+ return "Error while connecting to the Piwik database - please check your credentials in config/config.ini.php file";
+ } else {
+ return $e->getMessage();
+ }
}
}
diff --git a/core/Tracker/Action.php b/core/Tracker/Action.php
index 1fee863928..b7df4c0b1c 100644
--- a/core/Tracker/Action.php
+++ b/core/Tracker/Action.php
@@ -10,13 +10,14 @@
*/
use Piwik\Config;
use Piwik\Common;
+use Piwik\Tracker;
/**
* Interface of the Action object.
* New Action classes can be defined in plugins and used instead of the default one.
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
interface Piwik_Tracker_Action_Interface
{
@@ -51,7 +52,7 @@ interface Piwik_Tracker_Action_Interface
* Parses the action name and URL from the request array, then records the action in the log table.
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface
{
@@ -505,7 +506,7 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface
if (empty($bind)) {
return $actionNamesAndTypes;
}
- $actionIds = Piwik_Tracker::getDatabase()->fetchAll($sql, $bind);
+ $actionIds = Tracker::getDatabase()->fetchAll($sql, $bind);
// For the Actions found in the lookup table, add the idaction in the array,
// If not found in lookup table, queue for INSERT
@@ -545,8 +546,8 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface
$urlPrefix = $normalizedUrls[$actionToInsert]['prefixId'];
}
- Piwik_Tracker::getDatabase()->query($sql, array($name, $name, $type, $urlPrefix));
- $actionId = Piwik_Tracker::getDatabase()->lastInsertId();
+ Tracker::getDatabase()->query($sql, array($name, $name, $type, $urlPrefix));
+ $actionId = Tracker::getDatabase()->lastInsertId();
Common::printDebug("Recorded a new action (" . self::getActionTypeName($type) . ") in the lookup table: " . $name . " (idaction = " . $actionId . ")");
$actionNamesAndTypes[$actionToInsert][] = $actionId;
@@ -665,7 +666,7 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface
'idvisit' => $idVisit,
'idsite' => $this->request->getIdSite(),
'idvisitor' => $visitorIdCookie,
- 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()),
+ 'server_time' => Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()),
'idaction_url' => $this->getIdActionUrl(),
'idaction_name' => $idActionName,
'idaction_url_ref' => $idRefererActionUrl,
@@ -694,9 +695,9 @@ class Piwik_Tracker_Action implements Piwik_Tracker_Action_Interface
$values = Common::getSqlStringFieldsArray($insertWithoutNulls);
$sql = "INSERT INTO " . Common::prefixTable('log_link_visit_action') . " ($fields) VALUES ($values)";
- Piwik_Tracker::getDatabase()->query($sql, $bind);
+ Tracker::getDatabase()->query($sql, $bind);
- $this->idLinkVisitAction = Piwik_Tracker::getDatabase()->lastInsertId();
+ $this->idLinkVisitAction = Tracker::getDatabase()->lastInsertId();
$info = array(
'idSite' => $this->request->getIdSite(),
diff --git a/core/Tracker/Cache.php b/core/Tracker/Cache.php
index 72910c11e0..b65cbc37bd 100644
--- a/core/Tracker/Cache.php
+++ b/core/Tracker/Cache.php
@@ -11,18 +11,20 @@
use Piwik\ArchiveProcessor\Rules;
use Piwik\Config;
use Piwik\Piwik;
+use Piwik\CacheFile;
+use Piwik\Tracker;
/**
* Simple cache mechanism used in Tracker to avoid requesting settings from mysql on every request
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Cache
{
/**
* Public for tests only
- * @var Piwik_CacheFile
+ * @var CacheFile
*/
static public $trackerCache = null;
@@ -30,7 +32,7 @@ class Piwik_Tracker_Cache
{
if (is_null(self::$trackerCache)) {
$ttl = Config::getInstance()->Tracker['tracker_cache_file_ttl'];
- self::$trackerCache = new Piwik_CacheFile('tracker', $ttl);
+ self::$trackerCache = new CacheFile('tracker', $ttl);
}
return self::$trackerCache;
}
@@ -50,7 +52,7 @@ class Piwik_Tracker_Cache
return $cacheContent;
}
- Piwik_Tracker::initCorePiwikInTrackerMode();
+ Tracker::initCorePiwikInTrackerMode();
// save current user privilege and temporarily assume super user privilege
$isSuperUser = Piwik::isUserIsSuperUser();
@@ -95,7 +97,7 @@ class Piwik_Tracker_Cache
return $cacheContent;
}
- Piwik_Tracker::initCorePiwikInTrackerMode();
+ Tracker::initCorePiwikInTrackerMode();
$cacheContent = array(
'isBrowserTriggerEnabled' => Rules::isBrowserTriggerEnabled(),
'lastTrackerCronRun' => Piwik_GetOption('lastTrackerCronRun'),
diff --git a/core/Tracker/Db.php b/core/Tracker/Db.php
index 5b7cbde2cc..f917f3ed61 100644
--- a/core/Tracker/Db.php
+++ b/core/Tracker/Db.php
@@ -9,6 +9,7 @@
* @package Piwik
*/
use Piwik\Common;
+use Piwik\Timer;
/**
* Simple database wrapper.
@@ -16,7 +17,7 @@ use Piwik\Common;
* We wrote this simple class
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
abstract class Piwik_Tracker_Db
{
@@ -60,18 +61,18 @@ abstract class Piwik_Tracker_Db
/**
* Initialize profiler
*
- * @return Piwik_Timer
+ * @return Timer
*/
protected function initProfiler()
{
- return new Piwik_Timer;
+ return new Timer;
}
/**
* Record query profile
*
* @param string $query
- * @param Piwik_Timer $timer
+ * @param Timer $timer
*/
protected function recordQueryProfile($query, $timer)
{
diff --git a/core/Tracker/Db/Exception.php b/core/Tracker/Db/Exception.php
index 3958a1e008..2368503790 100644
--- a/core/Tracker/Db/Exception.php
+++ b/core/Tracker/Db/Exception.php
@@ -13,7 +13,7 @@
* Database Exception
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Db_Exception extends Exception
{
diff --git a/core/Tracker/Db/Mysqli.php b/core/Tracker/Db/Mysqli.php
index 96036499a0..12ed3ed725 100644
--- a/core/Tracker/Db/Mysqli.php
+++ b/core/Tracker/Db/Mysqli.php
@@ -13,7 +13,7 @@
* mysqli wrapper
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Db_Mysqli extends Piwik_Tracker_Db
{
diff --git a/core/Tracker/Db/Pdo/Mysql.php b/core/Tracker/Db/Pdo/Mysql.php
index aaca0b2780..de201fd511 100644
--- a/core/Tracker/Db/Pdo/Mysql.php
+++ b/core/Tracker/Db/Pdo/Mysql.php
@@ -13,7 +13,7 @@
* PDO MySQL wrapper
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Db_Pdo_Mysql extends Piwik_Tracker_Db
{
diff --git a/core/Tracker/Db/Pdo/Pgsql.php b/core/Tracker/Db/Pdo/Pgsql.php
index f6c282d156..52e04e27f4 100644
--- a/core/Tracker/Db/Pdo/Pgsql.php
+++ b/core/Tracker/Db/Pdo/Pgsql.php
@@ -13,7 +13,7 @@
* PDO PostgreSQL wrapper
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Db_Pdo_Pgsql extends Piwik_Tracker_Db_Pdo_Mysql
{
diff --git a/core/Tracker/GoalManager.php b/core/Tracker/GoalManager.php
index 719639619d..88e5057c09 100644
--- a/core/Tracker/GoalManager.php
+++ b/core/Tracker/GoalManager.php
@@ -10,10 +10,11 @@
*/
use Piwik\Config;
use Piwik\Common;
+use Piwik\Tracker;
/**
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_GoalManager
{
@@ -238,7 +239,7 @@ class Piwik_Tracker_GoalManager
'idvisit' => $visitorInformation['idvisit'],
'idsite' => $idSite,
'idvisitor' => $visitorInformation['idvisitor'],
- 'server_time' => Piwik_Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']),
+ 'server_time' => Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']),
'location_country' => $location_country,
'visitor_returning' => $visitorInformation['visitor_returning'],
'visitor_days_since_first' => $visitorInformation['visitor_days_since_first'],
@@ -254,7 +255,7 @@ class Piwik_Tracker_GoalManager
}
// Copy Custom Variables from Visit row to the Goal conversion
- for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) {
+ for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) {
if (isset($visitorInformation['custom_var_k' . $i])
&& strlen($visitorInformation['custom_var_k' . $i])
) {
@@ -449,7 +450,7 @@ class Piwik_Tracker_GoalManager
self::ITEM_IDORDER_ABANDONED_CART
);
- $itemsInDb = Piwik_Tracker::getDatabase()->fetchAll($sql, $bind);
+ $itemsInDb = Tracker::getDatabase()->fetchAll($sql, $bind);
Common::printDebug("Items found in current cart, for conversion_item (visit,idorder)=" . var_export($bind, true));
Common::printDebug($itemsInDb);
@@ -668,7 +669,7 @@ class Piwik_Tracker_GoalManager
$sqlBind[] = $newRow['idvisit'];
$sqlBind[] = $item['idorder_original_value'];
$sqlBind[] = $newRow['idaction_sku'];
- Piwik_Tracker::getDatabase()->query($sql, $sqlBind);
+ Tracker::getDatabase()->query($sql, $sqlBind);
}
}
@@ -704,7 +705,7 @@ class Piwik_Tracker_GoalManager
$i++;
$bind = array_merge($bind, $newRow);
}
- Piwik_Tracker::getDatabase()->query($sql, $bind);
+ Tracker::getDatabase()->query($sql, $bind);
Common::printDebug($sql);
Common::printDebug($bind);
}
@@ -793,16 +794,16 @@ class Piwik_Tracker_GoalManager
$sql = 'UPDATE ' . Common::prefixTable('log_conversion') . "
SET " . implode($updateParts, ', ') . "
WHERE " . implode($updateWhereParts, ' AND ');
- Piwik_Tracker::getDatabase()->query($sql, $sqlBind);
+ Tracker::getDatabase()->query($sql, $sqlBind);
return true;
} else {
$sql = 'INSERT IGNORE INTO ' . Common::prefixTable('log_conversion') . "
($fields) VALUES ($bindFields) ";
$bind = array_values($newGoal);
- $result = Piwik_Tracker::getDatabase()->query($sql, $bind);
+ $result = Tracker::getDatabase()->query($sql, $bind);
// If a record was inserted, we return true
- return Piwik_Tracker::getDatabase()->rowCount($result) > 0;
+ return Tracker::getDatabase()->rowCount($result) > 0;
}
}
diff --git a/core/Tracker/IgnoreCookie.php b/core/Tracker/IgnoreCookie.php
index 7253c25520..38f1b96f66 100644
--- a/core/Tracker/IgnoreCookie.php
+++ b/core/Tracker/IgnoreCookie.php
@@ -9,39 +9,40 @@
* @package Piwik
*/
use Piwik\Config;
+use Piwik\Cookie;
/**
* Tracking cookies.
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_IgnoreCookie
{
/**
* Get tracking cookie
*
- * @return Piwik_Cookie
+ * @return Cookie
*/
static public function getTrackingCookie()
{
$cookie_name = @Config::getInstance()->Tracker['cookie_name'];
$cookie_path = @Config::getInstance()->Tracker['cookie_path'];
- return new Piwik_Cookie($cookie_name, null, $cookie_path);
+ return new Cookie($cookie_name, null, $cookie_path);
}
/**
* Get ignore (visit) cookie
*
- * @return Piwik_Cookie
+ * @return Cookie
*/
static public function getIgnoreCookie()
{
$cookie_name = @Config::getInstance()->Tracker['ignore_visits_cookie_name'];
$cookie_path = @Config::getInstance()->Tracker['cookie_path'];
- return new Piwik_Cookie($cookie_name, null, $cookie_path);
+ return new Cookie($cookie_name, null, $cookie_path);
}
/**
diff --git a/core/Tracker/Referer.php b/core/Tracker/Referer.php
index b1389c256b..5b9765ecea 100644
--- a/core/Tracker/Referer.php
+++ b/core/Tracker/Referer.php
@@ -12,7 +12,7 @@ use Piwik\Common;
/**
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Referer
{
diff --git a/core/Tracker/Request.php b/core/Tracker/Request.php
index c27ebe6b9a..bf878bb106 100644
--- a/core/Tracker/Request.php
+++ b/core/Tracker/Request.php
@@ -1,6 +1,9 @@
<?php
use Piwik\Config;
use Piwik\Common;
+use Piwik\Cookie;
+use Piwik\IP;
+use Piwik\Tracker;
/**
* Piwik - Open source web analytics
@@ -292,7 +295,7 @@ class Piwik_Tracker_Request
foreach ($customVar as $id => $keyValue) {
$id = (int)$id;
if ($id < 1
- || $id > Piwik_Tracker::MAX_CUSTOM_VARIABLES
+ || $id > Tracker::MAX_CUSTOM_VARIABLES
|| count($keyValue) != 2
|| (!is_string($keyValue[0]) && !is_numeric($keyValue[0]))
) {
@@ -316,7 +319,7 @@ class Piwik_Tracker_Request
static public function truncateCustomVariable($input)
{
- return substr(trim($input), 0, Piwik_Tracker::MAX_LENGTH_CUSTOM_VARIABLE);
+ return substr(trim($input), 0, Tracker::MAX_LENGTH_CUSTOM_VARIABLE);
}
protected function shouldUseThirdPartyCookie()
@@ -342,7 +345,7 @@ class Piwik_Tracker_Request
protected function makeThirdPartyCookie()
{
- $cookie = new Piwik_Cookie(
+ $cookie = new Cookie(
$this->getCookieName(),
$this->getCookieExpire(),
$this->getCookiePath());
@@ -376,8 +379,8 @@ class Piwik_Tracker_Request
// Was a Visitor ID "forced" (@see Tracking API setVisitorId()) for this request?
$idVisitor = $this->getForcedVisitorId();
if (!empty($idVisitor)) {
- if (strlen($idVisitor) != Piwik_Tracker::LENGTH_HEX_ID_STRING) {
- throw new Exception("Visitor ID (cid) $idVisitor must be " . Piwik_Tracker::LENGTH_HEX_ID_STRING . " characters long");
+ if (strlen($idVisitor) != Tracker::LENGTH_HEX_ID_STRING) {
+ throw new Exception("Visitor ID (cid) $idVisitor must be " . Tracker::LENGTH_HEX_ID_STRING . " characters long");
}
Common::printDebug("Request will be recorded for this idvisitor = " . $idVisitor);
$found = true;
@@ -391,7 +394,7 @@ class Piwik_Tracker_Request
$cookie = $this->makeThirdPartyCookie();
$idVisitor = $cookie->get(0);
if ($idVisitor !== false
- && strlen($idVisitor) == Piwik_Tracker::LENGTH_HEX_ID_STRING
+ && strlen($idVisitor) == Tracker::LENGTH_HEX_ID_STRING
) {
$found = true;
}
@@ -400,11 +403,11 @@ class Piwik_Tracker_Request
// If a third party cookie was not found, we default to the first party cookie
if (!$found) {
$idVisitor = Common::getRequestVar('_id', '', 'string', $this->params);
- $found = strlen($idVisitor) >= Piwik_Tracker::LENGTH_HEX_ID_STRING;
+ $found = strlen($idVisitor) >= Tracker::LENGTH_HEX_ID_STRING;
}
if ($found) {
- $truncated = substr($idVisitor, 0, Piwik_Tracker::LENGTH_HEX_ID_STRING);
+ $truncated = substr($idVisitor, 0, Tracker::LENGTH_HEX_ID_STRING);
$binVisitorId = @Common::hex2bin($truncated);
if (!empty($binVisitorId)) {
return $binVisitorId;
@@ -418,9 +421,9 @@ class Piwik_Tracker_Request
if (!empty($this->enforcedIp)) {
$ipString = $this->enforcedIp;
} else {
- $ipString = Piwik_IP::getIpFromHeader();
+ $ipString = IP::getIpFromHeader();
}
- $ip = Piwik_IP::P2N($ipString);
+ $ip = IP::P2N($ipString);
return $ip;
}
diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php
index da14bb6de0..97e398b0f2 100644
--- a/core/Tracker/Visit.php
+++ b/core/Tracker/Visit.php
@@ -10,10 +10,12 @@
*/
use Piwik\Config;
use Piwik\Common;
+use Piwik\IP;
+use Piwik\Tracker;
/**
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
interface Piwik_Tracker_Visit_Interface
{
@@ -33,7 +35,7 @@ interface Piwik_Tracker_Visit_Interface
* One request to the piwik.php script is associated to one action.
*
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
{
@@ -268,9 +270,9 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
if ($incrementActions) {
$sqlActionUpdate .= "visit_total_actions = visit_total_actions + 1, ";
}
- Common::printDebug("Visit is known (IP = " . Piwik_IP::N2P($this->getVisitorIp()) . ")");
+ Common::printDebug("Visit is known (IP = " . IP::N2P($this->getVisitorIp()) . ")");
- $datetimeServer = Piwik_Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp());
+ $datetimeServer = Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp());
$valuesToUpdate['visit_last_action_time'] = $datetimeServer;
// Add 1 so it's always > 0
@@ -291,7 +293,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
}
// Might update the idvisitor when it was forced or overwritten for this visit
- if (strlen($this->visitorInfo['idvisitor']) == Piwik_Tracker::LENGTH_BINARY_ID) {
+ if (strlen($this->visitorInfo['idvisitor']) == Tracker::LENGTH_BINARY_ID) {
$valuesToUpdate['idvisitor'] = $this->visitorInfo['idvisitor'];
}
@@ -324,7 +326,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
AND idvisit = ?";
array_push($sqlBind, $this->request->getIdSite(), (int)$this->visitorInfo['idvisit']);
- $result = Piwik_Tracker::getDatabase()->query($sqlQuery, $sqlBind);
+ $result = Tracker::getDatabase()->query($sqlQuery, $sqlBind);
$this->visitorInfo['visit_last_action_time'] = $this->request->getCurrentTimestamp();
@@ -334,7 +336,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
}
Common::printDebug('Updating existing visit: ' . var_export($valuesToUpdate, true));
- if (Piwik_Tracker::getDatabase()->rowCount($result) == 0) {
+ if (Tracker::getDatabase()->rowCount($result) == 0) {
Common::printDebug("Visitor with this idvisit wasn't found in the DB.");
Common::printDebug("$sqlQuery --- ");
Common::printDebug($sqlBind);
@@ -373,7 +375,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
*/
protected function handleNewVisit($idActionUrl, $idActionName, $actionType, $visitIsConverted)
{
- Common::printDebug("New Visit (IP = " . Piwik_IP::N2P($this->getVisitorIp()) . ")");
+ Common::printDebug("New Visit (IP = " . IP::N2P($this->getVisitorIp()) . ")");
$daysSinceFirstVisit = $this->request->getDaysSinceFirstVisit();
$visitCount = $this->request->getVisitCount();
@@ -414,8 +416,8 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
'visitor_days_since_last' => $daysSinceLastVisit,
'visitor_days_since_order' => $daysSinceLastOrder,
'visitor_days_since_first' => $daysSinceFirstVisit,
- 'visit_first_action_time' => Piwik_Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()),
- 'visit_last_action_time' => Piwik_Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()),
+ 'visit_first_action_time' => Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()),
+ 'visit_last_action_time' => Tracker::getDatetimeFromTimestamp($this->request->getCurrentTimestamp()),
'visit_entry_idaction_url' => (int)$idActionUrl,
'visit_entry_idaction_name' => (int)$idActionName,
'visit_exit_idaction_url' => (int)$idActionUrl,
@@ -495,7 +497,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
private function getVisitorLocation($browserLang)
{
$location = array();
- $userInfo = array('lang' => $browserLang, 'ip' => Piwik_IP::N2P($this->getVisitorIp()));
+ $userInfo = array('lang' => $browserLang, 'ip' => IP::N2P($this->getVisitorIp()));
Piwik_PostEvent('Tracker.getVisitorLocation', array(&$location, $userInfo));
$location = $this->request->enrichLocation($location);
@@ -575,9 +577,9 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
$sql = "INSERT INTO " . Common::prefixTable('log_visit') . " ($fields) VALUES ($values)";
$bind = array_values($this->visitorInfo);
- Piwik_Tracker::getDatabase()->query($sql, $bind);
+ Tracker::getDatabase()->query($sql, $bind);
- $idVisit = Piwik_Tracker::getDatabase()->lastInsertId();
+ $idVisit = Tracker::getDatabase()->lastInsertId();
$this->visitorInfo['idvisit'] = $idVisit;
$this->visitorInfo['visit_first_action_time'] = $this->request->getCurrentTimestamp();
@@ -598,7 +600,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
}
// If the visitor had a first party ID cookie, then we use this value
if (!empty($this->visitorInfo['idvisitor'])
- && strlen($this->visitorInfo['idvisitor']) == Piwik_Tracker::LENGTH_BINARY_ID
+ && strlen($this->visitorInfo['idvisitor']) == Tracker::LENGTH_BINARY_ID
) {
return $this->visitorInfo['idvisitor'];
}
@@ -610,7 +612,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
*/
static public function generateUniqueVisitorId()
{
- $uniqueId = substr(Common::generateUniqId(), 0, Piwik_Tracker::LENGTH_HEX_ID_STRING);
+ $uniqueId = substr(Common::generateUniqId(), 0, Tracker::LENGTH_HEX_ID_STRING);
return $uniqueId;
}
@@ -758,7 +760,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
}
- $visitRow = Piwik_Tracker::getDatabase()->fetch($sql, $bindSql);
+ $visitRow = Tracker::getDatabase()->fetch($sql, $bindSql);
$isNewVisitForced = $this->request->getParam('new_visit');
$isNewVisitForced = !empty($isNewVisitForced);
@@ -798,7 +800,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
// Custom Variables copied from Visit in potential later conversion
if (!empty($selectCustomVariables)) {
- for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) {
+ for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) {
if (isset($visitRow['custom_var_k' . $i])
&& strlen($visitRow['custom_var_k' . $i])
) {
@@ -1018,7 +1020,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
protected function getConfigHash($os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
{
$hash = md5($os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang, $raw_output = true);
- return Common::substr($hash, 0, Piwik_Tracker::LENGTH_BINARY_ID);
+ return Common::substr($hash, 0, Tracker::LENGTH_BINARY_ID);
}
/**
@@ -1055,7 +1057,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface
/**
* @package Piwik
- * @subpackage Piwik_Tracker
+ * @subpackage Tracker
*/
class Piwik_Tracker_Visit_VisitorNotFoundInDatabase extends Exception
{
diff --git a/core/Tracker/VisitExcluded.php b/core/Tracker/VisitExcluded.php
index fc9fbfe52f..70d8d23e0b 100644
--- a/core/Tracker/VisitExcluded.php
+++ b/core/Tracker/VisitExcluded.php
@@ -9,6 +9,7 @@
* @package Piwik
*/
use Piwik\Common;
+use Piwik\IP;
/**
* This class contains the logic to exclude some visitors from being tracked as per user settings
@@ -134,7 +135,7 @@ class Piwik_Tracker_VisitExcluded
|| strpos($this->userAgent, 'Google Page Speed Insights') !== false // #4049
|| strpos($this->userAgent, 'bingbot') !== false // Bingbot
|| strpos($this->userAgent, 'YottaaMonitor') !== false // Yottaa
- || Piwik_IP::isIpInRange($this->ip, $this->getBotIpRanges()));
+ || IP::isIpInRange($this->ip, $this->getBotIpRanges()));
}
protected function getBotIpRanges()
@@ -182,8 +183,8 @@ class Piwik_Tracker_VisitExcluded
{
$websiteAttributes = Piwik_Tracker_Cache::getCacheWebsiteAttributes($this->idSite);
if (!empty($websiteAttributes['excluded_ips'])) {
- if (Piwik_IP::isIpInRange($this->ip, $websiteAttributes['excluded_ips'])) {
- Common::printDebug('Visitor IP ' . Piwik_IP::N2P($this->ip) . ' is excluded from being tracked');
+ if (IP::isIpInRange($this->ip, $websiteAttributes['excluded_ips'])) {
+ Common::printDebug('Visitor IP ' . IP::N2P($this->ip) . ' is excluded from being tracked');
return true;
}
}
diff --git a/core/TranslationWriter.php b/core/TranslationWriter.php
index a103799d33..566b2112f8 100644
--- a/core/TranslationWriter.php
+++ b/core/TranslationWriter.php
@@ -9,6 +9,9 @@
* @package Piwik
*
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Common;
/**
@@ -16,7 +19,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_TranslationWriter
+class TranslationWriter
{
static private $baseTranslation = null;
diff --git a/core/Twig.php b/core/Twig.php
index 124f018fb5..ea5e23d9f5 100644
--- a/core/Twig.php
+++ b/core/Twig.php
@@ -8,17 +8,29 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\AssetManager;
use Piwik\Translate;
+use Piwik\Url;
+use Piwik_Visualization_Sparkline;
+use Twig_Environment;
+use Twig_Extension_Debug;
+use Twig_Loader_Chain;
+use Twig_Loader_Filesystem;
+use Twig_SimpleFilter;
+use Twig_SimpleFunction;
/**
* Twig class
*
* @package Piwik
- * @subpackage Piwik_Twig
+ * @subpackage Twig
*/
-class Piwik_Twig
+class Twig
{
/**
* @var Twig_Environment
@@ -37,9 +49,9 @@ class Piwik_Twig
// Create new Twig Environment and set cache dir
$this->twig = new Twig_Environment($chainLoader,
array(
- 'debug' => true, // to use {{ dump(var) }} in twig templates
+ 'debug' => true, // to use {{ dump(var) }} in twig templates
'strict_variables' => true, // throw an exception if variables are invalid
- 'cache' => PIWIK_USER_PATH . '/tmp/templates_c',
+ 'cache' => PIWIK_USER_PATH . '/tmp/templates_c',
)
);
$this->twig->addExtension(new Twig_Extension_Debug());
@@ -50,7 +62,7 @@ class Piwik_Twig
$this->addFilter_sumTime();
$this->addFilter_money();
$this->addFilter_truncate();
- $this->twig->addFilter( new Twig_SimpleFilter('implode', 'implode'));
+ $this->twig->addFilter(new Twig_SimpleFilter('implode', 'implode'));
$this->addFunction_includeAssets();
$this->addFunction_linkTo();
@@ -69,9 +81,9 @@ class Piwik_Twig
$assetType = strtolower($params['type']);
switch ($assetType) {
case 'css':
- return Piwik_AssetManager::getCssAssets();
+ return AssetManager::getCssAssets();
case 'js':
- return Piwik_AssetManager::getJsAssets();
+ return AssetManager::getJsAssets();
default:
throw new Exception("The twig function includeAssets 'type' parameter needs to be either 'css' or 'js'.");
}
@@ -125,7 +137,7 @@ class Piwik_Twig
protected function addFunction_linkTo()
{
$urlFunction = new Twig_SimpleFunction('linkTo', function ($params) {
- return 'index.php' . Piwik_Url::getCurrentQueryStringWithParametersModified($params);
+ return 'index.php' . Url::getCurrentQueryStringWithParametersModified($params);
});
$this->twig->addFunction($urlFunction);
}
@@ -136,8 +148,8 @@ class Piwik_Twig
private function getDefaultThemeLoader()
{
$themeLoader = new Twig_Loader_Filesystem(array(
- sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, \Piwik\PluginsManager::DEFAULT_THEME)
- ));
+ sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, \Piwik\PluginsManager::DEFAULT_THEME)
+ ));
return $themeLoader;
}
@@ -185,7 +197,7 @@ class Piwik_Twig
{
$urlRewriteFilter = new Twig_SimpleFilter('urlRewriteWithParameters', function ($parameters) {
$parameters['updated'] = null;
- $url = Piwik_Url::getCurrentQueryStringWithParametersModified($parameters);
+ $url = Url::getCurrentQueryStringWithParametersModified($parameters);
return $url;
});
$this->twig->addFilter($urlRewriteFilter);
@@ -214,7 +226,7 @@ class Piwik_Twig
private function addPluginNamespaces(Twig_Loader_Filesystem $loader)
{
$plugins = \Piwik\PluginsManager::getInstance()->getLoadedPluginsName();
- foreach($plugins as $name) {
+ foreach ($plugins as $name) {
$name = Common::unprefixClass($name);
$path = sprintf("%s/plugins/%s/templates/", PIWIK_INCLUDE_PATH, $name);
if (is_dir($path)) {
diff --git a/core/Unzip.php b/core/Unzip.php
index ed915b27f7..003b37a9e0 100644
--- a/core/Unzip.php
+++ b/core/Unzip.php
@@ -9,12 +9,20 @@
* @package Piwik
*/
+namespace Piwik;
+
+use Piwik_Unzip_Gzip;
+use Piwik_Unzip_Interface;
+use Piwik_Unzip_PclZip;
+use Piwik_Unzip_Tar;
+use Piwik_Unzip_ZipArchive;
+
/**
* Unzip wrapper around ZipArchive and PclZip
*
* @package Piwik
*/
-class Piwik_Unzip
+class Unzip
{
/**
* Factory method to create an unarchiver
diff --git a/core/Unzip/Gzip.php b/core/Unzip/Gzip.php
index b7d7c14a35..86d7bace14 100755
--- a/core/Unzip/Gzip.php
+++ b/core/Unzip/Gzip.php
@@ -13,7 +13,7 @@
* Unzip implementation for .gz files.
*
* @package Piwik
- * @subpackage Piwik_Unzip
+ * @subpackage Unzip
*/
class Piwik_Unzip_Gzip implements Piwik_Unzip_Interface
{
diff --git a/core/Unzip/Interface.php b/core/Unzip/Interface.php
index 5c9bccd82d..bd20ddec0b 100644
--- a/core/Unzip/Interface.php
+++ b/core/Unzip/Interface.php
@@ -13,7 +13,7 @@
* Unzip interface
*
* @package Piwik
- * @subpackage Piwik_Unzip
+ * @subpackage Unzip
*/
interface Piwik_Unzip_Interface
{
diff --git a/core/Unzip/PclZip.php b/core/Unzip/PclZip.php
index d6351cdca9..043f77925c 100644
--- a/core/Unzip/PclZip.php
+++ b/core/Unzip/PclZip.php
@@ -18,7 +18,7 @@ require_once PIWIK_INCLUDE_PATH . '/libs/PclZip/pclzip.lib.php';
* Unzip wrapper around PclZip
*
* @package Piwik
- * @subpackage Piwik_Unzip
+ * @subpackage Unzip
*/
class Piwik_Unzip_PclZip implements Piwik_Unzip_Interface
{
diff --git a/core/Unzip/Tar.php b/core/Unzip/Tar.php
index ad7aebf6b9..e243cbeffb 100755
--- a/core/Unzip/Tar.php
+++ b/core/Unzip/Tar.php
@@ -18,7 +18,7 @@ require_once PIWIK_INCLUDE_PATH . '/libs/Archive_Tar/Tar.php';
* Unzip implementation for Archive_Tar PEAR lib.
*
* @package Piwik
- * @subpackage Piwik_Unzip
+ * @subpackage Unzip
*/
class Piwik_Unzip_Tar implements Piwik_Unzip_Interface
{
diff --git a/core/Unzip/ZipArchive.php b/core/Unzip/ZipArchive.php
index c542f5f259..fdb1aa8cfd 100644
--- a/core/Unzip/ZipArchive.php
+++ b/core/Unzip/ZipArchive.php
@@ -13,7 +13,7 @@
* Unzip wrapper around ZipArchive
*
* @package Piwik
- * @subpackage Piwik_Unzip
+ * @subpackage Unzip
*/
class Piwik_Unzip_ZipArchive implements Piwik_Unzip_Interface
{
diff --git a/core/UpdateCheck.php b/core/UpdateCheck.php
index 85d1716f29..2c30124676 100644
--- a/core/UpdateCheck.php
+++ b/core/UpdateCheck.php
@@ -8,15 +8,22 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Common;
+use Piwik\Http;
+use Piwik_SitesManager_API;
+use Piwik\Url;
+use Piwik\Version;
/**
* Class to check if a newer version of Piwik is available
*
* @package Piwik
*/
-class Piwik_UpdateCheck
+class UpdateCheck
{
const CHECK_INTERVAL = 28800; // every 8 hours
const UI_CLICK_CHECK_INTERVAL = 10; // every 10s when user clicks UI link
@@ -28,7 +35,7 @@ class Piwik_UpdateCheck
* Check for a newer version
*
* @param bool $force Force check
- * @param int $interval Interval used for update checks
+ * @param int $interval Interval used for update checks
*/
public static function check($force = false, $interval = null)
{
@@ -44,9 +51,9 @@ class Piwik_UpdateCheck
// set the time checked first, so that parallel Piwik requests don't all trigger the http requests
Piwik_SetOption(self::LAST_TIME_CHECKED, time(), $autoLoad = 1);
$parameters = array(
- 'piwik_version' => Piwik_Version::VERSION,
+ 'piwik_version' => Version::VERSION,
'php_version' => PHP_VERSION,
- 'url' => Piwik_Url::getCurrentUrlWithoutQueryString(),
+ 'url' => Url::getCurrentUrlWithoutQueryString(),
'trigger' => Common::getRequestVar('module', '', 'string'),
'timezone' => Piwik_SitesManager_API::getInstance()->getDefaultTimezone(),
);
@@ -61,7 +68,7 @@ class Piwik_UpdateCheck
}
try {
- $latestVersion = Piwik_Http::sendHttpRequest($url, $timeout);
+ $latestVersion = Http::sendHttpRequest($url, $timeout);
if (!preg_match('~^[0-9][0-9a-zA-Z_.-]*$~D', $latestVersion)) {
$latestVersion = '';
}
@@ -83,7 +90,7 @@ class Piwik_UpdateCheck
{
$latestVersion = Piwik_GetOption(self::LATEST_VERSION);
if (!empty($latestVersion)
- && version_compare(Piwik_Version::VERSION, $latestVersion) == -1
+ && version_compare(Version::VERSION, $latestVersion) == -1
) {
return $latestVersion;
}
diff --git a/core/Updater.php b/core/Updater.php
index bc62eca147..a0000eeb55 100644
--- a/core/Updater.php
+++ b/core/Updater.php
@@ -9,19 +9,15 @@
* @package Piwik
*/
use Piwik\Common;
-
-/**
- * @see core/Option.php
- */
-require_once PIWIK_INCLUDE_PATH . '/core/Option.php';
+use Piwik\Version;
/**
* Load and execute all relevant, incremental update scripts for Piwik core and plugins, and bump the component version numbers for completed updates.
*
* @package Piwik
- * @subpackage Piwik_Updater
+ * @subpackage Updater
*/
-class Piwik_Updater
+class Updater
{
const INDEX_CURRENT_VERSION = 0;
const INDEX_NEW_VERSION = 1;
@@ -130,7 +126,7 @@ class Piwik_Updater
$this->hasMajorDbUpdate = $this->hasMajorDbUpdate || call_user_func(array($className, 'isMajorUpdate'));
}
}
- // unfortunately had to extract this query from the Piwik_Option class
+ // unfortunately had to extract this query from the Option class
$queries[] = 'UPDATE `' . Common::prefixTable('option') . '`
SET option_value = \'' . $fileVersion . '\'
WHERE option_name = \'' . $this->getNameInOptionTable($componentName) . '\';';
@@ -257,7 +253,7 @@ class Piwik_Updater
if ($currentVersion === false) {
if ($name === 'core') {
// This should not happen
- $currentVersion = Piwik_Version::VERSION;
+ $currentVersion = Version::VERSION;
} else {
$currentVersion = '0.0.1';
}
@@ -288,7 +284,7 @@ class Piwik_Updater
{
foreach ($sqlarray as $update => $ignoreError) {
try {
- Piwik_Exec($update);
+ Db::exec($update);
} catch (Exception $e) {
if (($ignoreError === false)
|| !Zend_Registry::get('db')->isErrNo($e, $ignoreError)
@@ -305,7 +301,7 @@ class Piwik_Updater
* Exception thrown by updater if a non-recoverable error occurs
*
* @package Piwik
- * @subpackage Piwik_Updater
+ * @subpackage Updater
*/
class Piwik_Updater_UpdateErrorException extends Exception
{
diff --git a/core/Updates.php b/core/Updates.php
index e4387d0634..9f5e7ab1ee 100644
--- a/core/Updates.php
+++ b/core/Updates.php
@@ -8,6 +8,8 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Config;
/**
@@ -16,7 +18,7 @@ use Piwik\Config;
* @example core/Updates/0.4.2.php
* @package Piwik
*/
-abstract class Piwik_Updates
+abstract class Updates
{
/**
* Return SQL to be executed in this update
@@ -87,7 +89,6 @@ abstract class Piwik_Updates
$config->forceSave();
}
-
public static function deletePluginFromConfigFile($pluginToDelete)
{
$config = Config::getInstance();
@@ -108,6 +109,4 @@ abstract class Piwik_Updates
$config->forceSave();
}
}
-
-
}
diff --git a/core/Updates/0.2.10.php b/core/Updates/0.2.10.php
index a85bcb88a8..da9a669abd 100644
--- a/core/Updates/0.2.10.php
+++ b/core/Updates/0.2.10.php
@@ -10,11 +10,13 @@
*/
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_10 extends Piwik_Updates
+class Piwik_Updates_0_2_10 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.12.php b/core/Updates/0.2.12.php
index 378ad1c724..54b4dd41f8 100644
--- a/core/Updates/0.2.12.php
+++ b/core/Updates/0.2.12.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_12 extends Piwik_Updates
+class Piwik_Updates_0_2_12 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.13.php b/core/Updates/0.2.13.php
index 15c510bb25..0cf92efc3d 100644
--- a/core/Updates/0.2.13.php
+++ b/core/Updates/0.2.13.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_13 extends Piwik_Updates
+class Piwik_Updates_0_2_13 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.24.php b/core/Updates/0.2.24.php
index e6515309b1..f98c46fba6 100644
--- a/core/Updates/0.2.24.php
+++ b/core/Updates/0.2.24.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_24 extends Piwik_Updates
+class Piwik_Updates_0_2_24 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.27.php b/core/Updates/0.2.27.php
index e88ab68ffb..a53430d182 100644
--- a/core/Updates/0.2.27.php
+++ b/core/Updates/0.2.27.php
@@ -10,11 +10,13 @@
*/
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_27 extends Piwik_Updates
+class Piwik_Updates_0_2_27 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.32.php b/core/Updates/0.2.32.php
index b13a40ad18..d80b2826a9 100644
--- a/core/Updates/0.2.32.php
+++ b/core/Updates/0.2.32.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_32 extends Piwik_Updates
+class Piwik_Updates_0_2_32 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.33.php b/core/Updates/0.2.33.php
index 50d6a2eea3..b871521187 100644
--- a/core/Updates/0.2.33.php
+++ b/core/Updates/0.2.33.php
@@ -10,11 +10,13 @@
*/
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_33 extends Piwik_Updates
+class Piwik_Updates_0_2_33 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.34.php b/core/Updates/0.2.34.php
index bfefb5b501..b49b8cd28c 100644
--- a/core/Updates/0.2.34.php
+++ b/core/Updates/0.2.34.php
@@ -9,11 +9,12 @@
* @package Updates
*/
use Piwik\Piwik;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_34 extends Piwik_Updates
+class Piwik_Updates_0_2_34 extends Updates
{
static function update($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.35.php b/core/Updates/0.2.35.php
index c5377fb43f..23800f8404 100644
--- a/core/Updates/0.2.35.php
+++ b/core/Updates/0.2.35.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_35 extends Piwik_Updates
+class Piwik_Updates_0_2_35 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.2.37.php b/core/Updates/0.2.37.php
index a415ebbe58..be90976039 100644
--- a/core/Updates/0.2.37.php
+++ b/core/Updates/0.2.37.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_2_37 extends Piwik_Updates
+class Piwik_Updates_0_2_37 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.4.1.php b/core/Updates/0.4.1.php
index 1e06dd7fb3..4fa7ee8035 100644
--- a/core/Updates/0.4.1.php
+++ b/core/Updates/0.4.1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_4_1 extends Piwik_Updates
+class Piwik_Updates_0_4_1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.4.2.php b/core/Updates/0.4.2.php
index f03b443163..a52b4a181a 100644
--- a/core/Updates/0.4.2.php
+++ b/core/Updates/0.4.2.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_4_2 extends Piwik_Updates
+class Piwik_Updates_0_4_2 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.4.4.php b/core/Updates/0.4.4.php
index b63731c5e7..5c783c9ac9 100644
--- a/core/Updates/0.4.4.php
+++ b/core/Updates/0.4.4.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_4_4 extends Piwik_Updates
+class Piwik_Updates_0_4_4 extends Updates
{
static function update()
{
diff --git a/core/Updates/0.4.php b/core/Updates/0.4.php
index 9e9e1ee0b0..048de15e25 100644
--- a/core/Updates/0.4.php
+++ b/core/Updates/0.4.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_4 extends Piwik_Updates
+class Piwik_Updates_0_4 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.5.4.php b/core/Updates/0.5.4.php
index 2a48de630f..a0ce6d61b5 100644
--- a/core/Updates/0.5.4.php
+++ b/core/Updates/0.5.4.php
@@ -10,11 +10,13 @@
*/
use Piwik\Config;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_5_4 extends Piwik_Updates
+class Piwik_Updates_0_5_4 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.5.5.php b/core/Updates/0.5.5.php
index 8ad736b81d..cf1c287160 100644
--- a/core/Updates/0.5.5.php
+++ b/core/Updates/0.5.5.php
@@ -10,11 +10,13 @@
*/
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_5_5 extends Piwik_Updates
+class Piwik_Updates_0_5_5 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.5.php b/core/Updates/0.5.php
index f38c38aa46..01f52ba549 100644
--- a/core/Updates/0.5.php
+++ b/core/Updates/0.5.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_5 extends Piwik_Updates
+class Piwik_Updates_0_5 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.6-rc1.php b/core/Updates/0.6-rc1.php
index f383115ae1..b2c27728f7 100644
--- a/core/Updates/0.6-rc1.php
+++ b/core/Updates/0.6-rc1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_6_rc1 extends Piwik_Updates
+class Piwik_Updates_0_6_rc1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.6.2.php b/core/Updates/0.6.2.php
index a3625a479c..38847b6b8b 100644
--- a/core/Updates/0.6.2.php
+++ b/core/Updates/0.6.2.php
@@ -9,11 +9,12 @@
* @package Updates
*/
use Piwik\Piwik;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_6_2 extends Piwik_Updates
+class Piwik_Updates_0_6_2 extends Updates
{
static function update()
{
diff --git a/core/Updates/0.6.3.php b/core/Updates/0.6.3.php
index b20fd75627..8353628267 100644
--- a/core/Updates/0.6.3.php
+++ b/core/Updates/0.6.3.php
@@ -10,11 +10,13 @@
*/
use Piwik\Config;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_6_3 extends Piwik_Updates
+class Piwik_Updates_0_6_3 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.7.php b/core/Updates/0.7.php
index 6e00fc9f7f..ed132626c0 100644
--- a/core/Updates/0.7.php
+++ b/core/Updates/0.7.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_7 extends Piwik_Updates
+class Piwik_Updates_0_7 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/0.9.1.php b/core/Updates/0.9.1.php
index 4bc4aab764..526c365e76 100644
--- a/core/Updates/0.9.1.php
+++ b/core/Updates/0.9.1.php
@@ -10,11 +10,13 @@
*/
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_0_9_1 extends Piwik_Updates
+class Piwik_Updates_0_9_1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.1.php b/core/Updates/1.1.php
index de74d8c713..ee84f4b01c 100644
--- a/core/Updates/1.1.php
+++ b/core/Updates/1.1.php
@@ -10,11 +10,12 @@
*/
use Piwik\Config;
use Piwik\Piwik;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_1 extends Piwik_Updates
+class Piwik_Updates_1_1 extends Updates
{
static function update($schema = 'Myisam')
{
diff --git a/core/Updates/1.10-b4.php b/core/Updates/1.10-b4.php
index 59ae4cda68..ecf98b9d7c 100755
--- a/core/Updates/1.10-b4.php
+++ b/core/Updates/1.10-b4.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_10_b4 extends Piwik_Updates
+class Piwik_Updates_1_10_b4 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.10.1.php b/core/Updates/1.10.1.php
index 38a2b53e7f..f2649393b8 100755
--- a/core/Updates/1.10.1.php
+++ b/core/Updates/1.10.1.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_10_1 extends Piwik_Updates
+class Piwik_Updates_1_10_1 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.10.2-b1.php b/core/Updates/1.10.2-b1.php
index e2d9f2130f..70a5b906cf 100755
--- a/core/Updates/1.10.2-b1.php
+++ b/core/Updates/1.10.2-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_10_2_b1 extends Piwik_Updates
+class Piwik_Updates_1_10_2_b1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.10.2-b2.php b/core/Updates/1.10.2-b2.php
index 8e57c75297..40b048e27c 100644
--- a/core/Updates/1.10.2-b2.php
+++ b/core/Updates/1.10.2-b2.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_10_2_b2 extends Piwik_Updates
+class Piwik_Updates_1_10_2_b2 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.11-b1.php b/core/Updates/1.11-b1.php
index 3f7a31904e..82980a3c08 100644
--- a/core/Updates/1.11-b1.php
+++ b/core/Updates/1.11-b1.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_11_b1 extends Piwik_Updates
+class Piwik_Updates_1_11_b1 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.12-b1.php b/core/Updates/1.12-b1.php
index 75c69e3839..3a9b6dd742 100644
--- a/core/Updates/1.12-b1.php
+++ b/core/Updates/1.12-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_12_b1 extends Piwik_Updates
+class Piwik_Updates_1_12_b1 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.12-b15.php b/core/Updates/1.12-b15.php
index ea66360caf..916af1f4c7 100644
--- a/core/Updates/1.12-b15.php
+++ b/core/Updates/1.12-b15.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_12_b15 extends Piwik_Updates
+class Piwik_Updates_1_12_b15 extends Updates
{
static function update()
{
diff --git a/core/Updates/1.12-b16.php b/core/Updates/1.12-b16.php
index b3956fc6ce..44819663ba 100644
--- a/core/Updates/1.12-b16.php
+++ b/core/Updates/1.12-b16.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_12_b16 extends Piwik_Updates
+class Piwik_Updates_1_12_b16 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.2-rc1.php b/core/Updates/1.2-rc1.php
index 36c9e42899..409e7f7219 100644
--- a/core/Updates/1.2-rc1.php
+++ b/core/Updates/1.2-rc1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_2_rc1 extends Piwik_Updates
+class Piwik_Updates_1_2_rc1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.2-rc2.php b/core/Updates/1.2-rc2.php
index 0ab9c30bdc..681ee893fe 100644
--- a/core/Updates/1.2-rc2.php
+++ b/core/Updates/1.2-rc2.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_2_rc2 extends Piwik_Updates
+class Piwik_Updates_1_2_rc2 extends Updates
{
static function update()
{
diff --git a/core/Updates/1.2.3.php b/core/Updates/1.2.3.php
index f479dff100..56383d84ea 100644
--- a/core/Updates/1.2.3.php
+++ b/core/Updates/1.2.3.php
@@ -10,11 +10,13 @@
*/
use Piwik\Config;
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_2_3 extends Piwik_Updates
+class Piwik_Updates_1_2_3 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.2.5-rc1.php b/core/Updates/1.2.5-rc1.php
index 14d4e29a60..a13523927d 100644
--- a/core/Updates/1.2.5-rc1.php
+++ b/core/Updates/1.2.5-rc1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_2_5_rc1 extends Piwik_Updates
+class Piwik_Updates_1_2_5_rc1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.2.5-rc7.php b/core/Updates/1.2.5-rc7.php
index dc613a7f83..badfab6eaa 100644
--- a/core/Updates/1.2.5-rc7.php
+++ b/core/Updates/1.2.5-rc7.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_2_5_rc7 extends Piwik_Updates
+class Piwik_Updates_1_2_5_rc7 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.4-rc1.php b/core/Updates/1.4-rc1.php
index 6a1029a455..fcc404b06d 100644
--- a/core/Updates/1.4-rc1.php
+++ b/core/Updates/1.4-rc1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_4_rc1 extends Piwik_Updates
+class Piwik_Updates_1_4_rc1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.4-rc2.php b/core/Updates/1.4-rc2.php
index c1b52dd079..1655a9f1b7 100644
--- a/core/Updates/1.4-rc2.php
+++ b/core/Updates/1.4-rc2.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_4_rc2 extends Piwik_Updates
+class Piwik_Updates_1_4_rc2 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.5-b1.php b/core/Updates/1.5-b1.php
index 71670a7c6e..f3c2cf1a9b 100644
--- a/core/Updates/1.5-b1.php
+++ b/core/Updates/1.5-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_5_b1 extends Piwik_Updates
+class Piwik_Updates_1_5_b1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.5-b2.php b/core/Updates/1.5-b2.php
index 26ca5fdd38..7a992f6c18 100644
--- a/core/Updates/1.5-b2.php
+++ b/core/Updates/1.5-b2.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_5_b2 extends Piwik_Updates
+class Piwik_Updates_1_5_b2 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.5-b3.php b/core/Updates/1.5-b3.php
index 48af21fc13..4df144fe5d 100644
--- a/core/Updates/1.5-b3.php
+++ b/core/Updates/1.5-b3.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_5_b3 extends Piwik_Updates
+class Piwik_Updates_1_5_b3 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.5-b4.php b/core/Updates/1.5-b4.php
index 5f0c46dfec..b4c0b40f47 100644
--- a/core/Updates/1.5-b4.php
+++ b/core/Updates/1.5-b4.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_5_b4 extends Piwik_Updates
+class Piwik_Updates_1_5_b4 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.5-b5.php b/core/Updates/1.5-b5.php
index bea0539c39..d6e2cb9c7c 100644
--- a/core/Updates/1.5-b5.php
+++ b/core/Updates/1.5-b5.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_5_b5 extends Piwik_Updates
+class Piwik_Updates_1_5_b5 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.5-rc6.php b/core/Updates/1.5-rc6.php
index 1015ef63db..0de1b76d18 100644
--- a/core/Updates/1.5-rc6.php
+++ b/core/Updates/1.5-rc6.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_5_rc6 extends Piwik_Updates
+class Piwik_Updates_1_5_rc6 extends Updates
{
static function update()
{
diff --git a/core/Updates/1.6-b1.php b/core/Updates/1.6-b1.php
index 992e5b01ee..ca578ead28 100644
--- a/core/Updates/1.6-b1.php
+++ b/core/Updates/1.6-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_6_b1 extends Piwik_Updates
+class Piwik_Updates_1_6_b1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.6-rc1.php b/core/Updates/1.6-rc1.php
index b838a03727..2abd9983a9 100644
--- a/core/Updates/1.6-rc1.php
+++ b/core/Updates/1.6-rc1.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_6_rc1 extends Piwik_Updates
+class Piwik_Updates_1_6_rc1 extends Updates
{
static function update()
{
diff --git a/core/Updates/1.7-b1.php b/core/Updates/1.7-b1.php
index 04fb74269c..015960cb8b 100644
--- a/core/Updates/1.7-b1.php
+++ b/core/Updates/1.7-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_7_b1 extends Piwik_Updates
+class Piwik_Updates_1_7_b1 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.7.2-rc5.php b/core/Updates/1.7.2-rc5.php
index 42af42e7c8..72bc715645 100644
--- a/core/Updates/1.7.2-rc5.php
+++ b/core/Updates/1.7.2-rc5.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_7_2_rc5 extends Piwik_Updates
+class Piwik_Updates_1_7_2_rc5 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.7.2-rc7.php b/core/Updates/1.7.2-rc7.php
index cb1d96851c..4649c89a21 100755
--- a/core/Updates/1.7.2-rc7.php
+++ b/core/Updates/1.7.2-rc7.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_7_2_rc7 extends Piwik_Updates
+class Piwik_Updates_1_7_2_rc7 extends Updates
{
static function getSql($schema = 'Myisam')
{
@@ -26,14 +28,14 @@ class Piwik_Updates_1_7_2_rc7 extends Piwik_Updates
static function update()
{
try {
- $dashboards = Piwik_FetchAll('SELECT * FROM `' . Common::prefixTable('user_dashboard') . '`');
+ $dashboards = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('user_dashboard') . '`');
foreach ($dashboards AS $dashboard) {
$idDashboard = $dashboard['iddashboard'];
$login = $dashboard['login'];
$layout = $dashboard['layout'];
$layout = html_entity_decode($layout);
$layout = str_replace("\\\"", "\"", $layout);
- Piwik_Query('UPDATE `' . Common::prefixTable('user_dashboard') . '` SET layout = ? WHERE iddashboard = ? AND login = ?', array($layout, $idDashboard, $login));
+ Db::query('UPDATE `' . Common::prefixTable('user_dashboard') . '` SET layout = ? WHERE iddashboard = ? AND login = ?', array($layout, $idDashboard, $login));
}
Piwik_Updater::updateDatabase(__FILE__, self::getSql());
} catch (Exception $e) {
diff --git a/core/Updates/1.8.3-b1.php b/core/Updates/1.8.3-b1.php
index 99084a2814..a991ac1f2d 100644
--- a/core/Updates/1.8.3-b1.php
+++ b/core/Updates/1.8.3-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_8_3_b1 extends Piwik_Updates
+class Piwik_Updates_1_8_3_b1 extends Updates
{
static function getSql($schema = 'Myisam')
@@ -55,7 +57,7 @@ class Piwik_Updates_1_8_3_b1 extends Piwik_Updates
// - migrate previous reports, if any, from Common::prefixTable('pdf') to Common::prefixTable('report')
// - delete Common::prefixTable('pdf')
- $reports = Piwik_FetchAll('SELECT * FROM `' . Common::prefixTable('pdf') . '`');
+ $reports = Db::fetchAll('SELECT * FROM `' . Common::prefixTable('pdf') . '`');
foreach ($reports AS $report) {
$idreport = $report['idreport'];
@@ -81,7 +83,7 @@ class Piwik_Updates_1_8_3_b1 extends Piwik_Updates
$parameters[Piwik_PDFReports::EMAIL_ME_PARAMETER] = is_null($email_me) ? Piwik_PDFReports::EMAIL_ME_PARAMETER_DEFAULT_VALUE : (bool)$email_me;
$parameters[Piwik_PDFReports::DISPLAY_FORMAT_PARAMETER] = $display_format;
- Piwik_Query(
+ Db::query(
'INSERT INTO `' . Common::prefixTable('report') . '` SET
idreport = ?, idsite = ?, login = ?, description = ?, period = ?,
type = ?, format = ?, reports = ?, parameters = ?, ts_created = ?,
@@ -103,7 +105,7 @@ class Piwik_Updates_1_8_3_b1 extends Piwik_Updates
);
}
- Piwik_Query('DROP TABLE `' . Common::prefixTable('pdf') . '`');
+ Db::query('DROP TABLE `' . Common::prefixTable('pdf') . '`');
} catch (Exception $e) {
}
diff --git a/core/Updates/1.8.4-b1.php b/core/Updates/1.8.4-b1.php
index f230d13da6..8a4d066165 100644
--- a/core/Updates/1.8.4-b1.php
+++ b/core/Updates/1.8.4-b1.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_8_4_b1 extends Piwik_Updates
+class Piwik_Updates_1_8_4_b1 extends Updates
{
static function isMajorUpdate()
diff --git a/core/Updates/1.9-b16.php b/core/Updates/1.9-b16.php
index 380a75a808..7b362e0a5c 100755
--- a/core/Updates/1.9-b16.php
+++ b/core/Updates/1.9-b16.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_b16 extends Piwik_Updates
+class Piwik_Updates_1_9_b16 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.9-b19.php b/core/Updates/1.9-b19.php
index 03f142de0d..80e62a39f1 100755
--- a/core/Updates/1.9-b19.php
+++ b/core/Updates/1.9-b19.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_b19 extends Piwik_Updates
+class Piwik_Updates_1_9_b19 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.9-b9.php b/core/Updates/1.9-b9.php
index 737454231e..d5fd876b1f 100755
--- a/core/Updates/1.9-b9.php
+++ b/core/Updates/1.9-b9.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_b9 extends Piwik_Updates
+class Piwik_Updates_1_9_b9 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.9.1-b2.php b/core/Updates/1.9.1-b2.php
index 81347c0844..cff70446f8 100644
--- a/core/Updates/1.9.1-b2.php
+++ b/core/Updates/1.9.1-b2.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_1_b2 extends Piwik_Updates
+class Piwik_Updates_1_9_1_b2 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Updates/1.9.3-b10.php b/core/Updates/1.9.3-b10.php
index 97e2cd5d5e..c7dc2bb1f7 100755
--- a/core/Updates/1.9.3-b10.php
+++ b/core/Updates/1.9.3-b10.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_3_b10 extends Piwik_Updates
+class Piwik_Updates_1_9_3_b10 extends Updates
{
static function isMajorUpdate()
{
diff --git a/core/Updates/1.9.3-b3.php b/core/Updates/1.9.3-b3.php
index 60257c6884..3b317e96ba 100644
--- a/core/Updates/1.9.3-b3.php
+++ b/core/Updates/1.9.3-b3.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package Updates
*/
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_3_b3 extends Piwik_Updates
+class Piwik_Updates_1_9_3_b3 extends Updates
{
static function update()
{
diff --git a/core/Updates/1.9.3-b8.php b/core/Updates/1.9.3-b8.php
index 52938bd166..c961a189a6 100755
--- a/core/Updates/1.9.3-b8.php
+++ b/core/Updates/1.9.3-b8.php
@@ -9,11 +9,13 @@
* @package Updates
*/
use Piwik\Common;
+use Piwik\Piwik_Updater;
+use Piwik\Updates;
/**
* @package Updates
*/
-class Piwik_Updates_1_9_3_b8 extends Piwik_Updates
+class Piwik_Updates_1_9_3_b8 extends Updates
{
static function getSql($schema = 'Myisam')
{
diff --git a/core/Url.php b/core/Url.php
index 7ae67c1c94..80923d972c 100644
--- a/core/Url.php
+++ b/core/Url.php
@@ -8,9 +8,13 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\IP;
/**
* Class to retrieve absolute URL or URI components of the current URL,
@@ -18,7 +22,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_Url
+class Url
{
/**
* List of hosts that are never checked for validity.
@@ -44,7 +48,7 @@ class Piwik_Url
* will return "http://example.org/dir1/dir2/index.php"
*
* @param bool $checkTrustedHost Whether to do trusted host check. Should ALWAYS be true,
- * except in Piwik_Controller.
+ * except in Controller.
* @return string
*/
static public function getCurrentUrlWithoutQueryString($checkTrustedHost = true)
@@ -245,7 +249,7 @@ class Piwik_Url
* Get host
*
* @param bool $checkIfTrusted Whether to do trusted host check. Should ALWAYS be true,
- * except in Piwik_Controller.
+ * except in Controller.
* @return string|false
*/
static public function getHost($checkIfTrusted = true)
@@ -273,7 +277,7 @@ class Piwik_Url
*
* @param string $default Default value to return if host unknown
* @param bool $checkTrustedHost Whether to do trusted host check. Should ALWAYS be true,
- * except in Piwik_Controller.
+ * except in Controller.
* @return string
*/
static public function getCurrentHost($default = 'unknown', $checkTrustedHost = true)
@@ -286,7 +290,7 @@ class Piwik_Url
$host = self::getHost($checkTrustedHost);
$default = Common::sanitizeInputValue($host ? $host : $default);
- return Piwik_IP::getNonProxyIpFromHeader($default, $hostHeaders);
+ return IP::getNonProxyIpFromHeader($default, $hostHeaders);
}
/**
@@ -435,12 +439,12 @@ class Piwik_Url
}
// drop port numbers from hostnames and IP addresses
- $hosts = array_map(array('Piwik_IP', 'sanitizeIp'), $hosts);
+ $hosts = array_map(array('Piwik\IP', 'sanitizeIp'), $hosts);
$disableHostCheck = Config::getInstance()->General['enable_trusted_host_check'] == 0;
// compare scheme and host
$parsedUrl = @parse_url($url);
- $host = Piwik_IP::sanitizeIp(@$parsedUrl['host']);
+ $host = IP::sanitizeIp(@$parsedUrl['host']);
return !empty($host)
&& ($disableHostCheck || in_array($host, $hosts))
&& !empty($parsedUrl['scheme'])
diff --git a/core/Version.php b/core/Version.php
index 83d05be495..a34c106394 100644
--- a/core/Version.php
+++ b/core/Version.php
@@ -9,12 +9,14 @@
* @package Piwik
*/
+namespace Piwik;
+
/**
* Piwik version information.
*
* @package Piwik
*/
-final class Piwik_Version
+final class Version
{
/**
* Current Piwik version
diff --git a/core/View.php b/core/View.php
index 6d01d36329..7b5ea6d073 100644
--- a/core/View.php
+++ b/core/View.php
@@ -8,9 +8,23 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\AssetManager;
+use Piwik\Version;
+use Piwik\Url;
+use Piwik\UpdateCheck;
+use Piwik\Twig;
+use Piwik\QuickForm2;
+use Piwik_SitesManager_API;
+use Piwik_UsersManager_API;
+use Piwik_View_Interface;
+use Twig_Environment;
+use Zend_Registry;
/**
* Transition for pre-Piwik 0.4.4
@@ -24,7 +38,7 @@ if (!defined('PIWIK_USER_PATH')) {
*
* @package Piwik
*/
-class Piwik_View implements Piwik_View_Interface
+class View implements Piwik_View_Interface
{
private $template = '';
@@ -40,15 +54,15 @@ class Piwik_View implements Piwik_View_Interface
public function __construct($templateFile)
{
$templateExt = '.twig';
- if(substr($templateFile, -strlen($templateExt)) !== $templateExt) {
+ if (substr($templateFile, -strlen($templateExt)) !== $templateExt) {
$templateFile .= $templateExt;
}
$this->template = $templateFile;
$this->initializeTwig();
- $this->piwik_version = Piwik_Version::VERSION;
- $this->piwikUrl = Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName());
+ $this->piwik_version = Version::VERSION;
+ $this->piwikUrl = Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName());
}
/**
@@ -77,7 +91,7 @@ class Piwik_View implements Piwik_View_Interface
public function initializeTwig()
{
- $piwikTwig = new Piwik_Twig();
+ $piwikTwig = new Twig();
$this->twig = $piwikTwig->getTwigEnvironment();
}
@@ -99,11 +113,11 @@ class Piwik_View implements Piwik_View_Interface
$sites = Piwik_SitesManager_API::getInstance()->getSitesWithAtLeastViewAccess($count);
usort($sites, create_function('$site1, $site2', 'return strcasecmp($site1["name"], $site2["name"]);'));
$this->sites = $sites;
- $this->url = Common::sanitizeInputValue(Piwik_Url::getCurrentUrl());
+ $this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
$this->token_auth = Piwik::getCurrentUserTokenAuth();
$this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
$this->userIsSuperUser = Piwik::isUserIsSuperUser();
- $this->latest_version_available = Piwik_UpdateCheck::isNewestVersionAvailable();
+ $this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
$this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
$this->isWidget = Common::getRequestVar('widget', 0, 'int');
if (Config::getInstance()->General['autocomplete_min_sites'] <= count($sites)) {
@@ -116,7 +130,6 @@ class Piwik_View implements Piwik_View_Interface
$user = Piwik_UsersManager_API::getInstance()->getUser($userLogin);
$this->userAlias = $user['alias'];
-
} catch (Exception $e) {
// can fail, for example at installation (no plugin loaded yet)
}
@@ -146,7 +159,7 @@ class Piwik_View implements Piwik_View_Interface
protected function applyFilter_cacheBuster($output)
{
- $cacheBuster = Piwik_AssetManager::generateAssetsCacheBuster();
+ $cacheBuster = AssetManager::generateAssetsCacheBuster();
$tag = 'cb=' . $cacheBuster;
$pattern = array(
@@ -195,9 +208,9 @@ class Piwik_View implements Piwik_View_Interface
/**
* Add form to view
*
- * @param Piwik_QuickForm2 $form
+ * @param QuickForm2 $form
*/
- public function addForm(Piwik_QuickForm2 $form)
+ public function addForm(QuickForm2 $form)
{
// assign array with form data
@@ -227,7 +240,7 @@ class Piwik_View implements Piwik_View_Interface
*/
static public function clearCompiledTemplates()
{
- $view = new Piwik_View(null);
+ $view = new View(null);
$view->twig->clearTemplateCache();
}
@@ -241,7 +254,7 @@ class Piwik_View implements Piwik_View_Interface
*/
static public function singleReport($title, $reportHtml, $fetch = false)
{
- $view = new Piwik_View('@CoreHome/_singleReport');
+ $view = new View('@CoreHome/_singleReport');
$view->title = $title;
$view->report = $reportHtml;
@@ -256,6 +269,6 @@ class Piwik_View implements Piwik_View_Interface
*/
static public function factory($templateName = null)
{
- throw new Exception("Piwik_View::factory is deprecated. Use 'new Piwik_View(\$templateFile)' instead.");
+ throw new Exception("View::factory is deprecated. Use 'new View(\$templateFile)' instead.");
}
}
diff --git a/core/View/Interface.php b/core/View/Interface.php
index 1998ead861..a1730cebef 100644
--- a/core/View/Interface.php
+++ b/core/View/Interface.php
@@ -10,7 +10,7 @@
*/
/**
- * Rendering interface for Piwik_View and Piwik_Visualization
+ * Rendering interface for View and Piwik_Visualization
*
* @package Piwik
*/
diff --git a/core/View/ReportsByDimension.php b/core/View/ReportsByDimension.php
index 39da988de2..69ac869eb8 100644
--- a/core/View/ReportsByDimension.php
+++ b/core/View/ReportsByDimension.php
@@ -8,6 +8,9 @@
* @category Piwik
* @package SmartyPlugins
*/
+use Piwik\FrontController;
+use Piwik\View;
+use Piwik\Url;
/**
* A facade that makes it easier to use the '_reportsByDimension.twig' template.
@@ -16,7 +19,7 @@
* loads them by AJAX when clicked. The loaded report is displayed to the right
* of the report listing.
*/
-class Piwik_View_ReportsByDimension extends Piwik_View
+class Piwik_View_ReportsByDimension extends View
{
/**
* Constructor.
@@ -47,7 +50,7 @@ class Piwik_View_ReportsByDimension extends Piwik_View
$categories[$category][] = array(
'title' => $title,
'params' => $params,
- 'url' => Piwik_Url::getCurrentQueryStringWithParametersModified($params)
+ 'url' => Url::getCurrentQueryStringWithParametersModified($params)
);
$this->dimensionCategories = $categories;
}
@@ -93,7 +96,7 @@ class Piwik_View_ReportsByDimension extends Piwik_View
$module = $firstReportInfo['params']['module'];
$action = $firstReportInfo['params']['action'];
- $this->firstReport = Piwik_FrontController::getInstance()->fetchDispatch($module, $action);
+ $this->firstReport = FrontController::getInstance()->fetchDispatch($module, $action);
$_GET = $oldGet;
$_POST = $oldPost;
diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php
index decc8a0cd0..d1ec61db90 100644
--- a/core/ViewDataTable.php
+++ b/core/ViewDataTable.php
@@ -8,6 +8,8 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
use Piwik\Config;
use Piwik\Metrics;
use Piwik\Period;
@@ -16,6 +18,7 @@ use Piwik\Piwik;
use Piwik\Common;
use Piwik\Date;
use Piwik\DataTable;
+use Piwik\Url;
use Piwik\Site;
/**
@@ -34,7 +37,7 @@ use Piwik\Site;
* <pre>
* function getNumberOfVisitsPerVisitDuration( $fetch = false)
* {
- * $view = Piwik_ViewDataTable::factory( 'cloud' );
+ * $view = ViewDataTable::factory( 'cloud' );
* $view->init( $this->pluginName, __FUNCTION__, 'VisitorInterest.getNumberOfVisitsPerVisitDuration' );
* $view->setColumnsToDisplay( array('label','nb_visits') );
* $view->disableSort();
@@ -47,9 +50,9 @@ use Piwik\Site;
*
* @see factory() for all the available output (cloud tags, html table, pie chart, vertical bar chart)
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
-abstract class Piwik_ViewDataTable
+abstract class ViewDataTable
{
/**
* Template file that will be loaded for this view.
@@ -73,7 +76,7 @@ abstract class Piwik_ViewDataTable
* @var array
*/
protected $viewProperties = array();
-
+
/**
* If the current dataTable refers to a subDataTable (eg. keywordsBySearchEngineId for id=X) this variable is set to the Id
*
@@ -135,7 +138,7 @@ abstract class Piwik_ViewDataTable
* @var array
*/
protected $documentation = false;
-
+
/**
* Default constructor.
*/
@@ -216,7 +219,7 @@ abstract class Piwik_ViewDataTable
*
* @param string $defaultType Any of these: table, cloud, graphPie, graphVerticalBar, graphEvolution, sparkline, generateDataChart*
* @param string|bool $action
- * @return Piwik_ViewDataTable
+ * @return \Piwik\ViewDataTable
*/
static public function factory($defaultType = null, $action = false)
{
@@ -226,7 +229,7 @@ abstract class Piwik_ViewDataTable
$defaultType = $defaultProperties['default_view_type'];
}
}
-
+
if ($defaultType === null) {
$defaultType = 'table';
}
@@ -266,24 +269,24 @@ abstract class Piwik_ViewDataTable
$result = new Piwik_ViewDataTable_HtmlTable();
break;
}
-
+
if ($action !== false) {
list($plugin, $controllerAction) = explode('.', $action);
-
+
$subtableAction = $controllerAction;
if (isset($defaultProperties['subtable_action'])) {
$subtableAction = $defaultProperties['subtable_action'];
}
-
+
$result->init($plugin, $controllerAction, $action, $subtableAction, $defaultProperties);
}
-
+
return $result;
}
-
+
/**
* Returns the list of view properties that can be overridden by query parameters.
- *
+ *
* @return array
*/
public function getOverridableProperties()
@@ -308,11 +311,11 @@ abstract class Piwik_ViewDataTable
'columns'
);
}
-
+
/**
* Returns the list of view properties that should be sent with the HTML response
* as JSON. These properties can be manipulated via the ViewDataTable UI.
- *
+ *
* @return array
*/
public function getJavaScriptProperties()
@@ -349,7 +352,7 @@ abstract class Piwik_ViewDataTable
* @param string $currentControllerAction eg. 'getKeywords'
* @param string $apiMethodToRequestDataTable eg. 'Referers.getKeywords'
* @param string $controllerActionCalledWhenRequestSubTable eg. 'getSearchEnginesFromKeywordId'
- * @param array $defaultProperties
+ * @param array $defaultProperties
*/
public function init($currentControllerName,
$currentControllerAction,
@@ -361,28 +364,28 @@ abstract class Piwik_ViewDataTable
$this->currentControllerAction = $currentControllerAction;
$this->controllerActionCalledWhenRequestSubTable = $controllerActionCalledWhenRequestSubTable;
$this->idSubtable = Common::getRequestVar('idSubtable', false, 'int');
-
+
foreach ($defaultProperties as $name => $value) {
$this->setViewProperty($name, $value);
}
-
- $queryParams = Piwik_Url::getArrayFromCurrentQueryString();
+
+ $queryParams = Url::getArrayFromCurrentQueryString();
foreach ($this->getOverridableProperties() as $name) {
if (isset($queryParams[$name])) {
$this->setViewProperty($name, $queryParams[$name]);
}
}
-
+
$this->viewProperties['show_footer_icons'] = ($this->idSubtable == false);
$this->viewProperties['apiMethodToRequestDataTable'] = $apiMethodToRequestDataTable;
-
+
$this->viewProperties['report_id'] = $currentControllerName . '.' . $currentControllerAction;
$this->viewProperties['self_url'] = $this->getBaseReportUrl($currentControllerName, $currentControllerAction);
-
+
if (!\Piwik\PluginsManager::getInstance()->isPluginActivated('Goals')) {
$this->viewProperties['show_goals'] = false;
}
-
+
// the exclude low population threshold value is sometimes obtained by requesting data.
// to avoid issuing unecessary requests when display properties are determined by metadata,
// we allow it to be a closure.
@@ -393,7 +396,7 @@ abstract class Piwik_ViewDataTable
$this->viewProperties['filter_excludelowpop_value'] = $function();
}
}
-
+
/**
* Forces the View to use a given template.
* Usually the template to use is set in the specific ViewDataTable_*
@@ -482,14 +485,14 @@ abstract class Piwik_ViewDataTable
{
$properties = array();
Piwik_PostEvent('ViewDataTable.getReportDisplayProperties', array(&$properties, $apiAction));
-
+
return $properties;
}
-
+
/**
* Sets a view property by name. This function handles special view properties
* like 'translations' & 'relatedReports' that store arrays.
- *
+ *
* @param string $name
* @param mixed $value For array properties, $value can be a comma separated string.
*/
@@ -501,7 +504,7 @@ abstract class Piwik_ViewDataTable
) {
$value = Piwik::getArrayFromApiParameter($value);
}
-
+
if ($name == 'translations') {
$this->viewProperties[$name] = array_merge($this->viewProperties[$name], $value);
} else if ($name == 'relatedReports') {
@@ -523,7 +526,7 @@ abstract class Piwik_ViewDataTable
/**
* Function called by the ViewDataTable objects in order to fetch data from the API.
* The function init() must have been called before, so that the object knows which API module and action to call.
- * It builds the API request string and uses Piwik_API_Request to call the API.
+ * It builds the API request string and uses Request to call the API.
* The requested DataTable object is stored in $this->dataTable.
*/
protected function loadDataTableFromAPI()
@@ -584,7 +587,7 @@ abstract class Piwik_ViewDataTable
$filterParameters = $filter[1];
$this->dataTable->filter($filterName, $filterParameters);
}
-
+
if (!$this->areGenericFiltersDisabled()) {
// Second, generic filters (Sort, Limit, Replace Column Names, etc.)
$requestArray = $this->getRequestArray();
@@ -607,7 +610,7 @@ abstract class Piwik_ViewDataTable
$this->dataTable->filter($filterName, $filterParameters);
}
}
-
+
// default columns_to_display to label, nb_uniq_visitors/nb_visits if those columns exist in the
// dataset
if ($this->dataTable instanceof DataTable) {
@@ -616,18 +619,18 @@ abstract class Piwik_ViewDataTable
&& $this->dataTableColumnsContains($columns, array('nb_visits', 'nb_uniq_visitors'))
) {
$columnsToDisplay = array('label');
-
+
// if unique visitors data is available, show it, otherwise just visits
if ($this->dataTableColumnsContains($columns, 'nb_uniq_visitors')) {
$columnsToDisplay[] = 'nb_uniq_visitors';
} else {
$columnsToDisplay[] = 'nb_visits';
}
-
+
$this->viewProperties['columns_to_display'] = $columnsToDisplay;
}
}
-
+
return true;
}
@@ -695,8 +698,8 @@ abstract class Piwik_ViewDataTable
// - we request the method to call to get this specific DataTable
// - the format = original specifies that we want to get the original DataTable structure itself, not rendered
$requestArray = array(
- 'method' => $this->viewProperties['apiMethodToRequestDataTable'],
- 'format' => 'original',
+ 'method' => $this->viewProperties['apiMethodToRequestDataTable'],
+ 'format' => 'original',
'disable_generic_filters' => Common::getRequestVar('disable_generic_filters', 1, 'int')
);
@@ -718,14 +721,14 @@ abstract class Piwik_ViewDataTable
$requestArray[$varToSet] = $value;
}
}
-
+
$segment = $this->getRawSegmentFromRequest();
- if(!empty($segment)) {
+ if (!empty($segment)) {
$requestArray['segment'] = $segment;
}
-
+
$requestArray = array_merge($requestArray, $this->viewProperties['request_parameters_to_modify']);
-
+
return $requestArray;
}
@@ -739,7 +742,7 @@ abstract class Piwik_ViewDataTable
$segment = Common::getRequestVar('segment', '', 'string');
if (!empty($segment)) {
$request = Piwik_API_Request::getRequestParametersGET();
- if(!empty($request['segment'])) {
+ if (!empty($request['segment'])) {
$segmentRaw = $request['segment'];
}
}
@@ -811,7 +814,7 @@ abstract class Piwik_ViewDataTable
}
}
}
-
+
foreach ($this->viewProperties['custom_parameters'] as $name => $value) {
$javascriptVariablesToSet[$name] = $value;
}
@@ -884,7 +887,7 @@ abstract class Piwik_ViewDataTable
}
$rawSegment = $this->getRawSegmentFromRequest();
- if(!empty($rawSegment)) {
+ if (!empty($rawSegment)) {
$javascriptVariablesToSet['segment'] = $rawSegment;
}
@@ -921,10 +924,10 @@ abstract class Piwik_ViewDataTable
}
return $this->viewProperties[$nameVar];
}
-
+
/**
* Sets a set of extra request query parameters to be used when querying API data.
- *
+ *
* @param array $params
*/
public function setRequestParametersToModify($params)
@@ -1359,7 +1362,7 @@ abstract class Piwik_ViewDataTable
private function removeEmptyColumnsFromDisplay()
{
- if(empty($this->dataTable)) {
+ if (empty($this->dataTable)) {
return;
}
if ($this->dataTable instanceof DataTable\Map) {
@@ -1481,7 +1484,7 @@ abstract class Piwik_ViewDataTable
if (!empty($thisReportTitle)) {
$this->setReportTitle($thisReportTitle);
}
-
+
foreach ($relatedReports as $report => $title) {
list($module, $action) = explode('.', $report);
$this->addRelatedReport($module, $action, $title);
@@ -1501,9 +1504,9 @@ abstract class Piwik_ViewDataTable
/**
* Sets a custom URL to use to reference this report.
*
- * @param string $module
- * @param string $action
- * @param array $queryParams
+ * @param string $module
+ * @param string $action
+ * @param array $queryParams
*/
public function setReportUrl($module, $action, $queryParams = array())
{
@@ -1575,10 +1578,10 @@ abstract class Piwik_ViewDataTable
$params = array_merge($queryParams, array('module' => $module, 'action' => $action));
return Piwik_API_Request::getCurrentUrlWithoutGenericFilters($params);
}
-
+
/**
* Convenience method that creates and renders a ViewDataTable for a API method.
- *
+ *
* @param string $pluginName The name of the plugin (eg, UserSettings).
* @param string $apiAction The name of the API action (eg, getResolution).
* @param bool $fetch If true, the result is returned, if false it is echo'd.
@@ -1586,26 +1589,26 @@ abstract class Piwik_ViewDataTable
*/
static public function render($pluginName, $apiAction, $fetch = true)
{
- $apiClassName = 'Piwik_'.$pluginName.'_API';
+ $apiClassName = 'Piwik_' . $pluginName . '_API';
if (!method_exists($apiClassName::getInstance(), $apiAction)) {
throw new Exception("Invalid action name '$apiAction' for '$pluginName' plugin.");
}
-
- $view = self::factory(null, $pluginName.'.'.$apiAction);
+
+ $view = self::factory(null, $pluginName . '.' . $apiAction);
$view->main();
$rendered = $view->getView()->render();
-
+
if ($fetch) {
return $rendered;
} else {
echo $rendered;
}
}
-
+
/**
* Returns whether the DataTable result will have to be expanded for the
* current request before rendering.
- *
+ *
* @return bool
*/
public static function shouldLoadExpanded()
@@ -1613,14 +1616,14 @@ abstract class Piwik_ViewDataTable
// if filter_column_recursive & filter_pattern_recursive are supplied, and flat isn't supplied
// we have to load all the child subtables.
return Common::getRequestVar('filter_column_recursive', false) !== false
- && Common::getRequestVar('filter_pattern_recursive', false) !== false
- && Common::getRequestVar('flat', false) === false;
+ && Common::getRequestVar('filter_pattern_recursive', false) !== false
+ && Common::getRequestVar('flat', false) === false;
}
-
+
/**
* Returns true if the first array contains one or more of the specified
* column names or their associated integer INDEX_ value.
- *
+ *
* @param array $columns Row columns.
* @param array|string $columnsToCheckFor eg, array('nb_visits', 'nb_uniq_visitors')
* @return bool
@@ -1630,7 +1633,7 @@ abstract class Piwik_ViewDataTable
if (!is_array($columnsToCheckFor)) {
$columnsToCheckFor = array($columnsToCheckFor);
}
-
+
foreach ($columnsToCheckFor as $columnToCheckFor) {
foreach ($columns as $column) {
// check for the column name and its associated integer INDEX_ value
@@ -1642,7 +1645,7 @@ abstract class Piwik_ViewDataTable
}
}
}
-
+
return false;
}
}
diff --git a/core/ViewDataTable/Cloud.php b/core/ViewDataTable/Cloud.php
index bc2377b4e7..cf3d756089 100644
--- a/core/ViewDataTable/Cloud.php
+++ b/core/ViewDataTable/Cloud.php
@@ -8,15 +8,17 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\ViewDataTable;
+use Piwik\View;
/**
* Reads the requested DataTable from the API, and prepares the data to give
* to Piwik_Visualization_Cloud that will display the tag cloud (via the template _dataTable_cloud.twig).
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
-class Piwik_ViewDataTable_Cloud extends Piwik_ViewDataTable
+class Piwik_ViewDataTable_Cloud extends ViewDataTable
{
protected $displayLogoInsteadOfLabel = false;
@@ -76,7 +78,7 @@ class Piwik_ViewDataTable_Cloud extends Piwik_ViewDataTable
protected function buildView()
{
- $view = new Piwik_View($this->dataTableTemplate);
+ $view = new View($this->dataTableTemplate);
if (!$this->isDataAvailable) {
$view->cloudValues = array();
} else {
diff --git a/core/ViewDataTable/GenerateGraphHTML.php b/core/ViewDataTable/GenerateGraphHTML.php
index 2543d2a64c..4bdadbc791 100644
--- a/core/ViewDataTable/GenerateGraphHTML.php
+++ b/core/ViewDataTable/GenerateGraphHTML.php
@@ -8,17 +8,21 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\API\Request;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\JqplotDataGenerator;
+use Piwik\ViewDataTable;
+use Piwik\View;
/**
* This class generates the HTML code to embed graphs in the page.
* It doesn't call the API but simply prints the html snippet.
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
-abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
+abstract class Piwik_ViewDataTable_GenerateGraphHTML extends ViewDataTable
{
protected $width = '100%';
protected $height = 250;
@@ -89,7 +93,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
}
/**
- * The implementation of this method in Piwik_ViewDataTable passes to the graph whether the
+ * The implementation of this method in ViewDataTable passes to the graph whether the
* goals icon should be displayed or not. Here, we use it to implicitly add the goal metrics
* to the metrics picker.
*/
@@ -236,7 +240,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
{
// access control
$idSite = Common::getRequestVar('idSite', 1, 'int');
- Piwik_API_Request::reloadAuthUsingTokenAuth();
+ Request::reloadAuthUsingTokenAuth();
if (!Piwik::isUserHasViewAccess($idSite)) {
throw new Exception(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idSite)));
}
@@ -245,7 +249,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
$this->graphData = $this->getGraphData($this->dataTable);
// build view
- $view = new Piwik_View($this->dataTableTemplate);
+ $view = new View($this->dataTableTemplate);
$view->width = $this->width;
$view->height = $this->height;
@@ -270,7 +274,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable
protected function getGraphData($dataTable)
{
$properties = array_merge($this->viewProperties, $this->viewProperties['request_parameters_to_modify']);
- $dataGenerator = Piwik_JqplotDataGenerator::factory($this->graphType, $properties);
+ $dataGenerator = JqplotDataGenerator::factory($this->graphType, $properties);
$jsonData = $dataGenerator->generate($dataTable);
return str_replace(array("\r", "\n"), '', $jsonData);
diff --git a/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php b/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php
index 4ee089abd8..13b9047644 100644
--- a/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php
+++ b/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php
@@ -11,13 +11,14 @@
use Piwik\Common;
use Piwik\Period\Range;
+use Piwik\Controller;
use Piwik\Site;
/**
* Generates HTML embed for the Evolution graph
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
class Piwik_ViewDataTable_GenerateGraphHTML_ChartEvolution extends Piwik_ViewDataTable_GenerateGraphHTML
@@ -136,7 +137,7 @@ class Piwik_ViewDataTable_GenerateGraphHTML_ChartEvolution extends Piwik_ViewDat
$site = new Site(Common::getRequestVar('idSite'));
- $dateRange = Piwik_Controller::getDateRangeRelativeToEndDate($period, 'last' . $lastN, $endDate, $site);
+ $dateRange = Controller::getDateRangeRelativeToEndDate($period, 'last' . $lastN, $endDate, $site);
return array($dateRange, $lastN);
}
diff --git a/core/ViewDataTable/GenerateGraphHTML/ChartPie.php b/core/ViewDataTable/GenerateGraphHTML/ChartPie.php
index 35d99f2bac..c2acd2ea12 100644
--- a/core/ViewDataTable/GenerateGraphHTML/ChartPie.php
+++ b/core/ViewDataTable/GenerateGraphHTML/ChartPie.php
@@ -13,7 +13,7 @@
* Generates HTML embed for the Pie chart
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
class Piwik_ViewDataTable_GenerateGraphHTML_ChartPie extends Piwik_ViewDataTable_GenerateGraphHTML
diff --git a/core/ViewDataTable/GenerateGraphHTML/ChartVerticalBar.php b/core/ViewDataTable/GenerateGraphHTML/ChartVerticalBar.php
index e8efa53230..dfbaff4f63 100644
--- a/core/ViewDataTable/GenerateGraphHTML/ChartVerticalBar.php
+++ b/core/ViewDataTable/GenerateGraphHTML/ChartVerticalBar.php
@@ -14,7 +14,7 @@
* Generates HTML embed for the vertical bar chart
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
class Piwik_ViewDataTable_GenerateGraphHTML_ChartVerticalBar extends Piwik_ViewDataTable_GenerateGraphHTML
diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php
index 05b99543fa..cd5443a3e0 100644
--- a/core/ViewDataTable/HtmlTable.php
+++ b/core/ViewDataTable/HtmlTable.php
@@ -12,6 +12,8 @@ use Piwik\Config;
use Piwik\DataTable\Renderer;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\ViewDataTable;
+use Piwik\View;
/**
* Outputs an AJAX Table for a given DataTable.
@@ -19,9 +21,9 @@ use Piwik\Common;
* Reads the requested DataTable from the API.
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
-class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
+class Piwik_ViewDataTable_HtmlTable extends ViewDataTable
{
/**
* PHP array conversion of the DataTable
@@ -61,7 +63,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
/**
* @see Piwik_ViewDataTable::main()
- * @throws Exception|Access_NoAccessException
+ * @throws Exception|\Piwik\NoAccessException
* @return null
*/
public function main()
@@ -74,7 +76,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
$this->isDataAvailable = true;
try {
$this->loadDataTableFromAPI();
- } catch (Access_NoAccessException $e) {
+ } catch (\Piwik\NoAccessException $e) {
throw $e;
} catch (Exception $e) {
Piwik::log("Failed to get data from API: " . $e->getMessage());
@@ -113,12 +115,12 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable
}
/**
- * @return Piwik_View with all data set
+ * @return View with all data set
*/
protected function buildView()
{
$template = $this->idSubtable ? $this->viewProperties['subtable_template'] : $this->dataTableTemplate;
- $view = new Piwik_View($template);
+ $view = new View($template);
if (!empty($this->loadingError)) {
$view->error = $this->loadingError;
diff --git a/core/ViewDataTable/HtmlTable/AllColumns.php b/core/ViewDataTable/HtmlTable/AllColumns.php
index 6b88cfeeb3..87ed0412a4 100644
--- a/core/ViewDataTable/HtmlTable/AllColumns.php
+++ b/core/ViewDataTable/HtmlTable/AllColumns.php
@@ -8,10 +8,11 @@
* @category Piwik
* @package Piwik
*/
+use Piwik\Controller;
/**
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlTable
{
@@ -38,7 +39,7 @@ class Piwik_ViewDataTable_HtmlTable_AllColumns extends Piwik_ViewDataTable_HtmlT
$valid = parent::postDataTableLoadedFromAPI();
if (!$valid) return false;
- Piwik_Controller::setPeriodVariablesView($this);
+ Controller::setPeriodVariablesView($this);
$columnUniqueVisitors = false;
if ($this->period == 'day') {
$columnUniqueVisitors = 'nb_uniq_visitors';
diff --git a/core/ViewDataTable/HtmlTable/Goals.php b/core/ViewDataTable/HtmlTable/Goals.php
index 7714e7fd06..fc1fa842e7 100644
--- a/core/ViewDataTable/HtmlTable/Goals.php
+++ b/core/ViewDataTable/HtmlTable/Goals.php
@@ -15,7 +15,7 @@ use Piwik\Site;
/**
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
class Piwik_ViewDataTable_HtmlTable_Goals extends Piwik_ViewDataTable_HtmlTable
{
diff --git a/core/ViewDataTable/Sparkline.php b/core/ViewDataTable/Sparkline.php
index 74e72f03c9..6611bc4441 100644
--- a/core/ViewDataTable/Sparkline.php
+++ b/core/ViewDataTable/Sparkline.php
@@ -10,14 +10,15 @@
*/
use Piwik\Common;
use Piwik\DataTable;
+use Piwik\ViewDataTable;
/**
* Reads the requested DataTable from the API and prepare data for the Sparkline view.
*
* @package Piwik
- * @subpackage Piwik_ViewDataTable
+ * @subpackage ViewDataTable
*/
-class Piwik_ViewDataTable_Sparkline extends Piwik_ViewDataTable
+class Piwik_ViewDataTable_Sparkline extends ViewDataTable
{
protected function getViewDataTableId()
{
diff --git a/core/PluginsFunctions/WidgetsList.php b/core/WidgetsList.php
index 3bfefe386a..790ebfa89d 100644
--- a/core/PluginsFunctions/WidgetsList.php
+++ b/core/WidgetsList.php
@@ -8,11 +8,12 @@
* @category Piwik
* @package PluginsFunctions
*/
+namespace Piwik;
/**
* @package PluginsFunctions
*/
-class Piwik_WidgetsList
+class WidgetsList
{
/**
* List of widgets
@@ -39,7 +40,7 @@ class Piwik_WidgetsList
self::addWidgets();
Piwik_PostEvent('WidgetsList.get');
- uksort(self::$widgets, array('Piwik_WidgetsList', '_sortWidgetCategories'));
+ uksort(self::$widgets, array('Piwik\WidgetsList', '_sortWidgetCategories'));
$widgets = array();
foreach (self::$widgets as $key => $v) {
@@ -102,7 +103,7 @@ class Piwik_WidgetsList
* @param string $controllerAction
* @param array $customParameters
*/
- static public function add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters)
+ static public function add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array())
{
$widgetName = Piwik_Translate($widgetName);
$widgetUniqueId = 'widget' . $controllerName . $controllerAction;
@@ -171,44 +172,5 @@ class Piwik_WidgetsList
}
}
-/**
- * Returns all available widgets
- *
- * @see Piwik_WidgetsList::get
- *
- * @return array
- */
-function Piwik_GetWidgetsList()
-{
- return Piwik_WidgetsList::get();
-}
-/**
- * Adds an widget to the list
- *
- * @see Piwik_WidgetsList::add
- *
- * @param string $widgetCategory
- * @param string $widgetName
- * @param string $controllerName
- * @param string $controllerAction
- * @param array $customParameters
- */
-function Piwik_AddWidget($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array())
-{
- Piwik_WidgetsList::add($widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters);
-}
-/**
- * Checks if the widget with the given parameters exists in der widget list
- *
- * @see Piwik_WidgetsList::isDefined
- *
- * @param string $controllerName
- * @param string $controllerAction
- * @return bool
- */
-function Piwik_IsWidgetDefined($controllerName, $controllerAction)
-{
- return Piwik_WidgetsList::isDefined($controllerName, $controllerAction);
-}
diff --git a/core/functions.php b/core/functions.php
new file mode 100644
index 0000000000..81ef9326cc
--- /dev/null
+++ b/core/functions.php
@@ -0,0 +1,259 @@
+<?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
+ * @package Piwik
+ */
+
+// All classes and functions below are defined in the global namespace
+namespace {
+
+ use Piwik\EventDispatcher;
+ use Piwik\DataTable;
+ use Piwik\Menu\Admin;
+ use Piwik\Menu\Main;
+ use Piwik\Menu\Top;
+
+ /**
+ * Post an event to the dispatcher which will notice the observers.
+ *
+ * @param string $eventName The event name.
+ * @param array $params The parameter array to forward to observer callbacks.
+ * @param bool $pending
+ * @param null $plugins
+ * @return void
+ */
+ function Piwik_PostEvent($eventName, $params = array(), $pending = false, $plugins = null)
+ {
+ EventDispatcher::getInstance()->postEvent($eventName, $params, $pending, $plugins);
+ }
+
+ /**
+ * Register an action to execute for a given event
+ *
+ * @param string $eventName Name of event
+ * @param callable $function Callback hook
+ */
+ function Piwik_AddAction($eventName, $function)
+ {
+ EventDispatcher::getInstance()->addObserver($eventName, $function);
+ }
+
+
+ /**
+ * Returns translated string or given message if translation is not found.
+ *
+ * @param string $string Translation string index
+ * @param array|string|int $args sprintf arguments
+ * @return string
+ */
+ function Piwik_Translate($string, $args = array())
+ {
+ if (!is_array($args)) {
+ $args = array($args);
+ }
+ if (isset($GLOBALS['Piwik_translations'][$string])) {
+ $string = $GLOBALS['Piwik_translations'][$string];
+ }
+ if (count($args) == 0) {
+ return $string;
+ }
+ return vsprintf($string, $args);
+ }
+
+ /**
+ * Returns translated string or given message if translation is not found.
+ * This function does not throw any exception. Use it to translate exceptions.
+ *
+ * @param string $message Translation string index
+ * @param array $args sprintf arguments
+ * @return string
+ */
+ function Piwik_TranslateException($message, $args = array())
+ {
+ try {
+ return Piwik_Translate($message, $args);
+ } catch (Exception $e) {
+ return $message;
+ }
+ }
+
+
+ /**
+ * Returns the option value for the requested option $name
+ *
+ * @param string $name Key
+ * @return string|false Value or false, if not found
+ */
+ function Piwik_GetOption($name)
+ {
+ return Piwik\Option::getInstance()->get($name);
+ }
+
+ /**
+ * Sets the option value in the database
+ *
+ * @param string $name
+ * @param string $value
+ * @param int $autoLoad if set to 1, this option value will be automatically loaded; should be set to 1 for options that will always be used in the Piwik request.
+ */
+ function Piwik_SetOption($name, $value, $autoLoad = 0)
+ {
+ Piwik\Option::getInstance()->set($name, $value, $autoLoad);
+ }
+
+ /**
+ * Returns the AdminMenu
+ *
+ * @return Array
+ */
+ function Piwik_GetAdminMenu()
+ {
+ return Admin::getInstance()->get();
+ }
+
+ /**
+ * Adds a new AdminMenu entry.
+ *
+ * @param string $adminMenuName
+ * @param string $url
+ * @param boolean $displayedForCurrentUser
+ * @param int $order
+ */
+ function Piwik_AddAdminMenu($adminMenuName, $url, $displayedForCurrentUser = true, $order = 10)
+ {
+ Admin::getInstance()->add('General_Settings', $adminMenuName, $url, $displayedForCurrentUser, $order);
+ }
+
+ /**
+ * Adds a new AdminMenu entry with a submenu.
+ *
+ * @param string $adminMenuName
+ * @param string $adminSubMenuName
+ * @param string $url
+ * @param boolean $displayedForCurrentUser
+ * @param int $order
+ */
+ function Piwik_AddAdminSubMenu($adminMenuName, $adminSubMenuName, $url, $displayedForCurrentUser = true, $order = 10)
+ {
+ Admin::getInstance()->add($adminMenuName, $adminSubMenuName, $url, $displayedForCurrentUser, $order);
+ }
+
+ /**
+ * Renames an AdminMenu entry.
+ *
+ * @param string $adminMenuOriginal
+ * @param string $adminMenuRenamed
+ */
+ function Piwik_RenameAdminMenuEntry($adminMenuOriginal, $adminMenuRenamed)
+ {
+ Admin::getInstance()->rename($adminMenuOriginal, null, $adminMenuRenamed, null);
+ }
+
+
+ /**
+ * Returns the MainMenu as array.
+ *
+ * @return array
+ */
+ function Piwik_GetMenu()
+ {
+ return Main::getInstance()->get();
+ }
+
+ /**
+ * Adds a new entry to the MainMenu.
+ *
+ * @param string $mainMenuName
+ * @param string $subMenuName
+ * @param string $url
+ * @param boolean $displayedForCurrentUser
+ * @param int $order
+ */
+ function Piwik_AddMenu($mainMenuName, $subMenuName, $url, $displayedForCurrentUser = true, $order = 10)
+ {
+ Main::getInstance()->add($mainMenuName, $subMenuName, $url, $displayedForCurrentUser, $order);
+ }
+
+ /**
+ * Renames a menu entry.
+ *
+ * @param string $mainMenuOriginal
+ * @param string $subMenuOriginal
+ * @param string $mainMenuRenamed
+ * @param string $subMenuRenamed
+ */
+ function Piwik_RenameMenuEntry($mainMenuOriginal, $subMenuOriginal,
+ $mainMenuRenamed, $subMenuRenamed)
+ {
+ Main::getInstance()->rename($mainMenuOriginal, $subMenuOriginal, $mainMenuRenamed, $subMenuRenamed);
+ }
+
+ /**
+ * Edits the URL of a menu entry.
+ *
+ * @param string $mainMenuToEdit
+ * @param string $subMenuToEdit
+ * @param string $newUrl
+ */
+ function Piwik_EditMenuUrl($mainMenuToEdit, $subMenuToEdit, $newUrl)
+ {
+ Main::getInstance()->editUrl($mainMenuToEdit, $subMenuToEdit, $newUrl);
+ }
+
+ /**
+ * Returns the TopMenu as an array.
+ *
+ * @return array
+ */
+ function Piwik_GetTopMenu()
+ {
+ return Top::getInstance()->get();
+ }
+
+ /**
+ * Adds a new entry to the TopMenu.
+ *
+ * @param string $topMenuName
+ * @param string $data
+ * @param boolean $displayedForCurrentUser
+ * @param int $order
+ * @param bool $isHTML
+ * @param bool|string $tooltip Tooltip to display.
+ */
+ function Piwik_AddTopMenu($topMenuName, $data, $displayedForCurrentUser = true, $order = 10, $isHTML = false,
+ $tooltip = false)
+ {
+ if ($isHTML) {
+ Top::getInstance()->addHtml($topMenuName, $data, $displayedForCurrentUser, $order, $tooltip);
+ } else {
+ Top::getInstance()->add($topMenuName, null, $data, $displayedForCurrentUser, $order, $tooltip);
+ }
+ }
+
+ /**
+ * Renames a entry of the TopMenu
+ *
+ * @param string $topMenuOriginal
+ * @param string $topMenuRenamed
+ */
+ function Piwik_RenameTopMenuEntry($topMenuOriginal, $topMenuRenamed)
+ {
+ Top::getInstance()->rename($topMenuOriginal, null, $topMenuRenamed, null);
+ }
+
+
+ if(empty($GLOBALS['PIWIK_TRACKER_MODE'])) { // do not define these classes in tracker
+
+ class Piwik_DataTable_Row_DataTableSummary extends DataTable\Row\DataTableSummaryRow {
+ }
+
+ class Piwik_DataTable_Row extends DataTable\Row {
+ }
+
+ }
+}