diff options
Diffstat (limited to 'plugins/Actions')
-rw-r--r-- | plugins/Actions/API.php | 56 | ||||
-rw-r--r-- | plugins/Actions/Actions.php | 12 | ||||
-rw-r--r-- | plugins/Actions/Archiver.php | 26 | ||||
-rw-r--r-- | plugins/Actions/ArchivingHelper.php | 46 | ||||
-rw-r--r-- | plugins/Actions/Controller.php | 2 |
5 files changed, 76 insertions, 66 deletions
diff --git a/plugins/Actions/API.php b/plugins/Actions/API.php index 0262f807e0..b40afb87e2 100644 --- a/plugins/Actions/API.php +++ b/plugins/Actions/API.php @@ -12,6 +12,8 @@ use Piwik\Archive; use Piwik\Metrics; use Piwik\Piwik; use Piwik\Common; +use Piwik\Date; +use Piwik\DataTable; /** * The Actions API lets you request reports for all your Visitor Actions: Page URLs, Page titles (Piwik Events), @@ -50,7 +52,7 @@ class Piwik_Actions_API * @param string $date * @param bool|string $segment * @param bool|array $columns - * @return Piwik_DataTable + * @return DataTable */ public function get($idSite, $period, $date, $segment = false, $columns = false) { @@ -112,12 +114,12 @@ class Piwik_Actions_API /** * @param int $idSite * @param string $period - * @param Piwik_Date $date + * @param Date $date * @param bool $segment * @param bool $expanded * @param bool $idSubtable * - * @return Piwik_DataTable|Piwik_DataTable_Array + * @return DataTable|DataTable\Map */ public function getPageUrls($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false) { @@ -130,12 +132,12 @@ class Piwik_Actions_API /** * @param int $idSite * @param string $period - * @param Piwik_Date $date + * @param Date $date * @param bool $segment * @param bool $expanded * @param bool $idSubtable * - * @return Piwik_DataTable|Piwik_DataTable_Array + * @return DataTable|DataTable\Map */ public function getPageUrlsFollowingSiteSearch($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false) { @@ -147,12 +149,12 @@ class Piwik_Actions_API /** * @param int $idSite * @param string $period - * @param Piwik_Date $date + * @param Date $date * @param bool $segment * @param bool $expanded * @param bool $idSubtable * - * @return Piwik_DataTable|Piwik_DataTable_Array + * @return DataTable|DataTable\Map */ public function getPageTitlesFollowingSiteSearch($idSite, $period, $date, $segment = false, $expanded = false, $idSubtable = false) { @@ -162,7 +164,7 @@ class Piwik_Actions_API } /** - * @param Piwik_DataTable $dataTable + * @param DataTable $dataTable */ protected function keepPagesFollowingSearch($dataTable) { @@ -213,7 +215,7 @@ class Piwik_Actions_API } /** - * Returns a Piwik_DataTable with analytics information for every unique entry page title + * Returns a DataTable with analytics information for every unique entry page title * for the given site, time period & segment. */ public function getEntryPageTitles($idSite, $period, $date, $segment = false, $expanded = false, @@ -225,7 +227,7 @@ class Piwik_Actions_API } /** - * Returns a Piwik_DataTable with analytics information for every unique exit page title + * Returns a DataTable with analytics information for every unique exit page title * for the given site, time period & segment. */ public function getExitPageTitles($idSite, $period, $date, $segment = false, $expanded = false, @@ -306,7 +308,7 @@ class Piwik_Actions_API Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT, create_function('$value', 'return $value >= 1;') )); - $dataTable->deleteRow(Piwik_DataTable::ID_SUMMARY_ROW); + $dataTable->deleteRow(DataTable::ID_SUMMARY_ROW); $dataTable->deleteColumn(Metrics::INDEX_SITE_SEARCH_HAS_NO_RESULT); $this->filterPageDatatable($dataTable); $this->filterActionsDataTable($dataTable); @@ -317,10 +319,10 @@ class Piwik_Actions_API /** * @param int $idSite * @param string $period - * @param Piwik_Date $date + * @param Date $date * @param bool $segment * - * @return Piwik_DataTable|Piwik_DataTable_Array + * @return DataTable|DataTable\Map */ public function getSiteSearchCategories($idSite, $period, $date, $segment = false) { @@ -329,10 +331,10 @@ class Piwik_Actions_API $customVarNameToLookFor = Piwik_Tracker_Action::CVAR_KEY_SEARCH_CATEGORY; - $dataTable = new Piwik_DataTable(); + $dataTable = new DataTable(); // Handle case where date=last30&period=day // FIXMEA: this logic should really be refactored somewhere, this is ugly! - if ($customVariables instanceof Piwik_DataTable_Array) { + if ($customVariables instanceof DataTable\Map) { $dataTable = $customVariables->getEmptyClone(); $customVariableDatatables = $customVariables->getArray(); @@ -349,7 +351,7 @@ class Piwik_Actions_API } } } - } elseif ($customVariables instanceof Piwik_DataTable) { + } elseif ($customVariables instanceof DataTable) { $row = $customVariables->getRowFromLabel($customVarNameToLookFor); if ($row) { $idSubtable = $row->getIdSubDataTable(); @@ -388,7 +390,7 @@ class Piwik_Actions_API // fetch the data table $table = call_user_func_array(array('Piwik\Archive', 'getDataTableFromArchive'), $callBackParameters); - if ($table instanceof Piwik_DataTable_Array) { + if ($table instanceof DataTable\Map) { // search an array of tables, e.g. when using date=last30 // note that if the root is an array, we filter all children // if an array occurs inside the nested table, we only look for the first match (see below) @@ -414,7 +416,7 @@ class Piwik_Actions_API protected function doFilterPageDatatableSearch($callBackParameters, $table, $searchTree) { // filter a data table array - if ($table instanceof Piwik_DataTable_Array) { + if ($table instanceof DataTable\Map) { foreach ($table->getArray() as $subTable) { $filteredSubTable = $this->doFilterPageDatatableSearch($callBackParameters, $subTable, $searchTree); @@ -425,24 +427,24 @@ class Piwik_Actions_API } // nothing found in all sub tables - return new Piwik_DataTable; + return new DataTable; } // filter regular data table - if ($table instanceof Piwik_DataTable) { + if ($table instanceof DataTable) { // search for the first part of the tree search $search = array_shift($searchTree); $row = $table->getRowFromLabel($search); if ($row === false) { // not found - $result = new Piwik_DataTable; + $result = new DataTable; $result->metadata = $table->metadata; return $result; } // end of tree search reached if (count($searchTree) == 0) { - $result = new Piwik_DataTable(); + $result = new DataTable(); $result->addRow($row); $result->metadata = $table->metadata; return $result; @@ -489,8 +491,8 @@ class Piwik_Actions_API Metrics::INDEX_PAGE_MAX_TIME_GENERATION ))); - if ($dataTable instanceof Piwik_DataTable) { - $emptyColumns = $dataTable->getMetadata(Piwik_DataTable::EMPTY_COLUMNS_METADATA_NAME); + if ($dataTable instanceof DataTable) { + $emptyColumns = $dataTable->getMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME); if (!is_array($emptyColumns)) { $emptyColumns = array(); } @@ -498,7 +500,7 @@ class Piwik_Actions_API $emptyColumns[] = 'avg_time_generation'; $emptyColumns[] = 'min_time_generation'; $emptyColumns[] = 'max_time_generation'; - $dataTable->setMetadata(Piwik_DataTable::EMPTY_COLUMNS_METADATA_NAME, $emptyColumns); + $dataTable->setMetadata(DataTable::EMPTY_COLUMNS_METADATA_NAME, $emptyColumns); } } } @@ -519,7 +521,7 @@ class Piwik_Actions_API /** * Removes DataTable rows referencing actions that were never the first action of a visit. * - * @param Piwik_DataTable $dataTable + * @param DataTable $dataTable */ private function filterNonEntryActions($dataTable) { @@ -529,7 +531,7 @@ class Piwik_Actions_API /** * Removes DataTable rows referencing actions that were never the last action of a visit. * - * @param Piwik_DataTable $dataTable + * @param DataTable $dataTable */ private function filterNonExitActions($dataTable) { diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 03109bfdb9..0906c0cbd3 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -8,8 +8,10 @@ * @category Piwik_Plugins * @package Piwik_Actions */ +use Piwik\ArchiveProcessor; use Piwik\Piwik; use Piwik\Common; +use Piwik\Plugin; use Piwik\SegmentExpression; use Piwik\Site; @@ -20,7 +22,7 @@ use Piwik\Site; * * @package Piwik_Actions */ -class Piwik_Actions extends Piwik_Plugin +class Piwik_Actions extends Plugin { const ACTIONS_REPORT_ROWS_DISPLAY = 100; @@ -572,7 +574,7 @@ class Piwik_Actions extends Piwik_Plugin * For each action we process the "interest statistics" : * visits, unique visitors, bounce count, sum visit length. */ - public function archiveDay(Piwik_ArchiveProcessor_Day $archiveProcessor) + public function archiveDay(ArchiveProcessor\Day $archiveProcessor) { $archiving = new Piwik_Actions_Archiver($archiveProcessor); if($archiving->shouldArchive()) { @@ -580,7 +582,7 @@ class Piwik_Actions extends Piwik_Plugin } } - function archivePeriod(Piwik_ArchiveProcessor_Period $archiveProcessor) + function archivePeriod(ArchiveProcessor\Period $archiveProcessor) { $archiving = new Piwik_Actions_Archiver($archiveProcessor); if($archiving->shouldArchive()) { @@ -597,7 +599,7 @@ class Piwik_Actions extends Piwik_Plugin static protected function isCustomVariablesPluginsEnabled() { - return PluginsManager::getInstance()->isPluginActivated('CustomVariables'); + return \Piwik\PluginsManager::getInstance()->isPluginActivated('CustomVariables'); } /** @@ -711,7 +713,7 @@ class Piwik_Actions extends Piwik_Plugin ); // prettify avg_time_on_page column - $getPrettyTimeFromSeconds = array('Piwik', 'getPrettyTimeFromSeconds'); + $getPrettyTimeFromSeconds = '\Piwik\Piwik::getPrettyTimeFromSeconds'; $result['filters'][] = array('ColumnCallbackReplace', array('avg_time_on_page', $getPrettyTimeFromSeconds)); // prettify avg_time_generation column diff --git a/plugins/Actions/Archiver.php b/plugins/Actions/Archiver.php index f512bd36ea..987bf5104a 100644 --- a/plugins/Actions/Archiver.php +++ b/plugins/Actions/Archiver.php @@ -9,14 +9,18 @@ * @package Piwik_Actions */ use Piwik\Config; +use Piwik\DataTable\Manager; +use Piwik\DataTable\Row\DataTableSummaryRow; use Piwik\Metrics; +use Piwik\DataTable; +use Piwik\PluginsArchiver; /** * Class encapsulating logic to process Day/Period Archiving for the Actions reports * * @package Piwik_Actions */ -class Piwik_Actions_Archiver extends Piwik_PluginsArchiver +class Piwik_Actions_Archiver extends PluginsArchiver { const DOWNLOADS_RECORD_NAME = 'Actions_downloads'; const OUTLINKS_RECORD_NAME = 'Actions_outlink'; @@ -152,7 +156,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver { $this->actionsTablesByType = array(); foreach (self::$actionTypes as $type) { - $dataTable = new Piwik_DataTable(); + $dataTable = new DataTable(); $dataTable->setMaximumAllowedRows(Piwik_Actions_ArchivingHelper::$maximumRowsInDataTableLevelZero); if ($type == Piwik_Tracker_Action::TYPE_ACTION_URL @@ -212,7 +216,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(Piwik_DataTable::LABEL_SUMMARY_ROW); + $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn(array('idaction', 'name')); $rankingQuery->addColumn(array('url_prefix', Metrics::INDEX_NB_UNIQ_VISITORS)); $rankingQuery->addColumn(array(Metrics::INDEX_PAGE_NB_HITS, Metrics::INDEX_NB_VISITS), 'sum'); @@ -291,7 +295,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(Piwik_DataTable::LABEL_SUMMARY_ROW); + $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(Metrics::INDEX_PAGE_ENTRY_NB_UNIQ_VISITORS); $rankingQuery->addColumn(array(Metrics::INDEX_PAGE_ENTRY_NB_VISITS, @@ -342,7 +346,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(Piwik_DataTable::LABEL_SUMMARY_ROW); + $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(Metrics::INDEX_PAGE_EXIT_NB_UNIQ_VISITORS); $rankingQuery->addColumn(Metrics::INDEX_PAGE_EXIT_NB_VISITS, 'sum'); @@ -388,7 +392,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver $rankingQuery = false; if ($rankingQueryLimit > 0) { $rankingQuery = new Piwik_RankingQuery($rankingQueryLimit); - $rankingQuery->setOthersLabel(Piwik_DataTable::LABEL_SUMMARY_ROW); + $rankingQuery->setOthersLabel(DataTable::LABEL_SUMMARY_ROW); $rankingQuery->addLabelColumn('idaction'); $rankingQuery->addColumn(Metrics::INDEX_PAGE_SUM_TIME_SPENT, 'sum'); $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($this->actionsTablesByType)); @@ -454,7 +458,7 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver /** * @param $typeId - * @return Piwik_DataTable + * @return DataTable */ protected function getDataTable($typeId) { @@ -472,20 +476,20 @@ class Piwik_Actions_Archiver extends Piwik_PluginsArchiver * For rows which have subtables (eg. directories with sub pages), * deletes columns which don't make sense when all values of sub pages are summed. * - * @param $dataTable Piwik_DataTable + * @param $dataTable DataTable */ static public function deleteInvalidSummedColumnsFromDataTable($dataTable) { foreach ($dataTable->getRows() as $id => $row) { if (($idSubtable = $row->getIdSubDataTable()) !== null - || $id === Piwik_DataTable::ID_SUMMARY_ROW + || $id === DataTable::ID_SUMMARY_ROW ) { if ($idSubtable !== null) { - $subtable = Piwik_DataTable_Manager::getInstance()->getTable($idSubtable); + $subtable = Manager::getInstance()->getTable($idSubtable); self::deleteInvalidSummedColumnsFromDataTable($subtable); } - if ($row instanceof Piwik_DataTable_Row_DataTableSummary) { + if ($row instanceof DataTableSummaryRow) { $row->recalculate(); } diff --git a/plugins/Actions/ArchivingHelper.php b/plugins/Actions/ArchivingHelper.php index 514b75116b..2e885a435e 100644 --- a/plugins/Actions/ArchivingHelper.php +++ b/plugins/Actions/ArchivingHelper.php @@ -9,7 +9,9 @@ * @package Piwik_Actions */ use Piwik\Config; +use Piwik\DataTable\Row; use Piwik\Metrics; +use Piwik\DataTable; /** * This static class provides: @@ -55,7 +57,7 @@ class Piwik_Actions_ArchivingHelper ) { $url = null; } elseif (!empty($row['name']) - && $row['name'] != Piwik_DataTable::LABEL_SUMMARY_ROW + && $row['name'] != DataTable::LABEL_SUMMARY_ROW ) { $url = Piwik_Tracker_Action::reconstructNormalizedUrl((string)$row['name'], $row['url_prefix']); } @@ -70,7 +72,7 @@ class Piwik_Actions_ArchivingHelper // in some unknown case, the type field is NULL, as reported in #1082 - we ignore this page view if (empty($actionType)) { - if ($idaction != Piwik_DataTable::LABEL_SUMMARY_ROW) { + if ($idaction != DataTable::LABEL_SUMMARY_ROW) { self::setCachedActionRow($idaction, $actionType, false); } continue; @@ -97,7 +99,7 @@ class Piwik_Actions_ArchivingHelper // This is to ensure that when, different URLs are loaded with the same page name. // For example http://piwik.org and http://id.piwik.org are reported in Piwik > Actions > Pages with /index // But, we must make sure http://piwik.org is used to link & for transitions - // Note: this code is partly duplicated from Piwik_DataTable_Row->sumRowMetadata() + // Note: this code is partly duplicated from Row->sumRowMetadata() if (!is_null($url) && !$actionRow->isSummaryRow() ) { @@ -220,7 +222,7 @@ class Piwik_Actions_ArchivingHelper self::$maximumRowsInDataTableLevelZero = Config::getInstance()->General['datatable_archiving_maximum_rows_actions']; self::$maximumRowsInSubDataTable = Config::getInstance()->General['datatable_archiving_maximum_rows_subtable_actions']; - Piwik_DataTable::setMaximumDepthLevelAllowedAtLeast(self::getSubCategoryLevelLimit() + 1); + DataTable::setMaximumDepthLevelAllowedAtLeast(self::getSubCategoryLevelLimit() + 1); } @@ -229,7 +231,7 @@ class Piwik_Actions_ArchivingHelper * there could be pages that have exit/entry hits, but don't yet * have a record in the table (or the record was truncated). * - * @return Piwik_DataTable_Row + * @return Row */ static private function getDefaultRow() { @@ -238,8 +240,8 @@ class Piwik_Actions_ArchivingHelper // This row is used in the case where an action is know as an exit_action // but this action was not properly recorded when it was hit in the first place // so we add this fake row information to make sure there is a nb_hits, etc. column for every action - $row = new Piwik_DataTable_Row(array( - Piwik_DataTable_Row::COLUMNS => array( + $row = new Row(array( + Row::COLUMNS => array( Metrics::INDEX_NB_VISITS => 1, Metrics::INDEX_NB_UNIQ_VISITORS => 1, Metrics::INDEX_PAGE_NB_HITS => 1, @@ -256,17 +258,17 @@ class Piwik_Actions_ArchivingHelper * @param int $actionType * @param int $urlPrefix * @param array $actionsTablesByType - * @return Piwik_DataTable + * @return DataTable */ protected static function getActionRow($actionName, $actionType, $urlPrefix = null, &$actionsTablesByType) { // we work on the root table of the given TYPE (either ACTION_URL or DOWNLOAD or OUTLINK etc.) - /* @var Piwik_DataTable $currentTable */ + /* @var DataTable $currentTable */ $currentTable =& $actionsTablesByType[$actionType]; // check for ranking query cut-off - if ($actionName == Piwik_DataTable::LABEL_SUMMARY_ROW) { - $summaryRow = $currentTable->getRowFromId(Piwik_DataTable::ID_SUMMARY_ROW); + if ($actionName == DataTable::LABEL_SUMMARY_ROW) { + $summaryRow = $currentTable->getRowFromId(DataTable::ID_SUMMARY_ROW); if ($summaryRow === false) { $summaryRow = $currentTable->addSummaryRow(self::createSummaryRow()); } @@ -296,11 +298,11 @@ class Piwik_Actions_ArchivingHelper * we explode link http://piwik.org/some/path into an array( 'some', 'path' ); * * for action names: - * we explode name 'Piwik / Category 1 / Category 2' into an array('Piwik', 'Category 1', 'Category 2'); + * we explode name 'Piwik / Category 1 / Category 2' into an array('\Piwik\Piwik', 'Category 1', 'Category 2'); * - * @param string action name - * @param int action type - * @param int url prefix (only used for TYPE_ACTION_URL) + * @param string $name action name + * @param int $type action type + * @param int $urlPrefix url prefix (only used for TYPE_ACTION_URL) * @return array of exploded elements from $name */ static public function getActionExplodedNames($name, $type, $urlPrefix = null) @@ -402,7 +404,7 @@ class Piwik_Actions_ArchivingHelper */ private static function getCachedActionRowKey($idAction, $actionType) { - return $idAction == Piwik_DataTable::LABEL_SUMMARY_ROW + return $idAction == DataTable::LABEL_SUMMARY_ROW ? $actionType . '_others' : $idAction; } @@ -451,7 +453,7 @@ class Piwik_Actions_ArchivingHelper * * @param int $idAction * @param int $actionType - * @return Piwik_DataTable_Row|false + * @return Row|false */ private static function getCachedActionRow($idAction, $actionType) { @@ -472,7 +474,7 @@ class Piwik_Actions_ArchivingHelper * * @param int $idAction * @param int $actionType - * @param Piwik_DataTable_Row + * @param \DataTable\Row */ private static function setCachedActionRow($idAction, $actionType, $actionRow) { @@ -496,13 +498,13 @@ class Piwik_Actions_ArchivingHelper /** * Creates a summary row for an Actions DataTable. * - * @return Piwik_DataTable_Row + * @return Row */ private static function createSummaryRow() { - return new Piwik_DataTable_Row(array( - Piwik_DataTable_Row::COLUMNS => - array('label' => Piwik_DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns() + return new Row(array( + Row::COLUMNS => + array('label' => DataTable::LABEL_SUMMARY_ROW) + self::getDefaultRowColumns() )); } } diff --git a/plugins/Actions/Controller.php b/plugins/Actions/Controller.php index 6044c225d8..f90ad12f28 100644 --- a/plugins/Actions/Controller.php +++ b/plugins/Actions/Controller.php @@ -49,7 +49,7 @@ class Piwik_Actions_Controller extends Piwik_Controller $view->noResultKeywords = $this->getSiteSearchNoResultKeywords(true); $view->pagesUrlsFollowingSiteSearch = $this->getPageUrlsFollowingSiteSearch(true); - $categoryTrackingEnabled = PluginsManager::getInstance()->isPluginActivated('CustomVariables'); + $categoryTrackingEnabled = \Piwik\PluginsManager::getInstance()->isPluginActivated('CustomVariables'); if ($categoryTrackingEnabled) { $view->categories = $this->getSiteSearchCategories(true); } |