Esempio n. 1
0
 /**
  * Startup activity
  */
 public function __construct()
 {
     global $WT_TREE;
     parent::__construct();
     $this->setPageTitle(I18N::translate('Timeline'));
     $this->baseyear = (int) date('Y');
     $pids = Filter::getArray('pids', WT_REGEX_XREF);
     $remove = Filter::get('remove', WT_REGEX_XREF);
     foreach (array_unique($pids) as $pid) {
         if ($pid !== $remove) {
             $person = Individual::getInstance($pid, $WT_TREE);
             if ($person && $person->canShow()) {
                 $this->people[] = $person;
             }
         }
     }
     $this->pidlinks = '';
     foreach ($this->people as $indi) {
         // setup string of valid pids for links
         $this->pidlinks .= 'pids%5B%5D=' . $indi->getXref() . '&';
         $bdate = $indi->getBirthDate();
         if ($bdate->isOK()) {
             $date = new GregorianDate($bdate->minimumJulianDay());
             $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) {
                 $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 GregorianDate($date->minimumJulianDay());
                     $this->baseyear = min($this->baseyear, $date->y);
                     $this->topyear = max($this->topyear, $date->y);
                     if (!$indi->isDead()) {
                         $this->topyear = max($this->topyear, (int) date('Y'));
                     }
                     // do not add the same fact twice (prevents marriages from being added multiple times)
                     if (!in_array($event, $this->indifacts, true)) {
                         $this->indifacts[] = $event;
                     }
                 }
             }
         }
     }
     $scale = Filter::getInteger('scale', 0, 200);
     if ($scale === 0) {
         $this->scale = (int) (($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;
 }