Пример #1
0
 public function __construct()
 {
     parent::__construct();
     $this->rootid = WT_Filter::get('rootid', WT_REGEX_XREF);
     if ($this->rootid) {
         $this->root = WT_Individual::getInstance($this->rootid);
     } else {
         // Missing rootid parameter?  Do something.
         $this->root = $this->getSignificantIndividual();
         $this->rootid = $this->root->getXref();
     }
     if (!$this->root || !$this->root->canShowName()) {
         header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden');
         $this->error_message = WT_I18N::translate('This individual does not exist or you do not have permission to view it.');
         $this->rootid = null;
     }
 }
Пример #2
0
 public function __construct()
 {
     parent::__construct();
     $this->surname = WT_Filter::get('surname');
     $this->soundex_std = WT_Filter::getBool('soundex_std');
     $this->soundex_dm = WT_Filter::getBool('soundex_dm');
     if ($this->surname) {
         $this->setPageTitle(WT_I18N::translate('Branches of the %s family', WT_Filter::escapeHtml($this->surname)));
         $this->loadIndividuals();
         $self = WT_Individual::getInstance(WT_USER_GEDCOM_ID);
         if ($self) {
             $this->loadAncestors(WT_Individual::getInstance(WT_USER_GEDCOM_ID), 1);
         }
     } else {
         $this->setPageTitle(WT_I18N::translate('Branches'));
     }
 }
