Piwik\Plugin\Controller::setPeriodVariablesView PHP Method

setPeriodVariablesView() public static method

- **displayUniqueVisitors** - Whether unique visitors should be displayed for the current period. - **period** - The value of the **period** query parameter. - **otherPeriods** - array('day', 'week', 'month', 'year', 'range') - **periodsNames** - List of available periods mapped to their singular and plural translations.
public static setPeriodVariablesView ( View $view )
$view Piwik\View
    public static function setPeriodVariablesView($view)
    {
        if (isset($view->period)) {
            return;
        }
        $periodValidator = new PeriodValidator();
        $currentPeriod = Common::getRequestVar('period');
        $view->displayUniqueVisitors = SettingsPiwik::isUniqueVisitorsEnabled($currentPeriod);
        $availablePeriods = $periodValidator->getPeriodsAllowedForUI();
        if (!$periodValidator->isPeriodAllowedForUI($currentPeriod)) {
            throw new Exception("Period must be one of: " . implode(", ", $availablePeriods));
        }
        $found = array_search($currentPeriod, $availablePeriods);
        unset($availablePeriods[$found]);
        $view->period = $currentPeriod;
        $view->otherPeriods = $availablePeriods;
        $view->periodsNames = self::getEnabledPeriodsNames();
    }