Piwik\Plugins\UserCountryMap\Controller::realtimeMap PHP Method

realtimeMap() public method

public realtimeMap ( boolean $standalone = false, boolean $fetch = false, boolean | string $segmentOverride = false ) : string
$standalone boolean When set to true, the Top controls will be hidden to provide better full screen view
$fetch boolean
$segmentOverride boolean | string
return string
    public function realtimeMap($standalone = false, $fetch = false, $segmentOverride = false)
    {
        $this->checkUserCountryPluginEnabled();
        $idSite = Common::getRequestVar('idSite', 1, 'int');
        Piwik::checkUserHasViewAccess($idSite);
        $token_auth = Piwik::getCurrentUserTokenAuth();
        $view = new View('@UserCountryMap/realtimeMap');
        $view->mapIsStandaloneNotWidget = !(bool) Common::getRequestVar('widget', $standalone, 'int');
        $view->metrics = $this->getMetrics($idSite, 'range', self::REAL_TIME_WINDOW, $token_auth);
        $view->defaultMetric = 'nb_visits';
        $liveRefreshAfterMs = (int) Config::getInstance()->General['live_widget_refresh_after_seconds'] * 1000;
        $goals = APIGoals::getInstance()->getGoals($idSite);
        $site = new Site($idSite);
        $hasGoals = !empty($goals) || $site->isEcommerceEnabled();
        // maximum number of visits to be displayed in the map
        $maxVisits = Common::getRequestVar('filter_limit', 100, 'int');
        // some translations
        $locale = array('nb_actions' => $this->translator->translate('VisitsSummary_NbActionsDescription'), 'local_time' => $this->translator->translate('VisitTime_ColumnLocalTime'), 'from' => $this->translator->translate('General_FromReferrer'), 'seconds' => $this->translator->translate('Intl_Seconds'), 'seconds_ago' => $this->translator->translate('UserCountryMap_SecondsAgo'), 'minutes' => $this->translator->translate('Intl_Minutes'), 'minutes_ago' => $this->translator->translate('UserCountryMap_MinutesAgo'), 'hours' => $this->translator->translate('Intl_Hours'), 'hours_ago' => $this->translator->translate('UserCountryMap_HoursAgo'), 'days_ago' => $this->translator->translate('UserCountryMap_DaysAgo'), 'actions' => $this->translator->translate('VisitsSummary_NbPageviewsDescription'), 'searches' => $this->translator->translate('UserCountryMap_Searches'), 'goal_conversions' => $this->translator->translate('UserCountryMap_GoalConversions'));
        $segment = $segmentOverride ?: Request::getRawSegmentFromRequest() ?: '';
        $params = array('period' => 'range', 'idSite' => $idSite, 'segment' => $segment, 'token_auth' => $token_auth);
        $realtimeWindow = Common::getRequestVar('realtimeWindow', self::REAL_TIME_WINDOW, 'string');
        if ($realtimeWindow != 'false') {
            // handle special value
            $params['date'] = $realtimeWindow;
        }
        $reqParams = $this->getEnrichedRequest($params, $encode = false);
        $view->config = array('metrics' => array(), 'svgBasePath' => $view->piwikUrl . 'plugins/UserCountryMap/svg/', 'liveRefreshAfterMs' => $liveRefreshAfterMs, '_' => $locale, 'reqParams' => $reqParams, 'siteHasGoals' => $hasGoals, 'maxVisits' => $maxVisits, 'changeVisitAlpha' => Common::getRequestVar('changeVisitAlpha', true, 'int'), 'removeOldVisits' => Common::getRequestVar('removeOldVisits', true, 'int'), 'showFooterMessage' => Common::getRequestVar('showFooterMessage', true, 'int'), 'showDateTime' => Common::getRequestVar('showDateTime', true, 'int'), 'doNotRefreshVisits' => Common::getRequestVar('doNotRefreshVisits', false, 'int'), 'enableAnimation' => Common::getRequestVar('enableAnimation', true, 'int'), 'forceNowValue' => Common::getRequestVar('forceNowValue', false, 'int'));
        return $view->render();
    }