Пример #1
0
 function __construct()
 {
     global $WT_SESSION;
     parent::__construct();
     $this->setPageTitle(WT_I18N::translate('Lifespans'));
     $this->colorindex = 0;
     $this->Fcolorindex = 0;
     $this->Mcolorindex = 0;
     $this->zoomfactor = 10;
     $this->color = "#0000FF";
     $this->currentYear = date("Y");
     $this->deathMod = 0;
     $this->endDate = $this->currentYear;
     // Request parameters
     $newpid = WT_Filter::get('newpid', WT_REGEX_XREF);
     $remove = WT_Filter::get('remove', WT_REGEX_XREF);
     $pids = WT_Filter::getArray('pids', WT_REGEX_XREF);
     $clear = WT_Filter::getBool('clear');
     $addfam = WT_Filter::getBool('addFamily');
     $place = WT_Filter::get('place');
     $beginYear = WT_Filter::getInteger('beginYear', 0, date('Y') + 100, 0);
     $endYear = WT_Filter::getInteger('endYear', 0, date('Y') + 100, 0);
     if ($clear) {
         // Empty list
         $this->pids = array();
     } elseif ($pids) {
         // List of specified records
         $this->pids = $pids;
     } elseif ($place) {
         // All records found in a place
         $wt_place = new WT_Place($place, WT_GED_ID);
         $this->pids = WT_DB::prepare("SELECT DISTINCT pl_gid FROM `##placelinks` WHERE pl_p_id=? AND pl_file=?")->execute(array($wt_place->getPlaceId(), WT_GED_ID))->fetchOneColumn();
         $this->place = $place;
     } else {
         // Modify an existing list of records
         if (is_array($WT_SESSION->timeline_pids)) {
             $this->pids = $WT_SESSION->timeline_pids;
         } else {
             $this->pids = array();
         }
         if ($remove) {
             foreach ($this->pids as $key => $value) {
                 if ($value == $remove) {
                     unset($this->pids[$key]);
                 }
             }
         } elseif ($newpid) {
             $person = WT_Individual::getInstance($newpid);
             $this->addFamily($person, $addfam);
         } elseif (!$this->pids) {
             $this->addFamily($this->getSignificantIndividual(), false);
         }
     }
     $WT_SESSION->timeline_pids = $this->pids;
     $this->beginYear = $beginYear;
     $this->endYear = $endYear;
     if ($beginYear == 0 || $endYear == 0) {
         //-- cleanup user input
         $this->pids = array_unique($this->pids);
         //removes duplicates
         foreach ($this->pids as $key => $value) {
             if ($value != $remove) {
                 $this->pids[$key] = $value;
                 $person = WT_Individual::getInstance($value);
                 // list of linked records includes families as well as individuals.
                 if ($person) {
                     $bdate = $person->getEstimatedBirthDate();
                     if ($bdate->isOK() && $person->canShow()) {
                         $this->people[] = $person;
                     }
                 }
             }
         }
     } else {
         //--Finds if the begin year and end year textboxes are not empty
         //-- reset the people array when doing a year range search
         $this->people = array();
         //Takes the begining year and end year passed by the postback and modifies them and uses them to populate
         //the time line
         //Variables to restrict the person boxes to the year searched.
         //--Searches for individuals who had an even between the year begin and end years
         $indis = self::search_indis_year_range($beginYear, $endYear);
         //--Populates an array of people that had an event within those years
         foreach ($indis as $person) {
             if (empty($searchplace) || in_array($person->getXref(), $this->pids)) {
                 $bdate = $person->getEstimatedBirthDate();
                 if ($bdate->isOK() && $person->canShow()) {
                     $this->people[] = $person;
                 }
             }
         }
         $WT_SESSION->timeline_pids = null;
     }
     // Sort the array in order of birth year
     uasort($this->people, function (WT_Individual $a, WT_Individual $b) {
         return WT_Date::Compare($a->getEstimatedBirthDate(), $b->getEstimatedBirthDate());
     });
     //If there is people in the array posted back this if occurs
     if (isset($this->people[0])) {
         //Find the maximum Death year and mimimum Birth year for each individual returned in the array.
         $bdate = $this->people[0]->getEstimatedBirthDate();
         $ddate = $this->people[0]->getEstimatedDeathDate();
         $this->timelineMinYear = $bdate->gregorianYear();
         $this->timelineMaxYear = $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y');
         foreach ($this->people as $value) {
             $bdate = $value->getEstimatedBirthDate();
             $ddate = $value->getEstimatedDeathDate();
             $this->timelineMinYear = min($this->timelineMinYear, $bdate->gregorianYear());
             $this->timelineMaxYear = max($this->timelineMaxYear, $ddate->gregorianYear() ? $ddate->gregorianYear() : date('Y'));
         }
         if ($this->timelineMaxYear > $this->currentYear) {
             $this->timelineMaxYear = $this->currentYear;
         }
     } else {
         // Sets the default timeline length
         $this->timelineMinYear = date("Y") - 101;
         $this->timelineMaxYear = date("Y");
     }
 }
Пример #2
0
         }
         echo '</ul></td></tr>';
         echo '</table>';
     }
     echo '<h4><a href="placelist.php?display=hierarchy">', WT_I18N::translate('Show places in hierarchy'), '</a></h4>';
     break;
 case 'hierarchy':
     $all_modules = WT_Module::getActiveModules();
     if (array_key_exists('googlemap', $all_modules)) {
         $gm_module = $all_modules['googlemap'];
     } else {
         $gm_module = null;
     }
     // Find this place and its ID
     $place = new WT_Place(implode(', ', array_reverse($parent)), WT_GED_ID);
     $place_id = $place->getPlaceId();
     $child_places = $place->getChildPlaces();
     $numfound = count($child_places);
     //-- if the number of places found is 0 then automatically redirect to search page
     if ($numfound == 0) {
         $action = 'show';
     }
     echo '<h2>', $controller->getPageTitle();
     // Breadcrumbs
     if ($place_id) {
         $parent_place = $place->getParentPlace();
         while ($parent_place->getPlaceId()) {
             echo ', <a href="', $parent_place->getURL(), '" dir="auto">', $parent_place->getPlaceName(), '</a>';
             $parent_place = $parent_place->getParentPlace();
         }
         echo ', <a href="', WT_SCRIPT_NAME, '">', WT_I18N::translate('Top level'), '</a>';