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/Referers | |
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/Referers')
-rw-r--r-- | plugins/Referers/API.php | 3 | ||||
-rw-r--r-- | plugins/Referers/Archiver.php | 9 | ||||
-rw-r--r-- | plugins/Referers/Controller.php | 49 | ||||
-rw-r--r-- | plugins/Referers/Referers.php | 16 |
4 files changed, 42 insertions, 35 deletions
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'); } } |