diff options
| -rw-r--r-- | compact.php | 15 | ||||
| -rw-r--r-- | familybook.php | 6 | ||||
| -rw-r--r-- | fanchart.php | 7 | ||||
| -rw-r--r-- | includes/functions/functions.php | 1 | ||||
| -rw-r--r-- | includes/functions/functions_charts.php | 34 | ||||
| -rw-r--r-- | library/WT/Controller/Ancestry.php | 7 | ||||
| -rw-r--r-- | library/WT/Controller/Base.php | 11 | ||||
| -rw-r--r-- | library/WT/Controller/Descendancy.php | 13 | ||||
| -rw-r--r-- | library/WT/Controller/Hourglass.php | 7 | ||||
| -rw-r--r-- | library/WT/Controller/Lifespan.php | 2 | ||||
| -rw-r--r-- | library/WT/Controller/Pedigree.php | 8 | ||||
| -rw-r--r-- | library/WT/Controller/Timeline.php | 2 | ||||
| -rw-r--r-- | modules_v3/charts/module.php | 10 | ||||
| -rw-r--r-- | modules_v3/tree/class_treeview.php | 1 | ||||
| -rw-r--r-- | modules_v3/tree/module.php | 10 | ||||
| -rw-r--r-- | reportengine.php | 11 |
16 files changed, 65 insertions, 80 deletions
diff --git a/compact.php b/compact.php index bac175dc0f..552b3199e9 100644 --- a/compact.php +++ b/compact.php @@ -27,21 +27,24 @@ define('WT_SCRIPT_NAME', 'compact.php'); require './includes/session.php'; require_once WT_ROOT.'includes/functions/functions_charts.php'; +$controller=new WT_Controller_Base(); + // Extract form variables $rootid =safe_GET_xref('rootid'); $showthumbs=safe_GET('showthumbs', '1', '0'); -// Validate form variables -$rootid=check_rootid($rootid); - $person =WT_Person::getInstance($rootid); +if (!$person) { + $person=$controller->getSignificantIndividual(); + $rootid=$person->getXref(); +} $name =$person->getFullName(); $addname=$person->getAddName(); $title = /* I18N: %s is a person's name */ WT_I18N::translate('Compact tree of %s', $person->getFullName()); -$controller=new WT_Controller_Base(); -$controller->setPageTitle($title); -$controller->pageHeader(); +$controller + ->setPageTitle($title) + ->pageHeader(); if ($ENABLE_AUTOCOMPLETE) require WT_ROOT.'js/autocomplete.js.htm'; diff --git a/familybook.php b/familybook.php index 05b42b7b66..64582de73f 100644 --- a/familybook.php +++ b/familybook.php @@ -50,9 +50,11 @@ if ($show_full==false) { } // -- root id -$pid =check_rootid($pid); $person=WT_Person::getInstance($pid); -$name =$person->getFullName(); +if (!$person) { + $person=$controller->getSignificantIndividual(); +} +$name=$person->getFullName(); function print_descendency($person, $count) { global $show_spouse, $dgenerations, $bwidth, $bheight, $bhalfheight; diff --git a/fanchart.php b/fanchart.php index 457f2262d7..dbd9066a28 100644 --- a/fanchart.php +++ b/fanchart.php @@ -380,10 +380,11 @@ $fan_style=safe_GET_integer('fan_style', 2, 4, 3); $fan_width=safe_GET_integer('fan_width', 50, 300, 100); $PEDIGREE_GENERATIONS=safe_GET_integer('PEDIGREE_GENERATIONS', 2, $MAX_PEDIGREE_GENERATIONS, $DEFAULT_PEDIGREE_GENERATIONS); -// Validate form parameters -$rootid = check_rootid($rootid); - $person =WT_Person::getInstance($rootid); +if (!$person) { + $person=$controller->getSignificantIndividual(); + $rootid=$person->getXref(); +} $name =$person->getFullName(); $addname=$person->getAddName(); $title = /* I18N: http://en.wikipedia.org/wiki/Family_tree#Fan_chart - %s is a person's name */ WT_I18N::translate('Fan chart of %s', $person->getFullName()); diff --git a/includes/functions/functions.php b/includes/functions/functions.php index f712a4aae1..04aaa7a575 100644 --- a/includes/functions/functions.php +++ b/includes/functions/functions.php @@ -243,7 +243,6 @@ function load_gedcom_settings($ged_id=WT_GED_ID) { global $NO_UPDATE_CHAN; $NO_UPDATE_CHAN =get_gedcom_setting($ged_id, 'NO_UPDATE_CHAN'); global $PEDIGREE_FULL_DETAILS; $PEDIGREE_FULL_DETAILS =get_gedcom_setting($ged_id, 'PEDIGREE_FULL_DETAILS'); global $PEDIGREE_LAYOUT; $PEDIGREE_LAYOUT =get_gedcom_setting($ged_id, 'PEDIGREE_LAYOUT'); - global $PEDIGREE_ROOT_ID; $PEDIGREE_ROOT_ID =get_gedcom_setting($ged_id, 'PEDIGREE_ROOT_ID'); global $PEDIGREE_SHOW_GENDER; $PEDIGREE_SHOW_GENDER =get_gedcom_setting($ged_id, 'PEDIGREE_SHOW_GENDER'); global $POSTAL_CODE; $POSTAL_CODE =get_gedcom_setting($ged_id, 'POSTAL_CODE'); global $PREFER_LEVEL2_SOURCES; $PREFER_LEVEL2_SOURCES =get_gedcom_setting($ged_id, 'PREFER_LEVEL2_SOURCES'); diff --git a/includes/functions/functions_charts.php b/includes/functions/functions_charts.php index 857e20dcfe..8a8f492d74 100644 --- a/includes/functions/functions_charts.php +++ b/includes/functions/functions_charts.php @@ -519,40 +519,6 @@ function print_sosa_family($famid, $childid, $sosa, $label="", $parid="", $gpari echo "</td></tr></table>"; echo "<br />"; } -/** - * check root id for pedigree tree - * - * @param string $rootid root ID - * @return string $rootid validated root ID - */ -function check_rootid($rootid) { - global $PEDIGREE_ROOT_ID, $USE_RIN; - // -- if the $rootid is not already there then find the first person in the file and make him the root - if (!find_person_record($rootid, WT_GED_ID)) { - if (find_person_record(WT_USER_ROOT_ID, WT_GED_ID)) { - $rootid=WT_USER_ROOT_ID; - } else { - if (find_person_record(WT_USER_GEDCOM_ID, WT_GED_ID)) { - $rootid=WT_USER_GEDCOM_ID; - } else { - if (find_person_record($PEDIGREE_ROOT_ID, WT_GED_ID)) { - $rootid=trim($PEDIGREE_ROOT_ID); - } else { - $rootid=WT_DB::prepare( - "SELECT MIN(i_id) FROM `##individuals` WHERE i_file=?" - )->execute(array(WT_GED_ID))->fetchOne(); - } - } - } - } - - if ($USE_RIN) { - $indirec = find_person_record($rootid, WT_GED_ID); - if ($indirec == false) $rootid = find_rin_id($rootid); - } - - return $rootid; -} /** * creates an array with all of the individual ids to be displayed on an ascendancy chart diff --git a/library/WT/Controller/Ancestry.php b/library/WT/Controller/Ancestry.php index df8879bb13..74c6add22b 100644 --- a/library/WT/Controller/Ancestry.php +++ b/library/WT/Controller/Ancestry.php @@ -62,9 +62,6 @@ class WT_Controller_Ancestry extends WT_Controller_Chart { $OLD_PGENS = $PEDIGREE_GENERATIONS; - // Validate form parameters - $this->rootid = check_rootid($this->rootid); - // -- size of the detailed boxes based upon optional width parameter $Dbwidth=($box_width*$bwidth)/100; $Dbheight=($box_width*$bheight)/100; @@ -81,6 +78,10 @@ class WT_Controller_Ancestry extends WT_Controller_Chart { $pbheight = $bheight+14; $this->ancestry = WT_Person::getInstance($this->rootid); + if (!$this->ancestry) { + $this->ancestry=$this->getSignificantIndividual(); + $this->rootid=$this->ancestry->getXref(); + } $this->name = $this->ancestry->getFullName(); $this->addname = $this->ancestry->getAddName(); diff --git a/library/WT/Controller/Base.php b/library/WT/Controller/Base.php index f424d5b549..251135c2d0 100644 --- a/library/WT/Controller/Base.php +++ b/library/WT/Controller/Base.php @@ -309,13 +309,18 @@ class WT_Controller_Base { // Get significant information from this page, to allow other pages such as // charts and reports to initialise with the same records public function getSignificantIndividual() { - global $PEDIGREE_ROOT_ID; + static $individual; // Only query the DB once. - $individual=WT_Person::getInstance(WT_USER_GEDCOM_ID); - if (!$individual) { + if (!$individual && WT_USER_GEDCOM_ID) { + $individual=WT_Person::getInstance(WT_USER_GEDCOM_ID); + } + if (!$individual && WT_USER_ROOT_ID) { $individual=WT_Person::getInstance(WT_USER_ROOT_ID); } if (!$individual) { + $individual=WT_Person::getInstance(get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID')); + } + if (!$individual) { $individual=WT_Person::getInstance( WT_DB::prepare( "SELECT MIN(i_id) FROM `##individuals` WHERE i_file=?" diff --git a/library/WT/Controller/Descendancy.php b/library/WT/Controller/Descendancy.php index 6d73b5e050..ecfb8307ad 100644 --- a/library/WT/Controller/Descendancy.php +++ b/library/WT/Controller/Descendancy.php @@ -89,12 +89,17 @@ class WT_Controller_Descendancy extends WT_Controller_Chart { $pbheight = $bheight+14; // Validate form variables - $this->rootid=check_rootid($this->rootid); - - if (strlen($this->name)<30) $this->cellwidth="420"; - else $this->cellwidth=(strlen($this->name)*14); + if (strlen($this->name)<30) { + $this->cellwidth=420; + } else { + $this->cellwidth=(strlen($this->name)*14); + } $this->descPerson = WT_Person::getInstance($this->rootid); + if (!$this->descPerson) { + $this->descPerson=$this->getSignificantIndividual(); + $this->rootid=$this->descPerson->getXref(); + } $this->name=$this->descPerson->getFullName(); $this->setPageTitle(/* I18N: %s is a person's name */ WT_I18N::translate('Descendants of %s', $this->name)); diff --git a/library/WT/Controller/Hourglass.php b/library/WT/Controller/Hourglass.php index f5ff1a8acd..29a7d90ae8 100644 --- a/library/WT/Controller/Hourglass.php +++ b/library/WT/Controller/Hourglass.php @@ -108,9 +108,12 @@ class WT_Controller_Hourglass extends WT_Controller_Chart { $bhalfheight = (int)($bheight / 2); // Validate parameters - $this->pid=check_rootid($this->pid); - $this->hourPerson = WT_Person::getInstance($this->pid); + if (!$this->hourPerson) { + $this->hourPerson=$this->getSignificantIndividual(); + $this->pid=$this->hourPerson->getXref(); + } + $this->name=$this->hourPerson->getFullName(); //Checks how many generations of descendency is for the person for formatting purposes diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php index d29afe6020..e9ae4c479f 100644 --- a/library/WT/Controller/Lifespan.php +++ b/library/WT/Controller/Lifespan.php @@ -115,7 +115,7 @@ class WT_Controller_Lifespan extends WT_Controller_Chart { $person=WT_Person::getInstance($newpid); $this->addFamily($person, $addfam); } elseif (!$this->pids) { - $this->addFamily(WT_Person::getInstance(check_rootid("")), false); + $this->addFamily($this->getSignificantIndividual(), false); } } $_SESSION['timeline_pids']=$this->pids; diff --git a/library/WT/Controller/Pedigree.php b/library/WT/Controller/Pedigree.php index 34269437fb..3cddb105e8 100644 --- a/library/WT/Controller/Pedigree.php +++ b/library/WT/Controller/Pedigree.php @@ -83,11 +83,11 @@ class WT_Controller_Pedigree extends WT_Controller_Chart { $show_full = $this->show_full; $talloffset = $this->talloffset; - // Validate parameters - $this->rootid=check_rootid($this->rootid); - $this->rootPerson = WT_Person::getInstance($this->rootid); - if (is_null($this->rootPerson)) $this->rootPerson = new WT_Person(''); + if (!$this->rootPerson) { + $this->rootPerson=$this->getSignificantIndividual(); + $this->rootid=$this->rootPerson->getXref(); + } $this->name = $this->rootPerson->getFullName(); $this->addname = $this->rootPerson->getAddName(); diff --git a/library/WT/Controller/Timeline.php b/library/WT/Controller/Timeline.php index 7761a79fac..5fea9933ac 100644 --- a/library/WT/Controller/Timeline.php +++ b/library/WT/Controller/Timeline.php @@ -72,7 +72,7 @@ class WT_Controller_Timeline extends WT_Controller_Chart { if (!empty($newpid) && !in_array($newpid, $this->pids)) { $this->pids[] = $newpid; } - if (count($this->pids)==0) $this->pids[] = check_rootid(""); + if (count($this->pids)==0) $this->pids[] = $this->getSignificantIndividual()->getXref(); $remove = safe_GET_xref('remove'); //-- cleanup user input $newpids = array(); diff --git a/modules_v3/charts/module.php b/modules_v3/charts/module.php index 0c6a54feb1..f93a422ec6 100644 --- a/modules_v3/charts/module.php +++ b/modules_v3/charts/module.php @@ -41,7 +41,9 @@ class charts_WT_Module extends WT_Module implements WT_Module_Block { // Implement class WT_Module_Block public function getBlock($block_id, $template=true, $cfg=null) { - global $ctype, $WT_IMAGES, $PEDIGREE_ROOT_ID, $PEDIGREE_FULL_DETAILS, $show_full, $bwidth, $bheight; + global $ctype, $WT_IMAGES, $PEDIGREE_FULL_DETAILS, $show_full, $bwidth, $bheight; + + $PEDIGREE_ROOT_ID=get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID'); $details=get_block_setting($block_id, 'details', false); $type =get_block_setting($block_id, 'type', 'pedigree'); @@ -73,7 +75,7 @@ class charts_WT_Module extends WT_Module implements WT_Module_Block { } $person = WT_Person::getInstance($pid); - if ($person==null) { + if (!$person) { $pid = $PEDIGREE_ROOT_ID; set_block_setting($block_id, 'pid', $pid); $person = WT_Person::getInstance($pid); @@ -182,7 +184,9 @@ class charts_WT_Module extends WT_Module implements WT_Module_Block { // Implement class WT_Module_Block public function configureBlock($block_id) { - global $ctype, $PEDIGREE_ROOT_ID, $ENABLE_AUTOCOMPLETE; + global $ctype, $ENABLE_AUTOCOMPLETE; + + $PEDIGREE_ROOT_ID=get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID'); if (safe_POST_bool('save')) { set_block_setting($block_id, 'details', safe_POST_bool('details')); diff --git a/modules_v3/tree/class_treeview.php b/modules_v3/tree/class_treeview.php index cd77b0e361..ab658c84e1 100644 --- a/modules_v3/tree/class_treeview.php +++ b/modules_v3/tree/class_treeview.php @@ -63,7 +63,6 @@ class TreeView { public function drawViewport($rootPersonId, $generations, $style) { global $GEDCOM, $WT_IMAGES, $controller; - $rootPersonId = check_rootid($rootPersonId); $rootPerson = WT_Person::getInstance($rootPersonId); if (is_null($rootPerson)) $rootPerson = new WT_Person(''); diff --git a/modules_v3/tree/module.php b/modules_v3/tree/module.php index 8d97404682..a79badc58d 100644 --- a/modules_v3/tree/module.php +++ b/modules_v3/tree/module.php @@ -107,17 +107,21 @@ class tree_WT_Module extends WT_Module implements WT_Module_Tab { require_once WT_MODULES_DIR.$this->getName().'/class_treeview.php'; switch($mod_action) { case 'treeview': + global $controller; + $controller=new WT_Controller_Base(); + $tvName = 'tv'; $rootid = safe_GET('rootid'); - $rootid = check_rootid($rootid); $tv = new TreeView('tv'); ob_start(); $person=WT_Person::getInstance($rootid); + if (!$person) { + $person=$controller->getSignificantIndividual(); + } + list($html, $js)=$tv->drawViewport($rootid, 4, $this->style); - global $controller; - $controller=new WT_Controller_Base(); $controller ->setPageTitle(WT_I18N::translate('Interactive tree of %s', $person->getFullName())) ->pageHeader() diff --git a/reportengine.php b/reportengine.php index 5239b39b6c..871a8adacf 100644 --- a/reportengine.php +++ b/reportengine.php @@ -224,21 +224,14 @@ elseif ($action=='setup') { if (!empty($pid)) { $input['default'] = $pid; } else { - $input['default'] = check_rootid($input['default']); + $input['default'] = $controller->getSignificantIndividual()->getXref(); } } if ($input['lookup']=='FAM') { if (!empty($famid)) { $input['default'] = $famid; } else { - // Default the FAM to the first spouse family of the default INDI - $person=WT_Person::getInstance(check_rootid($input['default'])); - if ($person) { - $sfams=$person->getSpouseFamilies(); - if ($sfams) { - $input['default'] = reset($sfams)->getXref(); - } - } + $input['default'] = $controller->getSignificantFamily()->getXref(); } } if ($input['lookup']=='SOUR') { |
