Beispiel #1
0
 /**
  * @group Core
  * @group Period
  */
 public function testGetLabel()
 {
     $period = new Piwik_Period_Day(Piwik_Date::today());
     $label = $period->getLabel();
     $this->assertInternalType('string', $label);
     $this->assertNotEmpty($label);
     $period = new Piwik_Period_Week(Piwik_Date::today());
     $label = $period->getLabel();
     $this->assertInternalType('string', $label);
     $this->assertNotEmpty($label);
     $period = new Piwik_Period_Month(Piwik_Date::today());
     $label = $period->getLabel();
     $this->assertInternalType('string', $label);
     $this->assertNotEmpty($label);
     $period = new Piwik_Period_Year(Piwik_Date::today());
     $label = $period->getLabel();
     $this->assertInternalType('string', $label);
     $this->assertNotEmpty($label);
 }
Beispiel #2
0
 /**
  * General method to get transitions for an action
  * 
  * @param $actionName
  * @param $actionType "url"|"title"
  * @param $idSite
  * @param $period
  * @param $date
  * @param bool $segment
  * @param bool $limitBeforeGrouping
  * @param string $parts
  * @param bool $returnNormalizedUrls
  * @return array
  * @throws Exception
  */
 public function getTransitionsForAction($actionName, $actionType, $idSite, $period, $date, $segment = false, $limitBeforeGrouping = false, $parts = 'all', $returnNormalizedUrls = false)
 {
     Piwik::checkUserHasViewAccess($idSite);
     // get idaction of the requested action
     $idaction = $this->deriveIdAction($actionName, $actionType);
     if ($idaction < 0) {
         throw new Exception('NoDataForAction');
     }
     // prepare archive processing that can be used by the archiving code
     $archiveProcessing = new Piwik_ArchiveProcessing_Day();
     $archiveProcessing->setSite(new Piwik_Site($idSite));
     $archiveProcessing->setPeriod(Piwik_Period::advancedFactory($period, $date));
     $archiveProcessing->setSegment(new Piwik_Segment($segment, $idSite));
     $archiveProcessing->initForLiveUsage();
     // prepare the report
     $report = array('date' => Piwik_Period_Day::advancedFactory($period, $date)->getLocalizedShortString());
     // add data to the report
     $transitionsArchiving = new Piwik_Transitions();
     if ($returnNormalizedUrls) {
         $transitionsArchiving->returnNormalizedUrls();
     }
     $partsArray = explode(',', $parts);
     if ($parts == 'all' || in_array('internalReferrers', $partsArray)) {
         $this->addInternalReferrers($transitionsArchiving, $archiveProcessing, $report, $idaction, $actionType, $limitBeforeGrouping);
     }
     if ($parts == 'all' || in_array('followingActions', $partsArray)) {
         $includeLoops = $parts != 'all' && !in_array('internalReferrers', $partsArray);
         $this->addFollowingActions($transitionsArchiving, $archiveProcessing, $report, $idaction, $actionType, $limitBeforeGrouping, $includeLoops);
     }
     if ($parts == 'all' || in_array('externalReferrers', $partsArray)) {
         $this->addExternalReferrers($transitionsArchiving, $archiveProcessing, $report, $idaction, $actionType, $limitBeforeGrouping);
     }
     // derive the number of exits from the other metrics
     if ($parts == 'all') {
         $report['pageMetrics']['exits'] = $report['pageMetrics']['pageviews'] - $transitionsArchiving->getTotalTransitionsToFollowingActions() - $report['pageMetrics']['loops'];
     }
     // replace column names in the data tables
     $reportNames = array('previousPages' => true, 'previousSiteSearches' => false, 'followingPages' => true, 'followingSiteSearches' => false, 'outlinks' => true, 'downloads' => true);
     foreach ($reportNames as $reportName => $replaceLabel) {
         if (isset($report[$reportName])) {
             $columnNames = array(Piwik_Archive::INDEX_NB_ACTIONS => 'referrals');
             if ($replaceLabel) {
                 $columnNames[Piwik_Archive::INDEX_NB_ACTIONS] = 'referrals';
             }
             $report[$reportName]->filter('ReplaceColumnNames', array($columnNames));
         }
     }
     return $report;
 }
Beispiel #3
0
 function test_day_getDateEnd3()
 {
     // create the period
     $period = new Piwik_Period_Day(Piwik_Date::factory("2007-12-31"));
     // end date
     $endDate = $period->getDateEnd();
     // expected string
     $this->assertEqual($endDate->toString(), "2007-12-31");
 }
Beispiel #4
0
 /**
  * @group Core
  * @group Period
  * @group Period_Day
  */
 public function testGetPrettyString()
 {
     Piwik_Translate::getInstance()->loadEnglishTranslation();
     $month = new Piwik_Period_Day(Piwik_Date::factory('2024-10-09'));
     $shouldBe = '2024-10-09';
     $this->assertEquals($shouldBe, $month->getPrettyString());
 }