本文整理汇总了PHP中Piwik\Period\Range::getDateStart方法的典型用法代码示例。如果您正苦于以下问题:PHP Range::getDateStart方法的具体用法?PHP Range::getDateStart怎么用?PHP Range::getDateStart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Period\Range
的用法示例。
在下文中一共展示了Range::getDateStart方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasReportBeenPurged
/**
* Returns true if it is likely that the data for this report has been purged and if the
* user should be told about that.
*
* In order for this function to return true, the following must also be true:
* - The data table for this report must either be empty or not have been fetched.
* - The period of this report is not a multiple period.
* - The date of this report must be older than the delete_reports_older_than config option.
* @param DataTableInterface $dataTable
* @return bool
*/
public static function hasReportBeenPurged($dataTable)
{
$strPeriod = Common::getRequestVar('period', false);
$strDate = Common::getRequestVar('date', false);
if (false !== $strPeriod && false !== $strDate && (is_null($dataTable) || !empty($dataTable) && $dataTable->getRowsCount() == 0)) {
// if range, only look at the first date
if ($strPeriod == 'range') {
$idSite = Common::getRequestVar('idSite', '');
if (intval($idSite) != 0) {
$site = new Site($idSite);
$timezone = $site->getTimezone();
} else {
$timezone = 'UTC';
}
$period = new Range('range', $strDate, $timezone);
$reportDate = $period->getDateStart();
} elseif (Period::isMultiplePeriod($strDate, $strPeriod)) {
// if a multiple period, this function is irrelevant
return false;
} else {
// otherwise, use the date as given
$reportDate = Date::factory($strDate);
}
$reportYear = $reportDate->toString('Y');
$reportMonth = $reportDate->toString('m');
if (static::shouldReportBePurged($reportYear, $reportMonth)) {
return true;
}
}
return false;
}
示例2: getRelativeToEndDate
/**
* Returns a date range string given a period type, end date and number of periods
* the range spans over.
*
* @param string $period The sub period type, `'day'`, `'week'`, `'month'` and `'year'`.
* @param int $lastN The number of periods of type `$period` that the result range should
* span.
* @param string $endDate The desired end date of the range.
* @param Site $site The site whose timezone should be used.
* @return string The date range string, eg, `'2012-01-02,2013-01-02'`.
* @api
*/
public static function getRelativeToEndDate($period, $lastN, $endDate, $site)
{
$last30Relative = new Range($period, $lastN, $site->getTimezone());
$last30Relative->setDefaultEndDate(Date::factory($endDate));
$date = $last30Relative->getDateStart()->toString() . "," . $last30Relative->getDateEnd()->toString();
return $date;
}
示例3: setGeneralVariablesView
/**
* Assigns variables to {@link Piwik\View} instances that display an entire page.
*
* The following variables assigned:
*
* **date** - The value of the **date** query parameter.
* **idSite** - The value of the **idSite** query parameter.
* **rawDate** - The value of the **date** query parameter.
* **prettyDate** - A pretty string description of the current period.
* **siteName** - The current site's name.
* **siteMainUrl** - The URL of the current site.
* **startDate** - The start date of the current period. A {@link Piwik\Date} instance.
* **endDate** - The end date of the current period. A {@link Piwik\Date} instance.
* **language** - The current language's language code.
* **config_action_url_category_delimiter** - The value of the `[General] action_url_category_delimiter`
* INI config option.
* **topMenu** - The result of `MenuTop::getInstance()->getMenu()`.
*
* As well as the variables set by {@link setPeriodVariablesView()}.
*
* Will exit on error.
*
* @param View $view
* @return void
* @api
*/
protected function setGeneralVariablesView($view)
{
$view->idSite = $this->idSite;
$this->checkSitePermission();
$this->setPeriodVariablesView($view);
$view->siteName = $this->site->getName();
$view->siteMainUrl = $this->site->getMainUrl();
$siteTimezone = $this->site->getTimezone();
$datetimeMinDate = $this->site->getCreationDate()->getDatetime();
$minDate = Date::factory($datetimeMinDate, $siteTimezone);
$this->setMinDateView($minDate, $view);
$maxDate = Date::factory('now', $siteTimezone);
$this->setMaxDateView($maxDate, $view);
$rawDate = Common::getRequestVar('date');
Period::checkDateFormat($rawDate);
$periodStr = Common::getRequestVar('period');
if ($periodStr != 'range') {
$date = Date::factory($this->strDate);
$validDate = $this->getValidDate($date, $minDate, $maxDate);
$period = Period\Factory::build($periodStr, $validDate);
if ($date->toString() !== $validDate->toString()) {
// we to not always change date since it could convert a strDate "today" to "YYYY-MM-DD"
// only change $this->strDate if it was not valid before
$this->setDate($validDate);
}
} else {
$period = new Range($periodStr, $rawDate, $siteTimezone);
}
// Setting current period start & end dates, for pre-setting the calendar when "Date Range" is selected
$dateStart = $period->getDateStart();
$dateStart = $this->getValidDate($dateStart, $minDate, $maxDate);
$dateEnd = $period->getDateEnd();
$dateEnd = $this->getValidDate($dateEnd, $minDate, $maxDate);
if ($periodStr == 'range') {
// make sure we actually display the correct calendar pretty date
$newRawDate = $dateStart->toString() . ',' . $dateEnd->toString();
$period = new Range($periodStr, $newRawDate, $siteTimezone);
}
$view->date = $this->strDate;
$view->prettyDate = self::getCalendarPrettyDate($period);
$view->prettyDateLong = $period->getLocalizedLongString();
$view->rawDate = $rawDate;
$view->startDate = $dateStart;
$view->endDate = $dateEnd;
$language = LanguagesManager::getLanguageForSession();
$view->language = !empty($language) ? $language : LanguagesManager::getLanguageCodeForCurrentUser();
$this->setBasicVariablesView($view);
$view->topMenu = MenuTop::getInstance()->getMenu();
$view->adminMenu = MenuAdmin::getInstance()->getMenu();
$notifications = $view->notifications;
if (empty($notifications)) {
$view->notifications = NotificationManager::getAllNotificationsToDisplay();
NotificationManager::cancelAllNonPersistent();
}
}