public static function getAllProviderInfo($newline = "\n", $includeExtra = false)
{
$allInfo = array();
foreach (self::getAllProviders() as $provider) {
$info = $provider->getInfo();
$status = self::INSTALLED;
$location = false;
$statusMessage = false;
$availableOrMessage = $provider->isAvailable();
if ($availableOrMessage !== true) {
$status = self::NOT_INSTALLED;
if (is_string($availableOrMessage)) {
$statusMessage = $availableOrMessage;
}
} else {
$workingOrError = $provider->isWorking();
if ($workingOrError === true) {
$locInfo = array('ip' => IP::getIpFromHeader(), 'lang' => Common::getBrowserLanguage(), 'disable_fallbacks' => true);
$location = $provider->getLocation($locInfo);
$location = self::prettyFormatLocation($location, $newline, $includeExtra);
} else {
$status = self::BROKEN;
$statusMessage = $workingOrError;
}
}
$info['status'] = $status;
$info['statusMessage'] = $statusMessage;
$info['location'] = $location;
$allInfo[$info['order']] = $info;
}
ksort($allInfo);
$result = array();
foreach ($allInfo as $info) {
$result[$info['id']] = $info;
}
return $result;
}
public function adminIndex() { $this->dieIfGeolocationAdminIsDisabled(); Piwik::checkUserHasSuperUserAccess(); $view = new View('@UserCountry/adminIndex'); $allProviderInfo = LocationProvider::getAllProviderInfo($newline = '<br/>', $includeExtra = true); $view->locationProviders = $allProviderInfo; $view->currentProviderId = LocationProvider::getCurrentProviderId(); $view->thisIP = IP::getIpFromHeader(); $geoIPDatabasesInstalled = GeoIp::isDatabaseInstalled(); $view->geoIPDatabasesInstalled = $geoIPDatabasesInstalled; $view->updatePeriodOptions = $this->getPeriodUpdateOptions(); // check if there is a working provider (that isn't the default one) $isThereWorkingProvider = false; foreach ($allProviderInfo as $id => $provider) { if ($id != DefaultProvider::ID && $provider['status'] == LocationProvider::INSTALLED) { $isThereWorkingProvider = true; break; } } $view->isThereWorkingProvider = $isThereWorkingProvider; // if using either the Apache or PECL module, they are working and there are no databases // in misc, then the databases are located outside of Piwik, so we cannot update them $view->showGeoIPUpdateSection = true; $currentProviderId = LocationProvider::getCurrentProviderId(); if (!$geoIPDatabasesInstalled && ($currentProviderId == ServerBased::ID || $currentProviderId == Pecl::ID) && $allProviderInfo[$currentProviderId]['status'] == LocationProvider::INSTALLED) { $view->showGeoIPUpdateSection = false; } $this->setUpdaterManageVars($view); $this->setBasicVariablesView($view); $this->setBasicVariablesAdminView($view); return $view->render(); }