diff options
Diffstat (limited to 'plugins/Transitions/API.php')
-rw-r--r-- | plugins/Transitions/API.php | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/plugins/Transitions/API.php b/plugins/Transitions/API.php index d082013af6..dc419858e7 100644 --- a/plugins/Transitions/API.php +++ b/plugins/Transitions/API.php @@ -36,12 +36,12 @@ use Piwik\Tracker\TableLogAction; */ class API extends \Piwik\Plugin\API { - public function getTransitionsForPageTitle($pageTitle, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = false) + public function getTransitionsForPageTitle($pageTitle, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = 0) { return $this->getTransitionsForAction($pageTitle, 'title', $idSite, $period, $date, $segment, $limitBeforeGrouping); } - public function getTransitionsForPageUrl($pageUrl, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = false) + public function getTransitionsForPageUrl($pageUrl, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = 0) { return $this->getTransitionsForAction($pageUrl, 'url', $idSite, $period, $date, $segment, $limitBeforeGrouping); } @@ -55,13 +55,13 @@ class API extends \Piwik\Plugin\API * @param $period * @param $date * @param bool $segment - * @param bool $limitBeforeGrouping + * @param int $limitBeforeGrouping * @param string $parts * @return array * @throws Exception */ public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date, - $segment = false, $limitBeforeGrouping = false, $parts = 'all') + $segment = false, $limitBeforeGrouping = 0, $parts = 'all') { Piwik::checkUserHasViewAccess($idSite); @@ -69,6 +69,12 @@ class API extends \Piwik\Plugin\API throw new Exception('PeriodNotAllowed'); } + if ($limitBeforeGrouping && !is_numeric($limitBeforeGrouping)) { + throw new Exception('limitBeforeGrouping has to be an integer.'); + } + //convert string to int + $limitBeforeGrouping = (int)$limitBeforeGrouping; + // get idaction of the requested action $idaction = $this->deriveIdAction($actionName, $actionType); if ($idaction < 0) { @@ -212,11 +218,12 @@ class API extends \Piwik\Plugin\API * @param $report * @param $idaction * @param string $actionType - * @param $limitBeforeGrouping + * @param int $limitBeforeGrouping * @param boolean $includeLoops */ - private function addFollowingActions($logAggregator, &$report, $idaction, $actionType, $limitBeforeGrouping, $includeLoops = false) + private function addFollowingActions($logAggregator, &$report, $idaction, $actionType, $limitBeforeGrouping = 0, $includeLoops = false) { + $data = $this->queryFollowingActions( $idaction, $actionType, $logAggregator, $limitBeforeGrouping, $includeLoops); @@ -231,12 +238,12 @@ class API extends \Piwik\Plugin\API * @param $idaction * @param $actionType * @param LogAggregator $logAggregator - * @param $limitBeforeGrouping + * @param $limitBeforeGrouping * @param $includeLoops * @return array(followingPages:DataTable, outlinks:DataTable, downloads:DataTable) */ protected function queryFollowingActions($idaction, $actionType, LogAggregator $logAggregator, - $limitBeforeGrouping = false, $includeLoops = false) + $limitBeforeGrouping = 0, $includeLoops = false) { $types = array(); @@ -291,7 +298,7 @@ class API extends \Piwik\Plugin\API $types[Action::TYPE_OUTLINK] = 'outlinks'; $types[Action::TYPE_DOWNLOAD] = 'downloads'; - $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping: $this->limitBeforeGrouping); $rankingQuery->setOthersLabel('Others'); $rankingQuery->addLabelColumn(array('name', 'url_prefix')); $rankingQuery->partitionResultIntoMultipleGroups('type', array_keys($types)); @@ -326,12 +333,14 @@ class API extends \Piwik\Plugin\API * @param $idaction * @param $actionType * @param LogAggregator $logAggregator - * @param $limitBeforeGrouping + * @param int $limitBeforeGrouping * @return DataTable + * @throws Exception */ - protected function queryExternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = false) + protected function queryExternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = 0) { - $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + + $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping: $this->limitBeforeGrouping); $rankingQuery->setOthersLabel('Others'); // we generate a single column that contains the interesting data for each referrer. @@ -401,16 +410,16 @@ class API extends \Piwik\Plugin\API * @param $idaction * @param $actionType * @param LogAggregator $logAggregator - * @param $limitBeforeGrouping + * @param int $limitBeforeGrouping * @return array(previousPages:DataTable, loops:integer) */ - protected function queryInternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = false) + protected function queryInternalReferrers($idaction, $actionType, $logAggregator, $limitBeforeGrouping = 0) { $keyIsOther = 0; $keyIsPageUrlAction = 1; $keyIsSiteSearchAction = 2; - $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping : $this->limitBeforeGrouping); + $rankingQuery = new RankingQuery($limitBeforeGrouping ? $limitBeforeGrouping: $this->limitBeforeGrouping); $rankingQuery->setOthersLabel('Others'); $rankingQuery->addLabelColumn(array('name', 'url_prefix')); $rankingQuery->setColumnToMarkExcludedRows('is_self'); |