コード例 #1
0
 /**
  * Returns HTML code for the GeoAnalysis generations tab.
  *
  * @param GeoAnalysis $ga Reference GeoAnalysis 
  * @param array $placesGenerationsResults Analysis results at a generations level
  * @param (null|array) $flags Array of flags
  * @return string HTML code for the generations tab
  */
 protected function htmlPlacesAnalysisGenerationsTab(GeoAnalysis $ga, $placesGenerationsResults, $flags = null)
 {
     global $WT_TREE;
     if (!empty($placesGenerationsResults) && $ga->getOptions()) {
         $data = new ViewBag();
         ksort($placesGenerationsResults);
         $detailslevel = $ga->getOptions()->getMaxDetailsInGen();
         $data->set('max_details_gen', $detailslevel);
         $data->set('use_flags', $ga->getOptions()->isUsingFlags());
         $data->set('analysis_level', $ga->getAnalysisLevel());
         $display_all_places = !is_null($detailslevel) && $detailslevel == 0;
         $data->set('display_all_places', $display_all_places);
         $results_by_gen = array();
         foreach ($placesGenerationsResults as $gen => $genData) {
             $sum = 0;
             $other = 0;
             $unknown = 0;
             if (isset($genData['sum'])) {
                 $sum = $genData['sum'];
             }
             if (isset($genData['other'])) {
                 $other = $genData['other'];
             }
             if (isset($genData['unknown'])) {
                 $unknown = $genData['unknown'];
             }
             if ($sum > 0) {
                 $results_by_gen[$gen]['sum'] = $sum;
                 $results_by_gen[$gen]['other'] = $other;
                 $results_by_gen[$gen]['unknown'] = $unknown;
                 $results_by_gen[$gen]['places'] = array();
                 arsort($genData['places']);
                 if ($display_all_places) {
                     foreach ($genData['places'] as $placename => $count) {
                         $results_by_gen[$gen]['places'][$placename]['count'] = $count;
                         if ($ga->getOptions() && $ga->getOptions()->isUsingFlags() && ($flag = $flags[$placename]) != '') {
                             $results_by_gen[$gen]['places'][$placename]['place'] = new Place($placename, $WT_TREE);
                             $results_by_gen[$gen]['places'][$placename]['flag'] = $flag;
                         }
                     }
                 } else {
                     $tmp = $genData['places'];
                     if ($other > 0) {
                         $tmp = array_slice($tmp, 0, 5, true);
                         $tmp['other'] = $other;
                         arsort($tmp);
                     }
                     $results_by_gen[$gen]['places'] = array_slice($tmp, 0, 5, true);
                 }
             }
         }
         $data->set('results_by_generations', $results_by_gen);
         $html = ViewFactory::make('GeoAnalysisTabGenerations', $this, new BaseController(), $data)->getHtmlPartial();
     } else {
         $html = '<p class="warning">' . I18N::translate('No data is available for the generations analysis.') . '</p>';
     }
     return $html;
 }
コード例 #2
0
 /**
  * Delete a geodispersion analysis from the database.
  * 
  * @param GeoAnalysis $ga
  */
 public function deleteGeoAnalysis(GeoAnalysis $ga)
 {
     Database::prepare('DELETE FROM `##maj_geodispersion`' . ' WHERE majgd_file = :gedcom_id AND majgd_id=:ga_id')->execute(array('gedcom_id' => $this->tree->getTreeId(), 'ga_id' => $ga->getId()));
 }