/**
  * Renders the edit form, whether it is an edition of an existing GeoAnalysis, or the addition of a new one.
  * 
  * @param (GeoAnalysis!null) $ga GeoAnalysis to edit
  */
 protected function renderEdit(GeoAnalysis $ga = null)
 {
     global $WT_TREE;
     Theme::theme(new AdministrationTheme())->init($WT_TREE);
     $controller = new PageController();
     $controller->restrictAccess(Auth::isManager($WT_TREE))->addInlineJavascript('
             function toggleMapOptions() {
                 if($("input:radio[name=\'use_map\']:checked").val() == 1) {
                     $("#map_options").show();
                 }
                 else {
                     $("#map_options").hide();
                 }
             }
     
             $("[name=\'use_map\']").on("change", toggleMapOptions);
             toggleMapOptions();
         ');
     $data = new ViewBag();
     if ($ga) {
         $controller->setPageTitle(I18N::translate('Edit the geographical dispersion analysis'));
         $data->set('geo_analysis', $ga);
     } else {
         $controller->setPageTitle(I18N::translate('Add a geographical dispersion analysis'));
     }
     $data->set('title', $controller->getPageTitle());
     $data->set('admin_config_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig&ged=' . $WT_TREE->getNameUrl());
     $data->set('module_title', $this->module->getTitle());
     $data->set('save_url', 'module.php?mod=' . $this->module->getName() . '&mod_action=AdminConfig@save&ged=' . $WT_TREE->getNameUrl());
     $data->set('places_hierarchy', $this->provider->getPlacesHierarchy());
     $map_list = array_map(function (OutlineMap $map) {
         return $map->getDescription();
     }, $this->provider->getOutlineMapsList());
     asort($map_list);
     $data->set('map_list', $map_list);
     $gen_details = array(0 => I18N::translate('All'));
     for ($i = 1; $i <= 10; $i++) {
         $gen_details[$i] = $i;
     }
     $data->set('generation_details', $gen_details);
     ViewFactory::make('GeoAnalysisEdit', $this, $controller, $data)->render();
 }
 /**
  * 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);
 }