Пример #3
0
 public function __construct()
 {
     // Automatically fix broken links
     if ($this->record && $this->record->canEdit()) {
         $broken_links = 0;
         foreach ($this->record->getFacts('HUSB|WIFE|CHIL|FAMS|FAMC|REPO') as $fact) {
             if (!$fact->isOld() && $fact->getTarget() === null) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 WT_FlashMessages::addMessage(WT_I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         foreach ($this->record->getFacts('NOTE|SOUR|OBJE') as $fact) {
             // These can be links or inline.  Only delete links.
             if (!$fact->isOld() && $fact->getTarget() === null && preg_match('/^@.*@$/', $fact->getValue())) {
                 $this->record->deleteFact($fact->getFactId(), false);
                 WT_FlashMessages::addMessage(WT_I18N::translate('The link from “%1$s” to “%2$s” has been deleted.', $this->record->getFullName(), $fact->getValue()));
                 $broken_links = true;
             }
         }
         if ($broken_links) {
             // Reload the updated family
             $this->record = WT_GedcomRecord::getInstance($this->record->getXref());
         }
     }
     parent::__construct();
     // We want robots to index this page
     $this->setMetaRobots('index,follow');
     // Set a page title
     if ($this->record) {
         $this->setCanonicalUrl($this->record->getHtmlUrl());
         if ($this->record->canShowName()) {
             // e.g. "John Doe" or "1881 Census of Wales"
             $this->setPageTitle($this->record->getFullName());
         } else {
             // e.g. "Individual" or "Source"
             $record = $this->record;
             $this->setPageTitle(WT_Gedcom_Tag::getLabel($record::RECORD_TYPE));
         }
     } else {
         // No such record
         $this->setPageTitle(WT_I18N::translate('Private'));
     }
 }
Пример #4
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 = "";
     /* @var $indi Person */
     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 = $bdate->MinDate();
                 $date = $date->convert_to_cal('gregorian');
                 if ($date->y) {
                     $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();
                     $date = $date->MinDate();
                     $date = $date->convert_to_cal('gregorian');
                     if ($date->y) {
                         $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;
 }
Пример #5
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");
     }
 }
Пример #6
0
 function __construct()
 {
     parent::__construct();
     // $action comes from GET (menus) or POST (form submission)
     $this->action = WT_Filter::post('action', 'advanced|general|soundex|replace');
     if (!$this->action) {
         $this->action = WT_Filter::get('action', 'advanced|general|soundex|replace', 'general');
     }
     $topsearch = WT_Filter::postBool('topsearch');
     if ($topsearch) {
         $this->isPostBack = true;
         $this->srfams = 'yes';
         $this->srindi = 'yes';
         $this->srsour = 'yes';
         $this->srnote = 'yes';
     }
     // Get the query
     $this->query = WT_Filter::post('query', '.{2,}');
     $this->myquery = WT_Filter::escapeHtml($this->query);
     $this->replace = WT_Filter::post('replace');
     $this->replaceNames = WT_Filter::postBool('replaceNames');
     $this->replacePlaces = WT_Filter::postBool('replacePlaces');
     $this->replacePlacesWord = WT_Filter::postBool('replacePlacesWord');
     $this->replaceAll = WT_Filter::postBool('replaceAll');
     // TODO: fetch each variable independently, using appropriate validation
     // Aquire all the variables values from the $_REQUEST
     $varNames = array("isPostBack", "srfams", "srindi", "srsour", "srnote", "view", "soundex", "subaction", "nameprt", "showasso", "resultsPageNum", "resultsPerPage", "totalResults", "totalGeneralResults", "indiResultsPrinted", "famResultsPrinted", "srcResultsPrinted", "myindilist", "mysourcelist", "mynotelist", "myfamlist");
     $this->setRequestValues($varNames);
     if (!$this->isPostBack) {
         // Enable the default gedcom for search
         $str = str_replace(array(".", "-", " "), array("_", "_", "_"), WT_GEDCOM);
         $_REQUEST["{$str}"] = $str;
     }
     // Retrieve the gedcoms to search in
     if (count(WT_Tree::getAll()) > 1 && WT_Site::getPreference('ALLOW_CHANGE_GEDCOM')) {
         foreach (WT_Tree::getAll() as $tree) {
             $str = str_replace(array(".", "-", " "), array("_", "_", "_"), $tree->tree_name);
             if (isset($_REQUEST["{$str}"]) || $topsearch) {
                 $this->sgeds[$tree->tree_id] = $tree->tree_name;
                 $_REQUEST["{$str}"] = 'yes';
             }
         }
     } else {
         $this->sgeds[WT_GED_ID] = WT_GEDCOM;
     }
     // vars use for soundex search
     $this->firstname = WT_Filter::post('firstname');
     $this->lastname = WT_Filter::post('lastname');
     $this->place = WT_Filter::post('place');
     $this->year = WT_Filter::post('year');
     // Set the search result titles for soundex searches
     if ($this->firstname || $this->lastname || $this->place) {
         $this->myquery = WT_Filter::escapeHtml(implode(' ', array($this->firstname, $this->lastname, $this->place)));
     }
     if (!empty($_REQUEST["name"])) {
         $this->name = $_REQUEST["name"];
         $this->myname = $this->name;
     } else {
         $this->name = "";
         $this->myname = "";
     }
     if (!empty($_REQUEST["birthdate"])) {
         $this->birthdate = $_REQUEST["birthdate"];
         $this->mybirthdate = $this->birthdate;
     } else {
         $this->birthdate = "";
         $this->mybirthdate = "";
     }
     if (!empty($_REQUEST["birthplace"])) {
         $this->birthplace = $_REQUEST["birthplace"];
         $this->mybirthplace = $this->birthplace;
     } else {
         $this->birthplace = "";
         $this->mybirthplace = "";
     }
     if (!empty($_REQUEST["deathdate"])) {
         $this->deathdate = $_REQUEST["deathdate"];
         $this->mydeathdate = $this->deathdate;
     } else {
         $this->deathdate = "";
         $this->mydeathdate = "";
     }
     if (!empty($_REQUEST["deathplace"])) {
         $this->deathplace = $_REQUEST["deathplace"];
         $this->mydeathplace = $this->deathplace;
     } else {
         $this->deathplace = "";
         $this->mydeathplace = "";
     }
     if (!empty($_REQUEST["gender"])) {
         $this->gender = $_REQUEST["gender"];
         $this->mygender = $this->gender;
     } else {
         $this->gender = "";
         $this->mygender = "";
     }
     $this->inputFieldNames[] = "action";
     $this->inputFieldNames[] = "isPostBack";
     $this->inputFieldNames[] = "resultsPerPage";
     $this->inputFieldNames[] = "query";
     $this->inputFieldNames[] = "srindi";
     $this->inputFieldNames[] = "srfams";
     $this->inputFieldNames[] = "srsour";
     $this->inputFieldNames[] = "srnote";
     $this->inputFieldNames[] = "showasso";
     $this->inputFieldNames[] = "firstname";
     $this->inputFieldNames[] = "lastname";
     $this->inputFieldNames[] = "place";
     $this->inputFieldNames[] = "year";
     $this->inputFieldNames[] = "soundex";
     $this->inputFieldNames[] = "nameprt";
     $this->inputFieldNames[] = "subaction";
     $this->inputFieldNames[] = "name";
     $this->inputFieldNames[] = "birthdate";
     $this->inputFieldNames[] = "birthplace";
     $this->inputFieldNames[] = "deathdate";
     $this->inputFieldNames[] = "deathplace";
     $this->inputFieldNames[] = "gender";
     // Get the search results based on the action
     if ($topsearch) {
         $this->TopSearch();
     }
     // If we want to show associated persons, build the list
     switch ($this->action) {
         case 'general':
             $this->setPageTitle(WT_I18N::translate('General search'));
             $this->GeneralSearch();
             break;
         case 'soundex':
             $this->setPageTitle(WT_I18N::translate('Phonetic search'));
             $this->SoundexSearch();
             break;
         case 'replace':
             $this->setPageTitle(WT_I18N::translate('Search and replace'));
             $this->SearchAndReplace();
             return;
     }
 }
Пример #7
0
 public function __construct()
 {
     parent::__construct();
     $this->setPageTitle(WT_WEBTREES);
 }