Exemplo n.º 1
0
 /**
  * GeoAnalysis@dataTabs
  */
 public function dataTabs()
 {
     global $WT_TREE;
     $controller = new JsonController();
     $ga_id = Filter::getInteger('ga_id');
     $ga = $this->provider->getGeoAnalysis($ga_id);
     $sosa_provider = new SosaProvider($WT_TREE, Auth::user());
     $controller->restrictAccess($ga && $sosa_provider->isSetup())->pageHeader();
     $jsonArray = array();
     list($placesDispGeneral, $placesDispGenerations) = $ga->getAnalysisResults($sosa_provider->getAllSosaWithGenerations());
     $flags = array();
     if ($placesDispGeneral && $ga->getOptions() && $ga->getOptions()->isUsingFlags()) {
         $mapProvider = new GoogleMapsProvider();
         foreach ($placesDispGeneral['places'] as $place => $count) {
             $flags[$place] = $mapProvider->getPlaceIcon(new Place($place, $WT_TREE));
         }
     }
     $jsonArray['generaltab'] = $this->htmlPlacesAnalysisGeneralTab($ga, $placesDispGeneral, $flags);
     $jsonArray['generationstab'] = $this->htmlPlacesAnalysisGenerationsTab($ga, $placesDispGenerations, $flags);
     $controller->encode($jsonArray);
 }
Exemplo n.º 2
0
 /**
  * AdminConfig@save
  */
 public function save()
 {
     global $WT_TREE;
     $tmp_contrl = new PageController();
     $tmp_contrl->restrictAccess(Auth::isManager($WT_TREE) && Filter::checkCsrf());
     $ga_id = Filter::postInteger('ga_id');
     $description = Filter::post('description');
     $analysislevel = Filter::postInteger('analysislevel');
     $use_map = Filter::postBool('use_map');
     if ($use_map) {
         $map_file = base64_decode(Filter::post('map_file'));
         $map_top_level = Filter::postInteger('map_top_level');
     }
     $use_flags = Filter::postBool('use_flags');
     $gen_details = Filter::postInteger('gen_details');
     $success = false;
     if ($ga_id) {
         $ga = $this->provider->getGeoAnalysis($ga_id, false);
         if ($ga) {
             $ga->setTitle($description);
             $ga->setAnalysisLevel($analysislevel + 1);
             $options = $ga->getOptions();
             if ($options) {
                 $options->setUsingFlags($use_flags);
                 $options->setMaxDetailsInGen($gen_details);
                 if ($use_map) {
                     $options->setMap(new OutlineMap($map_file));
                     $options->setMapLevel($map_top_level + 1);
                 } else {
                     $options->setMap(null);
                 }
             }
             $res = $this->provider->updateGeoAnalysis($ga);
             if ($res) {
                 FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully updated', $res->getTitle()), 'success');
                 Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID “' . $res->getId() . '” has been updated.');
                 $ga = $res;
                 $success = true;
             } else {
                 FlashMessages::addMessage(I18N::translate('An error occured while updating the geographical dispersion analysis “%s”', $ga->getTitle()), 'danger');
                 Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID “' . $ga->getId() . '” could not be updated. See error log.');
             }
         }
     } else {
         $ga = $this->provider->createGeoAnalysis($description, $analysislevel + 1, $use_map ? $map_file : null, $use_map ? $map_top_level + 1 : null, $use_flags, $gen_details);
         if ($ga) {
             FlashMessages::addMessage(I18N::translate('The geographical dispersion analysis “%s” has been successfully added.', $ga->getTitle()), 'success');
             Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis ID “' . $ga->getId() . '” has been added.');
             $success = true;
         } else {
             FlashMessages::addMessage(I18N::translate('An error occured while adding the geographical dispersion analysis “%s”', $description), 'danger');
             Log::addConfigurationLog('Module ' . $this->module->getName() . ' : Geo Analysis “' . $description . '” could not be added. See error log.');
         }
     }
     $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl();
     if (!$success) {
         if ($ga) {
             $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@edit&ga_id=' . $ga->getId() . '&ged=' . $WT_TREE->getNameUrl();
         } else {
             $redirection_url = 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@add&ged=' . $WT_TREE->getNameUrl();
         }
     }
     header('Location: ' . WT_BASE_URL . $redirection_url);
 }