Ejemplo n.º 1
0
 function __construct()
 {
     parent::__construct();
     $this->setPageTitle(WT_I18N::translate('Timeline'));
     $this->baseyear = date("Y");
     // new pid
     $newpid = WT_Filter::get('newpid', WT_REGEX_XREF);
     // pids array
     $this->pids = WT_Filter::getArray('pids', WT_REGEX_XREF);
     // make sure that arrays are indexed by numbers
     $this->pids = array_values($this->pids);
     if (!empty($newpid) && !in_array($newpid, $this->pids)) {
         $this->pids[] = $newpid;
     }
     if (count($this->pids) == 0) {
         $this->pids[] = $this->getSignificantIndividual()->getXref();
     }
     $remove = WT_Filter::get('remove', WT_REGEX_XREF);
     // cleanup user input
     $newpids = array();
     foreach ($this->pids as $value) {
         if ($value != $remove) {
             $newpids[] = $value;
             $person = WT_Individual::getInstance($value);
             if ($person) {
                 $this->people[] = $person;
             }
         }
     }
     $this->pids = $newpids;
     $this->pidlinks = "";
     foreach ($this->people as $p => $indi) {
         if (!is_null($indi) && $indi->canShow()) {
             // setup string of valid pids for links
             $this->pidlinks .= "pids%5B%5D=" . $indi->getXref() . "&";
             $bdate = $indi->getBirthDate();
             if ($bdate->isOK()) {
                 $date = new WT_Date_Gregorian($bdate->MinDate()->minJD);
                 $this->birthyears[$indi->getXref()] = $date->y;
                 $this->birthmonths[$indi->getXref()] = max(1, $date->m);
                 $this->birthdays[$indi->getXref()] = max(1, $date->d);
             }
             // find all the fact information
             $facts = $indi->getFacts();
             foreach ($indi->getSpouseFamilies() as $family) {
                 foreach ($family->getFacts() as $fact) {
                     $fact->spouse = $family->getSpouse($indi);
                     $facts[] = $fact;
                 }
             }
             foreach ($facts as $event) {
                 // get the fact type
                 $fact = $event->getTag();
                 if (!in_array($fact, $this->nonfacts)) {
                     // check for a date
                     $date = $event->getDate();
                     if ($date->isOK()) {
                         $date = new WT_Date_Gregorian($date->MinDate()->minJD);
                         $this->baseyear = min($this->baseyear, $date->y);
                         $this->topyear = max($this->topyear, $date->y);
                         if (!$indi->isDead()) {
                             $this->topyear = max($this->topyear, date('Y'));
                         }
                         $event->temp = $p;
                         // do not add the same fact twice (prevents marriages from being added multiple times)
                         // TODO - this code does not work.  If both spouses are shown, their marriage is duplicated...
                         if (!in_array($event, $this->indifacts, true)) {
                             $this->indifacts[] = $event;
                         }
                     }
                 }
             }
         }
     }
     $scale = WT_Filter::getInteger('scale', 0, 200);
     if ($scale == 0) {
         $this->scale = round(($this->topyear - $this->baseyear) / 20 * count($this->indifacts) / 4);
         if ($this->scale < 6) {
             $this->scale = 6;
         }
     } else {
         $this->scale = $scale;
     }
     if ($this->scale < 2) {
         $this->scale = 2;
     }
     $this->baseyear -= 5;
     $this->topyear += 5;
 }