本文整理匯總了PHP中Piwik_Archive::makePeriodFromQueryParams方法的典型用法代碼示例。如果您正苦於以下問題:PHP Piwik_Archive::makePeriodFromQueryParams方法的具體用法?PHP Piwik_Archive::makePeriodFromQueryParams怎麽用?PHP Piwik_Archive::makePeriodFromQueryParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Piwik_Archive
的用法示例。
在下文中一共展示了Piwik_Archive::makePeriodFromQueryParams方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getByDayOfWeek
public function getByDayOfWeek($fetch = false)
{
$view = $this->getGraph(__FUNCTION__, 'VisitTime.getByDayOfWeek', 'VisitTime_DayOfWeek', $limit = 7, $sort = false);
$view->disableSort();
if ($view instanceof Piwik_ViewDataTable_GenerateGraphHTML) {
$view->showAllTicks();
}
// get query params
$idsite = Piwik_Common::getRequestVar('idSite');
$date = Piwik_Common::getRequestVar('date');
$period = Piwik_Common::getRequestVar('period');
// create a period instance
$oSite = new Piwik_Site($idsite);
$oPeriod = Piwik_Archive::makePeriodFromQueryParams($oSite, $period, $date);
// set the footer message using the period start & end date
$start = $oPeriod->getDateStart()->toString();
$end = $oPeriod->getDateEnd()->toString();
if ($start == $end) {
$dateRange = $start;
} else {
$dateRange = $start . " – " . $end;
}
$view->setFooterMessage(Piwik_Translate('General_ReportGeneratedFrom', $dateRange));
return $this->renderView($view, $fetch);
}
示例2: getByDayOfWeek
/**
* Returns datatable describing the number of visits for each day of the week.
*
* @param string $idSite The site ID. Cannot refer to multiple sites.
* @param string $period The period type: day, week, year, range...
* @param string $date The start date of the period. Cannot refer to multiple dates.
* @param string $segment The segment.
* @return Piwik_DataTable
*/
public function getByDayOfWeek($idSite, $period, $date, $segment = false)
{
Piwik::checkUserHasViewAccess($idSite);
// disabled for multiple sites/dates
if (Piwik_Archive::isMultipleSites($idSite)) {
throw new Exception("VisitTime.getByDayOfWeek does not support multiple sites.");
}
if (Piwik_Archive::isMultiplePeriod($date, $period)) {
throw new Exception("VisitTime.getByDayOfWeek does not support multiple dates.");
}
// metrics to query
$metrics = Piwik_ArchiveProcessing::getCoreMetrics();
// get metric data for every day within the supplied period
$oSite = new Piwik_Site($idSite);
$oPeriod = Piwik_Archive::makePeriodFromQueryParams($oSite, $period, $date);
$dateRange = $oPeriod->getDateStart()->toString() . ',' . $oPeriod->getDateEnd()->toString();
$archive = Piwik_Archive::build($idSite, 'day', $dateRange, $segment);
$dataTable = $archive->getDataTableFromNumeric($metrics)->mergeChildren();
// if there's no data for this report, don't bother w/ anything else
if ($dataTable->getRowsCount() == 0) {
return $dataTable;
}
// group by the day of the week (see below for dayOfWeekFromDate function)
$dataTable->filter('GroupBy', array('label', 'Piwik_VisitTime_dayOfWeekFromDate'));
// create new datatable w/ empty rows, then add calculated datatable
$rows = array();
foreach (array(1, 2, 3, 4, 5, 6, 7) as $day) {
$rows[] = array('label' => $day, 'nb_visits' => 0);
}
$result = new Piwik_DataTable();
$result->addRowsFromSimpleArray($rows);
$result->addDataTable($dataTable);
// set day of week integer as metadata
$result->filter('ColumnCallbackAddMetadata', array('label', 'day_of_week'));
// translate labels
$result->filter('ColumnCallbackReplace', array('label', 'Piwik_VisitTime_translateDayOfWeek'));
// set datatable metadata for period start & finish
$result->setMetadata('date_start', $oPeriod->getDateStart());
$result->setMetadata('date_end', $oPeriod->getDateEnd());
return $result;
}
示例3: build
/**
* Builds an Archive object or returns the same archive if previously built.
*
* @param int|string $idSite integer, or comma separated list of integer
* @param string $period 'week' 'day' etc.
* @param Piwik_Date|string $strDate 'YYYY-MM-DD' or magic keywords 'today' @see Piwik_Date::factory()
* @param bool|string $segment Segment definition - defaults to false for Backward Compatibility
* @param bool|string $_restrictSitesToLogin Used only when running as a scheduled task
* @return Piwik_Archive
*/
public static function build($idSite, $period, $strDate, $segment = false, $_restrictSitesToLogin = false)
{
if ($idSite === 'all') {
$sites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAtLeastViewAccess($_restrictSitesToLogin);
} else {
$sites = Piwik_Site::getIdSitesFromIdSitesString($idSite);
}
if (!$segment instanceof Piwik_Segment) {
$segment = new Piwik_Segment($segment, $idSite);
}
// idSite=1,3 or idSite=all
if (count($sites) > 1 || $idSite === 'all') {
$archive = new Piwik_Archive_Array_IndexedBySite($sites, $period, $strDate, $segment, $_restrictSitesToLogin);
} elseif (is_string($strDate) && self::isMultiplePeriod($strDate, $period)) {
$oSite = new Piwik_Site($idSite);
$archive = new Piwik_Archive_Array_IndexedByDate($oSite, $period, $strDate, $segment);
} else {
$oSite = new Piwik_Site($idSite);
$oPeriod = Piwik_Archive::makePeriodFromQueryParams($oSite, $period, $strDate);
$archive = new Piwik_Archive_Single();
$archive->setPeriod($oPeriod);
$archive->setSite($oSite);
$archive->setSegment($segment);
}
return $archive;
}