diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-07-23 11:52:15 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-07-23 11:52:15 +0400 |
commit | 5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch) | |
tree | 5f30daf7bc14373fb1bbd0504ce11a771dafc02f /plugins | |
parent | ae4b1f4e38077b174e4df5b7d4513d63fe026a24 (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 'plugins')
129 files changed, 906 insertions, 646 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php index e85974fd8e..74c7c011de 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -8,6 +8,8 @@ * @category Piwik_Plugins * @package Piwik_API */ +use Piwik\API\Request; +use Piwik\API\Proxy; use Piwik\DataTable\Filter\ColumnDelete; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -16,6 +18,7 @@ use Piwik\Common; use Piwik\Config; use Piwik\Date; use Piwik\DataTable; +use Piwik\Version; use Piwik\Plugin; use Piwik\Translate; @@ -105,7 +108,7 @@ class Piwik_API_API public function getPiwikVersion() { Piwik::checkUserHasSomeViewAccess(); - return Piwik_Version::VERSION; + return Version::VERSION; } /** @@ -143,7 +146,7 @@ class Piwik_API_API 'segment' => 'visitIp', 'acceptedValues' => '13.54.122.1, etc.', 'sqlSegment' => 'log_visit.location_ip', - 'sqlFilter' => array('Piwik_IP', 'P2N'), + 'sqlFilter' => array('IP', 'P2N'), 'permission' => $isAuthenticatedWithViewAccess, ); $segments[] = array( @@ -470,7 +473,7 @@ class Piwik_API_API // load the data $className = 'Piwik_' . $plugin . '_API'; $params['columns'] = implode(',', $columns); - $dataTable = Piwik_API_Proxy::getInstance()->call($className, 'get', $params); + $dataTable = Proxy::getInstance()->call($className, 'get', $params); // make sure the table has all columns $array = ($dataTable instanceof DataTable\Map ? $dataTable->getArray() : array($dataTable)); foreach ($array as $table) { @@ -567,7 +570,7 @@ class Piwik_API_API $result = array(); foreach ($urls as $url) { - $req = new Piwik_API_Request($url . '&format=php&serialize=0'); + $req = new Request($url . '&format=php&serialize=0'); $result[] = $req->process(); } return $result; @@ -618,7 +621,7 @@ class Piwik_API_API $requestLastVisits .= "&filter_limit=1000"; } - $request = new Piwik_API_Request($requestLastVisits); + $request = new Request($requestLastVisits); $table = $request->process(); if (empty($table)) { throw new Exception("There was no data to suggest for $segmentName"); diff --git a/plugins/API/Controller.php b/plugins/API/Controller.php index 16d8f9dd1f..ed4addae2c 100644 --- a/plugins/API/Controller.php +++ b/plugins/API/Controller.php @@ -8,14 +8,19 @@ * @category Piwik_Plugins * @package Piwik_API */ +use Piwik\API\DocumentationGenerator; +use Piwik\API\Request; +use Piwik\API\Proxy; use Piwik\Config; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * * @package Piwik_API */ -class Piwik_API_Controller extends Piwik_Controller +class Piwik_API_Controller extends Controller { function index() { @@ -23,23 +28,23 @@ class Piwik_API_Controller extends Piwik_Controller if (!isset($_GET['filter_limit'])) { $_GET['filter_limit'] = Config::getInstance()->General['API_datatable_default_limit']; } - $request = new Piwik_API_Request('token_auth=' . Common::getRequestVar('token_auth', 'anonymous', 'string')); + $request = new Request('token_auth=' . Common::getRequestVar('token_auth', 'anonymous', 'string')); echo $request->process(); } public function listAllMethods() { - $ApiDocumentation = new Piwik_API_DocumentationGenerator(); + $ApiDocumentation = new DocumentationGenerator(); echo $ApiDocumentation->getAllInterfaceString($outputExampleUrls = true, $prefixUrls = Common::getRequestVar('prefixUrl', '')); } public function listAllAPI() { - $view = new Piwik_View("@API/listAllAPI"); + $view = new View("@API/listAllAPI"); $this->setGeneralVariablesView($view); - $ApiDocumentation = new Piwik_API_DocumentationGenerator(); - $view->countLoadedAPI = Piwik_API_Proxy::getInstance()->getCountRegisteredClasses(); + $ApiDocumentation = new DocumentationGenerator(); + $view->countLoadedAPI = Proxy::getInstance()->getCountRegisteredClasses(); $view->list_api_methods_with_links = $ApiDocumentation->getAllInterfaceString(); echo $view->render(); } diff --git a/plugins/API/ProcessedReport.php b/plugins/API/ProcessedReport.php index a008c82025..b30a3d7901 100644 --- a/plugins/API/ProcessedReport.php +++ b/plugins/API/ProcessedReport.php @@ -1,4 +1,5 @@ <?php +use Piwik\API\Request; use Piwik\DataTable\Simple; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -7,6 +8,8 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Date; use Piwik\DataTable; +use Piwik\Url; +use Piwik\Timer; use Piwik\Site; /** @@ -243,7 +246,7 @@ class Piwik_API_ProcessedReport $apiParameters = false, $idGoal = false, $language = false, $showTimer = true, $hideMetricsDoc = false, $idSubtable = false, $showRawMetrics = false) { - $timer = new Piwik_Timer(); + $timer = new Timer(); if (empty($apiParameters)) { $apiParameters = array(); } @@ -273,8 +276,8 @@ class Piwik_API_ProcessedReport )); if (!empty($segment)) $parameters['segment'] = $segment; - $url = Piwik_Url::getQueryStringFromParameters($parameters); - $request = new Piwik_API_Request($url); + $url = Url::getQueryStringFromParameters($parameters); + $request = new Request($url); try { /** @var DataTable */ $dataTable = $request->process(); diff --git a/plugins/API/RowEvolution.php b/plugins/API/RowEvolution.php index ec6b3c06fc..21ab108c8d 100644 --- a/plugins/API/RowEvolution.php +++ b/plugins/API/RowEvolution.php @@ -8,6 +8,9 @@ * @category Piwik_Plugins * @package Piwik_API */ +use Piwik\API\DataTableManipulator\LabelFilter; +use Piwik\API\ResponseBuilder; +use Piwik\API\Request; use Piwik\DataTable\Filter\CalculateEvolutionFilter; use Piwik\DataTable\Filter\SafeDecodeLabel; use Piwik\DataTable\Row; @@ -15,6 +18,7 @@ use Piwik\Period; use Piwik\Piwik; use Piwik\Common; use Piwik\DataTable; +use Piwik\Url; /** * This class generates a Row evolution dataset, from input request @@ -36,7 +40,7 @@ class Piwik_API_RowEvolution throw new Exception("Row evolutions can not be processed with this combination of \'date\' and \'period\' parameters."); } - $label = Piwik_API_ResponseBuilder::unsanitizeLabelParameter($label); + $label = ResponseBuilder::unsanitizeLabelParameter($label); $labels = Piwik::getArrayFromApiParameter($label); @@ -80,7 +84,7 @@ class Piwik_API_RowEvolution foreach ($table->getRows() as $row) { $label = $row->getColumn('label'); if (isset($labelsToIndex[$label])) { - $row->setMetadata(Piwik_API_DataTableManipulator_LabelFilter::FLAG_IS_ROW_EVOLUTION, $labelsToIndex[$label]); + $row->setMetadata(LabelFilter::FLAG_IS_ROW_EVOLUTION, $labelsToIndex[$label]); } } } @@ -155,7 +159,7 @@ class Piwik_API_RowEvolution // if we have a recursive label and no url, use the path if (!$urlFound) { - $actualLabel = str_replace(Piwik_API_DataTableManipulator_LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label); + $actualLabel = str_replace(LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label); } $return = array( @@ -237,9 +241,9 @@ class Piwik_API_RowEvolution $parameters['filter_add_columns_when_show_all_columns'] = '1'; } - $url = Piwik_Url::getQueryStringFromParameters($parameters); + $url = Url::getQueryStringFromParameters($parameters); - $request = new Piwik_API_Request($url); + $request = new Request($url); try { $dataTable = $request->process(); @@ -450,7 +454,7 @@ class Piwik_API_RowEvolution } /** - * Returns the row in a datatable by its Piwik_API_DataTableManipulator_LabelFilter::FLAG_IS_ROW_EVOLUTION metadata. + * Returns the row in a datatable by its LabelFilter::FLAG_IS_ROW_EVOLUTION metadata. * * @param DataTable $table * @param int $labelIdx @@ -461,7 +465,7 @@ class Piwik_API_RowEvolution $labelIdx = (int)$labelIdx; foreach ($table->getRows() as $row) { - if ($row->getMetadata(Piwik_API_DataTableManipulator_LabelFilter::FLAG_IS_ROW_EVOLUTION) === $labelIdx) + if ($row->getMetadata(LabelFilter::FLAG_IS_ROW_EVOLUTION) === $labelIdx) { return $row; } @@ -476,6 +480,6 @@ class Piwik_API_RowEvolution */ private function cleanOriginalLabel($label) { - return str_replace(Piwik_API_DataTableManipulator_LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label); + return str_replace(LabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label); } } diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 0906c0cbd3..f333277c03 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -8,9 +8,11 @@ * @category Piwik_Plugins * @package Piwik_Actions */ +use Piwik\API\Request; use Piwik\ArchiveProcessor; use Piwik\Piwik; use Piwik\Common; +use Piwik\ViewDataTable; use Piwik\Plugin; use Piwik\SegmentExpression; use Piwik\Site; @@ -156,7 +158,7 @@ class Piwik_Actions extends Plugin ) { $sql = Piwik_Tracker_Action::getSqlSelectActionId(); $bind = array($valueToMatch, $valueToMatch, $actionType); - $idAction = Piwik_FetchOne($sql, $bind); + $idAction = Db::fetchOne($sql, $bind); // if the action is not found, we hack -100 to ensure it tries to match against an integer // otherwise binding idaction_name to "false" returns some rows for some reasons (in case &segment=pageTitle==Větrnásssssss) if (empty($idAction)) { @@ -523,24 +525,24 @@ class Piwik_Actions extends Plugin function addWidgets() { - Piwik_AddWidget('Actions_Actions', 'Actions_SubmenuPages', 'Actions', 'getPageUrls'); - Piwik_AddWidget('Actions_Actions', 'Actions_WidgetPageTitles', 'Actions', 'getPageTitles'); - Piwik_AddWidget('Actions_Actions', 'Actions_SubmenuOutlinks', 'Actions', 'getOutlinks'); - Piwik_AddWidget('Actions_Actions', 'Actions_SubmenuDownloads', 'Actions', 'getDownloads'); - Piwik_AddWidget('Actions_Actions', 'Actions_WidgetPagesEntry', 'Actions', 'getEntryPageUrls'); - Piwik_AddWidget('Actions_Actions', 'Actions_WidgetPagesExit', 'Actions', 'getExitPageUrls'); - Piwik_AddWidget('Actions_Actions', 'Actions_WidgetEntryPageTitles', 'Actions', 'getEntryPageTitles'); - Piwik_AddWidget('Actions_Actions', 'Actions_WidgetExitPageTitles', 'Actions', 'getExitPageTitles'); + WidgetsList::add('Actions_Actions', 'Actions_SubmenuPages', 'Actions', 'getPageUrls'); + WidgetsList::add('Actions_Actions', 'Actions_WidgetPageTitles', 'Actions', 'getPageTitles'); + WidgetsList::add('Actions_Actions', 'Actions_SubmenuOutlinks', 'Actions', 'getOutlinks'); + WidgetsList::add('Actions_Actions', 'Actions_SubmenuDownloads', 'Actions', 'getDownloads'); + WidgetsList::add('Actions_Actions', 'Actions_WidgetPagesEntry', 'Actions', 'getEntryPageUrls'); + WidgetsList::add('Actions_Actions', 'Actions_WidgetPagesExit', 'Actions', 'getExitPageUrls'); + WidgetsList::add('Actions_Actions', 'Actions_WidgetEntryPageTitles', 'Actions', 'getEntryPageTitles'); + WidgetsList::add('Actions_Actions', 'Actions_WidgetExitPageTitles', 'Actions', 'getExitPageTitles'); if ($this->isSiteSearchEnabled()) { - Piwik_AddWidget('Actions_SubmenuSitesearch', 'Actions_WidgetSearchKeywords', 'Actions', 'getSiteSearchKeywords'); + WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetSearchKeywords', 'Actions', 'getSiteSearchKeywords'); if (self::isCustomVariablesPluginsEnabled()) { - Piwik_AddWidget('Actions_SubmenuSitesearch', 'Actions_WidgetSearchCategories', 'Actions', 'getSiteSearchCategories'); + WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetSearchCategories', 'Actions', 'getSiteSearchCategories'); } - Piwik_AddWidget('Actions_SubmenuSitesearch', 'Actions_WidgetSearchNoResultKeywords', 'Actions', 'getSiteSearchNoResultKeywords'); - Piwik_AddWidget('Actions_SubmenuSitesearch', 'Actions_WidgetPageUrlsFollowingSearch', 'Actions', 'getPageUrlsFollowingSiteSearch'); - Piwik_AddWidget('Actions_SubmenuSitesearch', 'Actions_WidgetPageTitlesFollowingSearch', 'Actions', 'getPageTitlesFollowingSiteSearch'); + WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetSearchNoResultKeywords', 'Actions', 'getSiteSearchNoResultKeywords'); + WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetPageUrlsFollowingSearch', 'Actions', 'getPageUrlsFollowingSiteSearch'); + WidgetsList::add('Actions_SubmenuSitesearch', 'Actions_WidgetPageTitlesFollowingSearch', 'Actions', 'getPageTitlesFollowingSiteSearch'); } } @@ -660,7 +662,7 @@ class Piwik_Actions extends Plugin // so users can see that they can set it to 1 (see #3365) $result['custom_parameters'] = array('flat' => 0); - if (Piwik_ViewDataTable::shouldLoadExpanded()) { + if (ViewDataTable::shouldLoadExpanded()) { $result['show_expanded'] = true; $result['filters'][] = function ($dataTable) { @@ -764,7 +766,7 @@ class Piwik_Actions extends Plugin { // link to the page, not just the report, but only if not a widget $widget = Common::getRequestVar('widget', false); - $reportUrl = Piwik_API_Request::getCurrentUrlWithoutGenericFilters(array( + $reportUrl = Request::getCurrentUrlWithoutGenericFilters(array( 'module' => 'Actions', 'action' => $widget === false ? 'indexEntryPageUrls' : 'getEntryPageUrls' )); @@ -793,7 +795,7 @@ class Piwik_Actions extends Plugin { // link to the page, not just the report, but only if not a widget $widget = Common::getRequestVar('widget', false); - $reportUrl = Piwik_API_Request::getCurrentUrlWithoutGenericFilters(array( + $reportUrl = Request::getCurrentUrlWithoutGenericFilters(array( 'module' => 'Actions', 'action' => $widget === false ? 'indexExitPageUrls' : 'getExitPageUrls' )); @@ -901,7 +903,7 @@ class Piwik_Actions extends Plugin { // link to the page, not just the report, but only if not a widget $widget = Common::getRequestVar('widget', false); - $reportUrl = Piwik_API_Request::getCurrentUrlWithoutGenericFilters(array( + $reportUrl = Request::getCurrentUrlWithoutGenericFilters(array( 'module' => 'Actions', 'action' => $widget === false ? 'indexPageTitles' : 'getPageTitles' )); diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index 987bf5104a..dc6242dd95 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -13,6 +13,7 @@ use Piwik\DataTable\Manager; use Piwik\DataTable\Row\DataTableSummaryRow; use Piwik\Metrics; use Piwik\DataTable; +use Piwik\RankingQuery; use Piwik\PluginsArchiver; /** @@ -215,7 +216,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver $rankingQuery = false; if ($rankingQueryLimit > 0) { - $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); + $rankingQuery = new RankingQuery($rankingQueryLimit); $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn(array('idaction', 'name')); $rankingQuery->addColumn(array('url_prefix', Metrics::INDEX_NB_UNIQ_VISITORS)); @@ -294,7 +295,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver { $rankingQuery = false; if ($rankingQueryLimit > 0) { - $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); + $rankingQuery = new RankingQuery($rankingQueryLimit); $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(Metrics::INDEX_PAGE_ENTRY_NB_UNIQ_VISITORS); @@ -345,7 +346,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver { $rankingQuery = false; if ($rankingQueryLimit > 0) { - $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); + $rankingQuery = new RankingQuery($rankingQueryLimit); $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(Metrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS); @@ -391,7 +392,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver { $rankingQuery = false; if ($rankingQueryLimit > 0) { - $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); + $rankingQuery = new RankingQuery($rankingQueryLimit); $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(Metrics::INDEX_PAGE_SUM_TIME_SPENT, 'sum'); diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php index f90ad12f28..36002fe2de 100644 --- a/plugins/Actions/Controller.php +++ b/plugins/Actions/Controller.php @@ -8,13 +8,16 @@ * @category Piwik_Plugins * @package Piwik_Actions */ +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * Actions controller * * @package Piwik_Actions */ -class Piwik_Actions_Controller extends Piwik_Controller +class Piwik_Actions_Controller extends Controller { // // Actions that render whole pages @@ -22,28 +25,28 @@ class Piwik_Actions_Controller extends Piwik_Controller public function indexPageUrls($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Actions_SubmenuPages'), $this->getPageUrls(true), $fetch); } public function indexEntryPageUrls($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Actions_SubmenuPagesEntry'), $this->getEntryPageUrls(true), $fetch); } public function indexExitPageUrls($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Actions_SubmenuPagesExit'), $this->getExitPageUrls(true), $fetch); } public function indexSiteSearch() { - $view = new Piwik_View('@Actions/indexSiteSearch'); + $view = new View('@Actions/indexSiteSearch'); $view->keywords = $this->getSiteSearchKeywords(true); $view->noResultKeywords = $this->getSiteSearchNoResultKeywords(true); @@ -59,21 +62,21 @@ class Piwik_Actions_Controller extends Piwik_Controller public function indexPageTitles($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Actions_SubmenuPageTitles'), $this->getPageTitles(true), $fetch); } public function indexDownloads($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Actions_SubmenuDownloads'), $this->getDownloads(true), $fetch); } public function indexOutlinks($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Actions_SubmenuOutlinks'), $this->getOutlinks(true), $fetch); } @@ -84,66 +87,66 @@ class Piwik_Actions_Controller extends Piwik_Controller public function getPageUrls($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getEntryPageUrls($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getExitPageUrls($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getSiteSearchKeywords($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getSiteSearchNoResultKeywords($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getSiteSearchCategories($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getPageUrlsFollowingSiteSearch($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getPageTitlesFollowingSiteSearch($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getPageTitles($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getEntryPageTitles($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getExitPageTitles($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getDownloads($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getOutlinks($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } } diff --git a/plugins/Annotations/Controller.php b/plugins/Annotations/Controller.php index f632ab5ae8..739ec5deeb 100755 --- a/plugins/Annotations/Controller.php +++ b/plugins/Annotations/Controller.php @@ -8,14 +8,17 @@ * @category Piwik_Plugins * @package Piwik_Annotations */ +use Piwik\API\Request; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * Controller for the Annotations plugin. * * @package Piwik_Annotations */ -class Piwik_Annotations_Controller extends Piwik_Controller +class Piwik_Annotations_Controller extends Controller { /** * Controller action that returns HTML displaying annotations for a site and @@ -56,9 +59,9 @@ class Piwik_Annotations_Controller extends Piwik_Controller } // create & render the view - $view = new Piwik_View('@Annotations/getAnnotationManager'); + $view = new View('@Annotations/getAnnotationManager'); - $allAnnotations = Piwik_API_Request::processRequest( + $allAnnotations = Request::processRequest( 'Annotations.getAll', array('date' => $date, 'period' => $period, 'lastN' => $lastN)); $view->annotations = empty($allAnnotations[$idSite]) ? array() : $allAnnotations[$idSite]; @@ -104,11 +107,11 @@ class Piwik_Annotations_Controller extends Piwik_Controller if ($_SERVER["REQUEST_METHOD"] == "POST") { $this->checkTokenInUrl(); - $view = new Piwik_View('@Annotations/saveAnnotation'); + $view = new View('@Annotations/saveAnnotation'); // NOTE: permissions checked in API method // save the annotation - $view->annotation = Piwik_API_Request::processRequest("Annotations.save"); + $view->annotation = Request::processRequest("Annotations.save"); echo $view->render(); } @@ -147,7 +150,7 @@ class Piwik_Annotations_Controller extends Piwik_Controller } // add the annotation. NOTE: permissions checked in API method - Piwik_API_Request::processRequest("Annotations.add", array('date' => $date)); + Request::processRequest("Annotations.add", array('date' => $date)); $managerDate = Common::getRequestVar('managerDate', false); $managerPeriod = Common::getRequestVar('managerPeriod', false); @@ -178,7 +181,7 @@ class Piwik_Annotations_Controller extends Piwik_Controller $this->checkTokenInUrl(); // delete annotation. NOTE: permissions checked in API method - Piwik_API_Request::processRequest("Annotations.delete"); + Request::processRequest("Annotations.delete"); echo $this->getAnnotationManager($fetch = true); } @@ -205,11 +208,11 @@ class Piwik_Annotations_Controller extends Piwik_Controller public function getEvolutionIcons() { // get annotation the count - $annotationCounts = Piwik_API_Request::processRequest( + $annotationCounts = Request::processRequest( "Annotations.getAnnotationCountForDates", array('getAnnotationText' => 1)); // create & render the view - $view = new Piwik_View('@Annotations/getEvolutionIcons'); + $view = new View('@Annotations/getEvolutionIcons'); $view->annotationCounts = reset($annotationCounts); // only one idSite allowed for this action echo $view->render(); diff --git a/plugins/AnonymizeIP/AnonymizeIP.php b/plugins/AnonymizeIP/AnonymizeIP.php index 7d6ce520a9..79af7308a5 100644 --- a/plugins/AnonymizeIP/AnonymizeIP.php +++ b/plugins/AnonymizeIP/AnonymizeIP.php @@ -10,6 +10,7 @@ */ use Piwik\Config; use Piwik\Common; +use Piwik\Version; use Piwik\Plugin; /** @@ -28,7 +29,7 @@ class Piwik_AnonymizeIP extends Plugin 'description' => Piwik_Translate('AnonymizeIP_PluginDescription'), 'author' => 'Piwik', 'author_homepage' => 'http://piwik.org/', - 'version' => Piwik_Version::VERSION, + 'version' => Version::VERSION, ); } diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php index fe6772fe09..6877d8ac90 100644 --- a/plugins/CoreAdminHome/API.php +++ b/plugins/CoreAdminHome/API.php @@ -15,6 +15,7 @@ use Piwik\Piwik; use Piwik\Config; use Piwik\Common; use Piwik\Date; +use Piwik\TaskScheduler; use Piwik\Site; /** @@ -43,7 +44,7 @@ class Piwik_CoreAdminHome_API public function runScheduledTasks() { Piwik::checkUserIsSuperUser(); - return Piwik_TaskScheduler::runTasks(); + return TaskScheduler::runTasks(); } public function getKnownSegmentsToArchive() @@ -173,7 +174,7 @@ class Piwik_CoreAdminHome_API $query = "DELETE FROM $table " . " WHERE ( $sql ) " . " AND idsite IN (" . $sqlIdSites . ")"; - Piwik_Query($query, $bind); + Db::query($query, $bind); } // Update piwik_site.ts_created @@ -183,7 +184,7 @@ class Piwik_CoreAdminHome_API AND ts_created > ?"; $minDateSql = $minDate->subDay(1)->getDatetime(); $bind = array($minDateSql, $minDateSql); - Piwik_Query($query, $bind); + Db::query($query, $bind); // Force to re-process data for these websites in the next archive.php cron run $invalidatedIdSites = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate(); diff --git a/plugins/CoreAdminHome/Controller.php b/plugins/CoreAdminHome/Controller.php index 5bae81c756..7ccf51921e 100644 --- a/plugins/CoreAdminHome/Controller.php +++ b/plugins/CoreAdminHome/Controller.php @@ -8,17 +8,22 @@ * @category Piwik_Plugins * @package Piwik_CoreAdminHome */ +use Piwik\API\ResponseBuilder; use Piwik\ArchiveProcessor\Rules; use Piwik\Config; +use Piwik\Controller\Admin; use Piwik\Piwik; use Piwik\Common; +use Piwik\Nonce; +use Piwik\View; +use Piwik\Url; use Piwik\Site; /** * * @package Piwik_CoreAdminHome */ -class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin +class Piwik_CoreAdminHome_Controller extends Admin { const LOGO_HEIGHT = 300; const LOGO_SMALL_HEIGHT = 100; @@ -31,7 +36,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin public function generalSettings() { Piwik::checkUserHasSomeAdminAccess(); - $view = new Piwik_View('@CoreAdminHome/generalSettings'); + $view = new View('@CoreAdminHome/generalSettings'); if (Piwik::isUserIsSuperUser()) { $enableBrowserTriggerArchiving = Rules::isBrowserTriggerEnabled(); @@ -78,7 +83,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin public function setGeneralSettings() { Piwik::checkUserIsSuperUser(); - $response = new Piwik_API_ResponseBuilder(Common::getRequestVar('format')); + $response = new ResponseBuilder(Common::getRequestVar('format')); try { $this->checkTokenInUrl(); $enableBrowserTriggerArchiving = Common::getRequestVar('enableBrowserTriggerArchiving'); @@ -112,7 +117,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin // update trusted host settings $trustedHosts = Common::getRequestVar('trustedHosts', false, 'json'); if ($trustedHosts !== false) { - Piwik_Url::saveTrustedHostnameInConfig($trustedHosts); + Url::saveTrustedHostnameInConfig($trustedHosts); } $config->forceSave(); @@ -130,7 +135,7 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin */ public function trackingCodeGenerator() { - $view = new Piwik_View('@CoreAdminHome/trackingCodeGenerator'); + $view = new View('@CoreAdminHome/trackingCodeGenerator'); $this->setBasicVariablesView($view); $view->topMenu = Piwik_GetTopMenu(); @@ -170,15 +175,15 @@ class Piwik_CoreAdminHome_Controller extends Piwik_Controller_Admin $nonce = Common::getRequestVar('nonce', false); $language = Common::getRequestVar('language', ''); - if ($nonce !== false && Piwik_Nonce::verifyNonce('Piwik_OptOut', $nonce)) { - Piwik_Nonce::discardNonce('Piwik_OptOut'); + if ($nonce !== false && Nonce::verifyNonce('Piwik_OptOut', $nonce)) { + Nonce::discardNonce('Piwik_OptOut'); Piwik_Tracker_IgnoreCookie::setIgnoreCookie(); $trackVisits = !$trackVisits; } - $view = new Piwik_View('@CoreAdminHome/optOut'); + $view = new View('@CoreAdminHome/optOut'); $view->trackVisits = $trackVisits; - $view->nonce = Piwik_Nonce::getNonce('Piwik_OptOut', 3600); + $view->nonce = Nonce::getNonce('Piwik_OptOut', 3600); $view->language = Piwik_LanguagesManager_API::getInstance()->isLanguageAvailable($language) ? $language : Piwik_LanguagesManager::getLanguageCodeForCurrentUser(); diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php index 39a4f08199..8b4aece240 100644 --- a/plugins/CoreAdminHome/CoreAdminHome.php +++ b/plugins/CoreAdminHome/CoreAdminHome.php @@ -12,6 +12,7 @@ use Piwik\DataAccess\ArchiveSelector; use Piwik\DataAccess\ArchiveTableCreator; use Piwik\Piwik; use Piwik\Date; +use Piwik\ScheduledTask; use Piwik\Plugin; /** @@ -36,19 +37,19 @@ class Piwik_CoreAdminHome extends Plugin public function getScheduledTasks(&$tasks) { // general data purge on older archive tables, executed daily - $purgeArchiveTablesTask = new Piwik_ScheduledTask ($this, + $purgeArchiveTablesTask = new ScheduledTask ($this, 'purgeOutdatedArchives', null, new Piwik_ScheduledTime_Daily(), - Piwik_ScheduledTask::HIGH_PRIORITY); + ScheduledTask::HIGH_PRIORITY); $tasks[] = $purgeArchiveTablesTask; // lowest priority since tables should be optimized after they are modified - $optimizeArchiveTableTask = new Piwik_ScheduledTask ($this, + $optimizeArchiveTableTask = new ScheduledTask ($this, 'optimizeArchiveTable', null, new Piwik_ScheduledTime_Daily(), - Piwik_ScheduledTask::LOWEST_PRIORITY); + ScheduledTask::LOWEST_PRIORITY); $tasks[] = $optimizeArchiveTableTask; } @@ -104,6 +105,6 @@ class Piwik_CoreAdminHome extends Plugin function optimizeArchiveTable() { $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); - Piwik_OptimizeTables($archiveTables); + Db::optimizeTables($archiveTables); } } diff --git a/plugins/CoreHome/Controller.php b/plugins/CoreHome/Controller.php index c95b5d61ce..8d52088cae 100644 --- a/plugins/CoreHome/Controller.php +++ b/plugins/CoreHome/Controller.php @@ -8,16 +8,23 @@ * @category Piwik_Plugins * @package Piwik_CoreHome */ +use Piwik\API\Request; use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\AssetManager; +use Piwik\Controller; +use Piwik\FrontController; +use Piwik\View; +use Piwik\Url; +use Piwik\UpdateCheck; use Piwik\Site; /** * * @package Piwik_CoreHome */ -class Piwik_CoreHome_Controller extends Piwik_Controller +class Piwik_CoreHome_Controller extends Controller { function getDefaultAction() { @@ -52,13 +59,13 @@ class Piwik_CoreHome_Controller extends Piwik_Controller throw new Exception("Preventing infinite recursion..."); } $view = $this->getDefaultIndexView(); - $view->content = Piwik_FrontController::getInstance()->fetchDispatch($controllerName, $actionName); + $view->content = FrontController::getInstance()->fetchDispatch($controllerName, $actionName); echo $view->render(); } protected function getDefaultIndexView() { - $view = new Piwik_View('@CoreHome/getDefaultIndexView'); + $view = new View('@CoreHome/getDefaultIndexView'); $this->setGeneralVariablesView($view); $view->menu = Piwik_GetMenu(); $view->content = ''; @@ -104,7 +111,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller */ public function getCss() { - $cssMergedFile = Piwik_AssetManager::getMergedCssFileLocation(); + $cssMergedFile = AssetManager::getMergedCssFileLocation(); Piwik::serveStaticFile($cssMergedFile, "text/css"); } @@ -116,7 +123,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller */ public function getJs() { - $jsMergedFile = Piwik_AssetManager::getMergedJsFileLocation(); + $jsMergedFile = AssetManager::getMergedJsFileLocation(); Piwik::serveStaticFile($jsMergedFile, "application/javascript; charset=UTF-8"); } @@ -140,7 +147,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller { $rowEvolution = $this->makeRowEvolution($isMulti = false); self::$rowEvolutionCache = $rowEvolution; - $view = new Piwik_View('@CoreHome/getRowEvolutionPopover'); + $view = new View('@CoreHome/getRowEvolutionPopover'); echo $rowEvolution->renderPopover($this, $view); } @@ -149,7 +156,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller { $rowEvolution = $this->makeRowEvolution($isMulti = true); self::$rowEvolutionCache = $rowEvolution; - $view = new Piwik_View('@CoreHome/getMultiRowEvolutionPopover'); + $view = new View('@CoreHome/getMultiRowEvolutionPopover'); echo $rowEvolution->renderPopover($this, $view); } @@ -191,9 +198,9 @@ class Piwik_CoreHome_Controller extends Piwik_Controller $this->checkTokenInUrl(); // perform check (but only once every 10s) - Piwik_UpdateCheck::check($force = false, Piwik_UpdateCheck::UI_CLICK_CHECK_INTERVAL); + UpdateCheck::check($force = false, UpdateCheck::UI_CLICK_CHECK_INTERVAL); - $view = new Piwik_View('@CoreHome/checkForUpdates'); + $view = new View('@CoreHome/checkForUpdates'); $this->setGeneralVariablesView($view); echo $view->render(); } @@ -203,7 +210,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller */ public function getDonateForm() { - $view = new Piwik_View('@CoreHome/getDonateForm'); + $view = new View('@CoreHome/getDonateForm'); if (Common::getRequestVar('widget', false) && Piwik::isUserIsSuperUser() ) { @@ -217,7 +224,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller */ public function getPromoVideo() { - $view = new Piwik_View('@CoreHome/getPromoVideo'); + $view = new View('@CoreHome/getPromoVideo'); $view->shareText = Piwik_Translate('CoreHome_SharePiwikShort'); $view->shareTextLong = Piwik_Translate('CoreHome_SharePiwikLong'); $view->promoVideoUrl = 'http://www.youtube.com/watch?v=OslfF_EH81g'; @@ -229,7 +236,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller */ public function redirectToPaypal() { - $parameters = Piwik_API_Request::getRequestArrayFromString($request = null); + $parameters = Request::getRequestArrayFromString($request = null); foreach ($parameters as $name => $param) { if ($name == 'idSite' || $name == 'module' @@ -239,7 +246,7 @@ class Piwik_CoreHome_Controller extends Piwik_Controller } } - $url = "https://www.paypal.com/cgi-bin/webscr?".Piwik_Url::getQueryStringFromParameters($parameters); + $url = "https://www.paypal.com/cgi-bin/webscr?".Url::getQueryStringFromParameters($parameters); header("Location: $url"); exit; diff --git a/plugins/CoreHome/CoreHome.php b/plugins/CoreHome/CoreHome.php index 56c4dbbfd2..d568007482 100644 --- a/plugins/CoreHome/CoreHome.php +++ b/plugins/CoreHome/CoreHome.php @@ -33,8 +33,8 @@ class Piwik_CoreHome extends Plugin */ public function addWidgets() { - Piwik_AddWidget('Example Widgets', 'CoreHome_SupportPiwik', 'CoreHome', 'getDonateForm'); - Piwik_AddWidget('Example Widgets', 'Installation_Welcome', 'CoreHome', 'getPromoVideo'); + WidgetsList::add('Example Widgets', 'CoreHome_SupportPiwik', 'CoreHome', 'getDonateForm'); + WidgetsList::add('Example Widgets', 'Installation_Welcome', 'CoreHome', 'getPromoVideo'); } public function getCssFiles(&$cssFiles) diff --git a/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php b/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php index e8625a2e07..bbfc80832f 100644 --- a/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php +++ b/plugins/CoreHome/DataTableRowAction/MultiRowEvolution.php @@ -9,6 +9,7 @@ * @package Piwik_CoreHome */ use Piwik\Common; +use Piwik\ViewDataTable; /** * MULTI ROW EVOLUTION @@ -76,7 +77,7 @@ class Piwik_CoreHome_DataTableRowAction_MultiRowEvolution * Generic method to get an evolution graph or a sparkline for the row evolution popover. * Do as much as possible from outside the controller. * - * @return Piwik_ViewDataTable + * @return ViewDataTable */ public function getRowEvolutionGraph() { diff --git a/plugins/CoreHome/DataTableRowAction/RowEvolution.php b/plugins/CoreHome/DataTableRowAction/RowEvolution.php index 3b3bea686c..694a64c641 100644 --- a/plugins/CoreHome/DataTableRowAction/RowEvolution.php +++ b/plugins/CoreHome/DataTableRowAction/RowEvolution.php @@ -8,9 +8,13 @@ * @category Piwik_Plugins * @package Piwik_CoreHome */ +use Piwik\API\ResponseBuilder; +use Piwik\API\Request; use Piwik\Common; use Piwik\Metrics; use Piwik\Date; +use Piwik\ViewDataTable; +use Piwik\Url; /** * ROW EVOLUTION @@ -78,7 +82,7 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution $this->apiMethod = Common::getRequestVar('apiMethod', '', 'string'); if (empty($this->apiMethod)) throw new Exception("Parameter apiMethod not set."); - $this->label = Piwik_API_ResponseBuilder::getLabelFromRequest($_GET); + $this->label = ResponseBuilder::getLabelFromRequest($_GET); $this->label = $this->label[0]; if ($this->label === '') throw new Exception("Parameter label not set."); @@ -95,7 +99,7 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution list($this->date, $lastN) = Piwik_ViewDataTable_GenerateGraphHTML_ChartEvolution::getDateRangeAndLastN($this->period, $end); } - $this->segment = Piwik_ViewDataTable::getRawSegmentFromRequest(); + $this->segment = ViewDataTable::getRawSegmentFromRequest(); $this->loadEvolutionReport(); } @@ -154,9 +158,9 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution $parameters['column'] = $column; } - $url = Piwik_Url::getQueryStringFromParameters($parameters); + $url = Url::getQueryStringFromParameters($parameters); - $request = new Piwik_API_Request($url); + $request = new Request($url); $report = $request->process(); $this->extractEvolutionReport($report); @@ -174,12 +178,12 @@ class Piwik_CoreHome_DataTableRowAction_RowEvolution /** * Generic method to get an evolution graph or a sparkline for the row evolution popover. * Do as much as possible from outside the controller. - * @return Piwik_ViewDataTable + * @return ViewDataTable */ public function getRowEvolutionGraph() { // set up the view data table - $view = Piwik_ViewDataTable::factory($this->graphType); + $view = ViewDataTable::factory($this->graphType); $view->setDataTable($this->dataTable); $view->init('CoreHome', 'getRowEvolutionGraph', $this->apiMethod); diff --git a/plugins/CoreHome/javascripts/datatable_rowactions.js b/plugins/CoreHome/javascripts/datatable_rowactions.js index 5aea12e4b1..233fa34683 100644 --- a/plugins/CoreHome/javascripts/datatable_rowactions.js +++ b/plugins/CoreHome/javascripts/datatable_rowactions.js @@ -164,7 +164,7 @@ DataTable_RowAction.prototype.trigger = function (tr, e, subTableLabel) { label = label.trim(); // if we have received the event from the sub table, add the label if (subTableLabel) { - var separator = ' > '; // Piwik_API_DataTableManipulator_LabelFilter::SEPARATOR_RECURSIVE_LABEL + var separator = ' > '; // LabelFilter::SEPARATOR_RECURSIVE_LABEL label += separator + subTableLabel.trim(); } diff --git a/plugins/CoreHome/templates/_siteSelect.twig b/plugins/CoreHome/templates/_siteSelect.twig index 80d337828b..e78b93b0bd 100644 --- a/plugins/CoreHome/templates/_siteSelect.twig +++ b/plugins/CoreHome/templates/_siteSelect.twig @@ -4,14 +4,14 @@ * - allSitesItemText The text to use for the 'All Websites' option. Default = 'All Websites'. * - allWebsitesLinkLocation The location of the 'All Websites' option. Can be 'top' or 'bottom'. Default = 'bottom'. * - showSelectedSite false if the currently selected site should be excluded from the list of sites. Default = false. - * - sites The list of sites to use. By default, the first N sites are used. They are retrieved in Piwik_View. + * - sites The list of sites to use. By default, the first N sites are used. They are retrieved in View. * - show_autocompleter Whether to show the autocompleter or not. Default true. * - switchSiteOnSelect Whether to change the page w/ a new idSite value when a site is selected, or not. * Default = true. * - inputName If set, a hidden <input> w/ name == $inputName is created which will hold the selected site's ID. For * use with <form> elements. - * - siteName The currently selected site name. Defaults to the first name in $sites set by Piwik_View. - * - idSite The currently selected idSite. Defaults to the first id in $sites set by Piwik_View. + * - siteName The currently selected site name. Defaults to the first name in $sites set by View. + * - idSite The currently selected idSite. Defaults to the first id in $sites set by View. #} {% set sitesSelector_allWebsitesLink %} <div class="custom_select_all" style="clear: both"> diff --git a/plugins/CorePluginsAdmin/Controller.php b/plugins/CorePluginsAdmin/Controller.php index ff0900073e..c1156cce99 100644 --- a/plugins/CorePluginsAdmin/Controller.php +++ b/plugins/CorePluginsAdmin/Controller.php @@ -8,15 +8,18 @@ * @category Piwik_Plugins * @package Piwik_CorePluginsAdmin */ +use Piwik\Controller\Admin; use Piwik\Piwik; use Piwik\Common; use Piwik\Config; +use Piwik\View; +use Piwik\Url; /** * * @package Piwik_CorePluginsAdmin */ -class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin +class Piwik_CorePluginsAdmin_Controller extends Admin { function extend() { @@ -41,7 +44,7 @@ class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin protected function configureView($template) { Piwik::checkUserIsSuperUser(); - $view = new Piwik_View($template); + $view = new View($template); $this->setBasicVariablesView($view); $this->displayWarningIfConfigFileNotWritable($view); return $view; @@ -115,7 +118,7 @@ class Piwik_CorePluginsAdmin_Controller extends Piwik_Controller_Admin protected function redirectAfterModification($redirectAfter) { if ($redirectAfter) { - Piwik_Url::redirectToReferer(); + Url::redirectToReferer(); } } diff --git a/plugins/CoreUpdater/Controller.php b/plugins/CoreUpdater/Controller.php index 11e0c9c7d1..8d427b9813 100644 --- a/plugins/CoreUpdater/Controller.php +++ b/plugins/CoreUpdater/Controller.php @@ -8,16 +8,24 @@ * @category Piwik_Plugins * @package Piwik_CoreUpdater */ +use Piwik\API\Request; use Piwik\ArchiveProcessor\Rules; use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\Http; +use Piwik\Piwik_Updater; +use Piwik\View; +use Piwik\Version; +use Piwik\UpdateCheck; +use Piwik\Unzip; /** * * @package Piwik_CoreUpdater */ -class Piwik_CoreUpdater_Controller extends Piwik_Controller +class Piwik_CoreUpdater_Controller extends Controller { const CONFIG_FILE_BACKUP = '/config/global.ini.auto-backup-before-update.php'; const PATH_TO_EXTRACT_LATEST_VERSION = '/tmp/latest/'; @@ -41,8 +49,8 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller $newVersion = $this->checkNewVersionIsAvailableOrDie(); - $view = new Piwik_View('@CoreUpdater/newVersionAvailable'); - $view->piwik_version = Piwik_Version::VERSION; + $view = new View('@CoreUpdater/newVersionAvailable'); + $view->piwik_version = Version::VERSION; $view->piwik_new_version = $newVersion; $view->piwik_latest_version_url = self::getLatestZipUrl($newVersion); $view->can_auto_update = Piwik::canAutoUpdate(); @@ -90,10 +98,10 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller public function oneClickResults() { - Piwik_API_Request::reloadAuthUsingTokenAuth($_POST); + Request::reloadAuthUsingTokenAuth($_POST); Piwik::checkUserIsSuperUser(); - $view = new Piwik_View('@CoreUpdater/oneClickResults'); + $view = new View('@CoreUpdater/oneClickResults'); $view->coreError = Common::getRequestVar('error', '', 'string', $_POST); $view->feedbackMessages = safe_unserialize(Common::unsanitizeInputValue(Common::getRequestVar('messages', '', 'string', $_POST))); echo $view->render(); @@ -101,9 +109,9 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller private function checkNewVersionIsAvailableOrDie() { - $newVersion = Piwik_UpdateCheck::isNewestVersionAvailable(); + $newVersion = UpdateCheck::isNewestVersionAvailable(); if (!$newVersion) { - throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionAlreadyLatestVersion', Piwik_Version::VERSION)); + throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionAlreadyLatestVersion', Version::VERSION)); } return $newVersion; } @@ -115,7 +123,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller // we catch exceptions in the caller (i.e., oneClickUpdate) $url = self::getLatestZipUrl($this->newVersion) . '?cb=' . $this->newVersion; - $fetched = Piwik_Http::fetchRemoteFile($url, $this->pathPiwikZip); + $fetched = Http::fetchRemoteFile($url, $this->pathPiwikZip); } private function oneClick_Unpack() @@ -127,7 +135,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller Piwik::unlinkRecursive($this->pathRootExtractedPiwik, true); } - $archive = Piwik_Unzip::factory('PclZip', $this->pathPiwikZip); + $archive = Unzip::factory('PclZip', $this->pathPiwikZip); if (0 == ($archive_files = $archive->extract($pathExtracted))) { throw new Exception(Piwik_TranslateException('CoreUpdater_ExceptionArchiveIncompatible', $archive->errorInfo())); @@ -241,8 +249,8 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller $cli = Common::isPhpCliMode() ? '_cli' : ''; $welcomeTemplate = '@CoreUpdater/runUpdaterAndExit_welcome' . $cli; $doneTemplate = '@CoreUpdater/runUpdaterAndExit_done' . $cli; - $viewWelcome = new Piwik_View($welcomeTemplate); - $viewDone = new Piwik_View($doneTemplate); + $viewWelcome = new View($welcomeTemplate); + $viewDone = new View($doneTemplate); $sqlQueries = $updater->getSqlQueriesToExecute(); if (Common::isPhpCliMode()) { @@ -274,7 +282,7 @@ class Piwik_CoreUpdater_Controller extends Piwik_Controller private function doWelcomeUpdates($view, $componentsWithUpdateFile) { - $view->new_piwik_version = Piwik_Version::VERSION; + $view->new_piwik_version = Version::VERSION; $view->commandUpgradePiwik = "<br /><code>php " . Common::getPathToPiwikRoot() . "/index.php -- \"module=CoreUpdater\" </code>"; $pluginNamesToUpdate = array(); $coreToUpdate = false; diff --git a/plugins/CoreUpdater/CoreUpdater.php b/plugins/CoreUpdater/CoreUpdater.php index 99c7e4029d..b682a705d5 100644 --- a/plugins/CoreUpdater/CoreUpdater.php +++ b/plugins/CoreUpdater/CoreUpdater.php @@ -10,6 +10,10 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\FrontController; +use Piwik\Piwik_Updater; +use Piwik\Version; +use Piwik\UpdateCheck; use Piwik\Plugin; /** @@ -32,7 +36,7 @@ class Piwik_CoreUpdater extends Plugin public static function getComponentUpdates(Piwik_Updater $updater) { - $updater->addComponentToCheck('core', Piwik_Version::VERSION); + $updater->addComponentToCheck('core', Version::VERSION); $plugins = \Piwik\PluginsManager::getInstance()->getLoadedPlugins(); foreach ($plugins as $pluginName => $plugin) { $updater->addComponentToCheck($pluginName, $plugin->getVersion()); @@ -52,7 +56,7 @@ class Piwik_CoreUpdater extends Plugin $action = Common::getRequestVar('action', '', 'string'); $updater = new Piwik_Updater(); - $updater->addComponentToCheck('core', Piwik_Version::VERSION); + $updater->addComponentToCheck('core', Version::VERSION); $updates = $updater->getComponentsWithNewVersion(); if (!empty($updates)) { Piwik::deleteAllCacheOnUpdate(); @@ -64,7 +68,7 @@ class Piwik_CoreUpdater extends Plugin && !($module == 'LanguagesManager' && $action == 'saveLanguage') ) { - if (Piwik_FrontController::shouldRethrowException()) { + if (FrontController::shouldRethrowException()) { throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n". "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n"); } else { @@ -75,6 +79,6 @@ class Piwik_CoreUpdater extends Plugin public function updateCheck() { - Piwik_UpdateCheck::check(); + UpdateCheck::check(); } } diff --git a/plugins/CustomVariables/Archiver.php b/plugins/CustomVariables/Archiver.php index 654cf22835..198f7a8889 100644 --- a/plugins/CustomVariables/Archiver.php +++ b/plugins/CustomVariables/Archiver.php @@ -3,6 +3,8 @@ use Piwik\Common; use Piwik\Config; use Piwik\DataAccess\LogAggregator; use Piwik\Metrics; +use Piwik\DataArray; +use Piwik\Tracker; use Piwik\PluginsArchiver; /** @@ -21,7 +23,7 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver const CUSTOM_VARIABLE_RECORD_NAME = 'CustomVariables_valueByName'; /** - * @var Piwik_DataArray + * @var DataArray */ protected $dataArray; protected $maximumRowsInDataTableLevelZero; @@ -37,9 +39,9 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver public function archiveDay() { - $this->dataArray = new Piwik_DataArray(); + $this->dataArray = new DataArray(); - for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { + for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) { $this->aggregateCustomVariable($i); } @@ -190,7 +192,7 @@ class Piwik_CustomVariables_Archiver extends PluginsArchiver $dataArray = &$this->dataArray->getDataArray(); foreach ($dataArray as $key => &$row) { if (!self::isReservedKey($key) - && Piwik_DataArray::isRowActions($row) + && DataArray::isRowActions($row) ) { unset($row[Metrics::INDEX_NB_UNIQ_VISITORS]); unset($row[Metrics::INDEX_NB_VISITS]); diff --git a/plugins/CustomVariables/Controller.php b/plugins/CustomVariables/Controller.php index 867988a79b..6c6054f418 100644 --- a/plugins/CustomVariables/Controller.php +++ b/plugins/CustomVariables/Controller.php @@ -8,22 +8,25 @@ * @category Piwik_Plugins * @package Piwik_CustomVariables */ +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * @package Piwik_CustomVariables */ -class Piwik_CustomVariables_Controller extends Piwik_Controller +class Piwik_CustomVariables_Controller extends Controller { public function index($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('CustomVariables_CustomVariables'), $this->getCustomVariables(true), $fetch); } public function getCustomVariables($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, "CustomVariables.getCustomVariables", "getCustomVariablesValuesFromNameId"); $this->setPeriodVariablesView($view); @@ -39,7 +42,7 @@ class Piwik_CustomVariables_Controller extends Piwik_Controller public function getCustomVariablesValuesFromNameId($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'CustomVariables.getCustomVariablesValuesFromNameId'); $this->configureView($view); diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php index 971a967b8e..362d453aa2 100644 --- a/plugins/CustomVariables/CustomVariables.php +++ b/plugins/CustomVariables/CustomVariables.php @@ -9,6 +9,7 @@ * @package Piwik_CustomVariables */ use Piwik\ArchiveProcessor; +use Piwik\Tracker; use Piwik\Plugin; /** @@ -42,7 +43,7 @@ class Piwik_CustomVariables extends Plugin public function addWidgets() { - Piwik_AddWidget('General_Visitors', 'CustomVariables_CustomVariables', 'CustomVariables', 'getCustomVariables'); + WidgetsList::add('General_Visitors', 'CustomVariables_CustomVariables', 'CustomVariables', 'getCustomVariables'); } public function addMenus() @@ -79,7 +80,7 @@ class Piwik_CustomVariables extends Plugin public function getSegmentsMetadata(&$segments) { - for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { + for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) { $segments[] = array( 'type' => 'dimension', 'category' => 'CustomVariables_CustomVariables', diff --git a/plugins/DBStats/Controller.php b/plugins/DBStats/Controller.php index 7596dc4106..8194c29cc4 100644 --- a/plugins/DBStats/Controller.php +++ b/plugins/DBStats/Controller.php @@ -8,13 +8,16 @@ * @category Piwik_Plugins * @package Piwik_DBStats */ +use Piwik\Controller\Admin; use Piwik\Piwik; +use Piwik\ViewDataTable; +use Piwik\View; /** * * @package Piwik_DBStats */ -class Piwik_DBStats_Controller extends Piwik_Controller_Admin +class Piwik_DBStats_Controller extends Admin { /** * Returns the index for this plugin. Shows every other report defined by this plugin, @@ -26,7 +29,7 @@ class Piwik_DBStats_Controller extends Piwik_Controller_Admin public function index() { Piwik::checkUserIsSuperUser(); - $view = new Piwik_View('@DBStats/index'); + $view = new View('@DBStats/index'); $this->setBasicVariablesView($view); $view->databaseUsageSummary = $this->getDatabaseUsageSummary(true); @@ -248,7 +251,7 @@ class Piwik_DBStats_Controller extends Piwik_Controller_Admin 'estimated_size' => Piwik_Translate('DBStats_EstimatedSize') ); - $view = Piwik_ViewDataTable::factory($viewType); + $view = ViewDataTable::factory($viewType); $view->init($this->pluginName, $function, "DBStats.$function"); $view->setSortedColumn('label', $orderDir); $view->setLimit($limit); diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php index 770e00f0ed..955c0b6812 100644 --- a/plugins/DBStats/DBStats.php +++ b/plugins/DBStats/DBStats.php @@ -10,6 +10,7 @@ */ use Piwik\Piwik; use Piwik\Date; +use Piwik\ScheduledTask; use Piwik\Plugin; /** @@ -45,12 +46,12 @@ class Piwik_DBStats extends Plugin */ public function getScheduledTasks(&$tasks) { - $cacheDataByArchiveNameReportsTask = new Piwik_ScheduledTask( + $cacheDataByArchiveNameReportsTask = new ScheduledTask( $this, 'cacheDataByArchiveNameReports', null, new Piwik_ScheduledTime_Weekly(), - Piwik_ScheduledTask::LOWEST_PRIORITY + ScheduledTask::LOWEST_PRIORITY ); $tasks[] = $cacheDataByArchiveNameReportsTask; } diff --git a/plugins/DBStats/MySQLMetadataProvider.php b/plugins/DBStats/MySQLMetadataProvider.php index c7701e6023..c21f6f6009 100755 --- a/plugins/DBStats/MySQLMetadataProvider.php +++ b/plugins/DBStats/MySQLMetadataProvider.php @@ -51,7 +51,7 @@ class Piwik_DBStats_MySQLMetadataProvider mysql_close($link); $status = explode(" ", $status); } else { - $fullStatus = Piwik_FetchAssoc('SHOW STATUS'); + $fullStatus = Db::fetchAssoc('SHOW STATUS'); if (empty($fullStatus)) { throw new Exception('Error, SHOW STATUS failed'); } @@ -86,7 +86,7 @@ class Piwik_DBStats_MySQLMetadataProvider if (!is_null($this->tableStatuses) && isset($this->tableStatuses[$prefixed])) { return $this->tableStatuses[$prefixed]; } else { - return Piwik_FetchRow("SHOW TABLE STATUS LIKE ?", array($prefixed)); + return Db::fetchRow("SHOW TABLE STATUS LIKE ?", array($prefixed)); } } @@ -105,7 +105,7 @@ class Piwik_DBStats_MySQLMetadataProvider $tablesPiwik = Piwik::getTablesInstalled(); $this->tableStatuses = array(); - foreach (Piwik_FetchAll("SHOW TABLE STATUS") as $t) { + foreach (Db::fetchAll("SHOW TABLE STATUS") as $t) { if (in_array($t['Name'], $tablesPiwik)) { $this->tableStatuses[$t['Name']] = $t; } @@ -232,7 +232,7 @@ class Piwik_DBStats_MySQLMetadataProvider $sql = "SELECT name as 'label', COUNT(*) as 'row_count'$extraCols FROM {$status['Name']} GROUP BY name"; $table = new DataTable(); - $table->addRowsFromSimpleArray(Piwik_FetchAll($sql)); + $table->addRowsFromSimpleArray(Db::fetchAll($sql)); $reduceArchiveRowName = array($this, 'reduceArchiveRowName'); $table->filter('GroupBy', array('label', $reduceArchiveRowName)); @@ -275,7 +275,7 @@ class Piwik_DBStats_MySQLMetadataProvider static $fixedSizeColumnLength = null; if (is_null($fixedSizeColumnLength)) { $fixedSizeColumnLength = 0; - foreach (Piwik_FetchAll("SHOW COLUMNS FROM " . $status['Name']) as $column) { + foreach (Db::fetchAll("SHOW COLUMNS FROM " . $status['Name']) as $column) { $columnType = $column['Type']; if (($paren = strpos($columnType, '(')) !== false) { diff --git a/plugins/Dashboard/API.php b/plugins/Dashboard/API.php index 83a5c0b804..b3231c7bdc 100644 --- a/plugins/Dashboard/API.php +++ b/plugins/Dashboard/API.php @@ -155,7 +155,7 @@ class Piwik_Dashboard_API $module = $widget->parameters->module; $action = $widget->parameters->action; - return Piwik_IsWidgetDefined($module, $action); + return WidgetsList::isDefined($module, $action); } private function widgetIsNotHidden($widget) diff --git a/plugins/Dashboard/Controller.php b/plugins/Dashboard/Controller.php index 0f6cca6d00..c3743500b1 100644 --- a/plugins/Dashboard/Controller.php +++ b/plugins/Dashboard/Controller.php @@ -10,13 +10,15 @@ use Piwik\DataTable\Renderer\Json; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * Dashboard Controller * * @package Piwik_Dashboard */ -class Piwik_Dashboard_Controller extends Piwik_Controller +class Piwik_Dashboard_Controller extends Controller { /** * @var Piwik_Dashboard @@ -32,10 +34,10 @@ class Piwik_Dashboard_Controller extends Piwik_Controller protected function _getDashboardView($template) { - $view = new Piwik_View($template); + $view = new View($template); $this->setGeneralVariablesView($view); - $view->availableWidgets = Common::json_encode(Piwik_GetWidgetsList()); + $view->availableWidgets = Common::json_encode(WidgetsList::get()); $view->availableLayouts = $this->getAvailableLayouts(); $view->dashboardId = Common::getRequestVar('idDashboard', 1, 'int'); @@ -68,7 +70,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller $this->checkTokenInUrl(); Json::sendHeaderJSON(); - echo Common::json_encode(Piwik_GetWidgetsList()); + echo Common::json_encode(WidgetsList::get()); } public function getDashboardLayout() @@ -111,7 +113,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller $paramsBind = array($login, $idDashboard, $layout, $layout); $query = sprintf('INSERT INTO %s (login, iddashboard, layout) VALUES (?,?,?) ON DUPLICATE KEY UPDATE layout=?', Common::prefixTable('user_dashboard')); - Piwik_Query($query, $paramsBind); + Db::query($query, $paramsBind); } /** @@ -126,7 +128,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller $paramsBind = array($name, $login, $idDashboard); $query = sprintf('UPDATE %s SET name = ? WHERE login = ? AND iddashboard = ?', Common::prefixTable('user_dashboard')); - Piwik_Query($query, $paramsBind); + Db::query($query, $paramsBind); } /** @@ -146,7 +148,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller if ($idDashboard != 1) { $query = sprintf('DELETE FROM %s WHERE iddashboard = ? AND login = ?', Common::prefixTable('user_dashboard')); - Piwik_Query($query, array($idDashboard, Piwik::getCurrentUserLogin())); + Db::query($query, array($idDashboard, Piwik::getCurrentUserLogin())); } } @@ -196,7 +198,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller $query = sprintf('INSERT INTO %s (login, iddashboard, name, layout) VALUES (?, ?, ?, ?)', Common::prefixTable('user_dashboard')); - Piwik_Query($query, array($user, $nextId, $name, $layout)); + Db::query($query, array($user, $nextId, $name, $layout)); Json::sendHeaderJSON(); echo Common::json_encode($nextId); @@ -206,7 +208,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller { $nextIdQuery = sprintf('SELECT MAX(iddashboard)+1 FROM %s WHERE login = ?', Common::prefixTable('user_dashboard')); - $nextId = Piwik_FetchOne($nextIdQuery, array($login)); + $nextId = Db::fetchOne($nextIdQuery, array($login)); if (empty($nextId)) { $nextId = 1; @@ -234,7 +236,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller $query = sprintf('INSERT INTO %s (login, iddashboard, name, layout) VALUES (?, ?, ?, ?)', Common::prefixTable('user_dashboard')); - Piwik_Query($query, array($user, $nextId, $name, $layout)); + Db::query($query, array($user, $nextId, $name, $layout)); Json::sendHeaderJSON(); echo Common::json_encode($nextId); @@ -278,7 +280,7 @@ class Piwik_Dashboard_Controller extends Piwik_Controller $paramsBind = array('', '1', $layout, $layout); $query = sprintf('INSERT INTO %s (login, iddashboard, layout) VALUES (?,?,?) ON DUPLICATE KEY UPDATE layout=?', Common::prefixTable('user_dashboard')); - Piwik_Query($query, $paramsBind); + Db::query($query, $paramsBind); } } diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index 25fb766226..c019a49573 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -46,7 +46,7 @@ class Piwik_Dashboard extends Plugin $paramsBind = array($login, $idDashboard); $query = sprintf('SELECT layout FROM %s WHERE login = ? AND iddashboard = ?', Common::prefixTable('user_dashboard')); - $return = Piwik_FetchAll($query, $paramsBind); + $return = Db::fetchAll($query, $paramsBind); if (count($return) == 0) { return false; @@ -96,7 +96,7 @@ class Piwik_Dashboard extends Plugin public function getAllDashboards($login) { - $dashboards = Piwik_FetchAll('SELECT iddashboard, name, layout + $dashboards = Db::fetchAll('SELECT iddashboard, name, layout FROM ' . Common::prefixTable('user_dashboard') . ' WHERE login = ? ORDER BY iddashboard', array($login)); @@ -161,7 +161,7 @@ class Piwik_Dashboard extends Plugin if (isset($widget->parameters->module)) { $controllerName = $widget->parameters->module; $controllerAction = $widget->parameters->action; - if (!Piwik_IsWidgetDefined($controllerName, $controllerAction)) { + if (!WidgetsList::isDefined($controllerName, $controllerAction)) { unset($row[$widgetId]); } } else { @@ -240,7 +240,7 @@ class Piwik_Dashboard extends Plugin public function deleteDashboardLayout($userLogin) { - Piwik_Query('DELETE FROM ' . Common::prefixTable('user_dashboard') . ' WHERE login = ?', array($userLogin)); + Db::query('DELETE FROM ' . Common::prefixTable('user_dashboard') . ' WHERE login = ?', array($userLogin)); } public function install() @@ -254,7 +254,7 @@ class Piwik_Dashboard extends Plugin layout TEXT NOT NULL, PRIMARY KEY ( login , iddashboard ) ) DEFAULT CHARSET=utf8 "; - Piwik_Exec($sql); + Db::exec($sql); } catch (Exception $e) { // mysql code error 1050:table already exists // see bug #153 http://dev.piwik.org/trac/ticket/153 @@ -266,6 +266,6 @@ class Piwik_Dashboard extends Plugin public function uninstall() { - Piwik_DropTables(Common::prefixTable('user_dashboard')); + Db::dropTables(Common::prefixTable('user_dashboard')); } } diff --git a/plugins/DevicesDetection/Controller.php b/plugins/DevicesDetection/Controller.php index ae94f95375..d9b0136b77 100644 --- a/plugins/DevicesDetection/Controller.php +++ b/plugins/DevicesDetection/Controller.php @@ -1,6 +1,9 @@ <?php use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * Piwik - Open source web analytics @@ -11,7 +14,7 @@ use Piwik\Common; * @category Piwik_Plugins * @package Piwik_DevicesDetection */ -class Piwik_DevicesDetection_Controller extends Piwik_Controller +class Piwik_DevicesDetection_Controller extends Controller { /** The set of related reports displayed under the 'Operating Systems' header. */ @@ -33,7 +36,7 @@ class Piwik_DevicesDetection_Controller extends Piwik_Controller public function index($fetch = false) { - $view = new Piwik_View('@DevicesDetection/index'); + $view = new View('@DevicesDetection/index'); $view->deviceTypes = $view->deviceModels = $view->deviceBrands = $view->osReport = $view->browserReport = "blank"; $view->deviceTypes = $this->getType(true); $view->deviceBrands = $this->getBrand(true); @@ -120,7 +123,7 @@ class Piwik_DevicesDetection_Controller extends Piwik_Controller protected function getStandardDataTableUserSettings($currentControllerAction, $APItoCall, $defaultDatatableType = null) { - $view = Piwik_ViewDataTable::factory($defaultDatatableType); + $view = ViewDataTable::factory($defaultDatatableType); $view->init($this->pluginName, $currentControllerAction, $APItoCall); $view->disableSearchBox(); $view->disableExcludeLowPopulation(); @@ -136,7 +139,7 @@ class Piwik_DevicesDetection_Controller extends Piwik_Controller { Piwik::checkUserIsSuperUser(); $q = "SELECT idvisit, config_debug_ua FROM " . Common::prefixTable("log_visit"); - $res = Piwik_FetchAll($q); + $res = Db::fetchAll($q); foreach ($res as $rec) { $UAParser = new UserAgentParserEnhanced($rec['config_debug_ua']); $UAParser->parse(); @@ -174,7 +177,7 @@ class Piwik_DevicesDetection_Controller extends Piwik_Controller "config_device_model = " . (isset($uaDetails['config_device_model']) ? "'" . $uaDetails['config_device_model'] . "'" : "NULL") . " ," . "config_device_brand = " . (isset($uaDetails['config_device_brand']) ? "'" . $uaDetails['config_device_brand'] . "'" : "NULL") . " WHERE idvisit = " . $idVisit; - Piwik_Query($q); + Db::query($q); } } diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index 7129ee581b..f70fba50fa 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -130,7 +130,7 @@ class Piwik_DevicesDetection extends Plugin list($category, $name, $controllerName, $controllerAction) = $report; if ($category == false) continue; - Piwik_AddWidget($category, $name, $controllerName, $controllerAction); + WidgetsList::add($category, $name, $controllerName, $controllerAction); } } @@ -194,12 +194,12 @@ class Piwik_DevicesDetection extends Plugin ADD `config_device_type` TINYINT( 10 ) NULL DEFAULT NULL AFTER `config_browser_version` , ADD `config_device_brand` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_type` , ADD `config_device_model` VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_brand`"; - Piwik_Exec($q1); + Db::exec($q1); // conditionaly add this column if (@Config::getInstance()->Debug['store_user_agent_in_visit']) { $q2 = "ALTER TABLE `" . Common::prefixTable("log_visit") . "` ADD `config_debug_ua` VARCHAR( 512 ) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL AFTER `config_device_model`"; - Piwik_Exec($q2); + Db::exec($q2); } } catch (Exception $e) { if (!Zend_Registry::get('db')->isErrNo($e, '1060')) { diff --git a/plugins/ExampleAPI/API.php b/plugins/ExampleAPI/API.php index d4a0febccf..214d73eac5 100644 --- a/plugins/ExampleAPI/API.php +++ b/plugins/ExampleAPI/API.php @@ -11,6 +11,7 @@ use Piwik\DataTable\Row; use Piwik\Piwik; use Piwik\DataTable; +use Piwik\Version; /** * The ExampleAPI is useful to developers building a custom Piwik plugin. @@ -61,7 +62,7 @@ class Piwik_ExampleAPI_API public function getPiwikVersion() { Piwik::checkUserHasSomeViewAccess(); - return Piwik_Version::VERSION; + return Version::VERSION; } /** diff --git a/plugins/ExamplePlugin/Controller.php b/plugins/ExamplePlugin/Controller.php index 3e6c557130..0bebd89e57 100644 --- a/plugins/ExamplePlugin/Controller.php +++ b/plugins/ExamplePlugin/Controller.php @@ -10,12 +10,14 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * * @package Piwik_ExamplePlugin */ -class Piwik_ExamplePlugin_Controller extends Piwik_Controller +class Piwik_ExamplePlugin_Controller extends Controller { /** * Go to /piwik/?module=ExamplePlugin&action=helloWorld to execute this method @@ -54,7 +56,7 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller */ public function piwikDownloads() { - $view = new Piwik_View('@ExamplePlugin/piwikDownloads'); + $view = new View('@ExamplePlugin/piwikDownloads'); $this->setGeneralVariablesView($view); echo $view->render(); } @@ -81,7 +83,7 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller $out .= '<h3>Misc</h3>'; $out .= '<code>Piwik_AddMenu( $mainMenuName, $subMenuName, $url );</code> - Adds an entry to the menu in the Piwik interface (See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L76">UserCountry Plugin file</a>)<br />'; - $out .= '<code>Piwik_AddWidget( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L70">UserCountry Plugin file</a> or any other plugin)<br />'; + $out .= '<code>WidgetsList::add( $widgetCategory, $widgetName, $controllerName, $controllerAction, $customParameters = array());</code> - Adds a widget that users can add in the dashboard, or export using the Widgets link at the top of the screen. See the example in the <a href="https://github.com/piwik/piwik/blob/1.0/plugins/UserCountry/UserCountry.php#L70">UserCountry Plugin file</a> or any other plugin)<br />'; $out .= '<code>Common::prefixTable("site")</code> = <b>' . Common::prefixTable("site") . '</b><br />'; @@ -94,15 +96,15 @@ class Piwik_ExamplePlugin_Controller extends Piwik_Controller $out .= '<h2>Execute SQL queries</h2>'; $txtQuery = "SELECT token_auth FROM " . Common::prefixTable('user') . " WHERE login = ?"; - $result = Piwik_FetchOne($txtQuery, array('anonymous')); - $out .= '<code>Piwik_FetchOne("' . $txtQuery . '", array("anonymous"))</code> = <b>' . var_export($result, true) . '</b><br />'; + $result = Db::fetchOne($txtQuery, array('anonymous')); + $out .= '<code>Db::fetchOne("' . $txtQuery . '", array("anonymous"))</code> = <b>' . var_export($result, true) . '</b><br />'; $out .= '<br />'; - $query = Piwik_Query($txtQuery, array('anonymous')); + $query = Db::query($txtQuery, array('anonymous')); $fetched = $query->fetch(); $token_auth = $fetched['token_auth']; - $out .= '<code>$query = Piwik_Query("' . $txtQuery . '", array("anonymous"))</code><br />'; + $out .= '<code>$query = Db::query("' . $txtQuery . '", array("anonymous"))</code><br />'; $out .= '<code>$fetched = $query->fetch();</code><br />'; $out .= 'At this point, we have: <code>$fetched[\'token_auth\'] == <b>' . var_export($token_auth, true) . '</b></code><br />'; diff --git a/plugins/ExamplePlugin/ExamplePlugin.php b/plugins/ExamplePlugin/ExamplePlugin.php index 7fc7a2cc09..bb7c968452 100644 --- a/plugins/ExamplePlugin/ExamplePlugin.php +++ b/plugins/ExamplePlugin/ExamplePlugin.php @@ -51,8 +51,8 @@ class Piwik_ExamplePlugin extends Plugin { // we register the widgets so they appear in the "Add a new widget" window in the dashboard // Note that the first two parameters can be either a normal string, or an index to a translation string - Piwik_AddWidget('ExamplePlugin_exampleWidgets', 'ExamplePlugin_exampleWidget', 'ExamplePlugin', 'exampleWidget'); - Piwik_AddWidget('ExamplePlugin_exampleWidgets', 'ExamplePlugin_photostreamMatt', 'ExamplePlugin', 'photostreamMatt'); - Piwik_AddWidget('ExamplePlugin_exampleWidgets', 'ExamplePlugin_piwikForumVisits', 'ExamplePlugin', 'piwikDownloads'); + WidgetsList::add('ExamplePlugin_exampleWidgets', 'ExamplePlugin_exampleWidget', 'ExamplePlugin', 'exampleWidget'); + WidgetsList::add('ExamplePlugin_exampleWidgets', 'ExamplePlugin_photostreamMatt', 'ExamplePlugin', 'photostreamMatt'); + WidgetsList::add('ExamplePlugin_exampleWidgets', 'ExamplePlugin_piwikForumVisits', 'ExamplePlugin', 'piwikDownloads'); } } diff --git a/plugins/ExampleRssWidget/Controller.php b/plugins/ExampleRssWidget/Controller.php index 41e6691f9d..aaa53a7ef1 100644 --- a/plugins/ExampleRssWidget/Controller.php +++ b/plugins/ExampleRssWidget/Controller.php @@ -8,12 +8,13 @@ * @category Piwik_Plugins * @package Piwik_ExampleRssWidget */ +use Piwik\Controller; /** * * @package Piwik_ExampleRssWidget */ -class Piwik_ExampleRssWidget_Controller extends Piwik_Controller +class Piwik_ExampleRssWidget_Controller extends Controller { public function rssPiwik() { diff --git a/plugins/ExampleRssWidget/ExampleRssWidget.php b/plugins/ExampleRssWidget/ExampleRssWidget.php index 72831e6d0b..a0f7b33dca 100644 --- a/plugins/ExampleRssWidget/ExampleRssWidget.php +++ b/plugins/ExampleRssWidget/ExampleRssWidget.php @@ -34,7 +34,7 @@ class Piwik_ExampleRssWidget extends Plugin public function addWidgets() { - Piwik_AddWidget('Example Widgets', 'Piwik.org Blog', 'ExampleRssWidget', 'rssPiwik'); - Piwik_AddWidget('Example Widgets', 'Piwik Changelog', 'ExampleRssWidget', 'rssChangelog'); + WidgetsList::add('Example Widgets', 'Piwik.org Blog', 'ExampleRssWidget', 'rssPiwik'); + WidgetsList::add('Example Widgets', 'Piwik Changelog', 'ExampleRssWidget', 'rssChangelog'); } } diff --git a/plugins/ExampleUI/API.php b/plugins/ExampleUI/API.php index 5857ef112b..3730c54eba 100644 --- a/plugins/ExampleUI/API.php +++ b/plugins/ExampleUI/API.php @@ -44,7 +44,7 @@ class Piwik_ExampleUI_API AND date < ? GROUP BY date ORDER BY date ASC"; - //$result = Piwik_FetchAll($query, array($dateStart, $dateEnd)); + //$result = Db::fetchAll($query, array($dateStart, $dateEnd)); // to keep things simple, we generate the data foreach ($period->getSubperiods() as $subPeriod) { $server1 = mt_rand(50, 90); diff --git a/plugins/ExampleUI/Controller.php b/plugins/ExampleUI/Controller.php index 5ee8ffddd7..ffb9342830 100644 --- a/plugins/ExampleUI/Controller.php +++ b/plugins/ExampleUI/Controller.php @@ -9,15 +9,18 @@ * @package Piwik_ExampleUI */ use Piwik\Common; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * @package Piwik_ExampleUI */ -class Piwik_ExampleUI_Controller extends Piwik_Controller +class Piwik_ExampleUI_Controller extends Controller { function dataTables() { - $view = Piwik_ViewDataTable::factory('table'); + $view = ViewDataTable::factory('table'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getTemperatures'); $view->setColumnTranslation('value', "Temperature in °C"); $view->setColumnTranslation('label', "Hour of day"); @@ -39,7 +42,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function echoEvolutionGraph() { - $view = Piwik_ViewDataTable::factory('graphEvolution'); + $view = ViewDataTable::factory('graphEvolution'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getTemperaturesEvolution'); $view->setColumnTranslation('server1', "Temperature server piwik.org"); $view->setColumnTranslation('server2', "Temperature server dev.piwik.org"); @@ -49,7 +52,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function barGraph() { - $view = Piwik_ViewDataTable::factory('graphVerticalBar'); + $view = ViewDataTable::factory('graphVerticalBar'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getTemperatures'); $view->setColumnTranslation('value', "Temperature"); $view->setAxisYUnit('°C'); @@ -60,7 +63,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function pieGraph() { - $view = Piwik_ViewDataTable::factory('graphPie'); + $view = ViewDataTable::factory('graphPie'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getPlanetRatios'); $view->setColumnsToDisplay('value'); $view->setColumnTranslation('value', "times the diameter of Earth"); @@ -84,7 +87,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function echoSimpleTagClouds() { - $view = Piwik_ViewDataTable::factory('cloud'); + $view = ViewDataTable::factory('cloud'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getPlanetRatios'); $view->setColumnsToDisplay(array('label', 'value')); $view->setColumnTranslation('value', "times the diameter of Earth"); @@ -94,7 +97,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function echoAdvancedTagClouds() { - $view = Piwik_ViewDataTable::factory('cloud'); + $view = ViewDataTable::factory('cloud'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getPlanetRatiosWithLogos'); $view->setDisplayLogoInTagCloud(true); $view->disableFooterExceptExportIcons(); @@ -105,7 +108,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function sparklines() { - $view = new Piwik_View('@ExampleUI/sparklines'); + $view = new View('@ExampleUI/sparklines'); $view->urlSparkline1 = $this->getUrlSparkline('generateSparkline', array('server' => 'server1', 'rand' => mt_rand())); $view->urlSparkline2 = $this->getUrlSparkline('generateSparkline', array('server' => 'server2', 'rand' => mt_rand())); echo $view->render(); @@ -114,7 +117,7 @@ class Piwik_ExampleUI_Controller extends Piwik_Controller function generateSparkline() { $serverRequested = Common::getRequestVar('server', ''); - $view = Piwik_ViewDataTable::factory('sparkline'); + $view = ViewDataTable::factory('sparkline'); $view->init($this->pluginName, __FUNCTION__, 'ExampleUI.getTemperaturesEvolution'); $view->setColumnsToDisplay($serverRequested); $this->renderView($view); diff --git a/plugins/Feedback/Controller.php b/plugins/Feedback/Controller.php index 243a36bacd..3a43559d6f 100644 --- a/plugins/Feedback/Controller.php +++ b/plugins/Feedback/Controller.php @@ -11,17 +11,24 @@ use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\IP; +use Piwik\Mail; +use Piwik\Nonce; +use Piwik\View; +use Piwik\Version; +use Piwik\Url; /** * * @package Piwik_Feedback */ -class Piwik_Feedback_Controller extends Piwik_Controller +class Piwik_Feedback_Controller extends Controller { function index() { - $view = new Piwik_View('@Feedback/index'); - $view->nonce = Piwik_Nonce::getNonce('Piwik_Feedback.sendFeedback', 3600); + $view = new View('@Feedback/index'); + $view->nonce = Nonce::getNonce('Piwik_Feedback.sendFeedback', 3600); echo $view->render(); } @@ -36,7 +43,7 @@ class Piwik_Feedback_Controller extends Piwik_Controller $category = Common::getRequestVar('category', '', 'string'); $nonce = Common::getRequestVar('nonce', '', 'string'); - $view = new Piwik_View('@Feedback/sendFeedback'); + $view = new View('@Feedback/sendFeedback'); $view->feedbackEmailAddress = Config::getInstance()->General['feedback_email_address']; try { $minimumBodyLength = 40; @@ -53,19 +60,19 @@ class Piwik_Feedback_Controller extends Piwik_Controller if (preg_match('/https?:/i', $body)) { throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls')); } - if (!Piwik_Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) { + if (!Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) { throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch')); } - Piwik_Nonce::discardNonce('Piwik_Feedback.sendFeedback'); + Nonce::discardNonce('Piwik_Feedback.sendFeedback'); - $mail = new Piwik_Mail(); + $mail = new Mail(); $mail->setFrom(Common::unsanitizeInputValue($email)); $mail->addTo($view->feedbackEmailAddress, 'Piwik Team'); $mail->setSubject('[ Feedback form - Piwik ] ' . $category); $mail->setBodyText(Common::unsanitizeInputValue($body) . "\n" - . 'Piwik ' . Piwik_Version::VERSION . "\n" - . 'IP: ' . Piwik_IP::getIpFromHeader() . "\n" - . 'URL: ' . Piwik_Url::getReferer() . "\n"); + . 'Piwik ' . Version::VERSION . "\n" + . 'IP: ' . IP::getIpFromHeader() . "\n" + . 'URL: ' . Url::getReferer() . "\n"); @$mail->send(); } catch (Exception $e) { $view->errorString = $e->getMessage(); diff --git a/plugins/Goals/API.php b/plugins/Goals/API.php index db754b3bb3..2f5be105ba 100644 --- a/plugins/Goals/API.php +++ b/plugins/Goals/API.php @@ -65,7 +65,7 @@ class Piwik_Goals_API return array(); } Piwik::checkUserHasViewAccess($idSite); - $goals = Piwik_FetchAll("SELECT * + $goals = Db::fetchAll("SELECT * FROM " . Common::prefixTable('goal') . " WHERE idsite IN (" . implode(", ", $idSite) . ") AND deleted = 0"); @@ -194,12 +194,12 @@ class Piwik_Goals_API public function deleteGoal($idSite, $idGoal) { Piwik::checkUserHasAdminAccess($idSite); - Piwik_Query("UPDATE " . Common::prefixTable('goal') . " + Db::query("UPDATE " . Common::prefixTable('goal') . " SET deleted = 1 WHERE idsite = ? AND idgoal = ?", array($idSite, $idGoal)); - Piwik_DeleteAllRows(Common::prefixTable("log_conversion"), "WHERE idgoal = ?", 100000, array($idGoal)); + Db::deleteAllRows(Common::prefixTable("log_conversion"), "WHERE idgoal = ?", 100000, array($idGoal)); Piwik_Tracker_Cache::regenerateCacheWebsiteAttributes($idSite); } diff --git a/plugins/Goals/Archiver.php b/plugins/Goals/Archiver.php index 96792174c1..000de7d136 100644 --- a/plugins/Goals/Archiver.php +++ b/plugins/Goals/Archiver.php @@ -12,6 +12,7 @@ use Piwik\DataAccess\LogAggregator; use Piwik\Metrics; use Piwik\DataTable; +use Piwik\DataArray; use Piwik\PluginsArchiver; class Piwik_Goals_Archiver extends PluginsArchiver @@ -108,7 +109,7 @@ class Piwik_Goals_Archiver extends PluginsArchiver } $totalConversions = $totalRevenue = 0; - $goals = new Piwik_DataArray(); + $goals = new DataArray(); $visitsToConversions = $daysToConversions = array(); $conversionMetrics = $this->getLogAggregator()->getConversionsMetricFields(); @@ -161,7 +162,7 @@ class Piwik_Goals_Archiver extends PluginsArchiver $this->getProcessor()->insertNumericRecords($metrics); } - protected function getConversionsNumericMetrics(Piwik_DataArray $goals) + protected function getConversionsNumericMetrics(DataArray $goals) { $numericRecords = array(); $goals = $goals->getDataArray(); @@ -246,14 +247,14 @@ class Piwik_Goals_Archiver extends PluginsArchiver { foreach ($this->getEcommerceIdGoals() as $ecommerceType) { foreach ($this->dimensionRecord as $dimension => $record) { - $this->itemReports[$dimension][$ecommerceType] = new Piwik_DataArray(); + $this->itemReports[$dimension][$ecommerceType] = new DataArray(); } } } protected function recordItemReports() { - /** @var Piwik_DataArray $array */ + /** @var DataArray $array */ foreach ($this->itemReports as $dimension => $itemAggregatesByType) { foreach ($itemAggregatesByType as $ecommerceType => $itemAggregate) { $recordName = $this->dimensionRecord[$dimension]; diff --git a/plugins/Goals/Controller.php b/plugins/Goals/Controller.php index 64ab750b6b..953f73cf51 100644 --- a/plugins/Goals/Controller.php +++ b/plugins/Goals/Controller.php @@ -8,16 +8,21 @@ * @category Piwik_Plugins * @package Piwik_Goals */ +use Piwik\API\Request; use Piwik\DataTable\Filter\AddColumnsProcessedMetricsGoal; use Piwik\Piwik; use Piwik\Common; use Piwik\DataTable; +use Piwik\Controller; +use Piwik\FrontController; +use Piwik\ViewDataTable; +use Piwik\View; /** * * @package Piwik_Goals */ -class Piwik_Goals_Controller extends Piwik_Controller +class Piwik_Goals_Controller extends Controller { const CONVERSION_RATE_PRECISION = 1; @@ -92,14 +97,14 @@ class Piwik_Goals_Controller extends Piwik_Controller $_GET['filterEcommerce'] = Common::getRequestVar('filterEcommerce', 1, 'int'); $_GET['widget'] = 1; $_GET['segment'] = 'visitEcommerceStatus!=none'; - $output = Piwik_FrontController::getInstance()->dispatch('Live', 'getVisitorLog', array($fetch)); + $output = FrontController::getInstance()->dispatch('Live', 'getVisitorLog', array($fetch)); $_GET = $saveGET; return $output; } protected function getGoalReportView($idGoal = false) { - $view = new Piwik_View('@Goals/getGoalReportView'); + $view = new View('@Goals/getGoalReportView'); if ($idGoal == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER) { $goalDefinition['name'] = Piwik_Translate('Goals_Ecommerce'); $goalDefinition['allow_multiple'] = true; @@ -171,7 +176,7 @@ class Piwik_Goals_Controller extends Piwik_Controller protected function getOverviewView() { - $view = new Piwik_View('@Goals/getOverviewView'); + $view = new View('@Goals/getOverviewView'); $this->setGeneralVariablesView($view); $view->graphEvolution = $this->getEvolutionGraph(true, array('nb_conversions')); @@ -183,7 +188,7 @@ class Piwik_Goals_Controller extends Piwik_Controller $view->urlSparklineRevenue = $this->getUrlSparkline('getEvolutionGraph', array('columns' => array('revenue'), 'idGoal' => '')); // Pass empty idGoal will return Goal overview - $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal="); + $request = new Request("method=Goals.get&format=original&idGoal="); $datatable = $request->process(); $dataRow = $datatable->getFirstRow(); $view->nb_conversions = $dataRow->getColumn('nb_conversions'); @@ -225,7 +230,7 @@ class Piwik_Goals_Controller extends Piwik_Controller public function addNewGoal() { - $view = new Piwik_View('@Goals/addNewGoal'); + $view = new View('@Goals/addNewGoal'); $this->setGeneralVariablesView($view); $view->userCanEditGoals = Piwik::isUserHasAdminAccess($this->idSite); $view->onlyShowAddNewGoal = true; @@ -312,7 +317,7 @@ class Piwik_Goals_Controller extends Piwik_Controller } $topDimensions = array(); foreach ($topDimensionsToLoad as $dimensionName => $apiMethod) { - $request = new Piwik_API_Request("method=$apiMethod + $request = new Request("method=$apiMethod &format=original &filter_update_columns_when_show_all_goals=1 &idGoal=" . AddColumnsProcessedMetricsGoal::GOALS_FULL_TABLE . " @@ -348,7 +353,7 @@ class Piwik_Goals_Controller extends Piwik_Controller protected function getMetricsForGoal($idGoal) { - $request = new Piwik_API_Request("method=Goals.get&format=original&idGoal=$idGoal"); + $request = new Request("method=Goals.get&format=original&idGoal=$idGoal"); $datatable = $request->process(); $dataRow = $datatable->getFirstRow(); $nbConversions = $dataRow->getColumn('nb_conversions'); @@ -454,26 +459,26 @@ class Piwik_Goals_Controller extends Piwik_Controller public function getItemsSku($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getItemsName($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getItemsCategory($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getVisitsUntilConversion($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getDaysToConversion($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } } diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index cd9857e3fd..a12ce89280 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -11,6 +11,7 @@ use Piwik\ArchiveProcessor; use Piwik\Piwik; use Piwik\Common; +use Piwik\TranslationWriter; use Piwik\Plugin; use Piwik\Site; @@ -102,7 +103,7 @@ class Piwik_Goals extends Plugin */ function deleteSiteGoals($idSite) { - Piwik_Query("DELETE FROM " . Common::prefixTable('goal') . " WHERE idsite = ? ", array($idSite)); + Db::query("DELETE FROM " . Common::prefixTable('goal') . " WHERE idsite = ? ", array($idSite)); } /** @@ -418,19 +419,19 @@ class Piwik_Goals extends Plugin // Ecommerce widgets $site = new Site($idSite); if ($site->isEcommerceEnabled()) { - Piwik_AddWidget('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)); - Piwik_AddWidget('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog'); + WidgetsList::add('Goals_Ecommerce', 'Goals_EcommerceOverview', 'Goals', 'widgetGoalReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)); + WidgetsList::add('Goals_Ecommerce', 'Goals_EcommerceLog', 'Goals', 'getEcommerceLog'); foreach ($this->ecommerceReports as $widget) { - Piwik_AddWidget('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]); + WidgetsList::add('Goals_Ecommerce', $widget[0], $widget[1], $widget[2]); } } // Goals widgets - Piwik_AddWidget('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview'); + WidgetsList::add('Goals_Goals', 'Goals_GoalsOverview', 'Goals', 'widgetGoalsOverview'); $goals = Piwik_Goals_API::getInstance()->getGoals($idSite); if (count($goals) > 0) { foreach ($goals as $goal) { - Piwik_AddWidget('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal'])); + WidgetsList::add('Goals_Goals', Common::sanitizeInputValue($goal['name']), 'Goals', 'widgetGoalReport', array('idGoal' => $goal['idgoal'])); } } } @@ -465,7 +466,7 @@ class Piwik_Goals extends Plugin } Piwik_AddMenu($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); foreach ($goals as $goal) { - Piwik_AddMenu($mainGoalMenu, str_replace('%', '%%', Piwik_TranslationWriter::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal'])); + Piwik_AddMenu($mainGoalMenu, str_replace('%', '%%', TranslationWriter::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal'])); } } } diff --git a/plugins/ImageGraph/API.php b/plugins/ImageGraph/API.php index b2811772f0..dafd9d9399 100644 --- a/plugins/ImageGraph/API.php +++ b/plugins/ImageGraph/API.php @@ -283,7 +283,7 @@ class Piwik_ImageGraph_API $plottedMetric = reset($ordinateColumns); // when no labels are specified, getRowEvolution returns the top N=filter_limit row evolutions - // rows are sorted using filter_sort_column (see Piwik_API_DataTableGenericFilter for more info) + // rows are sorted using filter_sort_column (see DataTableGenericFilter for more info) if (!$labels) { $savedFilterSortColumnValue = Common::getRequestVar('filter_sort_column', ''); $_GET['filter_sort_column'] = $plottedMetric; diff --git a/plugins/ImageGraph/Controller.php b/plugins/ImageGraph/Controller.php index cd7700ef23..a36d520b8e 100644 --- a/plugins/ImageGraph/Controller.php +++ b/plugins/ImageGraph/Controller.php @@ -1,6 +1,8 @@ <?php use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * Piwik - Open source web analytics @@ -12,7 +14,7 @@ use Piwik\Common; * @package Piwik_ImageGraph */ -class Piwik_ImageGraph_Controller extends Piwik_Controller +class Piwik_ImageGraph_Controller extends Controller { // Call metadata reports, and draw the default graph for each report. public function index() @@ -34,7 +36,7 @@ class Piwik_ImageGraph_Controller extends Piwik_Controller ); } } - $view = new Piwik_View('@ImageGraph/index'); + $view = new View('@ImageGraph/index'); $view->titleAndUrls = $plot; echo $view->render(); } @@ -44,7 +46,7 @@ class Piwik_ImageGraph_Controller extends Piwik_Controller { Piwik::checkUserIsSuperUser(); - $view = new Piwik_View('@ImageGraph/testAllSizes'); + $view = new View('@ImageGraph/testAllSizes'); $this->setGeneralVariablesView($view); $period = Common::getRequestVar('period', 'day', 'string'); diff --git a/plugins/ImageGraph/ImageGraph.php b/plugins/ImageGraph/ImageGraph.php index 3a2f56bb58..6181877fb7 100644 --- a/plugins/ImageGraph/ImageGraph.php +++ b/plugins/ImageGraph/ImageGraph.php @@ -1,6 +1,8 @@ <?php use Piwik\Common; use Piwik\Period; +use Piwik\Controller; +use Piwik\Url; use Piwik\Plugin; use Piwik\Site; use Piwik\Config; @@ -28,7 +30,7 @@ class Piwik_ImageGraph extends Plugin public function getInformation() { - $suffix = ' Debug: <a href="' . Piwik_Url::getCurrentQueryStringWithParametersModified( + $suffix = ' Debug: <a href="' . Url::getCurrentQueryStringWithParametersModified( array('module' => 'ImageGraph', 'action' => 'index')) . '">All images</a>'; $info = parent::getInformation(); $info['description'] .= ' ' . $suffix; @@ -90,7 +92,7 @@ class Piwik_ImageGraph extends Plugin $dateForMultiplePeriodGraph = $dateForSinglePeriodGraph; } else { $periodForMultiplePeriodGraph = $periodForSinglePeriodGraph; - $dateForMultiplePeriodGraph = Piwik_Controller::getDateRangeRelativeToEndDate( + $dateForMultiplePeriodGraph = Controller::getDateRangeRelativeToEndDate( $periodForSinglePeriodGraph, 'last' . self::GRAPH_EVOLUTION_LAST_PERIODS, $dateForSinglePeriodGraph, @@ -135,7 +137,7 @@ class Piwik_ImageGraph extends Plugin $parameters['idSubtable'] = $idSubtable; } - $report['imageGraphUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters); + $report['imageGraphUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters); // thanks to API.getRowEvolution, reports with dimensions can now be plotted using an evolution graph // however, most reports with a fixed set of dimension values are excluded @@ -148,7 +150,7 @@ class Piwik_ImageGraph extends Plugin && $reportWithDimensionsSupportsEvolution) { $parameters['period'] = $periodForMultiplePeriodGraph; $parameters['date'] = $dateForMultiplePeriodGraph; - $report['imageGraphEvolutionUrl'] = $urlPrefix . Piwik_Url::getQueryStringFromParameters($parameters); + $report['imageGraphEvolutionUrl'] = $urlPrefix . Url::getQueryStringFromParameters($parameters); } } } diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php index 5fcfcbe39a..f661b3dd98 100644 --- a/plugins/Installation/Controller.php +++ b/plugins/Installation/Controller.php @@ -8,18 +8,27 @@ * @category Piwik_Plugins * @package Piwik_Installation */ +use Piwik\API\Request; +use Piwik\Controller\Admin; use Piwik\DataAccess\ArchiveTableCreator; +use Piwik\Db\Adapter; use Piwik\Piwik; use Piwik\Config; use Piwik\Common; use Piwik\Access; +use Piwik\Http; +use Piwik\Piwik_Updater; +use Piwik\View; +use Piwik\Version; +use Piwik\Url; +use Piwik\ProxyHeaders; /** * Installation controller * * @package Piwik_Installation */ -class Piwik_Installation_Controller extends Piwik_Controller_Admin +class Piwik_Installation_Controller extends Admin { // public so plugins can add/delete installation steps public $steps = array( @@ -286,7 +295,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin Piwik::createAnonymousUser(); $updater = new Piwik_Updater(); - $updater->recordComponentSuccessfullyUpdated('core', Piwik_Version::VERSION); + $updater->recordComponentSuccessfullyUpdated('core', Version::VERSION); $view->tablesCreated = true; $view->showNextStep = true; } @@ -327,7 +336,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin 'email' => $form->getSubmitValue('email'), 'security' => $form->getSubmitValue('subscribe_newsletter_security'), 'community' => $form->getSubmitValue('subscribe_newsletter_community'), - 'url' => Piwik_Url::getCurrentUrlWithoutQueryString(), + 'url' => Url::getCurrentUrlWithoutQueryString(), ); if ($params['security'] == '1' || $params['community'] == '1' @@ -340,7 +349,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin } $url .= '?' . http_build_query($params, '', '&'); try { - Piwik_Http::sendHttpRequest($url, $timeout = 2); + Http::sendHttpRequest($url, $timeout = 2); } catch (Exception $e) { // e.g., disable_functions = fsockopen; allow_url_open = Off } @@ -378,7 +387,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $url = urlencode($form->getSubmitValue('url')); $ecommerce = (int)$form->getSubmitValue('ecommerce'); - $request = new Piwik_API_Request(" + $request = new Request(" method=SitesManager.addSite &siteName=$name &urls=$url @@ -425,11 +434,11 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $idSite = $this->session->site_idSite; // Load the Tracking code and help text from the SitesManager - $viewTrackingHelp = new Piwik_View('@SitesManager/_displayJavascriptCode'); + $viewTrackingHelp = new View('@SitesManager/_displayJavascriptCode'); $viewTrackingHelp->displaySiteName = $siteName; - $viewTrackingHelp->jsTag = Piwik::getJavascriptCode($idSite, Piwik_Url::getCurrentUrlWithoutFileName()); + $viewTrackingHelp->jsTag = Piwik::getJavascriptCode($idSite, Url::getCurrentUrlWithoutFileName()); $viewTrackingHelp->idSite = $idSite; - $viewTrackingHelp->piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName(); + $viewTrackingHelp->piwikUrl = Url::getCurrentUrlWithoutFileName(); $view->trackingHelp = $viewTrackingHelp->render(); $view->displaySiteName = $siteName; @@ -478,7 +487,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin { Piwik::checkUserIsSuperUser(); - $view = new Piwik_View('@Installation/systemCheckPage'); + $view = new View('@Installation/systemCheckPage'); $this->setBasicVariablesView($view); $view->duringInstall = false; @@ -501,7 +510,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $this->createDbFromSessionInformation(); Piwik::setUserIsSuperUser(); - Piwik::createLogObject(); + \Piwik\Log::make(); } /** @@ -552,7 +561,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin { $language = Common::getRequestVar('language'); Piwik_LanguagesManager::setLanguageForSession($language); - Piwik_Url::redirectToReferer(); + Url::redirectToReferer(); } /** @@ -594,7 +603,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $message = Piwik_Translate('Installation_ErrorInvalidState', array('<br /><b>', '</b>', - '<a href=\'' . Common::sanitizeInputValue(Piwik_Url::getCurrentUrlWithoutFileName()) . '\'>', + '<a href=\'' . Common::sanitizeInputValue(Url::getCurrentUrlWithoutFileName()) . '\'>', '</a>') ); Piwik::exitWithErrorMessage($message); @@ -653,7 +662,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $trustedHosts = array(); // extract host from the request header - if (($host = $this->extractHost('http://' . Piwik_Url::getHost())) !== false) { + if (($host = $this->extractHost('http://' . Url::getHost())) !== false) { $trustedHosts[] = $host; } @@ -733,7 +742,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $infos['pdo_ok'] = true; } - $infos['adapters'] = Piwik_Db_Adapter::getAdapters(); + $infos['adapters'] = Adapter::getAdapters(); $needed_functions = array( 'debug_backtrace', @@ -780,7 +789,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin } } - $infos['openurl'] = Piwik_Http::getTransportMethod(); + $infos['openurl'] = Http::getTransportMethod(); $infos['gd_ok'] = Piwik::isGdExtensionEnabled(); @@ -827,14 +836,14 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin $infos['tracker_status'] = Common::getRequestVar('trackerStatus', 0, 'int'); - $infos['protocol'] = Piwik_ProxyHeaders::getProtocolInformation(); + $infos['protocol'] = ProxyHeaders::getProtocolInformation(); if (!Piwik::isHttps() && $infos['protocol'] !== null) { $infos['general_infos']['assume_secure_protocol'] = '1'; } - if (count($headers = Piwik_ProxyHeaders::getProxyClientHeaders()) > 0) { + if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) { $infos['general_infos']['proxy_client_headers'] = $headers; } - if (count($headers = Piwik_ProxyHeaders::getProxyHostHeaders()) > 0) { + if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) { $infos['general_infos']['proxy_host_headers'] = $headers; } @@ -902,7 +911,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin /** * Utility function, sets up a view that will display system check info. * - * @param Piwik_View $view + * @param View $view */ private function setupSystemCheckView($view) { @@ -967,7 +976,7 @@ class Piwik_Installation_Controller extends Piwik_Controller_Admin } // delete the temporary rows that were created - Piwik_Exec("DELETE FROM `$optionTable` WHERE option_name IN ('" . implode("','", $testOptionNames) . "')"); + Db::exec("DELETE FROM `$optionTable` WHERE option_name IN ('" . implode("','", $testOptionNames) . "')"); return $result; } diff --git a/plugins/Installation/FormDatabaseSetup.php b/plugins/Installation/FormDatabaseSetup.php index d10f3b5a49..8939ace24e 100644 --- a/plugins/Installation/FormDatabaseSetup.php +++ b/plugins/Installation/FormDatabaseSetup.php @@ -8,14 +8,16 @@ * @category Piwik_Plugins * @package Piwik_Installation */ +use Piwik\Db\Adapter; use Piwik\Piwik; use Piwik\Common; +use Piwik\QuickForm2; /** * * @package Piwik_Installation */ -class Piwik_Installation_FormDatabaseSetup extends Piwik_QuickForm2 +class Piwik_Installation_FormDatabaseSetup extends QuickForm2 { function __construct($id = 'databasesetupform', $method = 'post', $attributes = null, $trackSubmit = false) { @@ -29,7 +31,7 @@ class Piwik_Installation_FormDatabaseSetup extends Piwik_QuickForm2 $checkUserPrivilegesClass = 'Piwik_Installation_FormDatabaseSetup_Rule_checkUserPrivileges'; HTML_QuickForm2_Factory::registerRule('checkUserPrivileges', $checkUserPrivilegesClass); - $availableAdapters = Piwik_Db_Adapter::getAdapters(); + $availableAdapters = Adapter::getAdapters(); $adapters = array(); foreach ($availableAdapters as $adapter => $port) { $adapters[$adapter] = $adapter; @@ -88,7 +90,7 @@ class Piwik_Installation_FormDatabaseSetup extends Piwik_QuickForm2 } $adapter = $this->getSubmitValue('adapter'); - $port = Piwik_Db_Adapter::getDefaultPortForAdapter($adapter); + $port = Adapter::getDefaultPortForAdapter($adapter); $dbInfos = array( 'host' => $this->getSubmitValue('host'), @@ -113,7 +115,7 @@ class Piwik_Installation_FormDatabaseSetup extends Piwik_QuickForm2 try { @Piwik::createDatabaseObject($dbInfos); } catch (Zend_Db_Adapter_Exception $e) { - $db = Piwik_Db_Adapter::factory($adapter, $dbInfos, $connect = false); + $db = Adapter::factory($adapter, $dbInfos, $connect = false); // database not found, we try to create it if ($db->isErrNo($e, '1049')) { diff --git a/plugins/Installation/FormFirstWebsiteSetup.php b/plugins/Installation/FormFirstWebsiteSetup.php index d44151f1b5..31c3e4cf4a 100644 --- a/plugins/Installation/FormFirstWebsiteSetup.php +++ b/plugins/Installation/FormFirstWebsiteSetup.php @@ -8,12 +8,13 @@ * @category Piwik_Plugins * @package Piwik_Installation */ +use Piwik\QuickForm2; /** * * @package Piwik_Installation */ -class Piwik_Installation_FormFirstWebsiteSetup extends Piwik_QuickForm2 +class Piwik_Installation_FormFirstWebsiteSetup extends QuickForm2 { function __construct($id = 'websitesetupform', $method = 'post', $attributes = null, $trackSubmit = false) { diff --git a/plugins/Installation/FormGeneralSetup.php b/plugins/Installation/FormGeneralSetup.php index 23f1dbce94..bd2504588a 100644 --- a/plugins/Installation/FormGeneralSetup.php +++ b/plugins/Installation/FormGeneralSetup.php @@ -9,12 +9,13 @@ * @package Piwik_Installation */ use Piwik\Piwik; +use Piwik\QuickForm2; /** * * @package Piwik_Installation */ -class Piwik_Installation_FormGeneralSetup extends Piwik_QuickForm2 +class Piwik_Installation_FormGeneralSetup extends QuickForm2 { function __construct($id = 'generalsetupform', $method = 'post', $attributes = null, $trackSubmit = false) { diff --git a/plugins/Installation/View.php b/plugins/Installation/View.php index e2db289eb1..84a8d631cf 100644 --- a/plugins/Installation/View.php +++ b/plugins/Installation/View.php @@ -8,12 +8,13 @@ * @category Piwik_Plugins * @package Piwik_Installation */ +use Piwik\View; /** * * @package Piwik_Installation */ -class Piwik_Installation_View extends Piwik_View +class Piwik_Installation_View extends View { public function __construct($subtemplatePath, $installationSteps, $currentStepName) { diff --git a/plugins/LanguagesManager/API.php b/plugins/LanguagesManager/API.php index bda2419908..d42d5cdfc4 100644 --- a/plugins/LanguagesManager/API.php +++ b/plugins/LanguagesManager/API.php @@ -161,7 +161,7 @@ class Piwik_LanguagesManager_API { Piwik::checkUserIsSuperUserOrTheUser($login); Piwik::checkUserIsNotAnonymous(); - return Piwik_FetchOne('SELECT language FROM ' . Common::prefixTable('user_language') . + return Db::fetchOne('SELECT language FROM ' . Common::prefixTable('user_language') . ' WHERE login = ? ', array($login)); } @@ -180,7 +180,7 @@ class Piwik_LanguagesManager_API return false; } $paramsBind = array($login, $languageCode, $languageCode); - Piwik_Query('INSERT INTO ' . Common::prefixTable('user_language') . + Db::query('INSERT INTO ' . Common::prefixTable('user_language') . ' (login, language) VALUES (?,?) ON DUPLICATE KEY UPDATE language=?', diff --git a/plugins/LanguagesManager/Controller.php b/plugins/LanguagesManager/Controller.php index 6685b511e4..212293ce79 100644 --- a/plugins/LanguagesManager/Controller.php +++ b/plugins/LanguagesManager/Controller.php @@ -11,11 +11,13 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\Url; /** * @package Piwik_LanguagesManager */ -class Piwik_LanguagesManager_Controller extends Piwik_Controller +class Piwik_LanguagesManager_Controller extends Controller { /** * anonymous = in the session @@ -36,6 +38,6 @@ class Piwik_LanguagesManager_Controller extends Piwik_Controller Piwik_LanguagesManager_API::getInstance()->setLanguageForUser($currentUser, $language); } } - Piwik_Url::redirectToReferer(); + Url::redirectToReferer(); } } diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index 1d0bc24ed9..5b848784bd 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -12,6 +12,8 @@ use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Cookie; +use Piwik\View; use Piwik\Plugin; use Piwik\Translate; @@ -71,7 +73,7 @@ class Piwik_LanguagesManager extends Plugin */ private function getLanguagesSelector() { - $view = new Piwik_View("@LanguagesManager/getLanguagesSelector"); + $view = new View("@LanguagesManager/getLanguagesSelector"); $view->languages = Piwik_LanguagesManager_API::getInstance()->getAvailableLanguageNames(); $view->currentLanguageCode = self::getLanguageCodeForCurrentUser(); $view->currentLanguageName = self::getLanguageNameForCurrentUser(); @@ -90,7 +92,7 @@ class Piwik_LanguagesManager extends Plugin public function deleteUserLanguage($userLogin) { - Piwik_Query('DELETE FROM ' . Common::prefixTable('user_language') . ' WHERE login = ?', $userLogin); + Db::query('DELETE FROM ' . Common::prefixTable('user_language') . ' WHERE login = ?', $userLogin); } /** @@ -105,7 +107,7 @@ class Piwik_LanguagesManager extends Plugin language VARCHAR( 10 ) NOT NULL , PRIMARY KEY ( login ) ) DEFAULT CHARSET=utf8 "; - Piwik_Exec($sql); + Db::exec($sql); } catch (Exception $e) { // mysql code error 1050:table already exists // see bug #153 http://dev.piwik.org/trac/ticket/153 @@ -120,7 +122,7 @@ class Piwik_LanguagesManager extends Plugin */ public function uninstall() { - Piwik_DropTables(Common::prefixTable('user_language')); + Db::dropTables(Common::prefixTable('user_language')); } /** @@ -178,7 +180,7 @@ class Piwik_LanguagesManager extends Plugin static public function getLanguageForSession() { $cookieName = Config::getInstance()->General['language_cookie_name']; - $cookie = new Piwik_Cookie($cookieName); + $cookie = new Cookie($cookieName); if ($cookie->isCookieFound()) { return $cookie->get('language'); } @@ -198,7 +200,7 @@ class Piwik_LanguagesManager extends Plugin } $cookieName = Config::getInstance()->General['language_cookie_name']; - $cookie = new Piwik_Cookie($cookieName, 0); + $cookie = new Cookie($cookieName, 0); $cookie->set('language', $languageCode); $cookie->save(); } diff --git a/plugins/Live/API.php b/plugins/Live/API.php index 8a739a0b17..4fd3ab3b91 100644 --- a/plugins/Live/API.php +++ b/plugins/Live/API.php @@ -18,6 +18,7 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Date; use Piwik\DataTable; +use Piwik\Tracker; use Piwik\Segment; use Piwik\Site; @@ -93,7 +94,7 @@ class Piwik_Live_API $segment = new Segment($segment, $idSite); $query = $segment->getSelectQuery($select, $from, $where, $bind); - $data = Piwik_FetchAll($query['sql'], $query['bind']); + $data = Db::fetchAll($query['sql'], $query['bind']); // These could be unset for some reasons, ensure they are set to 0 if (empty($data[0]['actions'])) { @@ -416,7 +417,7 @@ class Piwik_Live_API ORDER BY $orderByParent "; try { - $data = Piwik_FetchAll($sql, $subQuery['bind']); + $data = Db::fetchAll($sql, $subQuery['bind']); } catch (Exception $e) { echo $e->getMessage(); exit; @@ -458,7 +459,7 @@ class Piwik_Live_API $idVisit = $visitorDetailsArray['idVisit']; $sqlCustomVariables = ''; - for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { + for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) { $sqlCustomVariables .= ', custom_var_k' . $i . ', custom_var_v' . $i; } // The second join is a LEFT join to allow returning records that don't have a matching page title @@ -484,12 +485,12 @@ class Piwik_Live_API ORDER BY server_time ASC LIMIT 0, $actionsLimit "; - $actionDetails = Piwik_FetchAll($sql, array($idVisit)); + $actionDetails = Db::fetchAll($sql, array($idVisit)); foreach ($actionDetails as $actionIdx => &$actionDetail) { $actionDetail =& $actionDetails[$actionIdx]; $customVariablesPage = array(); - for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { + for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) { if (!empty($actionDetail['custom_var_k' . $i])) { $cvarKey = $actionDetail['custom_var_k' . $i]; $cvarKey = $this->getCustomVariablePrettyKey($cvarKey); @@ -551,7 +552,7 @@ class Piwik_Live_API ORDER BY server_time ASC LIMIT 0, $actionsLimit "; - $goalDetails = Piwik_FetchAll($sql, array($idVisit)); + $goalDetails = Db::fetchAll($sql, array($idVisit)); $sql = "SELECT case idgoal when " . Piwik_Tracker_GoalManager::IDGOAL_CART . " then '" . Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART . "' else '" . Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER . "' end as type, @@ -569,7 +570,7 @@ class Piwik_Live_API AND idgoal <= " . Piwik_Tracker_GoalManager::IDGOAL_ORDER . " ORDER BY server_time ASC LIMIT 0, $actionsLimit"; - $ecommerceDetails = Piwik_FetchAll($sql, array($idVisit)); + $ecommerceDetails = Db::fetchAll($sql, array($idVisit)); foreach ($ecommerceDetails as &$ecommerceDetail) { if ($ecommerceDetail['type'] == Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_CART) { @@ -616,7 +617,7 @@ class Piwik_Live_API : Piwik_Tracker_GoalManager::ITEM_IDORDER_ABANDONED_CART ); - $itemsDetails = Piwik_FetchAll($sql, $bind); + $itemsDetails = Db::fetchAll($sql, $bind); foreach ($itemsDetails as &$detail) { if ($detail['price'] == round($detail['price'])) { $detail['price'] = round($detail['price']); diff --git a/plugins/Live/Controller.php b/plugins/Live/Controller.php index 69c94fdf87..0420f85615 100644 --- a/plugins/Live/Controller.php +++ b/plugins/Live/Controller.php @@ -8,14 +8,18 @@ * @category Piwik_Plugins * @package Piwik_Live */ +use Piwik\API\Request; use Piwik\Common; use Piwik\Piwik; use Piwik\Config; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * @package Piwik_Live */ -class Piwik_Live_Controller extends Piwik_Controller +class Piwik_Live_Controller extends Controller { const SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY = 'live_widget_visitor_count_last_minutes'; @@ -26,7 +30,7 @@ class Piwik_Live_Controller extends Piwik_Controller public function widget($fetch = false) { - $view = new Piwik_View('@Live/index'); + $view = new View('@Live/index'); $view->idSite = $this->idSite; $view = $this->setCounters($view); $view->liveRefreshAfterMs = (int)Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000; @@ -39,9 +43,9 @@ class Piwik_Live_Controller extends Piwik_Controller { $lastMinutes = Config::getInstance()->General[self::SIMPLE_VISIT_COUNT_WIDGET_LAST_MINUTES_CONFIG_KEY]; - $lastNData = Piwik_API_Request::processRequest('Live.getCounters', array('lastMinutes' => $lastMinutes)); + $lastNData = Request::processRequest('Live.getCounters', array('lastMinutes' => $lastMinutes)); - $view = new Piwik_View('@Live/getSimpleLastVisitCount'); + $view = new View('@Live/getSimpleLastVisitCount'); $view->lastMinutes = $lastMinutes; $view->visitors = Piwik::getPrettyNumber($lastNData[0]['visitors']); $view->visits = Piwik::getPrettyNumber($lastNData[0]['visits']); @@ -62,13 +66,13 @@ class Piwik_Live_Controller extends Piwik_Controller public function ajaxTotalVisitors($fetch = false) { - $view = new Piwik_View('@Live/ajaxTotalVisitors'); + $view = new View('@Live/ajaxTotalVisitors'); $view = $this->setCounters($view); $view->idSite = $this->idSite; return $this->render($view, $fetch); } - private function render(Piwik_View $view, $fetch) + private function render(View $view, $fetch) { $rendered = $view->render(); if ($fetch) { @@ -79,7 +83,7 @@ class Piwik_Live_Controller extends Piwik_Controller public function indexVisitorLog() { - $view = new Piwik_View('@Live/indexVisitorLog.twig'); + $view = new View('@Live/indexVisitorLog.twig'); $view->filterEcommerce = Common::getRequestVar('filterEcommerce', 0, 'int'); $view->visitorLog = $this->getVisitorLog($fetch = true); echo $view->render(); @@ -87,7 +91,7 @@ class Piwik_Live_Controller extends Piwik_Controller public function getVisitorLog($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Live.getLastVisitsDetails' @@ -129,10 +133,10 @@ class Piwik_Live_Controller extends Piwik_Controller // hack, ensure we load today's visits by default $_GET['date'] = 'today'; $_GET['period'] = 'day'; - $view = new Piwik_View('@Live/getLastVisitsStart'); + $view = new View('@Live/getLastVisitsStart'); $view->idSite = $this->idSite; - $api = new Piwik_API_Request("method=Live.getLastVisitsDetails&idSite={$this->idSite}&filter_limit=10&format=php&serialize=0&disable_generic_filters=1"); + $api = new Request("method=Live.getLastVisitsDetails&idSite={$this->idSite}&filter_limit=10&format=php&serialize=0&disable_generic_filters=1"); $visitors = $api->process(); $view->visitors = $visitors; @@ -141,7 +145,7 @@ class Piwik_Live_Controller extends Piwik_Controller private function setCounters($view) { - $segment = Piwik_ViewDataTable::getRawSegmentFromRequest(); + $segment = ViewDataTable::getRawSegmentFromRequest(); $last30min = Piwik_Live_API::getInstance()->getCounters($this->idSite, $lastMinutes = 30, $segment); $last30min = $last30min[0]; $today = Piwik_Live_API::getInstance()->getCounters($this->idSite, $lastMinutes = 24 * 60, $segment); diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index ba6bf5b219..4cd54520ef 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -46,9 +46,9 @@ class Piwik_Live extends Plugin public function addWidget() { - Piwik_AddWidget('Live!', 'Live_VisitorsInRealTime', 'Live', 'widget'); - Piwik_AddWidget('Live!', 'Live_VisitorLog', 'Live', 'getVisitorLog'); - Piwik_AddWidget('Live!', 'Live_RealTimeVisitorCount', 'Live', 'getSimpleLastVisitCount'); + WidgetsList::add('Live!', 'Live_VisitorsInRealTime', 'Live', 'widget'); + WidgetsList::add('Live!', 'Live_VisitorLog', 'Live', 'getVisitorLog'); + WidgetsList::add('Live!', 'Live_RealTimeVisitorCount', 'Live', 'getSimpleLastVisitCount'); } } diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index df7edf761d..db31fe886f 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -10,6 +10,8 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\IP; +use Piwik\Tracker; /** * @see plugins/Referers/functions.php @@ -168,7 +170,7 @@ class Piwik_Live_Visitor function getIp() { if (isset($this->details['location_ip'])) { - return Piwik_IP::N2P($this->details['location_ip']); + return IP::N2P($this->details['location_ip']); } return false; } @@ -319,7 +321,7 @@ class Piwik_Live_Visitor function getCustomVariables() { $customVariables = array(); - for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) { + for ($i = 1; $i <= Tracker::MAX_CUSTOM_VARIABLES; $i++) { if (!empty($this->details['custom_var_k' . $i])) { $customVariables[$i] = array( 'customVariableName' . $i => $this->details['custom_var_k' . $i], diff --git a/plugins/Login/Auth.php b/plugins/Login/Auth.php index 1f643b2843..4280321be3 100644 --- a/plugins/Login/Auth.php +++ b/plugins/Login/Auth.php @@ -48,7 +48,7 @@ class Piwik_Login_Auth implements Auth return new AuthResult(AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, $rootLogin, $this->token_auth); } - $login = Piwik_FetchOne( + $login = Db::fetchOne( 'SELECT login FROM ' . Common::prefixTable('user') . ' WHERE token_auth = ?', @@ -67,7 +67,7 @@ class Piwik_Login_Auth implements Auth } $login = $this->login; - $userToken = Piwik_FetchOne( + $userToken = Db::fetchOne( 'SELECT token_auth FROM ' . Common::prefixTable('user') . ' WHERE login = ?', diff --git a/plugins/Login/Controller.php b/plugins/Login/Controller.php index 28aa0e285c..4aebcd3a86 100644 --- a/plugins/Login/Controller.php +++ b/plugins/Login/Controller.php @@ -11,6 +11,15 @@ use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\Cookie; +use Piwik\IP; +use Piwik\Mail; +use Piwik\Nonce; +use Piwik\View; +use Piwik\Url; +use Piwik\QuickForm2; +use Piwik\Session; require_once PIWIK_INCLUDE_PATH . '/core/Config.php'; @@ -19,7 +28,7 @@ require_once PIWIK_INCLUDE_PATH . '/core/Config.php'; * * @package Piwik_Login */ -class Piwik_Login_Controller extends Piwik_Controller +class Piwik_Login_Controller extends Controller { /** * Generate hash on user info and password @@ -65,7 +74,7 @@ class Piwik_Login_Controller extends Piwik_Controller $form = new Piwik_Login_FormLogin(); if ($form->validate()) { $nonce = $form->getSubmitValue('form_nonce'); - if (Piwik_Nonce::verifyNonce('Piwik_Login.login', $nonce)) { + if (Nonce::verifyNonce('Piwik_Login.login', $nonce)) { $login = $form->getSubmitValue('form_login'); $password = $form->getSubmitValue('form_password'); $rememberMe = $form->getSubmitValue('form_rememberme') == '1'; @@ -80,7 +89,7 @@ class Piwik_Login_Controller extends Piwik_Controller } } - $view = new Piwik_View('@Login/login'); + $view = new View('@Login/login'); $view->AccessErrorString = $messageNoAccess; $view->infoMessage = nl2br($infoMessage); $view->addForm($form); @@ -92,7 +101,7 @@ class Piwik_Login_Controller extends Piwik_Controller /** * Configure common view properties * - * @param Piwik_View $view + * @param View $view */ private function configureView($view) { @@ -103,7 +112,7 @@ class Piwik_Login_Controller extends Piwik_Controller $view->forceSslLogin = Config::getInstance()->General['force_ssl_login']; // crsf token: don't trust the submitted value; generate/fetch it from session data - $view->nonce = Piwik_Nonce::getNonce('Piwik_Login.login'); + $view->nonce = Nonce::getNonce('Piwik_Login.login'); } /** @@ -153,9 +162,9 @@ class Piwik_Login_Controller extends Piwik_Controller 'md5Password' => $md5Password, 'rememberMe' => $rememberMe, ); - Piwik_Nonce::discardNonce('Piwik_Login.login'); + Nonce::discardNonce('Piwik_Login.login'); Piwik_PostEvent('Login.initSession', array(&$info)); - Piwik_Url::redirectToUrl($urlToRedirect); + Url::redirectToUrl($urlToRedirect); } protected function getMessageExceptionNoAccess() @@ -182,7 +191,7 @@ class Piwik_Login_Controller extends Piwik_Controller $form = new Piwik_Login_FormResetPassword(); if ($form->validate()) { $nonce = $form->getSubmitValue('form_nonce'); - if (Piwik_Nonce::verifyNonce('Piwik_Login.login', $nonce)) { + if (Nonce::verifyNonce('Piwik_Login.login', $nonce)) { $formErrors = $this->resetPasswordFirstStep($form); if (empty($formErrors)) { $infoMessage = Piwik_Translate('Login_ConfirmationLinkSent'); @@ -196,7 +205,7 @@ class Piwik_Login_Controller extends Piwik_Controller $formErrors = $formData['errors']; } - $view = new Piwik_View('@Login/resetPassword'); + $view = new View('@Login/resetPassword'); $view->infoMessage = $infoMessage; $view->formErrors = $formErrors; echo $view->render(); @@ -205,7 +214,7 @@ class Piwik_Login_Controller extends Piwik_Controller /** * Saves password reset info and sends confirmation email. * - * @param Piwik_QuickForm2 $form + * @param QuickForm2 $form * @return array Error message(s) if an error occurs. */ private function resetPasswordFirstStep($form) @@ -262,13 +271,13 @@ class Piwik_Login_Controller extends Piwik_Controller // construct a password reset token from user information $resetToken = self::generatePasswordResetToken($user); - $ip = Piwik_IP::getIpFromHeader(); - $url = Piwik_Url::getCurrentUrlWithoutQueryString() + $ip = IP::getIpFromHeader(); + $url = Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=confirmResetPassword&login=" . urlencode($login) . "&resetToken=" . urlencode($resetToken); // send email with new password - $mail = new Piwik_Mail(); + $mail = new Mail(); $mail->addTo($email, $login); $mail->setSubject(Piwik_Translate('Login_MailTopicPasswordChange')); $bodyText = str_replace( @@ -447,10 +456,10 @@ class Piwik_Login_Controller extends Piwik_Controller static public function clearSession() { $authCookieName = Config::getInstance()->General['login_cookie_name']; - $cookie = new Piwik_Cookie($authCookieName); + $cookie = new Cookie($authCookieName); $cookie->delete(); - Piwik_Session::expireSessionCookie(); + Session::expireSessionCookie(); } /** @@ -467,7 +476,7 @@ class Piwik_Login_Controller extends Piwik_Controller if (empty($logoutUrl)) { Piwik::redirectToModule('CoreHome'); } else { - Piwik_Url::redirectToUrl($logoutUrl); + Url::redirectToUrl($logoutUrl); } } @@ -484,10 +493,10 @@ class Piwik_Login_Controller extends Piwik_Controller && !Piwik::isHttps() ) { $url = 'https://' - . Piwik_Url::getCurrentHost() - . Piwik_Url::getCurrentScriptName() - . Piwik_Url::getCurrentQueryString(); - Piwik_Url::redirectToUrl($url); + . Url::getCurrentHost() + . Url::getCurrentScriptName() + . Url::getCurrentQueryString(); + Url::redirectToUrl($url); } } } diff --git a/plugins/Login/FormLogin.php b/plugins/Login/FormLogin.php index a90146f47e..229288e713 100644 --- a/plugins/Login/FormLogin.php +++ b/plugins/Login/FormLogin.php @@ -8,12 +8,13 @@ * @category Piwik_Plugins * @package Piwik_Login */ +use Piwik\QuickForm2; /** * * @package Piwik_Login */ -class Piwik_Login_FormLogin extends Piwik_QuickForm2 +class Piwik_Login_FormLogin extends QuickForm2 { function __construct($id = 'login_form', $method = 'post', $attributes = null, $trackSubmit = false) { diff --git a/plugins/Login/FormResetPassword.php b/plugins/Login/FormResetPassword.php index 0411beddbb..abbe1bd4a1 100644 --- a/plugins/Login/FormResetPassword.php +++ b/plugins/Login/FormResetPassword.php @@ -8,12 +8,13 @@ * @category Piwik_Plugins * @package Piwik_Login */ +use Piwik\QuickForm2; /** * * @package Piwik_Login */ -class Piwik_Login_FormResetPassword extends Piwik_QuickForm2 +class Piwik_Login_FormResetPassword extends QuickForm2 { function __construct($id = 'resetpasswordform', $method = 'post', $attributes = null, $trackSubmit = false) { diff --git a/plugins/Login/Login.php b/plugins/Login/Login.php index 7208328074..b8718f93d5 100644 --- a/plugins/Login/Login.php +++ b/plugins/Login/Login.php @@ -10,6 +10,9 @@ */ use Piwik\Config; use Piwik\Piwik; +use Piwik\Cookie; +use Piwik\Piwik_Option; +use Piwik\Session; use Piwik\Plugin; /** @@ -74,7 +77,7 @@ class Piwik_Login extends Plugin $authCookieName = Config::getInstance()->General['login_cookie_name']; $authCookieExpiry = 0; $authCookiePath = Config::getInstance()->General['login_cookie_path']; - $authCookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath); + $authCookie = new Cookie($authCookieName, $authCookieExpiry, $authCookiePath); $defaultLogin = 'anonymous'; $defaultTokenAuth = 'anonymous'; if ($authCookie->isCookieFound()) { @@ -107,7 +110,7 @@ class Piwik_Login extends Plugin $authCookieName = Config::getInstance()->General['login_cookie_name']; $authCookieExpiry = $rememberMe ? time() + Config::getInstance()->General['login_cookie_expire'] : 0; $authCookiePath = Config::getInstance()->General['login_cookie_path']; - $cookie = new Piwik_Cookie($authCookieName, $authCookieExpiry, $authCookiePath); + $cookie = new Cookie($authCookieName, $authCookieExpiry, $authCookiePath); if (!$authResult->isValid()) { $cookie->delete(); throw new Exception(Piwik_Translate('Login_LoginPasswordNotCorrect')); @@ -119,7 +122,7 @@ class Piwik_Login extends Plugin $cookie->setHttpOnly(true); $cookie->save(); - @Piwik_Session::regenerateId(); + @Session::regenerateId(); // remove password reset entry if it exists self::removePasswordResetInfo($login); diff --git a/plugins/MobileMessaging/Controller.php b/plugins/MobileMessaging/Controller.php index a97641ed0c..0054d62912 100644 --- a/plugins/MobileMessaging/Controller.php +++ b/plugins/MobileMessaging/Controller.php @@ -9,8 +9,11 @@ * @package Piwik_MobileMessaging */ +use Piwik\Controller\Admin; use Piwik\Piwik; use Piwik\Common; +use Piwik\IP; +use Piwik\View; require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php'; @@ -18,7 +21,7 @@ require_once PIWIK_INCLUDE_PATH . '/plugins/UserCountry/functions.php'; * * @package Piwik_MobileMessaging */ -class Piwik_MobileMessaging_Controller extends Piwik_Controller_Admin +class Piwik_MobileMessaging_Controller extends Admin { /* * Mobile Messaging Settings tab : @@ -31,7 +34,7 @@ class Piwik_MobileMessaging_Controller extends Piwik_Controller_Admin { Piwik::checkUserIsNotAnonymous(); - $view = new Piwik_View('@MobileMessaging/index'); + $view = new View('@MobileMessaging/index'); $view->isSuperUser = Piwik::isUserIsSuperUser(); @@ -63,7 +66,7 @@ class Piwik_MobileMessaging_Controller extends Piwik_Controller_Admin $view->defaultCountry = Common::getCountry( Piwik_LanguagesManager::getLanguageCodeForCurrentUser(), true, - Piwik_IP::getIpFromHeader() + IP::getIpFromHeader() ); $view->phoneNumbers = $mobileMessagingAPI->getPhoneNumbers(); diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php index 840ae48abc..532e511d73 100644 --- a/plugins/MobileMessaging/MobileMessaging.php +++ b/plugins/MobileMessaging/MobileMessaging.php @@ -9,6 +9,7 @@ * @package Piwik_MobileMessaging */ use Piwik\Piwik; +use Piwik\View; use Piwik\Plugin; /** @@ -216,7 +217,7 @@ class Piwik_MobileMessaging extends Plugin return; } - $view = new Piwik_View('@MobileMessaging/reportParametersPDFReports'); + $view = new View('@MobileMessaging/reportParametersPDFReports'); $view->reportType = self::MOBILE_TYPE; $view->phoneNumbers = Piwik_MobileMessaging_API::getInstance()->getActivatedPhoneNumbers(); $out .= $view->render(); diff --git a/plugins/MobileMessaging/ReportRenderer/Exception.php b/plugins/MobileMessaging/ReportRenderer/Exception.php index c6cdacf36b..cc5b137a38 100644 --- a/plugins/MobileMessaging/ReportRenderer/Exception.php +++ b/plugins/MobileMessaging/ReportRenderer/Exception.php @@ -8,12 +8,13 @@ * @category Piwik_Plugins * @package Piwik_MobileMessaging_ReportRenderer */ +use Piwik\ReportRenderer; /** * * @package Piwik_MobileMessaging_ReportRenderer */ -class Piwik_MobileMessaging_ReportRenderer_Exception extends Piwik_ReportRenderer +class Piwik_MobileMessaging_ReportRenderer_Exception extends ReportRenderer { private $rendering = ""; @@ -29,7 +30,7 @@ class Piwik_MobileMessaging_ReportRenderer_Exception extends Piwik_ReportRendere public function sendToDisk($filename) { - return Piwik_ReportRenderer::writeFile( + return ReportRenderer::writeFile( $filename, Piwik_MobileMessaging_ReportRenderer_Sms::SMS_FILE_EXTENSION, $this->rendering @@ -38,7 +39,7 @@ class Piwik_MobileMessaging_ReportRenderer_Exception extends Piwik_ReportRendere public function sendToBrowserDownload($filename) { - Piwik_ReportRenderer::sendToBrowser( + ReportRenderer::sendToBrowser( $filename, Piwik_MobileMessaging_ReportRenderer_Sms::SMS_FILE_EXTENSION, Piwik_MobileMessaging_ReportRenderer_Sms::SMS_CONTENT_TYPE, @@ -48,7 +49,7 @@ class Piwik_MobileMessaging_ReportRenderer_Exception extends Piwik_ReportRendere public function sendToBrowserInline($filename) { - Piwik_ReportRenderer::inlineToBrowser( + ReportRenderer::inlineToBrowser( Piwik_MobileMessaging_ReportRenderer_Sms::SMS_CONTENT_TYPE, $this->rendering ); diff --git a/plugins/MobileMessaging/ReportRenderer/Sms.php b/plugins/MobileMessaging/ReportRenderer/Sms.php index 68bc22691a..5c89166ea2 100644 --- a/plugins/MobileMessaging/ReportRenderer/Sms.php +++ b/plugins/MobileMessaging/ReportRenderer/Sms.php @@ -9,13 +9,15 @@ * @package Piwik_MobileMessaging_ReportRenderer */ use Piwik\Common; +use Piwik\View; +use Piwik\ReportRenderer; use Piwik\Site; /** * * @package Piwik_MobileMessaging_ReportRenderer */ -class Piwik_MobileMessaging_ReportRenderer_Sms extends Piwik_ReportRenderer +class Piwik_MobileMessaging_ReportRenderer_Sms extends ReportRenderer { const FLOAT_REGEXP = '/[-+]?[0-9]*[\.,]?[0-9]+/'; const SMS_CONTENT_TYPE = 'text/plain'; @@ -30,17 +32,17 @@ class Piwik_MobileMessaging_ReportRenderer_Sms extends Piwik_ReportRenderer public function sendToDisk($filename) { - return Piwik_ReportRenderer::writeFile($filename, self::SMS_FILE_EXTENSION, $this->rendering); + return ReportRenderer::writeFile($filename, self::SMS_FILE_EXTENSION, $this->rendering); } public function sendToBrowserDownload($filename) { - Piwik_ReportRenderer::sendToBrowser($filename, self::SMS_FILE_EXTENSION, self::SMS_CONTENT_TYPE, $this->rendering); + ReportRenderer::sendToBrowser($filename, self::SMS_FILE_EXTENSION, self::SMS_CONTENT_TYPE, $this->rendering); } public function sendToBrowserInline($filename) { - Piwik_ReportRenderer::inlineToBrowser(self::SMS_CONTENT_TYPE, $this->rendering); + ReportRenderer::inlineToBrowser(self::SMS_CONTENT_TYPE, $this->rendering); } public function getRenderedReport() @@ -114,7 +116,7 @@ class Piwik_MobileMessaging_ReportRenderer_Sms extends Piwik_ReportRenderer $siteHasECommerce[$idSite] = Site::isEcommerceEnabledFor($idSite); } - $view = new Piwik_View('@MobileMessaging/SMSReport'); + $view = new View('@MobileMessaging/SMSReport'); $view->assign("isGoalPluginEnabled", $isGoalPluginEnabled); $view->assign("reportRows", $dataRows); $view->assign("reportRowsMetadata", $reportRowsMetadata); diff --git a/plugins/MobileMessaging/SMSProvider/Clockwork.php b/plugins/MobileMessaging/SMSProvider/Clockwork.php index faf5effbc7..29a153c6da 100644 --- a/plugins/MobileMessaging/SMSProvider/Clockwork.php +++ b/plugins/MobileMessaging/SMSProvider/Clockwork.php @@ -9,6 +9,8 @@ * @package Piwik_MobileMessaging_SMSProvider */ +use Piwik\Http; + require_once PIWIK_INCLUDE_PATH . "/plugins/MobileMessaging/APIException.php"; /** * @@ -70,8 +72,8 @@ class Piwik_MobileMessaging_SMSProvider_Clockwork extends Piwik_MobileMessaging_ $timeout = self::SOCKET_TIMEOUT; try { - $result = Piwik_Http::sendHttpRequestBy( - Piwik_Http::getTransportMethod(), + $result = Http::sendHttpRequestBy( + Http::getTransportMethod(), $url, $timeout, $userAgent = null, diff --git a/plugins/MultiSites/API.php b/plugins/MultiSites/API.php index 2906edc981..6e4feeba76 100755 --- a/plugins/MultiSites/API.php +++ b/plugins/MultiSites/API.php @@ -8,12 +8,14 @@ * @category Piwik_Plugins * @package Piwik_MultiSites */ +use Piwik\API\Request; use Piwik\Archive; use Piwik\DataTable\Filter\CalculateEvolutionFilter; use Piwik\Period\Range; use Piwik\Piwik; use Piwik\Common; use Piwik\DataTable; +use Piwik\TaskScheduler; use Piwik\Site; /** @@ -132,7 +134,7 @@ class Piwik_MultiSites_API return $idSites; } $idSites = array(); - $sites = Piwik_API_Request::processRequest('SitesManager.getPatternMatchSites', + $sites = Request::processRequest('SitesManager.getPatternMatchSites', array('pattern' => $pattern, // added because caller could overwrite these 'serialize' => 0, @@ -180,7 +182,7 @@ class Piwik_MultiSites_API // Hack: when this API function is called as a Scheduled Task, Super User status is enforced. // This means this function would return ALL websites in all cases. // Instead, we make sure that only the right set of data is returned - && !Piwik_TaskScheduler::isTaskBeingExecuted() + && !TaskScheduler::isTaskBeingExecuted() ) { Site::setSites( Piwik_SitesManager_API::getInstance()->getAllSites() @@ -298,7 +300,7 @@ class Piwik_MultiSites_API // filter rows without visits // note: if only one website is queried and there are no visits, we can not remove the row otherwise - // Piwik_API_ResponseBuilder throws 'Call to a member function getColumns() on a non-object' + // ResponseBuilder throws 'Call to a member function getColumns() on a non-object' if ($multipleWebsitesRequested // We don't delete the 0 visits row, if "Enhanced" mode is on. && !$enhanced) { diff --git a/plugins/MultiSites/Controller.php b/plugins/MultiSites/Controller.php index 4986ba1abc..fd7ee849c8 100644 --- a/plugins/MultiSites/Controller.php +++ b/plugins/MultiSites/Controller.php @@ -13,13 +13,15 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Config; use Piwik\Date; +use Piwik\Controller; +use Piwik\View; use Piwik\Site; /** * * @package Piwik_MultiSites */ -class Piwik_MultiSites_Controller extends Piwik_Controller +class Piwik_MultiSites_Controller extends Controller { protected $orderBy = 'visits'; protected $order = 'desc'; @@ -122,7 +124,7 @@ class Piwik_MultiSites_Controller extends Piwik_Controller $this->applyPrettyMoney($digestableData); - $view = new Piwik_View("@MultiSites/getSitesInfo"); + $view = new View("@MultiSites/getSitesInfo"); $view->isWidgetized = $isWidgetized; $view->sitesData = array_values($digestableData); $view->evolutionBy = $this->evolutionBy; diff --git a/plugins/Overlay/Controller.php b/plugins/Overlay/Controller.php index d3bd8ab3b0..b034173e43 100644 --- a/plugins/Overlay/Controller.php +++ b/plugins/Overlay/Controller.php @@ -1,8 +1,11 @@ <?php +use Piwik\API\Request; use Piwik\Metrics; use Piwik\Piwik; use Piwik\Config; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * Piwik - Open source web analytics @@ -14,7 +17,7 @@ use Piwik\Common; * @package Piwik_Overlay */ -class Piwik_Overlay_Controller extends Piwik_Controller +class Piwik_Overlay_Controller extends Controller { /** The index of the plugin */ @@ -27,7 +30,7 @@ class Piwik_Overlay_Controller extends Piwik_Controller $template = '@Overlay/index_noframe'; } - $view = new Piwik_View($template); + $view = new View($template); $this->setGeneralVariablesView($view); @@ -57,7 +60,7 @@ class Piwik_Overlay_Controller extends Piwik_Controller $path = Piwik_Actions_ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Piwik_Tracker_Action::TYPE_ACTION_URL); $path = array_map('urlencode', $path); $label = implode('>', $path); - $request = new Piwik_API_Request( + $request = new Request( 'method=Actions.getPageUrls' . '&idSite=' . urlencode($idSite) . '&date=' . urlencode($date) @@ -103,7 +106,7 @@ class Piwik_Overlay_Controller extends Piwik_Controller } // render template - $view = new Piwik_View('@Overlay/renderSidebar'); + $view = new View('@Overlay/renderSidebar'); $view->data = $data; $view->location = $page; $view->normalizedUrl = $normalizedCurrentUrl; @@ -197,7 +200,7 @@ class Piwik_Overlay_Controller extends Piwik_Controller $message = Piwik_Translate('Overlay_RedirectUrlError', array($url, "\n")); $message = nl2br(htmlentities($message)); - $view = new Piwik_View('@Overlay/showErrorWrongDomain'); + $view = new View('@Overlay/showErrorWrongDomain'); $view->message = $message; if (Piwik::isUserHasAdminAccess($idSite)) { @@ -224,7 +227,7 @@ class Piwik_Overlay_Controller extends Piwik_Controller */ public function notifyParentIframe() { - $view = new Piwik_View('@Overlay/notifyParentIframe'); + $view = new View('@Overlay/notifyParentIframe'); echo $view->render(); } diff --git a/plugins/PDFReports/API.php b/plugins/PDFReports/API.php index 4826fe8c80..7c07598430 100644 --- a/plugins/PDFReports/API.php +++ b/plugins/PDFReports/API.php @@ -11,6 +11,8 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\ReportRenderer; +use Piwik\ReportRenderer\Html; use Piwik\Site; use Piwik\Translate; @@ -251,7 +253,7 @@ class Piwik_PDFReports_API } // Joining with the site table to work around pre-1.3 where reports could still be linked to a deleted site - $reports = Piwik_FetchAll("SELECT * + $reports = Db::fetchAll("SELECT * FROM " . Common::prefixTable('report') . " JOIN " . Common::prefixTable('site') . " USING (idsite) @@ -434,17 +436,17 @@ class Piwik_PDFReports_API $outputFilename = $reportRenderer->sendToDisk($outputFilename); $additionalFiles = array(); - if ($reportRenderer instanceof Piwik_ReportRenderer_Html) { + if ($reportRenderer instanceof Html) { foreach ($processedReports as &$report) { if ($report['displayGraph']) { $additionalFile = array(); $additionalFile['filename'] = $report['metadata']['name'] . '.png'; $additionalFile['cid'] = $report['metadata']['uniqueId']; $additionalFile['content'] = - Piwik_ReportRenderer::getStaticGraph( + ReportRenderer::getStaticGraph( $report['metadata'], - Piwik_ReportRenderer_Html::IMAGE_GRAPH_WIDTH, - Piwik_ReportRenderer_Html::IMAGE_GRAPH_HEIGHT, + Html::IMAGE_GRAPH_WIDTH, + Html::IMAGE_GRAPH_HEIGHT, $report['evolutionGraph'], $segment ); diff --git a/plugins/PDFReports/Controller.php b/plugins/PDFReports/Controller.php index 4e7e8c1644..3eed377084 100644 --- a/plugins/PDFReports/Controller.php +++ b/plugins/PDFReports/Controller.php @@ -10,18 +10,20 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * * @package Piwik_PDFReports */ -class Piwik_PDFReports_Controller extends Piwik_Controller +class Piwik_PDFReports_Controller extends Controller { const DEFAULT_REPORT_TYPE = Piwik_PDFReports::EMAIL_TYPE; public function index() { - $view = new Piwik_View('@PDFReports/index'); + $view = new View('@PDFReports/index'); $this->setGeneralVariablesView($view); $view->countWebsites = count(Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess()); diff --git a/plugins/PDFReports/PDFReports.php b/plugins/PDFReports/PDFReports.php index 69ddb3d498..f9eb619ea1 100644 --- a/plugins/PDFReports/PDFReports.php +++ b/plugins/PDFReports/PDFReports.php @@ -12,6 +12,11 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Config; use Piwik\Date; +use Piwik\Mail; +use Piwik\View; +use Piwik\ScheduledTime; +use Piwik\ScheduledTask; +use Piwik\ReportRenderer; use Piwik\Plugin; use Piwik\Site; @@ -30,7 +35,7 @@ class Piwik_PDFReports extends Plugin const DISPLAY_FORMAT_TABLES_ONLY = 4; // Display only tables for all reports const DEFAULT_DISPLAY_FORMAT = self::DISPLAY_FORMAT_GRAPHS_ONLY_FOR_KEY_METRICS; - const DEFAULT_REPORT_FORMAT = Piwik_ReportRenderer::HTML_FORMAT; + const DEFAULT_REPORT_FORMAT = ReportRenderer::HTML_FORMAT; const DEFAULT_PERIOD = 'week'; const DEFAULT_HOUR = '0'; @@ -55,8 +60,8 @@ class Piwik_PDFReports extends Plugin ); static private $managedReportFormats = array( - Piwik_ReportRenderer::HTML_FORMAT => 'plugins/Zeitgeist/images/html_icon.png', - Piwik_ReportRenderer::PDF_FORMAT => 'plugins/UserSettings/images/plugins/pdf.gif' + ReportRenderer::HTML_FORMAT => 'plugins/Zeitgeist/images/html_icon.png', + ReportRenderer::PDF_FORMAT => 'plugins/UserSettings/images/plugins/pdf.gif' ); /** @@ -233,9 +238,9 @@ class Piwik_PDFReports extends Plugin $reportFormat = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY]['format']; $outputType = $notificationInfo[Piwik_PDFReports_API::OUTPUT_TYPE_INFO_KEY]; - $reportRenderer = Piwik_ReportRenderer::factory($reportFormat); + $reportRenderer = ReportRenderer::factory($reportFormat); - if ($reportFormat == Piwik_ReportRenderer::HTML_FORMAT) { + if ($reportFormat == ReportRenderer::HTML_FORMAT) { $reportRenderer->setRenderImageInline($outputType != Piwik_PDFReports_API::OUTPUT_SAVE_ON_DISK); } } @@ -262,7 +267,7 @@ class Piwik_PDFReports extends Plugin $message = Piwik_Translate('PDFReports_EmailHello'); $subject = Piwik_Translate('General_Report') . ' ' . $reportTitle . " - " . $prettyDate; - $mail = new Piwik_Mail(); + $mail = new Mail(); $mail->setSubject($subject); $fromEmailName = Config::getInstance()->branding['use_custom_logo'] ? Piwik_Translate('CoreHome_WebAnalyticsReports') @@ -392,7 +397,7 @@ class Piwik_PDFReports extends Plugin static public function template_reportParametersPDFReports(&$out) { - $view = new Piwik_View('@PDFReports/reportParametersPDFReports'); + $view = new View('@PDFReports/reportParametersPDFReports'); $view->currentUserEmail = Piwik::getCurrentUserEmail(); $view->displayFormats = self::getDisplayFormats(); $view->reportType = self::EMAIL_TYPE; @@ -414,7 +419,7 @@ class Piwik_PDFReports extends Plugin { $arbitraryDateInUTC = Date::factory('2011-01-01'); foreach (Piwik_PDFReports_API::getInstance()->getReports() as $report) { - if (!$report['deleted'] && $report['period'] != Piwik_ScheduledTime::PERIOD_NEVER) { + if (!$report['deleted'] && $report['period'] != ScheduledTime::PERIOD_NEVER) { $midnightInSiteTimezone = date( 'H', @@ -426,9 +431,9 @@ class Piwik_PDFReports extends Plugin $hourInUTC = (24 - $midnightInSiteTimezone + $report['hour']) % 24; - $schedule = Piwik_ScheduledTime::getScheduledTimeForPeriod($report['period']); + $schedule = ScheduledTime::getScheduledTimeForPeriod($report['period']); $schedule->setHour($hourInUTC); - $tasks[] = new Piwik_ScheduledTask ( + $tasks[] = new ScheduledTask ( Piwik_PDFReports_API::getInstance(), 'sendReport', $report['idreport'], $schedule @@ -508,7 +513,7 @@ class Piwik_PDFReports extends Plugin public function deleteUserReport($userLogin) { - Piwik_Query('DELETE FROM ' . Common::prefixTable('report') . ' WHERE login = ?', $userLogin); + Db::query('DELETE FROM ' . Common::prefixTable('report') . ' WHERE login = ?', $userLogin); } public function install() @@ -533,7 +538,7 @@ class Piwik_PDFReports extends Plugin ) DEFAULT CHARSET=utf8'; try { foreach ($queries as $query) { - Piwik_Exec($query); + Db::exec($query); } } catch (Exception $e) { if (!Zend_Registry::get('db')->isErrNo($e, '1050')) { @@ -577,10 +582,10 @@ class Piwik_PDFReports extends Plugin static public function getPeriodToFrequency() { return array( - Piwik_ScheduledTime::PERIOD_NEVER => Piwik_Translate('General_Never'), - Piwik_ScheduledTime::PERIOD_DAY => Piwik_Translate('General_Daily'), - Piwik_ScheduledTime::PERIOD_WEEK => Piwik_Translate('General_Weekly'), - Piwik_ScheduledTime::PERIOD_MONTH => Piwik_Translate('General_Monthly'), + ScheduledTime::PERIOD_NEVER => Piwik_Translate('General_Never'), + ScheduledTime::PERIOD_DAY => Piwik_Translate('General_Daily'), + ScheduledTime::PERIOD_WEEK => Piwik_Translate('General_Weekly'), + ScheduledTime::PERIOD_MONTH => Piwik_Translate('General_Monthly'), ); } @@ -591,11 +596,11 @@ class Piwik_PDFReports extends Plugin static public function getPeriodToFrequencyAsAdjective() { return array( - Piwik_ScheduledTime::PERIOD_DAY => Piwik_Translate('General_DailyReport'), - Piwik_ScheduledTime::PERIOD_WEEK => Piwik_Translate('General_WeeklyReport'), - Piwik_ScheduledTime::PERIOD_MONTH => Piwik_Translate('General_MonthlyReport'), - Piwik_ScheduledTime::PERIOD_YEAR => Piwik_Translate('General_YearlyReport'), - Piwik_ScheduledTime::PERIOD_RANGE => Piwik_Translate('General_RangeReports'), + ScheduledTime::PERIOD_DAY => Piwik_Translate('General_DailyReport'), + ScheduledTime::PERIOD_WEEK => Piwik_Translate('General_WeeklyReport'), + ScheduledTime::PERIOD_MONTH => Piwik_Translate('General_MonthlyReport'), + ScheduledTime::PERIOD_YEAR => Piwik_Translate('General_YearlyReport'), + ScheduledTime::PERIOD_RANGE => Piwik_Translate('General_RangeReports'), ); } } diff --git a/plugins/PleineLune/PleineLune.php b/plugins/PleineLune/PleineLune.php index 12b581bdc1..b19ed3e288 100644 --- a/plugins/PleineLune/PleineLune.php +++ b/plugins/PleineLune/PleineLune.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_PleineLune */ +use Piwik\AssetManager; use Piwik\Plugin; /** @@ -19,7 +20,7 @@ class Piwik_PleineLune extends Plugin public function getListHooksRegistered() { return array( - Piwik_AssetManager::CSS_IMPORT_EVENT => 'getCssFiles', + AssetManager::CSS_IMPORT_EVENT => 'getCssFiles', ); } diff --git a/plugins/PrivacyManager/Controller.php b/plugins/PrivacyManager/Controller.php index a3af0246be..c11fb5d7f0 100644 --- a/plugins/PrivacyManager/Controller.php +++ b/plugins/PrivacyManager/Controller.php @@ -9,15 +9,18 @@ * @package Piwik_PrivacyManager */ use Piwik\Config; +use Piwik\Controller\Admin; use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\View; +use Piwik\TaskScheduler; /** * * @package Piwik_PrivacyManager */ -class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin +class Piwik_PrivacyManager_Controller extends Admin { const ANONYMIZE_IP_PLUGIN_NAME = "AnonymizeIP"; @@ -90,7 +93,7 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin public function getDatabaseSize() { Piwik::checkUserIsSuperUser(); - $view = new Piwik_View('@PrivacyManager/getDatabaseSize'); + $view = new View('@PrivacyManager/getDatabaseSize'); $forceEstimate = Common::getRequestVar('forceEstimate', 0); $view->dbStats = $this->getDeleteDBSizeEstimate($getSettingsFromQuery = true, $forceEstimate); @@ -112,7 +115,7 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin public function privacySettings() { Piwik::checkUserHasSomeAdminAccess(); - $view = new Piwik_View('@PrivacyManager/privacySettings'); + $view = new View('@PrivacyManager/privacySettings'); if (Piwik::isUserIsSuperUser()) { $view->deleteData = $this->getDeleteDataInfo(); @@ -229,7 +232,7 @@ class Piwik_PrivacyManager_Controller extends Piwik_Controller_Admin { Piwik::checkUserIsSuperUser(); $deleteDataInfos = array(); - $taskScheduler = new Piwik_TaskScheduler(); + $taskScheduler = new TaskScheduler(); $deleteDataInfos["config"] = Piwik_PrivacyManager::getPurgeDataSettings(); $deleteDataInfos["deleteTables"] = "<br/>" . implode(", ", Piwik_PrivacyManager_LogDataPurger::getDeleteTableLogTables()); diff --git a/plugins/PrivacyManager/LogDataPurger.php b/plugins/PrivacyManager/LogDataPurger.php index 6d7a06b951..d4fa491b43 100755 --- a/plugins/PrivacyManager/LogDataPurger.php +++ b/plugins/PrivacyManager/LogDataPurger.php @@ -11,6 +11,7 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\Db; /** * Purges the log_visit, log_conversion and related tables of old visit data. @@ -73,7 +74,7 @@ class Piwik_PrivacyManager_LogDataPurger foreach ($logTables as $logTable) { // deleting from log_action must be handled differently, so we do it later if ($logTable != Common::prefixTable('log_action')) { - Piwik_DeleteAllRows($logTable, $where, $this->maxRowsToDeletePerQuery, array($maxIdVisit)); + Db::deleteAllRows($logTable, $where, $this->maxRowsToDeletePerQuery, array($maxIdVisit)); } } @@ -86,7 +87,7 @@ class Piwik_PrivacyManager_LogDataPurger } // optimize table overhead after deletion - Piwik_OptimizeTables($logTables); + Db::optimizeTables($logTables); } /** @@ -138,7 +139,7 @@ class Piwik_PrivacyManager_LogDataPurger // delete before unlocking tables so there's no chance a new log row that references an // unused action will be inserted. $this->deleteUnusedActions(); - $this->unlockLogTables(); + Db::unlockAllTables(); } /** @@ -150,7 +151,7 @@ class Piwik_PrivacyManager_LogDataPurger $logVisit = Common::prefixTable("log_visit"); // get max idvisit - $maxIdVisit = Piwik_FetchOne("SELECT MAX(idvisit) FROM $logVisit"); + $maxIdVisit = Db::fetchOne("SELECT MAX(idvisit) FROM $logVisit"); if (empty($maxIdVisit)) { return false; } @@ -165,13 +166,13 @@ class Piwik_PrivacyManager_LogDataPurger ORDER BY idvisit DESC LIMIT 1"; - return Piwik_SegmentedFetchFirst($sql, $maxIdVisit, 0, -self::$selectSegmentSize); + return Db::segmentedFetchFirst($sql, $maxIdVisit, 0, -self::$selectSegmentSize); } private function getLogTableDeleteCount($table, $maxIdVisit) { $sql = "SELECT COUNT(*) FROM $table WHERE idvisit <= ?"; - return (int)Piwik_FetchOne($sql, array($maxIdVisit)); + return (int)Db::fetchOne($sql, array($maxIdVisit)); } private function createTempTable() @@ -180,7 +181,7 @@ class Piwik_PrivacyManager_LogDataPurger idaction INT(11), PRIMARY KEY (idaction) )"; - Piwik_Query($sql); + Db::query($sql); } private function getMaxIdsInLogTables() @@ -191,7 +192,7 @@ class Piwik_PrivacyManager_LogDataPurger $result = array(); foreach ($tables as $table) { $idCol = $idColumns[$table]; - $result[$table] = Piwik_FetchOne("SELECT MAX($idCol) FROM " . Common::prefixTable($table)); + $result[$table] = Db::fetchOne("SELECT MAX($idCol) FROM " . Common::prefixTable($table)); } return $result; @@ -214,10 +215,10 @@ class Piwik_PrivacyManager_LogDataPurger $finish = $maxIds[$table]; } else { $start = $maxIds[$table]; - $finish = Piwik_FetchOne("SELECT MAX($idCol) FROM " . Common::prefixTable($table)); + $finish = Db::fetchOne("SELECT MAX($idCol) FROM " . Common::prefixTable($table)); } - Piwik_SegmentedQuery($sql, $start, $finish, self::$selectSegmentSize); + Db::segmentedQuery($sql, $start, $finish, self::$selectSegmentSize); } } @@ -231,7 +232,7 @@ class Piwik_PrivacyManager_LogDataPurger private function lockLogTables() { - Piwik_LockTables( + Db::lockTables( $readLocks = Common::prefixTables('log_conversion', 'log_link_visit_action', 'log_visit', @@ -240,11 +241,6 @@ class Piwik_PrivacyManager_LogDataPurger ); } - private function unlockLogTables() - { - Piwik_UnlockAllTables(); - } - private function deleteUnusedActions() { list($logActionTable, $tempTableName) = Common::prefixTables("log_action", self::TEMP_TABLE_NAME); @@ -254,7 +250,7 @@ class Piwik_PrivacyManager_LogDataPurger LEFT JOIN $tempTableName tmp ON tmp.idaction = $logActionTable.idaction WHERE tmp.idaction IS NULL"; - Piwik_Query($deleteSql); + Db::query($deleteSql); } private function getIdActionColumns() diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php index 710232001b..4d01b4850a 100644 --- a/plugins/PrivacyManager/PrivacyManager.php +++ b/plugins/PrivacyManager/PrivacyManager.php @@ -13,6 +13,7 @@ use Piwik\Metrics; use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\ScheduledTask; use Piwik\Plugin; /** @@ -70,13 +71,13 @@ class Piwik_PrivacyManager extends Plugin // both tasks are low priority so they will execute after most others, but not lowest, so // they will execute before the optimize tables task - $purgeReportDataTask = new Piwik_ScheduledTask( - $this, 'deleteReportData', null, new Piwik_ScheduledTime_Daily(), Piwik_ScheduledTask::LOW_PRIORITY + $purgeReportDataTask = new ScheduledTask( + $this, 'deleteReportData', null, new Piwik_ScheduledTime_Daily(), ScheduledTask::LOW_PRIORITY ); $tasks[] = $purgeReportDataTask; - $purgeLogDataTask = new Piwik_ScheduledTask( - $this, 'deleteLogData', null, new Piwik_ScheduledTime_Daily(), Piwik_ScheduledTask::LOW_PRIORITY + $purgeLogDataTask = new ScheduledTask( + $this, 'deleteLogData', null, new Piwik_ScheduledTime_Daily(), ScheduledTask::LOW_PRIORITY ); $tasks[] = $purgeLogDataTask; } @@ -390,7 +391,7 @@ class Piwik_PrivacyManager extends Plugin private static function getMaxGoalId() { - return Piwik_FetchOne("SELECT MAX(idgoal) FROM " . Common::prefixTable('goal')); + return Db::fetchOne("SELECT MAX(idgoal) FROM " . Common::prefixTable('goal')); } } diff --git a/plugins/PrivacyManager/ReportsPurger.php b/plugins/PrivacyManager/ReportsPurger.php index a8ed8c3bfa..af527b6142 100755 --- a/plugins/PrivacyManager/ReportsPurger.php +++ b/plugins/PrivacyManager/ReportsPurger.php @@ -11,6 +11,7 @@ use Piwik\DataAccess\ArchiveTableCreator; use Piwik\Piwik; use Piwik\Date; +use Piwik\Db; /** * Purges archived reports and metrics that are considered old. @@ -107,18 +108,18 @@ class Piwik_PrivacyManager_ReportsPurger if (!empty($oldBlobTables)) { // if no reports should be kept, drop tables, otherwise drop individual reports if (empty($this->reportPeriodsToKeep) && !$this->keepSegmentReports) { - Piwik_DropTables($oldBlobTables); + Db::dropTables($oldBlobTables); } else { foreach ($oldBlobTables as $table) { $where = $this->getBlobTableWhereExpr($oldNumericTables, $table); if (!empty($where)) { $where = "WHERE $where"; } - Piwik_DeleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); + Db::deleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); } if ($optimize) { - Piwik_OptimizeTables($oldBlobTables); + Db::optimizeTables($oldBlobTables); } } } @@ -129,15 +130,15 @@ class Piwik_PrivacyManager_ReportsPurger if ($this->keepBasicMetrics == 1 && !empty($this->metricsToKeep)) { $where = "WHERE name NOT IN ('" . implode("','", $this->metricsToKeep) . "') AND name NOT LIKE 'done%'"; foreach ($oldNumericTables as $table) { - Piwik_DeleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); + Db::deleteAllRows($table, $where, $this->maxRowsToDeletePerQuery); } if ($optimize) { - Piwik_OptimizeTables($oldNumericTables); + Db::optimizeTables($oldNumericTables); } } else // drop numeric tables { - Piwik_DropTables($oldNumericTables); + Db::dropTables($oldNumericTables); } } } @@ -249,7 +250,7 @@ class Piwik_PrivacyManager_ReportsPurger private function getNumericTableDeleteCount($table) { - $maxIdArchive = Piwik_FetchOne("SELECT MAX(idarchive) FROM $table"); + $maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table"); $sql = "SELECT COUNT(*) FROM $table @@ -258,13 +259,13 @@ class Piwik_PrivacyManager_ReportsPurger AND idarchive >= ? AND idarchive < ?"; - $segments = Piwik_SegmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); + $segments = Db::segmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); return array_sum($segments); } private function getBlobTableDeleteCount($oldNumericTables, $table) { - $maxIdArchive = Piwik_FetchOne("SELECT MAX(idarchive) FROM $table"); + $maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table"); $sql = "SELECT COUNT(*) FROM $table @@ -272,7 +273,7 @@ class Piwik_PrivacyManager_ReportsPurger AND idarchive >= ? AND idarchive < ?"; - $segments = Piwik_SegmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); + $segments = Db::segmentedFetchOne($sql, 0, $maxIdArchive, self::$selectSegmentSize); return array_sum($segments); } @@ -312,7 +313,7 @@ class Piwik_PrivacyManager_ReportsPurger foreach ($numericTables as $table) { $tableDate = ArchiveTableCreator::getDateFromTableName($table); - $maxIdArchive = Piwik_FetchOne("SELECT MAX(idarchive) FROM $table"); + $maxIdArchive = Db::fetchOne("SELECT MAX(idarchive) FROM $table"); $sql = "SELECT idarchive FROM $table @@ -322,7 +323,7 @@ class Piwik_PrivacyManager_ReportsPurger AND idarchive < ?"; $this->segmentArchiveIds[$tableDate] = array(); - foreach (Piwik_SegmentedFetchAll($sql, 0, $maxIdArchive, self::$selectSegmentSize) as $row) { + foreach (Db::segmentedFetchAll($sql, 0, $maxIdArchive, self::$selectSegmentSize) as $row) { $this->segmentArchiveIds[$tableDate][] = $row['idarchive']; } } diff --git a/plugins/Provider/Controller.php b/plugins/Provider/Controller.php index f59b8d1b29..078e10fb52 100644 --- a/plugins/Provider/Controller.php +++ b/plugins/Provider/Controller.php @@ -8,12 +8,14 @@ * @category Piwik_Plugins * @package Piwik_Provider */ +use Piwik\Controller; +use Piwik\ViewDataTable; /** * * @package Piwik_Provider */ -class Piwik_Provider_Controller extends Piwik_Controller +class Piwik_Provider_Controller extends Controller { /** * Provider @@ -22,7 +24,7 @@ class Piwik_Provider_Controller extends Piwik_Controller */ function getProvider($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, "Provider.getProvider"); $this->setPeriodVariablesView($view); diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index fe448e7395..834c85034e 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -9,6 +9,8 @@ * @package Piwik_Provider */ use Piwik\Common; +use Piwik\FrontController; +use Piwik\IP; use Piwik\Plugin; use Piwik\ArchiveProcessor; @@ -67,7 +69,7 @@ class Piwik_Provider extends Plugin // if the column already exist do not throw error. Could be installed twice... try { - Piwik_Exec($query); + Db::exec($query); } catch (Exception $e) { if (!Zend_Registry::get('db')->isErrNo($e, '1060')) { throw $e; @@ -80,12 +82,12 @@ class Piwik_Provider extends Plugin { // add column hostname / hostname ext in the visit table $query = "ALTER TABLE `" . Common::prefixTable('log_visit') . "` DROP `location_provider`"; - Piwik_Exec($query); + Db::exec($query); } function addWidget() { - Piwik_AddWidget('General_Visitors', 'Provider_WidgetProviders', 'Provider', 'getProvider'); + WidgetsList::add('General_Visitors', 'Provider_WidgetProviders', 'Provider', 'getProvider'); } function addMenu() @@ -109,7 +111,7 @@ class Piwik_Provider extends Plugin return; } - $ip = Piwik_IP::N2P($visitorInfo['location_ip']); + $ip = IP::N2P($visitorInfo['location_ip']); // In case the IP was anonymized, we should not continue since the DNS reverse lookup will fail and this will slow down tracking if (substr($ip, -2, 2) == '.0') { @@ -180,14 +182,14 @@ class Piwik_Provider extends Plugin */ private function getHost($ip) { - return trim(strtolower(@Piwik_IP::getHostByAddr($ip))); + return trim(strtolower(@IP::getHostByAddr($ip))); } static public function footerUserCountry(&$out) { $out = '<div> <h2>' . Piwik_Translate('Provider_WidgetProviders') . '</h2>'; - $out .= Piwik_FrontController::getInstance()->fetchDispatch('Provider', 'getProvider'); + $out .= FrontController::getInstance()->fetchDispatch('Provider', 'getProvider'); $out .= '</div>'; } diff --git a/plugins/Proxy/Controller.php b/plugins/Proxy/Controller.php index 9f49505e97..6633a70f5d 100644 --- a/plugins/Proxy/Controller.php +++ b/plugins/Proxy/Controller.php @@ -10,13 +10,16 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\AssetManager; +use Piwik\Controller; +use Piwik\Url; /** * Controller for proxy services * * @package Piwik_Proxy */ -class Piwik_Proxy_Controller extends Piwik_Controller +class Piwik_Proxy_Controller extends Controller { const TRANSPARENT_PNG_PIXEL = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABAQMAAAAl21bKAAAAA1BMVEUAAACnej3aAAAAAXRSTlMAQObYZgAAAApJREFUCNdjYAAAAAIAAeIhvDMAAAAASUVORK5CYII='; @@ -28,7 +31,7 @@ class Piwik_Proxy_Controller extends Piwik_Controller */ public function getCss() { - $cssMergedFile = Piwik_AssetManager::getMergedCssFileLocation(); + $cssMergedFile = AssetManager::getMergedCssFileLocation(); Piwik::serveStaticFile($cssMergedFile, "text/css"); } @@ -40,7 +43,7 @@ class Piwik_Proxy_Controller extends Piwik_Controller */ public function getJs() { - $jsMergedFile = Piwik_AssetManager::getMergedJsFileLocation(); + $jsMergedFile = AssetManager::getMergedJsFileLocation(); Piwik::serveStaticFile($jsMergedFile, "application/javascript; charset=UTF-8"); } @@ -55,8 +58,8 @@ class Piwik_Proxy_Controller extends Piwik_Controller $url = Common::getRequestVar('url', '', 'string', $_GET); // validate referrer - $referrer = Piwik_Url::getReferer(); - if (empty($referrer) || !Piwik_Url::isLocalUrl($referrer)) { + $referrer = Url::getReferer(); + if (empty($referrer) || !Url::isLocalUrl($referrer)) { die('Invalid Referer detected - This means that your web browser is not sending the "Referer URL" which is required to proceed with the redirect. Verify your browser settings and add-ons, to check why your browser is not sending this referer. diff --git a/plugins/Proxy/Proxy.php b/plugins/Proxy/Proxy.php index fc404bfd2e..47d085a70c 100644 --- a/plugins/Proxy/Proxy.php +++ b/plugins/Proxy/Proxy.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Proxy */ +use Piwik\Version; use Piwik\Plugin; /** @@ -30,7 +31,7 @@ class Piwik_Proxy extends Plugin 'description' => 'Proxy services', 'author' => 'Piwik', 'author_homepage' => 'http://piwik.org/', - 'version' => Piwik_Version::VERSION, + 'version' => Version::VERSION, 'translationAvailable' => false, ); } diff --git a/plugins/Referers/API.php b/plugins/Referers/API.php index a8dba84e0d..495a73f53f 100644 --- a/plugins/Referers/API.php +++ b/plugins/Referers/API.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_Referers */ +use Piwik\API\ResponseBuilder; use Piwik\Archive; use Piwik\DataTable\Row; use Piwik\Metrics; @@ -211,7 +212,7 @@ class Piwik_Referers_API $request['serialize'] = 0; // Apply generic filters - $response = new Piwik_API_ResponseBuilder($format = 'original', $request); + $response = new ResponseBuilder($format = 'original', $request); $table = $response->getResponse($table); // If period=lastX we only keep the first resultset as we want to return a plain list diff --git a/plugins/Referers/Archiver.php b/plugins/Referers/Archiver.php index dd7a795e9e..4da6a19d07 100644 --- a/plugins/Referers/Archiver.php +++ b/plugins/Referers/Archiver.php @@ -2,6 +2,7 @@ use Piwik\Common; use Piwik\Config; use Piwik\Metrics; +use Piwik\DataArray; use Piwik\PluginsArchiver; /** @@ -29,7 +30,7 @@ class Piwik_Referers_Archiver extends PluginsArchiver protected $columnToSortByBeforeTruncation; protected $maximumRowsInDataTableLevelZero; protected $maximumRowsInSubDataTable; - /* @var array[Piwik_DataArray] $arrays */ + /* @var array[DataArray] $arrays */ protected $arrays = array(); protected $distinctUrls = array(); @@ -44,7 +45,7 @@ class Piwik_Referers_Archiver extends PluginsArchiver public function archiveDay() { foreach ($this->getRecordNames() as $record) { - $this->arrays[$record] = new Piwik_DataArray(); + $this->arrays[$record] = new DataArray(); } $query = $this->getLogAggregator()->queryVisitsByDimension(array("referer_type", "referer_name", "referer_keyword", "referer_url")); $this->aggregateFromVisits($query); @@ -127,7 +128,7 @@ class Piwik_Referers_Archiver extends PluginsArchiver /** * @param $name - * @return Piwik_DataArray + * @return DataArray */ protected function getDataArray($name) { @@ -149,7 +150,7 @@ class Piwik_Referers_Archiver extends PluginsArchiver } foreach ($this->arrays as $dataArray) { - /* @var Piwik_DataArray $dataArray */ + /* @var DataArray $dataArray */ $dataArray->enrichMetricsWithConversions(); } } diff --git a/plugins/Referers/Controller.php b/plugins/Referers/Controller.php index 97d920e175..072fc1ec4a 100644 --- a/plugins/Referers/Controller.php +++ b/plugins/Referers/Controller.php @@ -8,20 +8,25 @@ * @category Piwik_Plugins * @package Piwik_Referers */ +use Piwik\API\Request; use Piwik\Metrics; use Piwik\Period\Range; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; +use Piwik\Url; /** * * @package Piwik_Referers */ -class Piwik_Referers_Controller extends Piwik_Controller +class Piwik_Referers_Controller extends Controller { function index() { - $view = new Piwik_View('@Referers/index'); + $view = new View('@Referers/index'); $view->graphEvolutionReferers = $this->getEvolutionGraph(true, Common::REFERER_TYPE_DIRECT_ENTRY, array('nb_visits')); $view->nameGraphEvolutionReferers = 'ReferersgetEvolutionGraph'; @@ -124,7 +129,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getSearchEnginesAndKeywords() { - $view = new Piwik_View('@Referers/getSearchEnginesAndKeywords'); + $view = new View('@Referers/getSearchEnginesAndKeywords'); $view->searchEngines = $this->getSearchEngines(true); $view->keywords = $this->getKeywords(true); echo $view->render(); @@ -132,7 +137,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getRefererType($fetch = false) { - $view = Piwik_ViewDataTable::factory('tableAllColumns'); + $view = ViewDataTable::factory('tableAllColumns'); $view->init($this->pluginName, __FUNCTION__, 'Referers.getRefererType', @@ -179,7 +184,7 @@ class Piwik_Referers_Controller extends Piwik_Controller */ public function getAll($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getAll'); $view->disableExcludeLowPopulation(); $view->setColumnTranslation('label', Piwik_Translate('Referers_Referrer')); @@ -235,7 +240,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getKeywords($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getKeywords', 'getSearchEnginesFromKeywordId' @@ -253,7 +258,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getSearchEnginesFromKeywordId($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getSearchEnginesFromKeywordId' ); @@ -267,7 +272,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getSearchEngines($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getSearchEngines', 'getKeywordsFromSearchEngineId' @@ -286,7 +291,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getKeywordsFromSearchEngineId($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getKeywordsFromSearchEngineId' ); @@ -299,7 +304,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function indexWebsites($fetch = false) { - $view = new Piwik_View('@Referers/indexWebsites'); + $view = new View('@Referers/indexWebsites'); $view->websites = $this->getWebsites(true); $view->socials = $this->getSocials(true); if ($fetch) { @@ -311,7 +316,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getWebsites($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getWebsites', 'getUrlsFromWebsiteId' @@ -329,7 +334,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getSocials($fetch = false) { - $view = Piwik_ViewDataTable::factory('graphPie'); + $view = ViewDataTable::factory('graphPie'); $view->init($this->pluginName, __FUNCTION__, 'Referers.getSocials', 'getUrlsForSocial'); $view->disableExcludeLowPopulation(); $view->setLimit(10); @@ -348,7 +353,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getUrlsForSocial($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getUrlsForSocial'); $view->disableExcludeLowPopulation(); $view->setLimit(10); @@ -362,14 +367,14 @@ class Piwik_Referers_Controller extends Piwik_Controller function indexCampaigns($fetch = false) { - return Piwik_View::singleReport( + return View::singleReport( Piwik_Translate('Referers_Campaigns'), $this->getCampaigns(true), $fetch); } function getCampaigns($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getCampaigns', 'getKeywordsFromCampaignId' @@ -391,7 +396,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getKeywordsFromCampaignId($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getKeywordsFromCampaignId' ); @@ -406,7 +411,7 @@ class Piwik_Referers_Controller extends Piwik_Controller function getUrlsFromWebsiteId($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'Referers.getUrlsFromWebsiteId' ); @@ -427,7 +432,7 @@ class Piwik_Referers_Controller extends Piwik_Controller // we disable the queued filters because here we want to get the visits coming from search engines // if the filters were applied we would have to look up for a label looking like "Search Engines" // which is not good when we have translations - $dataTableReferersType = Piwik_API_Request::processRequest( + $dataTableReferersType = Request::processRequest( "Referers.getRefererType", array('disable_queued_filters' => '1', 'date' => $date)); $nameToColumnId = array( @@ -548,7 +553,7 @@ class Piwik_Referers_Controller extends Piwik_Controller . '&method=Actions.getPageUrls' . '&filter_limit=50' . '&format=original'; - $request = new Piwik_API_Request($topPageUrlRequest); + $request = new Request($topPageUrlRequest); $request = $request->process(); $tables = $request->getArray(); @@ -566,7 +571,7 @@ class Piwik_Referers_Controller extends Piwik_Controller $url = $topPageUrl; // HTML - $api = Piwik_Url::getCurrentUrlWithoutFileName() + $api = Url::getCurrentUrlWithoutFileName() . '?module=API&method=Referers.getKeywordsForPageUrl' . '&format=php' . '&filter_limit=10' @@ -711,9 +716,9 @@ function DisplayTopKeywords($url = "") /** * Utility method that calculates evolution values for a set of current & past values - * and sets properties on a Piwik_View w/ HTML that displays the evolution percents. + * and sets properties on a View w/ HTML that displays the evolution percents. * - * @param Piwik_View $view The view to set properties on. + * @param View $view The view to set properties on. * @param string $date The date of the current values. * @param array $currentValues Array mapping view property names w/ present values. * @param string $lastPeriodDate The date of the period in the past. diff --git a/plugins/Referers/Referers.php b/plugins/Referers/Referers.php index 449bc0ce41..cc8642df6e 100644 --- a/plugins/Referers/Referers.php +++ b/plugins/Referers/Referers.php @@ -208,15 +208,15 @@ class Piwik_Referers extends Plugin */ function addWidgets() { - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetKeywords', 'Referers', 'getKeywords'); - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetExternalWebsites', 'Referers', 'getWebsites'); - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetSocials', 'Referers', 'getSocials'); - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetSearchEngines', 'Referers', 'getSearchEngines'); - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetCampaigns', 'Referers', 'getCampaigns'); - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetOverview', 'Referers', 'getRefererType'); - Piwik_AddWidget('Referers_Referers', 'Referers_WidgetGetAll', 'Referers', 'getAll'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetKeywords', 'Referers', 'getKeywords'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetExternalWebsites', 'Referers', 'getWebsites'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetSocials', 'Referers', 'getSocials'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetSearchEngines', 'Referers', 'getSearchEngines'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetCampaigns', 'Referers', 'getCampaigns'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetOverview', 'Referers', 'getRefererType'); + WidgetsList::add('Referers_Referers', 'Referers_WidgetGetAll', 'Referers', 'getAll'); if (Piwik::isSegmentationEnabled()) { - Piwik_AddWidget('SEO', 'Referers_WidgetTopKeywordsForPages', 'Referers', 'getKeywordsForPage'); + WidgetsList::add('SEO', 'Referers_WidgetTopKeywordsForPages', 'Referers', 'getKeywordsForPage'); } } diff --git a/plugins/SEO/Controller.php b/plugins/SEO/Controller.php index b509264871..207d92a179 100644 --- a/plugins/SEO/Controller.php +++ b/plugins/SEO/Controller.php @@ -10,12 +10,14 @@ */ use Piwik\Common; use Piwik\DataTable\Renderer; +use Piwik\Controller; +use Piwik\View; use Piwik\Site; /** * @package Piwik_SEO */ -class Piwik_SEO_Controller extends Piwik_Controller +class Piwik_SEO_Controller extends Controller { function getRank() { @@ -34,7 +36,7 @@ class Piwik_SEO_Controller extends Piwik_Controller $dataTable = Piwik_SEO_API::getInstance()->getRank($url); - $view = new Piwik_View('@SEO/getRank'); + $view = new View('@SEO/getRank'); $view->urlToRank = Piwik_SEO_RankChecker::extractDomainFromUrl($url); $renderer = Renderer::factory('php'); diff --git a/plugins/SEO/MajesticClient.php b/plugins/SEO/MajesticClient.php index 250fa0025b..34f16a038e 100644 --- a/plugins/SEO/MajesticClient.php +++ b/plugins/SEO/MajesticClient.php @@ -9,6 +9,7 @@ * @package Piwik_SEO */ use Piwik\Common; +use Piwik\Http; /** * Client for Majestic SEO's HTTP API. @@ -57,7 +58,7 @@ class Piwik_SEO_MajesticClient 'items' => '1', 'item0' => $siteDomain )); - $apiResponse = Piwik_Http::sendHttpRequest($apiUrl, $timeout); + $apiResponse = Http::sendHttpRequest($apiUrl, $timeout); $result = array( 'backlink_count' => false, diff --git a/plugins/SEO/RankChecker.php b/plugins/SEO/RankChecker.php index aa4d44c87e..cdc858176c 100644 --- a/plugins/SEO/RankChecker.php +++ b/plugins/SEO/RankChecker.php @@ -9,6 +9,7 @@ * @package Piwik_SEO */ use Piwik\Piwik; +use Piwik\Http; /** * The functions below are derived/adapted from GetRank.org's @@ -56,7 +57,7 @@ class Piwik_SEO_RankChecker private function getPage($url) { try { - return str_replace(' ', ' ', Piwik_Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT'])); + return str_replace(' ', ' ', Http::sendHttpRequest($url, $timeout = 10, @$_SERVER['HTTP_USER_AGENT'])); } catch (Exception $e) { return ''; } diff --git a/plugins/SEO/SEO.php b/plugins/SEO/SEO.php index e41c93385c..9d5b68efe9 100644 --- a/plugins/SEO/SEO.php +++ b/plugins/SEO/SEO.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_SEO */ +use Piwik\Version; use Piwik\Plugin; /** @@ -24,7 +25,7 @@ class Piwik_SEO extends Plugin 'description' => 'This Plugin extracts and displays SEO metrics: Alexa web ranking, Google Pagerank, number of Indexed pages and backlinks of the currently selected website.', 'author' => 'Piwik', 'author_homepage' => 'http://piwik.org/', - 'version' => Piwik_Version::VERSION, + 'version' => Version::VERSION, ); } @@ -39,6 +40,6 @@ class Piwik_SEO extends Plugin function addWidgets() { - Piwik_AddWidget('SEO', 'SEO_SeoRankings', 'SEO', 'getRank'); + WidgetsList::add('SEO', 'SEO_SeoRankings', 'SEO', 'getRank'); } } diff --git a/plugins/SecurityInfo/Controller.php b/plugins/SecurityInfo/Controller.php index c9b307bba4..7195185fdd 100644 --- a/plugins/SecurityInfo/Controller.php +++ b/plugins/SecurityInfo/Controller.php @@ -8,12 +8,14 @@ * @category Piwik_Plugins * @package Piwik_SecurityInfo */ +use Piwik\Controller\Admin; use Piwik\Piwik; +use Piwik\View; /** * @package Piwik_SecurityInfo */ -class Piwik_SecurityInfo_Controller extends Piwik_Controller_Admin +class Piwik_SecurityInfo_Controller extends Admin { function index() { @@ -35,7 +37,7 @@ class Piwik_SecurityInfo_Controller extends Piwik_Controller_Admin unset($results['test_results']['Core']['post_max_size']); unset($results['test_results']['Core']['upload_max_filesize']); - $view = new Piwik_View('@SecurityInfo/index'); + $view = new View('@SecurityInfo/index'); $this->setBasicVariablesView($view); $view->results = $results; echo $view->render(); diff --git a/plugins/SecurityInfo/PhpSecInfo/Test/Application/php.php b/plugins/SecurityInfo/PhpSecInfo/Test/Application/php.php index 3199cb3167..98b170f427 100644 --- a/plugins/SecurityInfo/PhpSecInfo/Test/Application/php.php +++ b/plugins/SecurityInfo/PhpSecInfo/Test/Application/php.php @@ -5,6 +5,8 @@ * @package PhpSecInfo * @author Piwik */ +use Piwik\Http; +use Piwik\UpdateCheck; /** * require the PhpSecInfo_Test_Application class @@ -30,9 +32,9 @@ class PhpSecInfo_Test_Application_Php extends PhpSecInfo_Test_Application $this->current_value = PHP_VERSION; $url = 'http://php.net/releases/?serialize=1&version=5'; - $timeout = Piwik_UpdateCheck::SOCKET_TIMEOUT; + $timeout = UpdateCheck::SOCKET_TIMEOUT; try { - $latestVersion = Piwik_Http::sendHttpRequest($url, $timeout); + $latestVersion = Http::sendHttpRequest($url, $timeout); $versionInfo = safe_unserialize($latestVersion); $this->recommended_value = $versionInfo['version']; } catch (Exception $e) { diff --git a/plugins/SecurityInfo/PhpSecInfo/Test/Application/piwik.php b/plugins/SecurityInfo/PhpSecInfo/Test/Application/piwik.php index 16e7fbf42f..e3aa84f16b 100644 --- a/plugins/SecurityInfo/PhpSecInfo/Test/Application/piwik.php +++ b/plugins/SecurityInfo/PhpSecInfo/Test/Application/piwik.php @@ -5,6 +5,8 @@ * @package PhpSecInfo * @author Piwik */ +use Piwik\Version; +use Piwik\UpdateCheck; /** * require the PhpSecInfo_Test_Application class @@ -27,9 +29,9 @@ class PhpSecInfo_Test_Application_Piwik extends PhpSecInfo_Test_Application function _retrieveCurrentValue() { - $this->current_value = Piwik_Version::VERSION; + $this->current_value = Version::VERSION; - $this->recommended_value = Piwik_GetOption(Piwik_UpdateCheck::LATEST_VERSION); + $this->recommended_value = Piwik_GetOption(UpdateCheck::LATEST_VERSION); } function _execTest() diff --git a/plugins/SecurityInfo/PhpSecInfo/Test/Test_Application.php b/plugins/SecurityInfo/PhpSecInfo/Test/Test_Application.php index af97310aad..c87b9d2856 100644 --- a/plugins/SecurityInfo/PhpSecInfo/Test/Test_Application.php +++ b/plugins/SecurityInfo/PhpSecInfo/Test/Test_Application.php @@ -5,6 +5,7 @@ * @package PhpSecInfo * @author Anthon Pang */ +use Piwik\Http; /** * require the main PhpSecInfo class @@ -36,7 +37,7 @@ class PhpSecInfo_Test_Application extends PhpSecInfo_Test */ function isTestable() { - return Piwik_Http::getTransportMethod() !== null; + return Http::getTransportMethod() !== null; } function getMoreInfoURL() diff --git a/plugins/SegmentEditor/Controller.php b/plugins/SegmentEditor/Controller.php index bafab7ac46..4083369ece 100644 --- a/plugins/SegmentEditor/Controller.php +++ b/plugins/SegmentEditor/Controller.php @@ -10,16 +10,18 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * @package Piwik_SegmentEditor */ -class Piwik_SegmentEditor_Controller extends Piwik_Controller +class Piwik_SegmentEditor_Controller extends Controller { public function getSelector() { - $view = new Piwik_View('@SegmentEditor/getSelector'); + $view = new View('@SegmentEditor/getSelector'); $idSite = Common::getRequestVar('idSite'); $this->setGeneralVariablesView($view); $segments = Piwik_API_API::getInstance()->getSegmentsMetadata($idSite); diff --git a/plugins/SegmentEditor/SegmentEditor.php b/plugins/SegmentEditor/SegmentEditor.php index a4f54d01e7..0d539b078f 100644 --- a/plugins/SegmentEditor/SegmentEditor.php +++ b/plugins/SegmentEditor/SegmentEditor.php @@ -9,6 +9,7 @@ * @package Piwik_SegmentEditor */ use Piwik\Common; +use Piwik\Version; use Piwik\Plugin; /** @@ -25,7 +26,7 @@ class Piwik_SegmentEditor extends Plugin 'description' => 'Create and reuse custom visitor Segments with the Segment Editor.', 'author' => 'Piwik', 'author_homepage' => 'http://piwik.org/', - 'version' => Piwik_Version::VERSION, + 'version' => Version::VERSION, ); } @@ -84,7 +85,7 @@ class Piwik_SegmentEditor extends Plugin ) DEFAULT CHARSET=utf8'; try { foreach ($queries as $query) { - Piwik_Exec($query); + Db::exec($query); } } catch (Exception $e) { if (!Zend_Registry::get('db')->isErrNo($e, '1050')) { diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php index edc66625e6..47b3e44f1d 100644 --- a/plugins/SitesManager/API.php +++ b/plugins/SitesManager/API.php @@ -12,6 +12,9 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Access; use Piwik\Date; +use Piwik\IP; +use Piwik\Url; +use Piwik\TaskScheduler; use Piwik\Site; /** @@ -69,7 +72,7 @@ class Piwik_SitesManager_API Piwik::checkUserHasViewAccess($idSite); if (empty($piwikUrl)) { - $piwikUrl = Piwik_Url::getCurrentUrlWithoutFileName(); + $piwikUrl = Url::getCurrentUrlWithoutFileName(); } $piwikUrl = Common::sanitizeInputValues($piwikUrl); @@ -170,7 +173,7 @@ class Piwik_SitesManager_API */ private function getSitesId() { - $result = Piwik_FetchAll("SELECT idsite FROM " . Common::prefixTable('site')); + $result = Db::fetchAll("SELECT idsite FROM " . Common::prefixTable('site')); $idSites = array(); foreach ($result as $idSite) { $idSites[] = $idSite['idsite']; @@ -225,7 +228,7 @@ class Piwik_SitesManager_API if (empty($timestamp)) $timestamp = time(); $time = Date::factory((int)$timestamp)->getDatetime(); - $result = Piwik_FetchAll(" + $result = Db::fetchAll(" SELECT idsite FROM @@ -321,7 +324,7 @@ class Piwik_SitesManager_API // but during scheduled task execution, we sometimes want to restrict sites to // a different login than the superuser. && (Piwik::isUserIsSuperUserOrTheUser($_restrictSitesToLogin) - || Piwik_TaskScheduler::isTaskBeingExecuted()) + || TaskScheduler::isTaskBeingExecuted()) ) { $accessRaw = Access::getInstance()->getRawSitesWithSomeViewAccess($_restrictSitesToLogin); $sitesId = array(); @@ -681,12 +684,12 @@ class Piwik_SitesManager_API */ public function getIpsForRange($ipRange) { - $range = Piwik_IP::getIpsForRange($ipRange); + $range = IP::getIpsForRange($ipRange); if ($range === false) { return false; } - return array(Piwik_IP::N2P($range[0]), Piwik_IP::N2P($range[1])); + return array(IP::N2P($range[0]), IP::N2P($range[1])); } /** @@ -1164,7 +1167,7 @@ class Piwik_SitesManager_API public function getUniqueSiteTimezones() { Piwik::checkUserIsSuperUser(); - $results = Piwik_FetchAll("SELECT distinct timezone FROM " . Common::prefixTable('site')); + $results = Db::fetchAll("SELECT distinct timezone FROM " . Common::prefixTable('site')); $timezones = array(); foreach ($results as $result) { $timezones[] = $result['timezone']; @@ -1237,7 +1240,7 @@ class Piwik_SitesManager_API */ private function isValidIp($ip) { - return Piwik_IP::getIpsForRange($ip) !== false; + return IP::getIpsForRange($ip) !== false; } /** diff --git a/plugins/SitesManager/Controller.php b/plugins/SitesManager/Controller.php index afbd9d21ed..3a8f339693 100644 --- a/plugins/SitesManager/Controller.php +++ b/plugins/SitesManager/Controller.php @@ -8,24 +8,29 @@ * @category Piwik_Plugins * @package Piwik_SitesManager */ +use Piwik\API\ResponseBuilder; +use Piwik\Controller\Admin; use Piwik\DataTable\Renderer\Json; use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\IP; +use Piwik\View; +use Piwik\Url; use Piwik\Site; /** * * @package Piwik_SitesManager */ -class Piwik_SitesManager_Controller extends Piwik_Controller_Admin +class Piwik_SitesManager_Controller extends Admin { /** * Main view showing listing of websites and settings */ public function index() { - $view = new Piwik_View('@SitesManager/index'); + $view = new View('@SitesManager/index'); if (Piwik::isUserIsSuperUser()) { $sites = Piwik_SitesManager_API::getInstance()->getAllSites(); @@ -70,7 +75,7 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin $view->globalKeepURLFragments = Piwik_SitesManager_API::getInstance()->getKeepURLFragmentsGlobal(); - $view->currentIpAddress = Piwik_IP::getIpFromHeader(); + $view->currentIpAddress = IP::getIpFromHeader(); $view->showAddSite = (boolean)Common::getRequestVar('showaddsite', false); @@ -83,7 +88,7 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin */ public function setGlobalSettings() { - $response = new Piwik_API_ResponseBuilder(Common::getRequestVar('format')); + $response = new ResponseBuilder(Common::getRequestVar('format')); try { $this->checkTokenInUrl(); @@ -122,8 +127,8 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin { $idSite = Common::getRequestVar('idSite'); Piwik::checkUserHasViewAccess($idSite); - $jsTag = Piwik::getJavascriptCode($idSite, Piwik_Url::getCurrentUrlWithoutFileName()); - $view = new Piwik_View('@SitesManager/displayJavascriptCode'); + $jsTag = Piwik::getJavascriptCode($idSite, Url::getCurrentUrlWithoutFileName()); + $view = new View('@SitesManager/displayJavascriptCode'); $this->setBasicVariablesView($view); $view->idSite = $idSite; $site = new Site($idSite); @@ -149,7 +154,7 @@ class Piwik_SitesManager_Controller extends Piwik_Controller_Admin */ function displayAlternativeTagsHelp() { - $view = new Piwik_View('@SitesManager/displayAlternativeTagsHelp'); + $view = new View('@SitesManager/displayAlternativeTagsHelp'); $view->idSite = Common::getRequestVar('idSite'); $url = Common::getRequestVar('piwikUrl', '', 'string'); if (empty($url) diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index ac04dac368..4b4e034750 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -19,6 +19,8 @@ use Piwik\Period\Day; use Piwik\Piwik; use Piwik\Common; use Piwik\DataTable; +use Piwik\DataArray; +use Piwik\RankingQuery; use Piwik\Segment; use Piwik\SegmentExpression; use Piwik\Site; @@ -286,7 +288,7 @@ class Piwik_Transitions_API $types[Piwik_Tracker_Action::TYPE_OUTLINK] = 'outlinks'; $types[Piwik_Tracker_Action::TYPE_DOWNLOAD] = 'downloads'; - $rankingQuery = new Piwik_RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); $rankingQuery->addLabelColumn(array('name', 'url_prefix')); $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($types)); @@ -343,7 +345,7 @@ class Piwik_Transitions_API */ public function queryExternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = false) { - $rankingQuery = new Piwik_RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); // we generate a single column that contains the interesting data for each referrer. // the reason we cannot group by referer_* becomes clear when we look at search engine keywords. @@ -401,7 +403,7 @@ class Piwik_Transitions_API } //FIXMEA refactor after integration tests written - $array = new Piwik_DataArray($referrerData, $referrerSubData); + $array = new DataArray($referrerData, $referrerSubData); return Day::getDataTableFromDataArray($array); } @@ -416,7 +418,7 @@ class Piwik_Transitions_API */ protected function queryInternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = false) { - $rankingQuery = new Piwik_RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); $rankingQuery->addLabelColumn(array('name', 'url_prefix')); $rankingQuery->setColumnToMarkExcludedRows('is_self'); $rankingQuery->partitionResultIntoMultipleGroups('action_partition', array(0, 1, 2)); @@ -588,7 +590,7 @@ class Piwik_Transitions_API } } - // if there's no data for referrers, Piwik_API_ResponseBuilder::handleMultiDimensionalArray + // if there's no data for referrers, ResponseBuilder::handleMultiDimensionalArray // does not detect the multi dimensional array and the data is rendered differently, which // causes an exception. if (count($report['referrers']) == 0) { diff --git a/plugins/Transitions/Controller.php b/plugins/Transitions/Controller.php index 01b72bb7ff..5178b1923f 100644 --- a/plugins/Transitions/Controller.php +++ b/plugins/Transitions/Controller.php @@ -8,11 +8,13 @@ * @category Piwik_Plugins * @package Piwik_Transitions */ +use Piwik\Controller; +use Piwik\View; /** * @package Piwik_Transitions */ -class Piwik_Transitions_Controller extends Piwik_Controller +class Piwik_Transitions_Controller extends Controller { /** @@ -74,7 +76,7 @@ class Piwik_Transitions_Controller extends Piwik_Controller */ public function renderPopover() { - $view = new Piwik_View('@Transitions/renderPopover'); + $view = new View('@Transitions/renderPopover'); $view->translations = $this->getTranslations(); echo $view->render(); } diff --git a/plugins/Transitions/javascripts/transitions.js b/plugins/Transitions/javascripts/transitions.js index 14ccd28a19..6f0a633bec 100644 --- a/plugins/Transitions/javascripts/transitions.js +++ b/plugins/Transitions/javascripts/transitions.js @@ -47,7 +47,7 @@ DataTable_RowActions_Transitions.prototype.trigger = function (tr, e, subTableLa }; DataTable_RowAction.prototype.performAction = function (label, tr, e) { - var separator = ' > '; // Piwik_API_DataTableManipulator_LabelFilter::SEPARATOR_RECURSIVE_LABEL + var separator = ' > '; // LabelFilter::SEPARATOR_RECURSIVE_LABEL var labelParts = label.split(separator); for (var i = 0; i < labelParts.length; i++) { labelParts[i] = $.trim(decodeURIComponent(labelParts[i])); diff --git a/plugins/UserCountry/Archiver.php b/plugins/UserCountry/Archiver.php index 129da79557..4544f2b764 100644 --- a/plugins/UserCountry/Archiver.php +++ b/plugins/UserCountry/Archiver.php @@ -12,6 +12,7 @@ use Piwik\ArchiveProcessor\Day; use Piwik\Metrics; use Piwik\DataTable; +use Piwik\DataArray; use Piwik\PluginsArchiver; class Piwik_UserCountry_Archiver extends PluginsArchiver @@ -44,7 +45,7 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver public function archiveDay() { foreach($this->dimensions as $dimension) { - $this->arrays[$dimension] = new Piwik_DataArray(); + $this->arrays[$dimension] = new DataArray(); } $this->aggregateFromVisits(); $this->aggregateFromConversions(); @@ -64,7 +65,7 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver $this->makeRegionCityLabelsUnique($row); $this->rememberCityLatLong($row); - /* @var $dataArray Piwik_DataArray */ + /* @var $dataArray DataArray */ foreach ($this->arrays as $dimension => $dataArray) { $dataArray->sumMetricsVisits($row[$dimension], $row); } @@ -113,13 +114,13 @@ class Piwik_UserCountry_Archiver extends PluginsArchiver while ($row = $query->fetch()) { $this->makeRegionCityLabelsUnique($row); - /* @var $dataArray Piwik_DataArray */ + /* @var $dataArray DataArray */ foreach ($this->arrays as $dimension => $dataArray) { $dataArray->sumMetricsGoals($row[$dimension], $row); } } - /* @var $dataArray Piwik_DataArray */ + /* @var $dataArray DataArray */ foreach ($this->arrays as $dataArray) { $dataArray->enrichMetricsWithConversions(); } diff --git a/plugins/UserCountry/Controller.php b/plugins/UserCountry/Controller.php index 9c547ee6dc..1fcd911832 100644 --- a/plugins/UserCountry/Controller.php +++ b/plugins/UserCountry/Controller.php @@ -8,19 +8,25 @@ * @category Piwik_Plugins * @package Piwik_UserCountry */ +use Piwik\Controller\Admin; use Piwik\DataTable\Renderer\Json; use Piwik\Piwik; use Piwik\Common; +use Piwik\Http; +use Piwik\IP; +use Piwik\ViewDataTable; +use Piwik\View; +use Piwik\Url; /** * * @package Piwik_UserCountry */ -class Piwik_UserCountry_Controller extends Piwik_Controller_Admin +class Piwik_UserCountry_Controller extends Admin { function index() { - $view = new Piwik_View('@UserCountry/index'); + $view = new View('@UserCountry/index'); $view->urlSparklineCountries = $this->getUrlSparkline('getLastDistinctCountriesGraph'); $view->numberDistinctCountries = $this->getNumberOfDistinctCountries(true); @@ -36,13 +42,13 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin function adminIndex() { Piwik::checkUserIsSuperUser(); - $view = new Piwik_View('@UserCountry/adminIndex'); + $view = new View('@UserCountry/adminIndex'); $allProviderInfo = Piwik_UserCountry_LocationProvider::getAllProviderInfo( $newline = '<br/>', $includeExtra = true); $view->locationProviders = $allProviderInfo; $view->currentProviderId = Piwik_UserCountry_LocationProvider::getCurrentProviderId(); - $view->thisIP = Piwik_IP::getIpFromHeader(); + $view->thisIP = IP::getIpFromHeader(); $geoIPDatabasesInstalled = Piwik_UserCountry_LocationProvider_GeoIp::isDatabaseInstalled(); $view->geoIPDatabasesInstalled = $geoIPDatabasesInstalled; @@ -72,7 +78,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin $this->setUpdaterManageVars($view); $this->setBasicVariablesView($view); - Piwik_Controller_Admin::setBasicVariablesAdminView($view); + Admin::setBasicVariablesAdminView($view); echo $view->render(); } @@ -102,7 +108,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin Json::sendHeaderJSON(); $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase('GeoIPCity.dat') . '.gz'; try { - $result = Piwik_Http::downloadChunk( + $result = Http::downloadChunk( $url = Piwik_UserCountry_LocationProvider_GeoIp::GEO_LITE_URL, $outputPath, $continue = Common::getRequestVar('continue', true, 'int') @@ -136,7 +142,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin */ private function getGeoIpUpdaterManageScreen() { - $view = new Piwik_View('@UserCountry/getGeoIpUpdaterManageScreen'); + $view = new View('@UserCountry/getGeoIpUpdaterManageScreen'); $view->geoIPDatabasesInstalled = true; $this->setUpdaterManageVars($view); return $view->render(); @@ -145,7 +151,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin /** * Sets some variables needed by the _updaterManage.twig template. * - * @param Piwik_View $view + * @param View $view */ private function setUpdaterManageVars($view) { @@ -242,7 +248,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin $outputPath = Piwik_UserCountry_LocationProvider_GeoIp::getPathForGeoIpDatabase($filename); // download part of the file - $result = Piwik_Http::downloadChunk( + $result = Http::downloadChunk( $url, $outputPath, Common::getRequestVar('continue', true, 'int')); // if the file is done @@ -304,7 +310,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin throw new Exception("Invalid provider ID: '$providerId'."); } - $location = $provider->getLocation(array('ip' => Piwik_IP::getIpFromHeader(), + $location = $provider->getLocation(array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true)); $location = Piwik_UserCountry_LocationProvider::prettyFormatLocation( @@ -380,7 +386,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin $APItoCall, $defaultDatatableType = null) { - $view = Piwik_ViewDataTable::factory($defaultDatatableType); + $view = ViewDataTable::factory($defaultDatatableType); $view->init($this->pluginName, $currentControllerAction, $APItoCall); $view->disableExcludeLowPopulation(); @@ -427,7 +433,7 @@ class Piwik_UserCountry_Controller extends Piwik_Controller_Admin if (!$this->isGeoIPWorking()) { $params = array('module' => 'UserCountry', 'action' => 'adminIndex'); $footerMessage .= ' ' . Piwik_Translate('UserCountry_NoDataForGeoIPReport2', array( - '<a target="_blank" href="' . Piwik_Url::getCurrentQueryStringWithParametersModified($params) . '">', + '<a target="_blank" href="' . Url::getCurrentQueryStringWithParametersModified($params) . '">', '</a>', '<a target="_blank" href="http://dev.maxmind.com/geoip/geolite?rId=piwik">', '</a>' diff --git a/plugins/UserCountry/GeoIPAutoUpdater.php b/plugins/UserCountry/GeoIPAutoUpdater.php index dea98daa0f..d981e47b6d 100755 --- a/plugins/UserCountry/GeoIPAutoUpdater.php +++ b/plugins/UserCountry/GeoIPAutoUpdater.php @@ -11,6 +11,9 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\Http; +use Piwik\Unzip; +use Piwik\ScheduledTask; /** * Used to automatically update installed GeoIP databases, and manages the updater's @@ -96,7 +99,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater // download zipped file to misc dir try { - $success = Piwik_Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath); + $success = Http::sendHttpRequest($url, $timeout = 3600, $userAgent = null, $zippedOutputPath); } catch (Exception $ex) { throw new Exception("Piwik_UserCountry_GeoIPAutoUpdater: failed to download '$url' to " . "'$zippedOutputPath': " . $ex->getMessage()); @@ -138,7 +141,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater // extract file if (substr($path, -7, 7) == '.tar.gz') { // find the .dat file in the tar archive - $unzip = Piwik_Unzip::factory('tar.gz', $path); + $unzip = Unzip::factory('tar.gz', $path); $content = $unzip->listContent(); if (empty($content)) { @@ -172,7 +175,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater fwrite($fd, $unzipped); fclose($fd); } else if (substr($path, -3, 3) == '.gz') { - $unzip = Piwik_Unzip::factory('gz', $path); + $unzip = Unzip::factory('gz', $path); $success = $unzip->extract($outputPath); if ($success !== true) { @@ -242,7 +245,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater /** * Creates a ScheduledTask instance based on set option values. * - * @return Piwik_ScheduledTask + * @return ScheduledTask */ public static function makeScheduledTask() { @@ -264,7 +267,7 @@ class Piwik_UserCountry_GeoIPAutoUpdater break; } - return new Piwik_ScheduledTask($instance, 'update', null, $schedulePeriod, Piwik_ScheduledTask::LOWEST_PRIORITY); + return new ScheduledTask($instance, 'update', null, $schedulePeriod, ScheduledTask::LOWEST_PRIORITY); } /** diff --git a/plugins/UserCountry/LocationProvider.php b/plugins/UserCountry/LocationProvider.php index 153247a252..5fb24a4dd2 100755 --- a/plugins/UserCountry/LocationProvider.php +++ b/plugins/UserCountry/LocationProvider.php @@ -9,6 +9,7 @@ * @package Piwik_UserCountry */ use Piwik\Common; +use Piwik\IP; /** * @see plugins/UserCountry/LocationProvider/Default.php @@ -179,7 +180,7 @@ abstract class Piwik_UserCountry_LocationProvider * 'status' - Either self::NOT_INSTALLED, self::INSTALLED or self::BROKEN. * 'statusMessage' - If the status is self::BROKEN, then the message describes why. * 'location' - A pretty formatted location of the current IP address - * (Piwik_IP::getIpFromHeader()). + * (IP::getIpFromHeader()). * * An example result: * array( @@ -216,7 +217,7 @@ abstract class Piwik_UserCountry_LocationProvider $workingOrError = $provider->isWorking(); if ($workingOrError === true) // if the implementation is configured correctly, get the location { - $locInfo = array('ip' => Piwik_IP::getIpFromHeader(), + $locInfo = array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true); @@ -439,9 +440,9 @@ abstract class Piwik_UserCountry_LocationProvider protected function getIpFromInfo($info) { $ip = $info['ip']; - if (Piwik_IP::isMappedIPv4($ip)) { - return Piwik_IP::getIPv4FromMappedIPv6($ip); - } else if (Piwik_IP::isIPv6($ip)) // IPv6 is not supported (yet) + if (IP::isMappedIPv4($ip)) { + return IP::getIPv4FromMappedIPv6($ip); + } else if (IP::isIPv6($ip)) // IPv6 is not supported (yet) { return false; } else { diff --git a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php index 382ee9a319..ab3942974f 100755 --- a/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php +++ b/plugins/UserCountry/LocationProvider/GeoIp/ServerBased.php @@ -10,6 +10,7 @@ */ use Piwik\Common; +use Piwik\IP; /** * A LocationProvider that uses an GeoIP module installed in an HTTP Server. @@ -66,7 +67,7 @@ class Piwik_UserCountry_LocationProvider_GeoIp_ServerBased extends Piwik_UserCou // geoip modules that are built into servers can't use a forced IP. in this case we try // to fallback to another version. - $myIP = Piwik_IP::getIpFromHeader(); + $myIP = IP::getIpFromHeader(); if (!self::isSameOrAnonymizedIp($ip, $myIP) && (!isset($info['disable_fallbacks']) || !$info['disable_fallbacks']) diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index 72c7cbda9b..008345a785 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -98,10 +98,10 @@ class Piwik_UserCountry extends Plugin $widgetCityLabel = Piwik_Translate('UserCountry_WidgetLocation') . ' (' . Piwik_Translate('UserCountry_City') . ')'; - Piwik_AddWidget('General_Visitors', $widgetContinentLabel, 'UserCountry', 'getContinent'); - Piwik_AddWidget('General_Visitors', $widgetCountryLabel, 'UserCountry', 'getCountry'); - Piwik_AddWidget('General_Visitors', $widgetRegionLabel, 'UserCountry', 'getRegion'); - Piwik_AddWidget('General_Visitors', $widgetCityLabel, 'UserCountry', 'getCity'); + WidgetsList::add('General_Visitors', $widgetContinentLabel, 'UserCountry', 'getContinent'); + WidgetsList::add('General_Visitors', $widgetCountryLabel, 'UserCountry', 'getCountry'); + WidgetsList::add('General_Visitors', $widgetRegionLabel, 'UserCountry', 'getRegion'); + WidgetsList::add('General_Visitors', $widgetCityLabel, 'UserCountry', 'getCity'); } function addMenu() diff --git a/plugins/UserCountryMap/Controller.php b/plugins/UserCountryMap/Controller.php index f9f52e8233..a70e3a83d7 100644 --- a/plugins/UserCountryMap/Controller.php +++ b/plugins/UserCountryMap/Controller.php @@ -8,8 +8,12 @@ * @category Piwik_Plugins * @package Piwik_UserCountryMap */ +use Piwik\API\Request; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; use Piwik\Site; use Piwik\Config; @@ -17,7 +21,7 @@ use Piwik\Config; * * @package Piwik_UserCountryMap */ -class Piwik_UserCountryMap_Controller extends Piwik_Controller +class Piwik_UserCountryMap_Controller extends Controller { // By default plot up to the last 30 days of visitors on the map, for low traffic sites @@ -34,10 +38,10 @@ class Piwik_UserCountryMap_Controller extends Piwik_Controller $date = Common::getRequestVar('date'); $token_auth = Piwik::getCurrentUserTokenAuth(); - $view = new Piwik_View('@UserCountryMap/visitorMap'); + $view = new View('@UserCountryMap/visitorMap'); // request visits summary - $request = new Piwik_API_Request( + $request = new Request( 'method=VisitsSummary.get&format=PHP' . '&idSite=' . $idSite . '&period=' . $period @@ -107,7 +111,7 @@ class Piwik_UserCountryMap_Controller extends Piwik_Controller Piwik::checkUserHasViewAccess($idSite); $token_auth = Piwik::getCurrentUserTokenAuth(); - $view = new Piwik_View('@UserCountryMap/realtimeMap'); + $view = new View('@UserCountryMap/realtimeMap'); $view->mapIsStandaloneNotWidget = $standalone; @@ -153,7 +157,7 @@ class Piwik_UserCountryMap_Controller extends Piwik_Controller { $params['format'] = 'json'; $params['showRawMetrics'] = 1; - $segment = Piwik_ViewDataTable::getRawSegmentFromRequest(); + $segment = ViewDataTable::getRawSegmentFromRequest(); if(!empty($segment)) { $params['segment'] = $segment; } @@ -171,7 +175,7 @@ class Piwik_UserCountryMap_Controller extends Piwik_Controller private function getMetrics($idSite, $period, $date, $token_auth) { - $request = new Piwik_API_Request( + $request = new Request( 'method=API.getMetadata&format=PHP' . '&apiModule=UserCountry&apiAction=getCountry' . '&idSite=' . $idSite @@ -203,7 +207,7 @@ class Piwik_UserCountryMap_Controller extends Piwik_Controller . "&period=" . $period . "&date=" . $date . "&token_auth=" . $token_auth - . "&segment=" . Piwik_ViewDataTable::getRawSegmentFromRequest() + . "&segment=" . ViewDataTable::getRawSegmentFromRequest() . "&enable_filter_excludelowpop=1" . "&showRawMetrics=1"; diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php index 1659288d1c..ac9255a303 100644 --- a/plugins/UserCountryMap/UserCountryMap.php +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -8,6 +8,8 @@ * @category Piwik_Plugins * @package Piwik_UserCountryMap */ +use Piwik\FrontController; +use Piwik\Version; use Piwik\Plugin; /** @@ -26,14 +28,14 @@ class Piwik_UserCountryMap extends Plugin 'description' => 'This plugin provides the widgets Visitor Map and Real-time Map. Note: Requires the UserCountry plugin enabled.', 'author' => 'Piwik', 'author_homepage' => 'http://piwik.org/', - 'version' => Piwik_Version::VERSION + 'version' => Version::VERSION ); } public function postLoad() { - Piwik_AddWidget('General_Visitors', Piwik_Translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap'); - Piwik_AddWidget('Live!', Piwik_Translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap'); + WidgetsList::add('General_Visitors', Piwik_Translate('UserCountryMap_VisitorMap'), 'UserCountryMap', 'visitorMap'); + WidgetsList::add('Live!', Piwik_Translate('UserCountryMap_RealTimeMap'), 'UserCountryMap', 'realtimeMap'); Piwik_AddAction('template_leftColumnUserCountry', array('Piwik_UserCountryMap', 'insertMapInLocationReport')); } @@ -41,7 +43,7 @@ class Piwik_UserCountryMap extends Plugin static public function insertMapInLocationReport(&$out) { $out = '<h2>' . Piwik_Translate('UserCountryMap_VisitorMap') . '</h2>'; - $out .= Piwik_FrontController::getInstance()->fetchDispatch('UserCountryMap', 'visitorMap'); + $out .= FrontController::getInstance()->fetchDispatch('UserCountryMap', 'visitorMap'); } /** diff --git a/plugins/UserSettings/Archiver.php b/plugins/UserSettings/Archiver.php index 40f6b94eb3..cdfa858d6e 100644 --- a/plugins/UserSettings/Archiver.php +++ b/plugins/UserSettings/Archiver.php @@ -13,6 +13,7 @@ use Piwik\Common; use Piwik\DataAccess\LogAggregator; use Piwik\Metrics; use Piwik\DataTable; +use Piwik\DataArray; use Piwik\PluginsArchiver; require_once PIWIK_INCLUDE_PATH . '/plugins/UserSettings/functions.php'; @@ -125,7 +126,7 @@ class Piwik_UserSettings_Archiver extends PluginsArchiver { $query = $this->getLogAggregator()->queryVisitsByDimension( array("label" => self::LANGUAGE_DIMENSION) ); $languageCodes = array_keys(Common::getLanguagesList()); - $metricsByLanguage = new Piwik_DataArray(); + $metricsByLanguage = new DataArray(); while ($row = $query->fetch()) { $code = Common::extractLanguageCodeFromBrowserLanguage($row['label'], $languageCodes); $metricsByLanguage->sumMetricsVisits($code, $row); diff --git a/plugins/UserSettings/Controller.php b/plugins/UserSettings/Controller.php index 515eacf118..086cd020e7 100644 --- a/plugins/UserSettings/Controller.php +++ b/plugins/UserSettings/Controller.php @@ -8,16 +8,19 @@ * @category Piwik_Plugins * @package Piwik_UserSettings */ +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * * @package Piwik_UserSettings */ -class Piwik_UserSettings_Controller extends Piwik_Controller +class Piwik_UserSettings_Controller extends Controller { public function index() { - $view = new Piwik_View('@UserSettings/index'); + $view = new View('@UserSettings/index'); $view->dataTablePlugin = $this->getPlugin(true); $view->dataTableResolution = $this->getResolution(true); @@ -33,56 +36,56 @@ class Piwik_UserSettings_Controller extends Piwik_Controller public function getResolution($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getConfiguration($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getOS($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getOSFamily($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getMobileVsDesktop($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getBrowserVersion($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getBrowser($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getBrowserType($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getWideScreen($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getPlugin($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getLanguage($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } } diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index ce5a37f707..618f8fdfd9 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -355,7 +355,7 @@ class Piwik_UserSettings extends Plugin foreach ($this->reportMetadata as $report) { list($category, $name, $controllerName, $controllerAction) = $report; if ($category == false) continue; - Piwik_AddWidget($category, $name, $controllerName, $controllerAction); + WidgetsList::add($category, $name, $controllerName, $controllerAction); } } diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php index c4c8dc0806..0eeda5be60 100644 --- a/plugins/UsersManager/API.php +++ b/plugins/UsersManager/API.php @@ -485,7 +485,7 @@ class Piwik_UsersManager_API */ public function userExists($userLogin) { - $count = Piwik_FetchOne("SELECT count(*) + $count = Db::fetchOne("SELECT count(*) FROM " . Common::prefixTable("user") . " WHERE login = ?", $userLogin); return $count != 0; @@ -500,7 +500,7 @@ class Piwik_UsersManager_API public function userEmailExists($userEmail) { Piwik::checkUserIsNotAnonymous(); - $count = Piwik_FetchOne("SELECT count(*) + $count = Db::fetchOne("SELECT count(*) FROM " . Common::prefixTable("user") . " WHERE email = ?", $userEmail); return $count != 0 diff --git a/plugins/UsersManager/Controller.php b/plugins/UsersManager/Controller.php index 506c6e6acc..9bc778c6ff 100644 --- a/plugins/UsersManager/Controller.php +++ b/plugins/UsersManager/Controller.php @@ -8,16 +8,20 @@ * @category Piwik_Plugins * @package Piwik_UsersManager */ +use Piwik\API\ResponseBuilder; +use Piwik\Controller\Admin; use Piwik\Piwik; use Piwik\Common; use Piwik\Config; +use Piwik\View; +use Piwik\Url; use Piwik\Site; /** * * @package Piwik_UsersManager */ -class Piwik_UsersManager_Controller extends Piwik_Controller_Admin +class Piwik_UsersManager_Controller extends Admin { static function orderByName($a, $b) { @@ -31,7 +35,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin { Piwik::checkUserIsNotAnonymous(); - $view = new Piwik_View('@UsersManager/index'); + $view = new View('@UsersManager/index'); $IdSitesAdmin = Piwik_SitesManager_API::getInstance()->getSitesIdWithAdminAccess(); $idSiteSelected = 1; @@ -123,7 +127,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin { Piwik::checkUserIsNotAnonymous(); - $view = new Piwik_View('@UsersManager/userSettings'); + $view = new View('@UsersManager/userSettings'); $userLogin = Piwik::getCurrentUserLogin(); if (Piwik::isUserIsSuperUser()) { @@ -164,7 +168,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin $view->ignoreCookieSet = Piwik_Tracker_IgnoreCookie::isIgnoreCookieFound(); $this->initViewAnonymousUserSettings($view); - $view->piwikHost = Piwik_Url::getCurrentHost(); + $view->piwikHost = Url::getCurrentHost(); $this->setBasicVariablesView($view); echo $view->render(); } @@ -181,7 +185,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin /** * The Super User can modify Anonymous user settings - * @param Piwik_View $view + * @param View $view */ protected function initViewAnonymousUserSettings($view) { @@ -226,7 +230,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin */ public function recordAnonymousUserSettings() { - $response = new Piwik_API_ResponseBuilder(Common::getRequestVar('format')); + $response = new ResponseBuilder(Common::getRequestVar('format')); try { Piwik::checkUserIsSuperUser(); $this->checkTokenInUrl(); @@ -253,7 +257,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin */ public function recordUserSettings() { - $response = new Piwik_API_ResponseBuilder(Common::getRequestVar('format')); + $response = new ResponseBuilder(Common::getRequestVar('format')); try { $this->checkTokenInUrl(); @@ -275,7 +279,7 @@ class Piwik_UsersManager_Controller extends Piwik_Controller_Admin } // UI disables password change on invalid host, but check here anyway - if (!Piwik_Url::isValidHost() + if (!Url::isValidHost() && $newPassword !== false ) { throw new Exception("Cannot change password with untrusted hostname!"); diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php index 8d2aeb7a57..3c3b0a761a 100644 --- a/plugins/UsersManager/UsersManager.php +++ b/plugins/UsersManager/UsersManager.php @@ -9,6 +9,7 @@ * @package Piwik_UsersManager */ use Piwik\Piwik; +use Piwik\Piwik_Option; use Piwik\Plugin; /** diff --git a/plugins/VisitFrequency/API.php b/plugins/VisitFrequency/API.php index 08d37c30b2..7e77d561ec 100644 --- a/plugins/VisitFrequency/API.php +++ b/plugins/VisitFrequency/API.php @@ -8,6 +8,7 @@ * @category Piwik_Plugins * @package Piwik_VisitFrequency */ +use Piwik\API\Request; use Piwik\Piwik; use Piwik\SegmentExpression; @@ -43,7 +44,7 @@ class Piwik_VisitFrequency_API 'format' => 'original', 'serialize' => 0 // tests set this to 1 ); - $table = Piwik_API_Request::processRequest('VisitsSummary.get', $params); + $table = Request::processRequest('VisitsSummary.get', $params); $this->prefixColumns($table, $period); return $table; } diff --git a/plugins/VisitFrequency/Controller.php b/plugins/VisitFrequency/Controller.php index c9362959cc..77baa6b539 100644 --- a/plugins/VisitFrequency/Controller.php +++ b/plugins/VisitFrequency/Controller.php @@ -8,18 +8,21 @@ * @category Piwik_Plugins * @package Piwik_VisitFrequency */ +use Piwik\API\Request; use Piwik\Piwik; use Piwik\Common; +use Piwik\Controller; +use Piwik\View; /** * * @package Piwik_VisitFrequency */ -class Piwik_VisitFrequency_Controller extends Piwik_Controller +class Piwik_VisitFrequency_Controller extends Controller { function index() { - $view = new Piwik_View('@VisitFrequency/index'); + $view = new View('@VisitFrequency/index'); $view->graphEvolutionVisitFrequency = $this->getEvolutionGraph(true, array('nb_visits_returning')); $this->setSparklinesAndNumbers($view); echo $view->render(); @@ -27,7 +30,7 @@ class Piwik_VisitFrequency_Controller extends Piwik_Controller public function getSparklines() { - $view = new Piwik_View('@VisitFrequency/getSparklines'); + $view = new View('@VisitFrequency/getSparklines'); $this->setSparklinesAndNumbers($view); echo $view->render(); } @@ -99,7 +102,7 @@ class Piwik_VisitFrequency_Controller extends Piwik_Controller protected function getSummary() { $requestString = "method=VisitFrequency.get&format=original"; - $request = new Piwik_API_Request($requestString); + $request = new Request($requestString); return $request->process(); } } diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index ee5c0ecd2a..95586de73e 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -56,8 +56,8 @@ class Piwik_VisitFrequency extends Plugin function addWidgets() { - Piwik_AddWidget('General_Visitors', 'VisitFrequency_WidgetOverview', 'VisitFrequency', 'getSparklines'); - Piwik_AddWidget('General_Visitors', 'VisitFrequency_WidgetGraphReturning', 'VisitFrequency', 'getEvolutionGraph', array('columns' => array('nb_visits_returning'))); + WidgetsList::add('General_Visitors', 'VisitFrequency_WidgetOverview', 'VisitFrequency', 'getSparklines'); + WidgetsList::add('General_Visitors', 'VisitFrequency_WidgetGraphReturning', 'VisitFrequency', 'getEvolutionGraph', array('columns' => array('nb_visits_returning'))); } function addMenu() diff --git a/plugins/VisitTime/Archiver.php b/plugins/VisitTime/Archiver.php index fd6c1dcc8b..77b7659d9b 100644 --- a/plugins/VisitTime/Archiver.php +++ b/plugins/VisitTime/Archiver.php @@ -10,6 +10,7 @@ */ use Piwik\Date; +use Piwik\DataArray; use Piwik\PluginsArchiver; class Piwik_VisitTime_Archiver extends PluginsArchiver @@ -47,7 +48,7 @@ class Piwik_VisitTime_Archiver extends PluginsArchiver $this->getProcessor()->insertBlobRecord(self::LOCAL_TIME_RECORD_NAME, $this->getProcessor()->getDataTableFromDataArray($array)->getSerialized()); } - protected function convertTimeToLocalTimezone(Piwik_DataArray &$array) + protected function convertTimeToLocalTimezone(DataArray &$array) { $date = Date::factory($this->getProcessor()->getDateStart()->getDateStartUTC())->toString(); $timezone = $this->getProcessor()->getSite()->getTimezone(); @@ -58,16 +59,16 @@ class Piwik_VisitTime_Archiver extends PluginsArchiver $hourInTz = (int)Date::factory($datetime, $timezone)->toString('H'); $converted[$hourInTz] = $stats; } - return new Piwik_DataArray($converted); + return new DataArray($converted); } - private function ensureAllHoursAreSet( Piwik_DataArray &$array) + private function ensureAllHoursAreSet( DataArray &$array) { $data = $array->getDataArray(); for ($i = 0; $i <= 23; $i++) { if (empty($data[$i])) { - $array->sumMetricsVisits( $i, Piwik_DataArray::makeEmptyRow()); + $array->sumMetricsVisits( $i, DataArray::makeEmptyRow()); } } } diff --git a/plugins/VisitTime/Controller.php b/plugins/VisitTime/Controller.php index 600262625c..1cc2169741 100644 --- a/plugins/VisitTime/Controller.php +++ b/plugins/VisitTime/Controller.php @@ -8,16 +8,19 @@ * @category Piwik_Plugins * @package Piwik_VisitTime */ +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * * @package Piwik_VisitTime */ -class Piwik_VisitTime_Controller extends Piwik_Controller +class Piwik_VisitTime_Controller extends Controller { public function index() { - $view = new Piwik_View('@VisitTime/index'); + $view = new View('@VisitTime/index'); $view->dataTableVisitInformationPerLocalTime = $this->getVisitInformationPerLocalTime(true); $view->dataTableVisitInformationPerServerTime = $this->getVisitInformationPerServerTime(true); echo $view->render(); @@ -25,16 +28,16 @@ class Piwik_VisitTime_Controller extends Piwik_Controller public function getVisitInformationPerServerTime($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getVisitInformationPerLocalTime($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } public function getByDayOfWeek($fetch = false) { - return Piwik_ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); + return ViewDataTable::render($this->pluginName, __FUNCTION__, $fetch); } } diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index 4d73dd8ae0..d654eeb947 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -76,9 +76,9 @@ class Piwik_VisitTime extends Plugin function addWidgets() { - Piwik_AddWidget('VisitsSummary_VisitsSummary', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime'); - Piwik_AddWidget('VisitsSummary_VisitsSummary', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime'); - Piwik_AddWidget('VisitsSummary_VisitsSummary', 'VisitTime_VisitsByDayOfWeek', 'VisitTime', 'getByDayOfWeek'); + WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetLocalTime', 'VisitTime', 'getVisitInformationPerLocalTime'); + WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_WidgetServerTime', 'VisitTime', 'getVisitInformationPerServerTime'); + WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_VisitsByDayOfWeek', 'VisitTime', 'getByDayOfWeek'); } function addMenu() diff --git a/plugins/VisitorGenerator/Controller.php b/plugins/VisitorGenerator/Controller.php index 1a4f9facd0..f0275b3348 100644 --- a/plugins/VisitorGenerator/Controller.php +++ b/plugins/VisitorGenerator/Controller.php @@ -9,16 +9,22 @@ * @package Piwik_VisitorGenerator */ use Piwik\ArchiveProcessor\Rules; +use Piwik\Controller\Admin; use Piwik\Piwik; use Piwik\Common; use Piwik\Date; +use Piwik\Http; +use Piwik\Nonce; +use Piwik\View; +use Piwik\Url; +use Piwik\Timer; use Piwik\Site; /** * * @package Piwik_VisitorGenerator */ -class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin +class Piwik_VisitorGenerator_Controller extends Admin { public function index() { @@ -26,10 +32,10 @@ class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin $sitesList = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess(); - $view = new Piwik_View('@VisitorGenerator/index'); + $view = new View('@VisitorGenerator/index'); $this->setBasicVariablesView($view); $view->assign('sitesList', $sitesList); - $view->nonce = Piwik_Nonce::getNonce('Piwik_VisitorGenerator.generate'); + $view->nonce = Nonce::getNonce('Piwik_VisitorGenerator.generate'); $view->countActionsPerRun = count($this->getAccessLog()); $view->accessLogPath = $this->getAccessLogPath(); echo $view->render(); @@ -51,11 +57,11 @@ class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin Piwik::checkUserIsSuperUser(); $nonce = Common::getRequestVar('form_nonce', '', 'string', $_POST); if (Common::getRequestVar('choice', 'no') != 'yes' || - !Piwik_Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce) + !Nonce::verifyNonce('Piwik_VisitorGenerator.generate', $nonce) ) { Piwik::redirectToModule('VisitorGenerator', 'index'); } - Piwik_Nonce::discardNonce('Piwik_VisitorGenerator.generate'); + Nonce::discardNonce('Piwik_VisitorGenerator.generate'); $daysToCompute = Common::getRequestVar('daysToCompute', 1, 'int'); @@ -65,7 +71,7 @@ class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin Piwik::setMaxExecutionTime(0); - $timer = new Piwik_Timer; + $timer = new Timer; $time = time() - ($daysToCompute - 1) * 86400; $nbActionsTotal = 0; @@ -83,7 +89,7 @@ class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin $browserArchiving = Rules::isBrowserTriggerEnabled(); // Init view - $view = new Piwik_View('@VisitorGenerator/generate'); + $view = new View('@VisitorGenerator/generate'); $this->setBasicVariablesView($view); $view->assign('browserArchivingEnabled', $browserArchiving); $view->assign('timer', $timer); @@ -114,7 +120,7 @@ class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin "fr-ch", "fr", ); - $prefix = Piwik_Url::getCurrentUrlWithoutFileName() . "piwik.php"; + $prefix = Url::getCurrentUrlWithoutFileName() . "piwik.php"; $count = 0; foreach ($logs as $log) { if (!preg_match('/^(\S+) \S+ \S+ \[(.*?)\] "GET (\S+.*?)" \d+ \d+ "(.*?)" "(.*?)"/', $log, $m)) { @@ -150,7 +156,7 @@ class Piwik_VisitorGenerator_Controller extends Piwik_Controller_Admin $acceptLanguage = $acceptLanguages[$count % count($acceptLanguages)]; - if ($output = Piwik_Http::sendHttpRequest($url, $timeout = 5, $ua, $path = null, $follow = 0, $acceptLanguage)) { + if ($output = Http::sendHttpRequest($url, $timeout = 5, $ua, $path = null, $follow = 0, $acceptLanguage)) { $count++; } } diff --git a/plugins/VisitorInterest/Controller.php b/plugins/VisitorInterest/Controller.php index cecb7fd61c..b3a658f5c8 100644 --- a/plugins/VisitorInterest/Controller.php +++ b/plugins/VisitorInterest/Controller.php @@ -9,15 +9,18 @@ * @package Piwik_VisitorInterest */ use Piwik\Metrics; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; /** * @package Piwik_VisitorInterest */ -class Piwik_VisitorInterest_Controller extends Piwik_Controller +class Piwik_VisitorInterest_Controller extends Controller { public function index() { - $view = new Piwik_View('@VisitorInterest/index'); + $view = new View('@VisitorInterest/index'); $view->dataTableNumberOfVisitsPerVisitDuration = $this->getNumberOfVisitsPerVisitDuration(true); $view->dataTableNumberOfVisitsPerPage = $this->getNumberOfVisitsPerPage(true); $view->dataTableNumberOfVisitsByVisitNum = $this->getNumberOfVisitsByVisitCount(true); @@ -27,7 +30,7 @@ class Piwik_VisitorInterest_Controller extends Piwik_Controller public 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')); @@ -45,7 +48,7 @@ class Piwik_VisitorInterest_Controller extends Piwik_Controller public function getNumberOfVisitsPerPage($fetch = false) { - $view = Piwik_ViewDataTable::factory('cloud'); + $view = ViewDataTable::factory('cloud'); $view->init($this->pluginName, __FUNCTION__, "VisitorInterest.getNumberOfVisitsPerPage"); $view->setColumnsToDisplay(array('label', 'nb_visits')); $view->setSortedColumn('label', 'asc'); @@ -69,7 +72,7 @@ class Piwik_VisitorInterest_Controller extends Piwik_Controller */ public function getNumberOfVisitsByVisitCount($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, "VisitorInterest.getNumberOfVisitsByVisitCount"); $view->setColumnsToDisplay(array('label', 'nb_visits', 'nb_visits_percentage')); $view->setSortedColumn('label', 'asc'); @@ -95,7 +98,7 @@ class Piwik_VisitorInterest_Controller extends Piwik_Controller */ public function getNumberOfVisitsByDaysSinceLast($fetch = false) { - $view = Piwik_ViewDataTable::factory(); + $view = ViewDataTable::factory(); $view->init($this->pluginName, __FUNCTION__, 'VisitorInterest.getNumberOfVisitsByDaysSinceLast'); $view->setColumnsToDisplay(array('label', 'nb_visits')); $view->setSortedColumn('label', 'asc'); diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index a503253e1c..12cc0b79c1 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -9,6 +9,7 @@ * @package Piwik_VisitorInterest */ use Piwik\ArchiveProcessor; +use Piwik\FrontController; use Piwik\Plugin; /** @@ -95,10 +96,10 @@ class Piwik_VisitorInterest extends Plugin function addWidgets() { - Piwik_AddWidget('General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration'); - Piwik_AddWidget('General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage'); - Piwik_AddWidget('General_Visitors', 'VisitorInterest_visitsByVisitCount', 'VisitorInterest', 'getNumberOfVisitsByVisitCount'); - Piwik_AddWidget('General_Visitors', 'VisitorInterest_WidgetVisitsByDaysSinceLast', 'VisitorInterest', 'getNumberOfVisitsByDaysSinceLast'); + WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetLengths', 'VisitorInterest', 'getNumberOfVisitsPerVisitDuration'); + WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetPages', 'VisitorInterest', 'getNumberOfVisitsPerPage'); + WidgetsList::add('General_Visitors', 'VisitorInterest_visitsByVisitCount', 'VisitorInterest', 'getNumberOfVisitsByVisitCount'); + WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetVisitsByDaysSinceLast', 'VisitorInterest', 'getNumberOfVisitsByDaysSinceLast'); } function addMenu() @@ -139,7 +140,7 @@ class Piwik_VisitorInterest extends Plugin $out = '</div> <div id="rightcolumn"> '; - $out .= Piwik_FrontController::getInstance()->fetchDispatch('VisitorInterest', 'index'); + $out .= FrontController::getInstance()->fetchDispatch('VisitorInterest', 'index'); $out .= '</div>'; } } diff --git a/plugins/VisitsSummary/Controller.php b/plugins/VisitsSummary/Controller.php index bc30a1e6aa..fc32e77e9e 100644 --- a/plugins/VisitsSummary/Controller.php +++ b/plugins/VisitsSummary/Controller.php @@ -8,21 +8,25 @@ * @category Piwik_Plugins * @package Piwik_VisitsSummary */ +use Piwik\API\Request; use Piwik\DataTable\Row; use Piwik\Piwik; use Piwik\Common; use Piwik\DataTable; +use Piwik\Controller; +use Piwik\ViewDataTable; +use Piwik\View; use Piwik\Site; /** * * @package Piwik_VisitsSummary */ -class Piwik_VisitsSummary_Controller extends Piwik_Controller +class Piwik_VisitsSummary_Controller extends Controller { public function index() { - $view = new Piwik_View('@VisitsSummary/index'); + $view = new View('@VisitsSummary/index'); $this->setPeriodVariablesView($view); $view->graphEvolutionVisitsSummary = $this->getEvolutionGraph(true, array('nb_visits')); $this->setSparklinesAndNumbers($view); @@ -31,7 +35,7 @@ class Piwik_VisitsSummary_Controller extends Piwik_Controller public function getSparklines() { - $view = new Piwik_View('@VisitsSummary/getSparklines'); + $view = new View('@VisitsSummary/getSparklines'); $this->setPeriodVariablesView($view); $this->setSparklinesAndNumbers($view); echo $view->render(); @@ -98,7 +102,7 @@ class Piwik_VisitsSummary_Controller extends Piwik_Controller // we disable filters for example "search for pattern", in the case this method is called // by a method that already calls the API with some generic filters applied "&disable_generic_filters=1"; - $request = new Piwik_API_Request($requestString); + $request = new Request($requestString); $result = $request->process(); return empty($result) ? new DataTable() : $result; } @@ -108,7 +112,7 @@ class Piwik_VisitsSummary_Controller extends Piwik_Controller $requestString = "method=VisitsSummary.getVisits" . "&format=original" . "&disable_generic_filters=1"; - $request = new Piwik_API_Request($requestString); + $request = new Request($requestString); return $request->process(); } @@ -134,7 +138,7 @@ class Piwik_VisitsSummary_Controller extends Piwik_Controller $dataTableVisit = self::getVisitsSummary(); $dataRow = $dataTableVisit->getRowsCount() == 0 ? new Row() : $dataTableVisit->getFirstRow(); - $dataTableActions = Piwik_Actions_API::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), Piwik_ViewDataTable::getRawSegmentFromRequest()); + $dataTableActions = Piwik_Actions_API::getInstance()->get($idSite, Common::getRequestVar('period'), Common::getRequestVar('date'), ViewDataTable::getRawSegmentFromRequest()); $dataActionsRow = $dataTableActions->getRowsCount() == 0 ? new Row() : $dataTableActions->getFirstRow(); diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index fec9352492..70da748a5e 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -58,9 +58,9 @@ class Piwik_VisitsSummary extends Plugin function addWidgets() { - Piwik_AddWidget('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetLastVisits', 'VisitsSummary', 'getEvolutionGraph', array('columns' => array('nb_visits'))); - Piwik_AddWidget('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetVisits', 'VisitsSummary', 'getSparklines'); - Piwik_AddWidget('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetOverviewGraph', 'VisitsSummary', 'index'); + WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetLastVisits', 'VisitsSummary', 'getEvolutionGraph', array('columns' => array('nb_visits'))); + WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetVisits', 'VisitsSummary', 'getSparklines'); + WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetOverviewGraph', 'VisitsSummary', 'index'); } function addMenu() diff --git a/plugins/Widgetize/Controller.php b/plugins/Widgetize/Controller.php index dad2506936..c7e80a2464 100644 --- a/plugins/Widgetize/Controller.php +++ b/plugins/Widgetize/Controller.php @@ -8,25 +8,29 @@ * @category Piwik_Plugins * @package Piwik_Widgetize */ +use Piwik\API\Request; use Piwik\Common; +use Piwik\Controller; +use Piwik\FrontController; +use Piwik\View; /** * * @package Piwik_Widgetize */ -class Piwik_Widgetize_Controller extends Piwik_Controller +class Piwik_Widgetize_Controller extends Controller { public function index() { - $view = new Piwik_View('@Widgetize/index'); - $view->availableWidgets = Common::json_encode(Piwik_GetWidgetsList()); + $view = new View('@Widgetize/index'); + $view->availableWidgets = Common::json_encode(WidgetsList::get()); $this->setGeneralVariablesView($view); echo $view->render(); } public function testJsInclude1() { - $view = new Piwik_View('@Widgetize/testJsInclude1'); + $view = new View('@Widgetize/testJsInclude1'); $view->url1 = '?module=Widgetize&action=js&moduleToWidgetize=UserSettings&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday'; $view->url2 = '?module=Widgetize&action=js&moduleToWidgetize=API&actionToWidgetize=index&method=ExamplePlugin.getGoldenRatio&format=original'; echo $view->render(); @@ -34,7 +38,7 @@ class Piwik_Widgetize_Controller extends Piwik_Controller public function testJsInclude2() { - $view = new Piwik_View('@Widgetize/testJsInclude2'); + $view = new View('@Widgetize/testJsInclude2'); $view->url1 = '?module=Widgetize&action=js&moduleToWidgetize=UserSettings&actionToWidgetize=getBrowser&idSite=1&period=day&date=yesterday'; $view->url2 = '?module=Widgetize&action=js&moduleToWidgetize=UserCountry&actionToWidgetize=getCountry&idSite=1&period=day&date=yesterday&viewDataTable=cloud&show_footer=0'; $view->url3 = '?module=Widgetize&action=js&moduleToWidgetize=Referers&actionToWidgetize=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=table&show_footer=0'; @@ -43,16 +47,16 @@ class Piwik_Widgetize_Controller extends Piwik_Controller public function iframe() { - Piwik_API_Request::reloadAuthUsingTokenAuth(); + Request::reloadAuthUsingTokenAuth(); $this->init(); $controllerName = Common::getRequestVar('moduleToWidgetize'); $actionName = Common::getRequestVar('actionToWidgetize'); $parameters = array($fetch = true); - $outputDataTable = Piwik_FrontController::getInstance()->fetchDispatch($controllerName, $actionName, $parameters); + $outputDataTable = FrontController::getInstance()->fetchDispatch($controllerName, $actionName, $parameters); if ($controllerName == 'Dashboard' && $actionName == 'index') { - $view = new Piwik_View('@Widgetize/iframe_empty'); + $view = new View('@Widgetize/iframe_empty'); } else { - $view = new Piwik_View('@Widgetize/iframe'); + $view = new View('@Widgetize/iframe'); } $this->setGeneralVariablesView($view); $view->setXFrameOptions('allow'); |