Number of websites to show in the Website selector
public static getWebsitesCountToDisplay ( ) : integer | ||
return | integer |
public function getPatternMatchSites($pattern) { $ids = $this->getSitesIdWithAtLeastViewAccess(); if (empty($ids)) { return array(); } $ids_str = ''; foreach ($ids as $id_val) { $ids_str .= $id_val . ' , '; } $ids_str .= $id_val; $db = Db::get(); $bind = array('%' . $pattern . '%', 'http%' . $pattern . '%', '%' . $pattern . '%'); // Also match the idsite $where = ''; if (is_numeric($pattern)) { $bind[] = $pattern; $where = 'OR s.idsite = ?'; } $sites = $db->fetchAll("SELECT idsite, name, main_url, `group`\n\t\t\t\t\t\t\t\tFROM " . Common::prefixTable('site') . " s\n\t\t\t\t\t\t\t\tWHERE (\t\ts.name like ?\n\t\t\t\t\t\t\t\t\t\tOR \ts.main_url like ?\n\t\t\t\t\t\t\t\t\t\tOR \ts.`group` like ?\n\t\t\t\t\t\t\t\t\t\t {$where} )\n\t\t\t\t\t\t\t\t\tAND idsite in ({$ids_str})\n\t\t\t\t\t\t\t\tLIMIT " . SettingsPiwik::getWebsitesCountToDisplay(), $bind); return $sites; }
public function getPatternMatchSites($pattern) { $ids = $this->getSitesIdWithAtLeastViewAccess(); if (empty($ids)) { return array(); } $limit = SettingsPiwik::getWebsitesCountToDisplay(); $sites = $this->getModel()->getPatternMatchSites($ids, $pattern, $limit); return $sites; }
/** * Fetches the list of sites which names match the string pattern * * @param string $pattern * @param bool $_restrictSitesToLogin * @return array|string */ private function getSitesIdFromPattern($pattern, $_restrictSitesToLogin) { // First clear cache Site::clearCache(); if (empty($pattern)) { /** @var Scheduler $scheduler */ $scheduler = StaticContainer::getContainer()->get('Piwik\\Scheduler\\Scheduler'); // Then, warm the cache with only the data we should have access to if (Piwik::hasUserSuperUserAccess() && !$scheduler->isRunningTask()) { APISitesManager::getInstance()->getAllSites(); } else { APISitesManager::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin); } } else { $sites = Request::processRequest('SitesManager.getPatternMatchSites', array('pattern' => $pattern, 'limit' => SettingsPiwik::getWebsitesCountToDisplay(), 'showColumns' => '', 'hideColumns' => '', 'format' => 'original')); if (!empty($sites)) { Site::setSitesFromArray($sites); } } // Both calls above have called Site::setSitesFromArray. We now get these sites: $sitesToProblablyAdd = Site::getSites(); return $sitesToProblablyAdd; }
/** * Returns the number of websites to display per page. * * For example this is used in the All Websites Dashboard, in the Website Selector etc. If multiple websites are * shown somewhere, one should request this method to detect how many websites should be shown per page when * using paging. To use paging is always recommended since some installations have thousands of websites. * * @return int */ public function getNumWebsitesToDisplayPerPage() { Piwik::checkUserHasSomeViewAccess(); return SettingsPiwik::getWebsitesCountToDisplay(); }
/** * Renders the current view. Also sends the stored 'Content-Type' HTML header. * See {@link setContentType()}. * * @return string Generated template. */ public function render() { try { $this->currentModule = Piwik::getModule(); $this->currentAction = Piwik::getAction(); $userLogin = Piwik::getCurrentUserLogin(); $this->userLogin = $userLogin; $count = SettingsPiwik::getWebsitesCountToDisplay(); $sites = APISitesManager::getInstance()->getSitesWithAtLeastViewAccess($count); usort($sites, function ($site1, $site2) { return strcasecmp($site1["name"], $site2["name"]); }); $this->sites = $sites; $this->url = Common::sanitizeInputValue(Url::getCurrentUrl()); $this->token_auth = Piwik::getCurrentUserTokenAuth(); $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess(); $this->userIsSuperUser = Piwik::isUserIsSuperUser(); $this->latest_version_available = UpdateCheck::isNewestVersionAvailable(); $this->disableLink = Common::getRequestVar('disableLink', 0, 'int'); $this->isWidget = Common::getRequestVar('widget', 0, 'int'); if (Config::getInstance()->General['autocomplete_min_sites'] <= count($sites)) { $this->show_autocompleter = true; } else { $this->show_autocompleter = false; } $this->loginModule = Piwik::getLoginPluginName(); $user = APIUsersManager::getInstance()->getUser($userLogin); $this->userAlias = $user['alias']; } catch (Exception $e) { // can fail, for example at installation (no plugin loaded yet) } try { $this->totalTimeGeneration = Registry::get('timer')->getTime(); $this->totalNumberOfQueries = Profiler::getQueryCount(); } catch (Exception $e) { $this->totalNumberOfQueries = 0; } ProxyHttp::overrideCacheControlHeaders('no-store'); @header('Content-Type: ' . $this->contentType); // always sending this header, sometimes empty, to ensure that Dashboard embed loads (which could call this header() multiple times, the last one will prevail) @header('X-Frame-Options: ' . (string) $this->xFrameOptions); return $this->renderTwigTemplate(); }