当前位置: 首页>>代码示例>>PHP>>正文


PHP Piwik::getPrettyTimeFromSeconds方法代码示例

本文整理汇总了PHP中Piwik::getPrettyTimeFromSeconds方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getPrettyTimeFromSeconds方法的具体用法?PHP Piwik::getPrettyTimeFromSeconds怎么用?PHP Piwik::getPrettyTimeFromSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik的用法示例。


在下文中一共展示了Piwik::getPrettyTimeFromSeconds方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testGetPrettyTimeFromSeconds

 /**
  * @group Core
  * @group Piwik
  * @dataProvider getPrettyTimeFromSecondsData
  */
 public function testGetPrettyTimeFromSeconds($seconds, $expected)
 {
     Piwik_Translate::getInstance()->loadEnglishTranslation();
     $sentenceExpected = str_replace(' ', ' ', $expected[0]);
     $numericExpected = $expected[1];
     $this->assertEquals($sentenceExpected, Piwik::getPrettyTimeFromSeconds($seconds, $sentence = true));
     $this->assertEquals($numericExpected, Piwik::getPrettyTimeFromSeconds($seconds, $sentence = false));
     Piwik_Translate::getInstance()->unloadEnglishTranslation();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:14,代码来源:PiwikTest.php

示例2: test_getPrettyTimeFromSeconds

 public function test_getPrettyTimeFromSeconds()
 {
     Piwik_Translate::getInstance()->loadEnglishTranslation();
     $tests = array(30 => array('30s', '00:00:30'), 60 => array('1 min 0s', '00:01:00'), 100 => array('1 min 40s', '00:01:40'), 3600 => array('1 hours 0 min', '01:00:00'), 3700 => array('1 hours 1 min', '01:01:40'), 86400 + 3600 * 10 => array('1 days 10 hours', '34:00:00'), 86400 * 365 => array('365 days 0 hours', '8760:00:00'), 86400 * (365.25 + 10) => array('1 years 10 days', '9006:00:00'));
     foreach ($tests as $seconds => $expected) {
         $sentenceExpected = str_replace(' ', ' ', $expected[0]);
         $numericExpected = $expected[1];
         $this->assertEqual(Piwik::getPrettyTimeFromSeconds($seconds, $sentence = true), $sentenceExpected);
         $this->assertEqual(Piwik::getPrettyTimeFromSeconds($seconds, $sentence = false), $numericExpected);
     }
     Piwik_Translate::getInstance()->unloadEnglishTranslation();
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:12,代码来源:Piwik.test.php

示例3: renderSidebar

 /** Render the area left of the iframe */
 public function renderSidebar()
 {
     $idSite = Piwik_Common::getRequestVar('idSite');
     $period = Piwik_Common::getRequestVar('period');
     $date = Piwik_Common::getRequestVar('date');
     $currentUrl = Piwik_Common::getRequestVar('currentUrl');
     $currentUrl = Piwik_Common::unsanitizeInputValue($currentUrl);
     $normalizedCurrentUrl = Piwik_Tracker_Action::excludeQueryParametersFromUrl($currentUrl, $idSite);
     $normalizedCurrentUrl = Piwik_Common::unsanitizeInputValue($normalizedCurrentUrl);
     // load the appropriate row of the page urls report using the label filter
     Piwik_Actions_ArchivingHelper::reloadConfig();
     $path = Piwik_Actions_ArchivingHelper::getActionExplodedNames($normalizedCurrentUrl, Piwik_Tracker_Action::TYPE_ACTION_URL);
     $path = array_map('urlencode', $path);
     $label = implode('>', $path);
     $request = new Piwik_API_Request('method=Actions.getPageUrls' . '&idSite=' . urlencode($idSite) . '&date=' . urlencode($date) . '&period=' . urlencode($period) . '&label=' . urlencode($label) . '&format=original');
     $dataTable = $request->process();
     $data = array();
     if ($dataTable->getRowsCount() > 0) {
         $row = $dataTable->getFirstRow();
         $translations = Piwik_API_API::getDefaultMetricTranslations();
         $showMetrics = array('nb_hits', 'nb_visits', 'nb_uniq_visitors', 'bounce_rate', 'exit_rate', 'avg_time_on_page');
         foreach ($showMetrics as $metric) {
             $value = $row->getColumn($metric);
             if ($value === false) {
                 // skip unique visitors for period != day
                 continue;
             }
             if ($metric == 'avg_time_on_page') {
                 $value = Piwik::getPrettyTimeFromSeconds($value);
             }
             $data[] = array('name' => $translations[$metric], 'value' => $value);
         }
     }
     // generate page url string
     foreach ($path as &$part) {
         $part = preg_replace(';^/;', '', urldecode($part));
     }
     $page = '/' . implode('/', $path);
     $page = preg_replace(';/index$;', '/', $page);
     if ($page == '/') {
         $page = '/index';
     }
     // render template
     $view = Piwik_View::factory('sidebar');
     $view->data = $data;
     $view->location = $page;
     $view->normalizedUrl = $normalizedCurrentUrl;
     $view->label = $label;
     $view->idSite = $idSite;
     $view->period = $period;
     $view->date = $date;
     echo $view->render();
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:54,代码来源:Controller.php

示例4: getDeleteLogsInfo

 protected function getDeleteLogsInfo()
 {
     Piwik::checkUserIsSuperUser();
     $deleteLogsInfos = array();
     $taskScheduler = new Piwik_TaskScheduler();
     $deleteLogsInfos["config"] = Zend_Registry::get('config')->Deletelogs->toArray();
     $privacyManager = new Piwik_PrivacyManager();
     $deleteLogsInfos["deleteTables"] = implode(", ", $privacyManager->getDeleteTableLogTables());
     $scheduleTimetable = $taskScheduler->getScheduledTimeForTask("Piwik_PrivacyManager", "deleteLogTables");
     $optionTable = Piwik_GetOption(self::OPTION_LAST_DELETE_PIWIK_LOGS);
     //If task was already rescheduled, read time from taskTimetable. Else, calculate next possible runtime.
     if (!empty($scheduleTimetable) && $scheduleTimetable - time() > 0) {
         $nextPossibleSchedule = (int) $scheduleTimetable;
     } else {
         $date = Piwik_Date::factory("today");
         $nextPossibleSchedule = $date->addDay(1)->getTimestamp();
     }
     //deletion schedule did not run before
     if (empty($optionTable)) {
         $deleteLogsInfos["lastRun"] = false;
         //next run ASAP (with next schedule run)
         $date = Piwik_Date::factory("today");
         $deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
     } else {
         $deleteLogsInfos["lastRun"] = $optionTable;
         $deleteLogsInfos["lastRunPretty"] = Piwik_Date::factory((int) $optionTable)->getLocalized('%day% %shortMonth% %longYear%');
         //Calculate next run based on last run + interval
         $nextScheduleRun = (int) ($deleteLogsInfos["lastRun"] + $deleteLogsInfos["config"]["delete_logs_schedule_lowest_interval"] * 24 * 60 * 60);
         //is the calculated next run in the past? (e.g. plugin was disabled in the meantime or something) -> run ASAP
         if ($nextScheduleRun - time() <= 0) {
             $deleteLogsInfos["nextScheduleTime"] = $nextPossibleSchedule;
         } else {
             $deleteLogsInfos["nextScheduleTime"] = $nextScheduleRun;
         }
     }
     $deleteLogsInfos["nextRunPretty"] = Piwik::getPrettyTimeFromSeconds($deleteLogsInfos["nextScheduleTime"] - time());
     return $deleteLogsInfos;
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:38,代码来源:Controller.php

示例5: getVisitLengthPretty

 function getVisitLengthPretty()
 {
     return Piwik::getPrettyTimeFromSeconds($this->details['visit_total_time']);
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:4,代码来源:Visitor.php

示例6: getPrettyValue

 /**
  * For the given value, based on the column name, will apply: pretty time, pretty money
  * @param int $idSite
  * @param string $columnName
  * @param mixed $value
  * @param bool $htmlAllowed
  * @param string $timeAsSentence
  * @return string
  */
 public static function getPrettyValue($idSite, $columnName, $value, $htmlAllowed, $timeAsSentence)
 {
     // Display time in human readable
     if (strpos($columnName, 'time') !== false) {
         return Piwik::getPrettyTimeFromSeconds($value, $timeAsSentence);
     }
     // Add revenue symbol to revenues
     if (strpos($columnName, 'revenue') !== false) {
         return Piwik::getPrettyMoney($value, $idSite, $htmlAllowed);
     }
     // Add % symbol to rates
     if (strpos($columnName, '_rate') !== false) {
         if (strpos($value, "%") === false) {
             return $value . "%";
         }
     }
     return $value;
 }
开发者ID:neolf,项目名称:PIWIK4MOBILE,代码行数:27,代码来源:Piwik.php

示例7: getAge

 /**
  * Returns the domain age for the current url
  *
  * @return int
  */
 public function getAge()
 {
     $ageArchiveOrg = $this->_getAgeArchiveOrg();
     $ageWhoIs = $this->_getAgeWhoIs();
     $ageWhoisCom = $this->_getAgeWhoisCom();
     $ages = array();
     if ($ageArchiveOrg > 0) {
         $ages[] = $ageArchiveOrg;
     }
     if ($ageWhoIs > 0) {
         $ages[] = $ageWhoIs;
     }
     if ($ageWhoisCom > 0) {
         $ages[] = $ageWhoisCom;
     }
     if (count($ages) > 1) {
         $maxAge = min($ages);
     } else {
         $maxAge = array_shift($ages);
     }
     if ($maxAge) {
         return Piwik::getPrettyTimeFromSeconds(time() - $maxAge);
     }
     return false;
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:30,代码来源:RankChecker.php

示例8: smarty_modifier_sumtime

/**
 * Returns a string that displays the number of days and hours from a number of seconds
 * 
 * How to use:
 * {4200|sumtime} will display '1h 10min'
 * 
 * Examples:
 * - 10 gives "10s"
 * - 4200 gives "1h 10min"
 * - 86400 gives "1 day"
 * - 90600 gives "1 day 1h" (it is exactly 1day 1h 10min but we truncate)
 * 
 * @return string
 * 
 */
function smarty_modifier_sumtime($numberOfSeconds)
{
    return Piwik::getPrettyTimeFromSeconds($numberOfSeconds);
}
开发者ID:klando,项目名称:pgpiwik,代码行数:19,代码来源:modifier.sumtime.php

示例9: getSumVisitsLengthPretty

 public function getSumVisitsLengthPretty($idSite, $period, $date, $segment = false)
 {
     $table = $this->getSumVisitsLength($idSite, $period, $date, $segment);
     if ($table instanceof Piwik_DataTable_Array) {
         $table->filter('ColumnCallbackReplace', array(0, array('Piwik', 'getPrettyTimeFromSeconds')));
     } else {
         $table = Piwik::getPrettyTimeFromSeconds($table);
     }
     return $table;
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:10,代码来源:API.php

示例10: initWebsitesToProcess

 protected function initWebsitesToProcess()
 {
     $this->allWebsites = Piwik_SitesManager_API::getInstance()->getAllSitesId();
     if ($this->shouldArchiveAllWebsites) {
         $this->websites = $this->allWebsites;
         $this->log("Will process " . count($this->websites) . " websites");
     } else {
         // 1) All websites with visits since the last archive.php execution
         $timestampActiveTraffic = $this->timeLastCompleted;
         if (empty($timestampActiveTraffic)) {
             $timestampActiveTraffic = time() - $this->firstRunActiveWebsitesWithTraffic;
             $this->log("--force-all-periods was detected: we will process websites with visits in the last " . Piwik::getPrettyTimeFromSeconds($this->firstRunActiveWebsitesWithTraffic, true, false));
         }
         $this->websites = Piwik_SitesManager_API::getInstance()->getSitesIdWithVisits($timestampActiveTraffic);
         $websiteIds = !empty($this->websites) ? ", IDs: " . implode(", ", $this->websites) : "";
         $prettySeconds = Piwik::getPrettyTimeFromSeconds(empty($this->timeLastCompleted) ? $this->firstRunActiveWebsitesWithTraffic : time() - $this->timeLastCompleted, true, false);
         $this->log("Will process " . count($this->websites) . " websites with new visits since " . $prettySeconds . " " . $websiteIds);
         // 2) All websites that had reports in the past invalidated recently
         //	eg. when using Python log import script
         $this->idSitesInvalidatedOldReports = Piwik_CoreAdminHome_API::getWebsiteIdsToInvalidate();
         $this->idSitesInvalidatedOldReports = array_intersect($this->idSitesInvalidatedOldReports, $this->allWebsites);
         if (count($this->idSitesInvalidatedOldReports) > 0) {
             $websiteIds = ", IDs: " . implode(", ", $this->idSitesInvalidatedOldReports);
             $this->log("Will process " . count($this->idSitesInvalidatedOldReports) . " other websites because some old data reports have been invalidated (eg. using the Log Import script) " . $websiteIds);
             $this->websites = array_merge($this->websites, $this->idSitesInvalidatedOldReports);
         }
         // 3) Also process all other websites which days have finished since the last run.
         //    This ensures we process the previous day/week/month/year that just finished, even if there was no new visit
         $uniqueTimezones = Piwik_SitesManager_API::getInstance()->getUniqueSiteTimezones();
         $timezoneToProcess = array();
         foreach ($uniqueTimezones as &$timezone) {
             $processedDateInTz = Piwik_Date::factory((int) $timestampActiveTraffic, $timezone);
             $currentDateInTz = Piwik_Date::factory('now', $timezone);
             if ($processedDateInTz->toString() != $currentDateInTz->toString()) {
                 $timezoneToProcess[] = $timezone;
             }
         }
         $websiteDayHasFinishedSinceLastRun = Piwik_SitesManager_API::getInstance()->getSitesIdFromTimezones($timezoneToProcess);
         $websiteDayHasFinishedSinceLastRun = array_diff($websiteDayHasFinishedSinceLastRun, $this->websites);
         $this->websiteDayHasFinishedSinceLastRun = $websiteDayHasFinishedSinceLastRun;
         if (count($websiteDayHasFinishedSinceLastRun) > 0) {
             $websiteIds = !empty($websiteDayHasFinishedSinceLastRun) ? ", IDs: " . implode(", ", $websiteDayHasFinishedSinceLastRun) : "";
             $this->log("Will process " . count($websiteDayHasFinishedSinceLastRun) . " other websites because the last time they were archived was on a different day (in the website's timezone) " . $websiteIds);
             $this->websites = array_merge($this->websites, $websiteDayHasFinishedSinceLastRun);
         }
     }
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:47,代码来源:archive.php

示例11: makePrettyArchivedOnText

 /**
  * Returns prettified and translated text that describes when a report was last updated.
  * 
  * @return string
  */
 private function makePrettyArchivedOnText()
 {
     $dateText = $this->viewProperties['metadata'][Piwik_DataTable::ARCHIVED_DATE_METADATA_NAME];
     $date = Piwik_Date::factory($dateText);
     $today = mktime(0, 0, 0);
     if ($date->getTimestamp() > $today) {
         $elapsedSeconds = time() - $date->getTimestamp();
         $timeAgo = Piwik::getPrettyTimeFromSeconds($elapsedSeconds);
         return Piwik_Translate('CoreHome_ReportGeneratedXAgo', $timeAgo);
     }
     $prettyDate = $date->getLocalized("%longYear%, %longMonth% %day%") . $date->toString('S');
     return Piwik_Translate('CoreHome_ReportGeneratedOn', $prettyDate);
 }
开发者ID:nomoto-ubicast,项目名称:piwik,代码行数:18,代码来源:ViewDataTable.php

示例12: getSumVisitsLengthPretty

 public function getSumVisitsLengthPretty($idSite, $period, $date)
 {
     return Piwik::getPrettyTimeFromSeconds(self::getSumVisitsLength($idSite, $period, $date));
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:4,代码来源:API.php

示例13: getAge

	public function getAge()
	{
		$url = preg_replace('/^www\./', '', $this->url);
		$url = 'http://www.who.is/whois/'.urlencode($url);
		$data = $this->getPage($url);
		preg_match('#(?:Creation Date|Created On):\s*([a-z0-9/-]+)#si', $data, $p);
		if(!isset($p[1]))
		{
			return null;
		}
		$value = time() - strtotime($p[1]);
		$value = Piwik::getPrettyTimeFromSeconds($value);
		return $value;
	}
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:14,代码来源:RankChecker.php

示例14: getCleanedVisitorsFromDetails

 /**
  * For an array of visits, query the list of pages for this visit
  * as well as make the data human readable
  * @param array $visitorDetails
  * @param int $idSite
  * @return Piwik_DataTable
  */
 private function getCleanedVisitorsFromDetails($visitorDetails, $idSite)
 {
     $table = new Piwik_DataTable();
     $site = new Piwik_Site($idSite);
     $timezone = $site->getTimezone();
     $currencies = Piwik_SitesManager_API::getInstance()->getCurrencySymbols();
     foreach ($visitorDetails as $visitorDetail) {
         $this->cleanVisitorDetails($visitorDetail, $idSite);
         $visitor = new Piwik_Live_Visitor($visitorDetail);
         $visitorDetailsArray = $visitor->getAllVisitorDetails();
         $visitorDetailsArray['siteCurrency'] = $site->getCurrency();
         $visitorDetailsArray['siteCurrencySymbol'] = @$currencies[$site->getCurrency()];
         $visitorDetailsArray['serverTimestamp'] = $visitorDetailsArray['lastActionTimestamp'];
         $dateTimeVisit = Piwik_Date::factory($visitorDetailsArray['lastActionTimestamp'], $timezone);
         $visitorDetailsArray['serverTimePretty'] = $dateTimeVisit->getLocalized('%time%');
         $visitorDetailsArray['serverDatePretty'] = $dateTimeVisit->getLocalized(Piwik_Translate('CoreHome_ShortDateFormat'));
         $dateTimeVisitFirstAction = Piwik_Date::factory($visitorDetailsArray['firstActionTimestamp'], $timezone);
         $visitorDetailsArray['serverDatePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized(Piwik_Translate('CoreHome_ShortDateFormat'));
         $visitorDetailsArray['serverTimePrettyFirstAction'] = $dateTimeVisitFirstAction->getLocalized('%time%');
         $idvisit = $visitorDetailsArray['idVisit'];
         $sqlCustomVariables = '';
         for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) {
             $sqlCustomVariables .= ', custom_var_k' . $i . ', custom_var_v' . $i;
         }
         // The second join is a LEFT join to allow returning records that don't have a matching page title
         // eg. Downloads, Outlinks. For these, idaction_name is set to 0
         $sql = "\n\t\t\t\tSELECT\n\t\t\t\t\tlog_action.type AS type,\n\t\t\t\t\tlog_action.name AS url,\n\t\t\t\t\tlog_action.url_prefix,\n\t\t\t\t\tlog_action_title.name AS pageTitle,\n\t\t\t\t\tlog_action.idaction AS pageIdAction,\n\t\t\t\t\tlog_link_visit_action.idlink_va AS pageId,\n\t\t\t\t\tlog_link_visit_action.server_time as serverTimePretty,\n\t\t\t\t\tlog_link_visit_action.time_spent_ref_action as timeSpentRef\n\t\t\t\t\t{$sqlCustomVariables}\n\t\t\t\tFROM " . Piwik_Common::prefixTable('log_link_visit_action') . " AS log_link_visit_action\n\t\t\t\t\tINNER JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action\n\t\t\t\t\tON  log_link_visit_action.idaction_url = log_action.idaction\n\t\t\t\t\tLEFT JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action_title\n\t\t\t\t\tON  log_link_visit_action.idaction_name = log_action_title.idaction\n\t\t\t\tWHERE log_link_visit_action.idvisit = ?\n\t\t\t\t ";
         $actionDetails = Piwik_FetchAll($sql, array($idvisit));
         foreach ($actionDetails as $actionIdx => &$actionDetail) {
             $customVariablesPage = array();
             for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) {
                 if (!empty($actionDetail['custom_var_k' . $i]) && !empty($actionDetail['custom_var_v' . $i])) {
                     $customVariablesPage[$i] = array('customVariableName' . $i => $actionDetail['custom_var_k' . $i], 'customVariableValue' . $i => $actionDetail['custom_var_v' . $i]);
                 }
                 unset($actionDetail['custom_var_k' . $i]);
                 unset($actionDetail['custom_var_v' . $i]);
             }
             if (!empty($customVariablesPage)) {
                 $actionDetail['customVariables'] = $customVariablesPage;
             }
             // reconstruct url from prefix
             $actionDetail['url'] = Piwik_Tracker_Action::reconstructNormalizedUrl($actionDetail['url'], $actionDetail['url_prefix']);
             unset($actionDetail['url_prefix']);
             // set the time spent for this action (which is the timeSpentRef of the next action)
             if (isset($actionDetails[$actionIdx + 1])) {
                 $actionDetail['timeSpent'] = $actionDetails[$actionIdx + 1]['timeSpentRef'];
                 $actionDetail['timeSpentPretty'] = Piwik::getPrettyTimeFromSeconds($actionDetail['timeSpent']);
             }
             unset($actionDetails[$actionIdx]['timeSpentRef']);
             // not needed after timeSpent is added
         }
         // If the visitor converted a goal, we shall select all Goals
         $sql = "\n\t\t\t\tSELECT \n\t\t\t\t\t\t'goal' as type,\n\t\t\t\t\t\tgoal.name as goalName,\n\t\t\t\t\t\tgoal.revenue as revenue,\n\t\t\t\t\t\tlog_conversion.idlink_va as goalPageId,\n\t\t\t\t\t\tlog_conversion.server_time as serverTimePretty,\n\t\t\t\t\t\tlog_conversion.url as url\n\t\t\t\tFROM " . Piwik_Common::prefixTable('log_conversion') . " AS log_conversion\n\t\t\t\tLEFT JOIN " . Piwik_Common::prefixTable('goal') . " AS goal \n\t\t\t\t\tON (goal.idsite = log_conversion.idsite\n\t\t\t\t\t\tAND  \n\t\t\t\t\t\tgoal.idgoal = log_conversion.idgoal)\n\t\t\t\t\tAND goal.deleted = 0\n\t\t\t\tWHERE log_conversion.idvisit = ?\n\t\t\t\t\tAND log_conversion.idgoal > 0\n\t\t\t";
         $goalDetails = Piwik_FetchAll($sql, array($idvisit));
         $sql = "SELECT \n\t\t\t\t\t\tcase idgoal when " . Piwik_Tracker_GoalManager::IDGOAL_CART . " then '" . Piwik_Archive::LABEL_ECOMMERCE_CART . "' else '" . Piwik_Archive::LABEL_ECOMMERCE_ORDER . "' end as type,\n\t\t\t\t\t\tidorder as orderId,\n\t\t\t\t\t\t" . Piwik_ArchiveProcessing_Day::getSqlRevenue('revenue') . " as revenue,\n\t\t\t\t\t\t" . Piwik_ArchiveProcessing_Day::getSqlRevenue('revenue_subtotal') . " as revenueSubTotal,\n\t\t\t\t\t\t" . Piwik_ArchiveProcessing_Day::getSqlRevenue('revenue_tax') . " as revenueTax,\n\t\t\t\t\t\t" . Piwik_ArchiveProcessing_Day::getSqlRevenue('revenue_shipping') . " as revenueShipping,\n\t\t\t\t\t\t" . Piwik_ArchiveProcessing_Day::getSqlRevenue('revenue_discount') . " as revenueDiscount,\n\t\t\t\t\t\titems as items,\n\t\t\t\t\t\t\n\t\t\t\t\t\tlog_conversion.server_time as serverTimePretty\n\t\t\t\t\tFROM " . Piwik_Common::prefixTable('log_conversion') . " AS log_conversion\n\t\t\t\t\tWHERE idvisit = ?\n\t\t\t\t\t\tAND idgoal <= " . Piwik_Tracker_GoalManager::IDGOAL_ORDER;
         $ecommerceDetails = Piwik_FetchAll($sql, array($idvisit));
         foreach ($ecommerceDetails as &$ecommerceDetail) {
             if ($ecommerceDetail['type'] == Piwik_Archive::LABEL_ECOMMERCE_CART) {
                 unset($ecommerceDetail['orderId']);
                 unset($ecommerceDetail['revenueSubTotal']);
                 unset($ecommerceDetail['revenueTax']);
                 unset($ecommerceDetail['revenueShipping']);
                 unset($ecommerceDetail['revenueDiscount']);
             }
             // 25.00 => 25
             foreach ($ecommerceDetail as $column => $value) {
                 if (strpos($column, 'revenue') !== false) {
                     if ($value == round($value)) {
                         $ecommerceDetail[$column] = round($value);
                     }
                 }
             }
         }
         // Enrich ecommerce carts/orders with the list of products
         usort($ecommerceDetails, array($this, 'sortByServerTime'));
         foreach ($ecommerceDetails as $key => &$ecommerceConversion) {
             $sql = "SELECT \n\t\t\t\t\t\t\tlog_action_sku.name as itemSKU,\n\t\t\t\t\t\t\tlog_action_name.name as itemName,\n\t\t\t\t\t\t\tlog_action_category.name as itemCategory,\n\t\t\t\t\t\t\t" . Piwik_ArchiveProcessing_Day::getSqlRevenue('price') . " as price,\n\t\t\t\t\t\t\tquantity as quantity\n\t\t\t\t\t\tFROM " . Piwik_Common::prefixTable('log_conversion_item') . "\n\t\t\t\t\t\t\tINNER JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action_sku\n\t\t\t\t\t\t\tON  idaction_sku = log_action_sku.idaction\n\t\t\t\t\t\t\tLEFT JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action_name\n\t\t\t\t\t\t\tON  idaction_name = log_action_name.idaction\n\t\t\t\t\t\t\tLEFT JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action_category\n\t\t\t\t\t\t\tON idaction_category = log_action_category.idaction\n\t\t\t\t\t\tWHERE idvisit = ? \n\t\t\t\t\t\t\tAND idorder = ?\n\t\t\t\t\t\t\tAND deleted = 0\n\t\t\t\t";
             $bind = array($idvisit, isset($ecommerceConversion['orderId']) ? $ecommerceConversion['orderId'] : Piwik_Tracker_GoalManager::ITEM_IDORDER_ABANDONED_CART);
             $itemsDetails = Piwik_FetchAll($sql, $bind);
             foreach ($itemsDetails as &$detail) {
                 if ($detail['price'] == round($detail['price'])) {
                     $detail['price'] = round($detail['price']);
                 }
             }
             $ecommerceConversion['itemDetails'] = $itemsDetails;
         }
         $actions = array_merge($actionDetails, $goalDetails, $ecommerceDetails);
         usort($actions, array($this, 'sortByServerTime'));
         $visitorDetailsArray['actionDetails'] = $actions;
         // Convert datetimes to the site timezone
         foreach ($visitorDetailsArray['actionDetails'] as &$details) {
             switch ($details['type']) {
                 case 'goal':
//.........这里部分代码省略.........
开发者ID:nnnnathann,项目名称:piwik,代码行数:101,代码来源:API.php


注:本文中的Piwik::getPrettyTimeFromSeconds方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。