From 11752942f0e6526a0d254af2bb2b101491238f29 Mon Sep 17 00:00:00 2001 From: mattab Date: Wed, 31 Jul 2013 18:46:40 +0200 Subject: Refs #3741 PHP Namespace conversion continued: Tracker classes, renaming Unzip to Uncompress, Renaming Tracker/Referer to Tracker/Referrer, and few more --- plugins/Actions/API.php | 15 +++++++------- plugins/Actions/Actions.php | 11 ++++++----- plugins/Actions/Archiver.php | 39 +++++++++++++++++++------------------ plugins/Actions/ArchivingHelper.php | 29 ++++++++++++++------------- 4 files changed, 49 insertions(+), 45 deletions(-) (limited to 'plugins/Actions') diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php index b40afb87e2..263e3e4a6b 100644 --- a/plugins/Actions/API.php +++ b/plugins/Actions/API.php @@ -14,6 +14,7 @@ use Piwik\Piwik; use Piwik\Common; use Piwik\Date; use Piwik\DataTable; +use Piwik\Tracker\Action; /** * The Actions API lets you request reports for all your Visitor Actions: Page URLs, Page titles (Piwik Events), @@ -200,7 +201,7 @@ class Piwik_Actions_API public function getPageUrl($pageUrl, $idSite, $period, $date, $segment = false) { $callBackParameters = array('Actions_actions_url', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false); - $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageUrl, Piwik_Tracker_Action::TYPE_ACTION_URL); + $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageUrl, Action::TYPE_ACTION_URL); $this->filterPageDatatable($dataTable); $this->filterActionsDataTable($dataTable); return $dataTable; @@ -241,7 +242,7 @@ class Piwik_Actions_API public function getPageTitle($pageName, $idSite, $period, $date, $segment = false) { $callBackParameters = array('Actions_actions', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false); - $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageName, Piwik_Tracker_Action::TYPE_ACTION_NAME); + $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $pageName, Action::TYPE_ACTION_NAME); $this->filterPageDatatable($dataTable); $this->filterActionsDataTable($dataTable); return $dataTable; @@ -257,7 +258,7 @@ class Piwik_Actions_API public function getDownload($downloadUrl, $idSite, $period, $date, $segment = false) { $callBackParameters = array('Actions_downloads', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false); - $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $downloadUrl, Piwik_Tracker_Action::TYPE_DOWNLOAD); + $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $downloadUrl, Action::TYPE_DOWNLOAD); $this->filterActionsDataTable($dataTable); return $dataTable; } @@ -272,7 +273,7 @@ class Piwik_Actions_API public function getOutlink($outlinkUrl, $idSite, $period, $date, $segment = false) { $callBackParameters = array('Actions_outlink', $idSite, $period, $date, $segment, $expanded = false, $idSubtable = false); - $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $outlinkUrl, Piwik_Tracker_Action::TYPE_OUTLINK); + $dataTable = $this->getFilterPageDatatableSearch($callBackParameters, $outlinkUrl, Action::TYPE_OUTLINK); $this->filterActionsDataTable($dataTable); return $dataTable; } @@ -329,7 +330,7 @@ class Piwik_Actions_API Piwik_Actions::checkCustomVariablesPluginEnabled(); $customVariables = Piwik_CustomVariables_API::getInstance()->getCustomVariables($idSite, $period, $date, $segment, $expanded = false, $_leavePiwikCoreVariables = true); - $customVarNameToLookFor = Piwik_Tracker_Action::CVAR_KEY_SEARCH_CATEGORY; + $customVarNameToLookFor = Action::CVAR_KEY_SEARCH_CATEGORY; $dataTable = new DataTable(); // Handle case where date=last30&period=day @@ -372,12 +373,12 @@ class Piwik_Actions_API { if ($searchTree === false) { // build the query parts that are searched inside the tree - if ($actionType == Piwik_Tracker_Action::TYPE_ACTION_NAME) { + if ($actionType == Action::TYPE_ACTION_NAME) { $searchedString = Common::unsanitizeInputValue($search); } else { $idSite = $callBackParameters[1]; try { - $searchedString = Piwik_Tracker_Action::excludeQueryParametersFromUrl($search, $idSite); + $searchedString = Action::excludeQueryParametersFromUrl($search, $idSite); } catch (Exception $e) { $searchedString = $search; } diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index f7bcef4b1f..fdd116c671 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -12,6 +12,7 @@ use Piwik\API\Request; use Piwik\ArchiveProcessor; use Piwik\Piwik; use Piwik\Common; +use Piwik\Tracker\Action; use Piwik\ViewDataTable; use Piwik\WidgetsList; use Piwik\Plugin; @@ -147,7 +148,7 @@ class Piwik_Actions extends Plugin { $actionType = $this->guessActionTypeFromSegment($segmentName); - if ($actionType == Piwik_Tracker_Action::TYPE_ACTION_URL) { + if ($actionType == Action::TYPE_ACTION_URL) { // for urls trim protocol and www because it is not recorded in the db $valueToMatch = preg_replace('@^http[s]?://(www\.)?@i', '', $valueToMatch); } @@ -158,7 +159,7 @@ class Piwik_Actions extends Plugin if ($matchType == SegmentExpression::MATCH_EQUAL || $matchType == SegmentExpression::MATCH_NOT_EQUAL ) { - $sql = Piwik_Tracker_Action::getSqlSelectActionId(); + $sql = Action::getSqlSelectActionId(); $bind = array($valueToMatch, $valueToMatch, $actionType); $idAction = Db::fetchOne($sql, $bind); // if the action is not found, we hack -100 to ensure it tries to match against an integer @@ -614,13 +615,13 @@ class Piwik_Actions extends Plugin protected function guessActionTypeFromSegment($segmentName) { if (stripos($segmentName, 'pageurl') !== false) { - $actionType = Piwik_Tracker_Action::TYPE_ACTION_URL; + $actionType = Action::TYPE_ACTION_URL; return $actionType; } elseif (stripos($segmentName, 'pagetitle') !== false) { - $actionType = Piwik_Tracker_Action::TYPE_ACTION_NAME; + $actionType = Action::TYPE_ACTION_NAME; return $actionType; } elseif (stripos($segmentName, 'sitesearch') !== false) { - $actionType = Piwik_Tracker_Action::TYPE_SITE_SEARCH; + $actionType = Action::TYPE_SITE_SEARCH; return $actionType; } else { throw new Exception(" The segment $segmentName has an unexpected value."); diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index dc6242dd95..f3dfa31138 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -15,6 +15,7 @@ use Piwik\Metrics; use Piwik\DataTable; use Piwik\RankingQuery; use Piwik\PluginsArchiver; +use Piwik\Tracker\Action; /** * Class encapsulating logic to process Day/Period Archiving for the Actions reports @@ -53,11 +54,11 @@ class Piwik_Actions_Archiver extends PluginsArchiver ); public static $actionTypes = array( - Piwik_Tracker_Action::TYPE_ACTION_URL, - Piwik_Tracker_Action::TYPE_OUTLINK, - Piwik_Tracker_Action::TYPE_DOWNLOAD, - Piwik_Tracker_Action::TYPE_ACTION_NAME, - Piwik_Tracker_Action::TYPE_SITE_SEARCH, + Action::TYPE_ACTION_URL, + Action::TYPE_OUTLINK, + Action::TYPE_DOWNLOAD, + Action::TYPE_ACTION_NAME, + Action::TYPE_SITE_SEARCH, ); static protected $invalidSummedColumnNameToRenamedNameFromPeriodArchive = array( Metrics::INDEX_NB_UNIQ_VISITORS => Metrics::INDEX_SUM_DAILY_NB_UNIQ_VISITORS, @@ -160,8 +161,8 @@ class Piwik_Actions_Archiver extends PluginsArchiver $dataTable = new DataTable(); $dataTable->setMaximumAllowedRows(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero); - if ($type == Piwik_Tracker_Action::TYPE_ACTION_URL - || $type == Piwik_Tracker_Action::TYPE_ACTION_NAME + if ($type == Action::TYPE_ACTION_URL + || $type == Action::TYPE_ACTION_NAME ) { // for page urls and page titles, performance metrics exist and have to be aggregated correctly $dataTable->setColumnAggregationOperations(self::$actionColumnAggregationOperations); @@ -181,20 +182,20 @@ class Piwik_Actions_Archiver extends PluginsArchiver count(distinct log_link_visit_action.idvisitor) as `" . Metrics::INDEX_NB_UNIQ_VISITORS . "`, count(*) as `" . Metrics::INDEX_PAGE_NB_HITS . "`, sum( - case when " . Piwik_Tracker_Action::DB_COLUMN_TIME_GENERATION . " is null + case when " . Action::DB_COLUMN_TIME_GENERATION . " is null then 0 - else " . Piwik_Tracker_Action::DB_COLUMN_TIME_GENERATION . " + else " . Action::DB_COLUMN_TIME_GENERATION . " end ) / 1000 as `" . Metrics::INDEX_PAGE_SUM_TIME_GENERATION . "`, sum( - case when " . Piwik_Tracker_Action::DB_COLUMN_TIME_GENERATION . " is null + case when " . Action::DB_COLUMN_TIME_GENERATION . " is null then 0 else 1 end ) as `" . Metrics::INDEX_PAGE_NB_HITS_WITH_TIME_GENERATION . "`, - min(" . Piwik_Tracker_Action::DB_COLUMN_TIME_GENERATION . ") / 1000 + min(" . Action::DB_COLUMN_TIME_GENERATION . ") / 1000 as `" . Metrics::INDEX_PAGE_MIN_TIME_GENERATION . "`, - max(" . Piwik_Tracker_Action::DB_COLUMN_TIME_GENERATION . ") / 1000 + max(" . Action::DB_COLUMN_TIME_GENERATION . ") / 1000 as `" . Metrics::INDEX_PAGE_MAX_TIME_GENERATION . "` "; @@ -237,7 +238,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver // 2) For each page view, count number of times the referrer page was a Site Search if ($this->isSiteSearchEnabled()) { $selectFlagNoResultKeywords = ", - CASE WHEN (MAX(log_link_visit_action.custom_var_v" . Piwik_Tracker_Action::CVAR_INDEX_SEARCH_COUNT . ") = 0 AND log_link_visit_action.custom_var_k" . Piwik_Tracker_Action::CVAR_INDEX_SEARCH_COUNT . " = '" . Piwik_Tracker_Action::CVAR_KEY_SEARCH_COUNT . "') THEN 1 ELSE 0 END AS `" . Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT . "`"; + CASE WHEN (MAX(log_link_visit_action.custom_var_v" . Action::CVAR_INDEX_SEARCH_COUNT . ") = 0 AND log_link_visit_action.custom_var_k" . Action::CVAR_INDEX_SEARCH_COUNT . " = '" . Action::CVAR_KEY_SEARCH_COUNT . "') THEN 1 ELSE 0 END AS `" . Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT . "`"; //we need an extra JOIN to know whether the referrer "idaction_name_ref" was a Site Search request $from[] = array( @@ -247,7 +248,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver ); $selectSiteSearchFollowingPages = ", - SUM(CASE WHEN log_action_name_ref.type = " . Piwik_Tracker_Action::TYPE_SITE_SEARCH . " THEN 1 ELSE 0 END) AS `" . Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS . "`"; + SUM(CASE WHEN log_action_name_ref.type = " . Action::TYPE_SITE_SEARCH . " THEN 1 ELSE 0 END) AS `" . Metrics::INDEX_PAGE_IS_FOLLOWING_SITE_SEARCH_NB_HITS . "`"; $select .= $selectFlagNoResultKeywords . $selectSiteSearchFollowingPages; @@ -445,7 +446,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver protected function recordPageUrlsReports() { - $dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_ACTION_URL); + $dataTable = $this->getDataTable(Action::TYPE_ACTION_URL); $this->recordDataTable($dataTable, self::PAGE_URLS_RECORD_NAME); $records = array( @@ -516,7 +517,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver protected function recordDownloadsReports() { - $dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_DOWNLOAD); + $dataTable = $this->getDataTable(Action::TYPE_DOWNLOAD); $this->recordDataTable($dataTable, self::DOWNLOADS_RECORD_NAME); $this->getProcessor()->insertNumericRecord(self::METRIC_DOWNLOADS_RECORD_NAME, array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS))); @@ -525,7 +526,7 @@ class Piwik_Actions_Archiver extends PluginsArchiver protected function recordOutlinksReports() { - $dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_OUTLINK); + $dataTable = $this->getDataTable(Action::TYPE_OUTLINK); $this->recordDataTable($dataTable, self::OUTLINKS_RECORD_NAME); $this->getProcessor()->insertNumericRecord(self::METRIC_OUTLINKS_RECORD_NAME, array_sum($dataTable->getColumn(Metrics::INDEX_PAGE_NB_HITS))); @@ -534,13 +535,13 @@ class Piwik_Actions_Archiver extends PluginsArchiver protected function recordPageTitlesReports() { - $dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_ACTION_NAME); + $dataTable = $this->getDataTable(Action::TYPE_ACTION_NAME); $this->recordDataTable($dataTable, self::PAGE_TITLES_RECORD_NAME); } protected function recordSiteSearchReports() { - $dataTable = $this->getDataTable(Piwik_Tracker_Action::TYPE_SITE_SEARCH); + $dataTable = $this->getDataTable(Action::TYPE_SITE_SEARCH); $this->deleteUnusedColumnsFromKeywordsDataTable($dataTable); $this->recordDataTable($dataTable, self::SITE_SEARCH_RECORD_NAME); diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php index 2e885a435e..8c95ae629f 100644 --- a/plugins/Actions/ArchivingHelper.php +++ b/plugins/Actions/ArchivingHelper.php @@ -12,6 +12,7 @@ use Piwik\Config; use Piwik\DataTable\Row; use Piwik\Metrics; use Piwik\DataTable; +use Piwik\Tracker\Action; /** * This static class provides: @@ -38,28 +39,28 @@ class Piwik_Actions_ArchivingHelper $rowsProcessed = 0; while ($row = $query->fetch()) { if (empty($row['idaction'])) { - $row['type'] = ($fieldQueried == 'idaction_url' ? Piwik_Tracker_Action::TYPE_ACTION_URL : Piwik_Tracker_Action::TYPE_ACTION_NAME); + $row['type'] = ($fieldQueried == 'idaction_url' ? Action::TYPE_ACTION_URL : Action::TYPE_ACTION_NAME); // This will be replaced with 'X not defined' later $row['name'] = ''; // Yes, this is kind of a hack, so we don't mix 'page url not defined' with 'page title not defined' etc. $row['idaction'] = -$row['type']; } - if ($row['type'] != Piwik_Tracker_Action::TYPE_SITE_SEARCH) { + if ($row['type'] != Action::TYPE_SITE_SEARCH) { unset($row[Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT]); } // This will appear as in the API, which is actually very important to keep // eg. When there's at least one row in a report that does not have a URL, not having this would break HTML/PDF reports. $url = ''; - if ($row['type'] == Piwik_Tracker_Action::TYPE_SITE_SEARCH - || $row['type'] == Piwik_Tracker_Action::TYPE_ACTION_NAME + if ($row['type'] == Action::TYPE_SITE_SEARCH + || $row['type'] == Action::TYPE_ACTION_NAME ) { $url = null; } elseif (!empty($row['name']) && $row['name'] != DataTable::LABEL_SUMMARY_ROW ) { - $url = Piwik_Tracker_Action::reconstructNormalizedUrl((string)$row['name'], $row['url_prefix']); + $url = Action::reconstructNormalizedUrl((string)$row['name'], $row['url_prefix']); } if (isset($row['name']) @@ -116,8 +117,8 @@ class Piwik_Actions_ArchivingHelper } } - if ($row['type'] != Piwik_Tracker_Action::TYPE_ACTION_URL - && $row['type'] != Piwik_Tracker_Action::TYPE_ACTION_NAME + if ($row['type'] != Action::TYPE_ACTION_URL + && $row['type'] != Action::TYPE_ACTION_NAME ) { // only keep performance metrics when they're used (i.e. for URLs and page titles) if (array_key_exists(Metrics::INDEX_PAGE_SUM_TIME_GENERATION, $row)) { @@ -308,7 +309,7 @@ class Piwik_Actions_ArchivingHelper static public function getActionExplodedNames($name, $type, $urlPrefix = null) { // Site Search does not split Search keywords - if ($type == Piwik_Tracker_Action::TYPE_SITE_SEARCH) { + if ($type == Action::TYPE_SITE_SEARCH) { return array($name); } @@ -334,8 +335,8 @@ class Piwik_Actions_ArchivingHelper $urlFragment = $matches[3]; } - if ($type == Piwik_Tracker_Action::TYPE_DOWNLOAD - || $type == Piwik_Tracker_Action::TYPE_OUTLINK + if ($type == Action::TYPE_DOWNLOAD + || $type == Action::TYPE_OUTLINK ) { if ($isUrl) { return array(trim($urlHost), '/' . trim($urlPath)); @@ -350,7 +351,7 @@ class Piwik_Actions_ArchivingHelper } } - if ($type == Piwik_Tracker_Action::TYPE_ACTION_NAME) { + if ($type == Action::TYPE_ACTION_NAME) { $categoryDelimiter = self::$actionTitleCategoryDelimiter; } else { $categoryDelimiter = self::$actionUrlCategoryDelimiter; @@ -358,7 +359,7 @@ class Piwik_Actions_ArchivingHelper if ($isUrl) { - $urlFragment = Piwik_Tracker_Action::processUrlFragment($urlFragment); + $urlFragment = Action::processUrlFragment($urlFragment); if (!empty($urlFragment)) { $name .= '#' . $urlFragment; } @@ -386,7 +387,7 @@ class Piwik_Actions_ArchivingHelper // we are careful to prefix the page URL / name with some value // so that if a page has the same name as a category // we don't merge both entries - if ($type != Piwik_Tracker_Action::TYPE_ACTION_NAME) { + if ($type != Action::TYPE_ACTION_NAME) { $lastPageName = '/' . $lastPageName; } else { $lastPageName = ' ' . $lastPageName; @@ -431,7 +432,7 @@ class Piwik_Actions_ArchivingHelper self::$defaultActionNameWhenNotDefined = Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageName')); self::$defaultActionUrlWhenNotDefined = Piwik_Translate('General_NotDefined', Piwik_Translate('Actions_ColumnPageURL')); } - if ($type == Piwik_Tracker_Action::TYPE_ACTION_NAME) { + if ($type == Action::TYPE_ACTION_NAME) { return self::$defaultActionNameWhenNotDefined; } return self::$defaultActionUrlWhenNotDefined; -- cgit v1.2.3