diff options
Diffstat (limited to 'library/WT/Controller')
| -rw-r--r-- | library/WT/Controller/AdvancedSearch.php | 10 | ||||
| -rw-r--r-- | library/WT/Controller/Ancestry.php | 4 | ||||
| -rw-r--r-- | library/WT/Controller/Chart.php | 4 | ||||
| -rw-r--r-- | library/WT/Controller/Compact.php | 12 | ||||
| -rw-r--r-- | library/WT/Controller/Descendancy.php | 8 | ||||
| -rw-r--r-- | library/WT/Controller/Family.php | 62 | ||||
| -rw-r--r-- | library/WT/Controller/Familybook.php | 10 | ||||
| -rw-r--r-- | library/WT/Controller/Fanchart.php | 8 | ||||
| -rw-r--r-- | library/WT/Controller/GedcomRecord.php | 18 | ||||
| -rw-r--r-- | library/WT/Controller/Hourglass.php | 8 | ||||
| -rw-r--r-- | library/WT/Controller/Individual.php | 356 | ||||
| -rw-r--r-- | library/WT/Controller/Lifespan.php | 16 | ||||
| -rw-r--r-- | library/WT/Controller/Media.php | 56 | ||||
| -rw-r--r-- | library/WT/Controller/Note.php | 50 | ||||
| -rw-r--r-- | library/WT/Controller/Page.php | 13 | ||||
| -rw-r--r-- | library/WT/Controller/Pedigree.php | 4 | ||||
| -rw-r--r-- | library/WT/Controller/Repository.php | 50 | ||||
| -rw-r--r-- | library/WT/Controller/Search.php | 30 | ||||
| -rw-r--r-- | library/WT/Controller/Source.php | 50 | ||||
| -rw-r--r-- | library/WT/Controller/Timeline.php | 42 |
20 files changed, 225 insertions, 586 deletions
diff --git a/library/WT/Controller/AdvancedSearch.php b/library/WT/Controller/AdvancedSearch.php index cba844cd74..586db82939 100644 --- a/library/WT/Controller/AdvancedSearch.php +++ b/library/WT/Controller/AdvancedSearch.php @@ -2,7 +2,7 @@ // Controller for the advanced search page // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -202,7 +202,7 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search { } // Dynamic SQL query, plus bind variables - $sql="SELECT DISTINCT 'INDI' AS type, ind.i_id AS xref, ind.i_file AS ged_id, ind.i_gedcom AS gedrec FROM `##individuals` ind"; + $sql="SELECT DISTINCT ind.i_id AS xref, ind.i_file AS gedcom_id, ind.i_gedcom AS gedcom FROM `##individuals` ind"; $bind=array(); // Join the following tables @@ -486,13 +486,13 @@ class WT_Controller_AdvancedSearch extends WT_Controller_Search { $bind[]=$value; } } - $rows=WT_DB::prepare($sql)->execute($bind)->fetchAll(PDO::FETCH_ASSOC); + $rows=WT_DB::prepare($sql)->execute($bind)->fetchAll(); foreach ($rows as $row) { - $person=WT_Person::getInstance($row); + $person=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); // Check for XXXX:PLAC fields, which were only partially matched by SQL foreach ($this->fields as $n=>$field) { if ($this->values[$n] && preg_match('/^('.WT_REGEX_TAG.'):PLAC$/', $field, $match)) { - if (!preg_match('/\n1 '.$match[1].'(\n[2-9].*)*\n2 PLAC .*'.preg_quote($this->values[$n], '/').'/i', $person->getGedcomRecord())) { + if (!preg_match('/\n1 '.$match[1].'(\n[2-9].*)*\n2 PLAC .*'.preg_quote($this->values[$n], '/').'/i', $person->getGedcom())) { continue 2; } } diff --git a/library/WT/Controller/Ancestry.php b/library/WT/Controller/Ancestry.php index 6228418cdc..23bafdd5b5 100644 --- a/library/WT/Controller/Ancestry.php +++ b/library/WT/Controller/Ancestry.php @@ -2,7 +2,7 @@ // Controller for the ancestry chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -74,7 +74,7 @@ class WT_Controller_Ancestry extends WT_Controller_Chart { $pbwidth = $bwidth+12; $pbheight = $bheight+14; - if ($this->root && $this->root->canDisplayName()) { + if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: %s is an individual’s name */ WT_I18N::translate('Ancestors of %s', $this->root->getFullName()) diff --git a/library/WT/Controller/Chart.php b/library/WT/Controller/Chart.php index 6e54c135d7..ce9f1d9726 100644 --- a/library/WT/Controller/Chart.php +++ b/library/WT/Controller/Chart.php @@ -35,14 +35,14 @@ class WT_Controller_Chart extends WT_Controller_Page { $this->rootid = safe_GET_xref('rootid'); if ($this->rootid) { - $this->root = WT_Person::getInstance($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->canDisplayName()) { + 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; diff --git a/library/WT/Controller/Compact.php b/library/WT/Controller/Compact.php index d8b051e248..5bda1695b1 100644 --- a/library/WT/Controller/Compact.php +++ b/library/WT/Controller/Compact.php @@ -2,7 +2,7 @@ // Controller for the compact chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -41,7 +41,7 @@ class WT_Controller_Compact extends WT_Controller_Chart { // Extract the request parameters $this->show_thumbs=safe_GET_bool('show_thumbs'); - if ($this->root && $this->root->canDisplayName()) { + if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: %s is an individual’s name */ WT_I18N::translate('Compact tree of %s', $this->root->getFullName()) @@ -55,9 +55,9 @@ class WT_Controller_Compact extends WT_Controller_Chart { function sosa_person($n) { global $SHOW_HIGHLIGHT_IMAGES; - $indi=WT_Person::getInstance($this->treeid[$n]); + $indi=WT_Individual::getInstance($this->treeid[$n]); - if ($indi && $indi->canDisplayName()) { + if ($indi && $indi->canShowName()) { $name=$indi->getFullName(); $addname=$indi->getAddName(); @@ -72,7 +72,7 @@ class WT_Controller_Compact extends WT_Controller_Chart { if ($addname) $html .= '<br>' . $addname; $html .= '</a>'; $html .= '<br>'; - if ($indi->canDisplayDetails()) { + if ($indi->canShow()) { $html.='<div class="details1">'.$indi->getLifeSpan().'</div>'; } } else { @@ -115,7 +115,7 @@ class WT_Controller_Compact extends WT_Controller_Chart { } if ($pid) { - $indi=WT_Person::getInstance($pid); + $indi=WT_Individual::getInstance($pid); $title=WT_I18N::translate('Compact tree of %s', $indi->getFullName()); $text = '<a class="icon-'.$arrow_dir.'arrow" title="'.strip_tags($title).'" href="?rootid='.$pid; if ($this->show_thumbs) $text .= "&show_thumbs=".$this->show_thumbs; diff --git a/library/WT/Controller/Descendancy.php b/library/WT/Controller/Descendancy.php index f9d07c6977..9ee2c3d733 100644 --- a/library/WT/Controller/Descendancy.php +++ b/library/WT/Controller/Descendancy.php @@ -2,7 +2,7 @@ // Controller for the descendancy chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -92,7 +92,7 @@ class WT_Controller_Descendancy extends WT_Controller_Chart { $this->cellwidth=(strlen($this->name)*14); } - if ($this->root && $this->root->canDisplayName()) { + if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: %s is an individual’s name */ WT_I18N::translate('Descendants of %s', $this->root->getFullName()) @@ -199,7 +199,7 @@ class WT_Controller_Descendancy extends WT_Controller_Chart { $spouse=$family->getSpouse($person); if (!$spouse) { // One parent families have no spouse - $spouse=new WT_Person(''); + $spouse=new WT_Individual(''); } // print marriage info @@ -244,7 +244,7 @@ class WT_Controller_Descendancy extends WT_Controller_Chart { } else { // Distinguish between no children (NCHI 0) and no recorded // children (no CHIL records) - if (strpos($family->getGedcomRecord(), '\n1 NCHI 0')) { + if (strpos($family->getGedcom(), '\n1 NCHI 0')) { echo WT_Gedcom_Tag::getLabel('NCHI').': '.count($children); } else { echo WT_I18N::translate('No children'); diff --git a/library/WT/Controller/Family.php b/library/WT/Controller/Family.php index 68151a0d35..686627562b 100644 --- a/library/WT/Controller/Family.php +++ b/library/WT/Controller/Family.php @@ -2,7 +2,7 @@ // Controller for the family page // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved. @@ -32,46 +32,14 @@ require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; class WT_Controller_Family extends WT_Controller_GedcomRecord { - var $diff_record; - var $record = null; - var $user = null; - var $display = false; - var $famrec = ''; - var $title = ''; - public function __construct() { global $Dbwidth, $bwidth, $pbwidth, $pbheight, $bheight; - $bwidth = $Dbwidth; - $pbwidth = $bwidth + 12; + $bwidth = $Dbwidth; + $pbwidth = $bwidth + 12; $pbheight = $bheight + 14; - $xref = safe_GET_xref('famid'); - - $gedrec = find_family_record($xref, WT_GED_ID); - - if (empty($gedrec)) { - $gedrec = "0 @".$xref."@ FAM\n"; - } - - if (find_family_record($xref, WT_GED_ID) || find_updated_record($xref, WT_GED_ID)!==null) { - $this->record = new WT_Family($gedrec); - $this->record->ged_id=WT_GED_ID; // This record is from a file - } else if (!$this->record) { - parent::__construct(); - return; - } - - $xref=$this->record->getXref(); // Correct upper/lower case mismatch - - //-- if the user can edit and there are changes then get the new changes - if (WT_USER_CAN_EDIT) { - $newrec = find_updated_record($xref, WT_GED_ID); - if (!empty($newrec)) { - $this->diff_record = new WT_Family($newrec); - $this->diff_record->setChanged(true); - $this->record->diffMerge($this->diff_record); - } - } + $xref = safe_GET_xref('famid'); + $this->record = WT_Family::getInstance($xref); parent::__construct(); } @@ -98,7 +66,7 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord { // $tags is an array of HUSB/WIFE/CHIL function getTimelineIndis($tags) { - preg_match_all('/\n1 (?:'.implode('|', $tags).') @('.WT_REGEX_XREF.')@/', $this->record->getGedcomRecord(), $matches); + preg_match_all('/\n1 (?:'.implode('|', $tags).') @('.WT_REGEX_XREF.')@/', $this->record->getGedcom(), $matches); foreach ($matches[1] as &$match) { $match='pids[]='.$match; } @@ -111,7 +79,7 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->record || $this->record->isMarkedDeleted()) { + if (!$this->record || $this->record->isOld()) { return null; } @@ -138,21 +106,6 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord { } } - // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-fam-editraw'); - $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); - $menu->addSubmenu($submenu); - } elseif ($SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('View GEDCOM Record'), '#', 'menu-fam-viewraw'); - if (WT_USER_CAN_EDIT) { - $submenu->addOnclick("return show_gedcom_record('new');"); - } else { - $submenu->addOnclick("return show_gedcom_record();"); - } - $menu->addSubmenu($submenu); - } - // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-fam-del'); @@ -202,7 +155,6 @@ class WT_Controller_Family extends WT_Controller_GedcomRecord { foreach ($indifacts as $fact) { print_fact($fact, $this->record); } - print_main_media($this->record->getXref()); } else { echo '<tr><td class="messagebox" colspan="2">', WT_I18N::translate('No facts for this family.'), '</td></tr>'; } diff --git a/library/WT/Controller/Familybook.php b/library/WT/Controller/Familybook.php index e75a46b6a6..c509a10af4 100644 --- a/library/WT/Controller/Familybook.php +++ b/library/WT/Controller/Familybook.php @@ -2,7 +2,7 @@ // Controller for the familybook chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -64,7 +64,7 @@ class WT_Controller_Familybook extends WT_Controller_Chart { // Validate parameters if (!empty($rootid)) $this->pid = $rootid; $rootid=$this->rootid; - $this->hourPerson = WT_Person::getInstance($this->pid); + $this->hourPerson = WT_Individual::getInstance($this->pid); if (!$this->hourPerson) { $this->hourPerson=$this->getSignificantIndividual(); $this->pid=$this->hourPerson->getXref(); @@ -75,7 +75,7 @@ class WT_Controller_Familybook extends WT_Controller_Chart { $bheight = $cbheight; } $bhalfheight = $bheight / 2; - if ($this->root && $this->root->canDisplayName()) { + if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: %s is an individual’s name */ WT_I18N::translate('Family book of %s', $this->root->getFullName()) @@ -334,7 +334,7 @@ class WT_Controller_Familybook extends WT_Controller_Chart { */ function max_descendency_generations($pid, $depth) { if ($depth > $this->generations) return $depth; - $person = WT_Person::getInstance($pid); + $person = WT_Individual::getInstance($pid); if (is_null($person)) return $depth; $maxdc = $depth; foreach ($person->getSpouseFamilies() as $family) { @@ -360,7 +360,7 @@ class WT_Controller_Familybook extends WT_Controller_Chart { } function print_family_book($person, $descent) { global $firstrun; - if ($descent==0 || !$person->canDisplayName()) { + if ($descent==0 || !$person->canShowName()) { return; } $families=$person->getSpouseFamilies(); diff --git a/library/WT/Controller/Fanchart.php b/library/WT/Controller/Fanchart.php index 2b86dab1d6..ea6edf7c12 100644 --- a/library/WT/Controller/Fanchart.php +++ b/library/WT/Controller/Fanchart.php @@ -2,7 +2,7 @@ // Controller for the fan chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -46,7 +46,7 @@ class WT_Controller_Fanchart extends WT_Controller_Chart { $this->fan_width =safe_GET_integer('fan_width', 50, 300, 100); $this->generations=safe_GET_integer('generations', 2, 9, $default_generations); - if ($this->root && $this->root->canDisplayName()) { + if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: http://en.wikipedia.org/wiki/Family_tree#Fan_chart - %s is an individual’s name */ WT_I18N::translate('Fan chart of %s', $this->root->getFullName()) @@ -211,7 +211,7 @@ class WT_Controller_Fanchart extends WT_Controller_Chart { while ($sosa >= $p2) { $pid=$treeid[$sosa]; if ($pid) { - $person =WT_Person::getInstance($pid); + $person =WT_Individual::getInstance($pid); $name =$person->getFullName(); $addname=$person->getAddName(); @@ -234,8 +234,8 @@ class WT_Controller_Fanchart extends WT_Controller_Chart { $text .= $person->getLifeSpan(); - $text = unhtmlentities($text); $text = strip_tags($text); + $text = htmlspecialchars_decode($text); // split and center text by lines $wmax = (int)($angle*7/$fanChart['size']*$scale); diff --git a/library/WT/Controller/GedcomRecord.php b/library/WT/Controller/GedcomRecord.php index 18c64bd9fa..233c7fbaac 100644 --- a/library/WT/Controller/GedcomRecord.php +++ b/library/WT/Controller/GedcomRecord.php @@ -29,6 +29,22 @@ class WT_Controller_GedcomRecord extends WT_Controller_Page { public $record; // individual, source, repository, etc. 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|SOUR|REPO|OBJE') as $fact) { // Not NOTE! + if (!$fact->isOld() && $fact->getTarget() === null) { + $this->record->updateFact($fact->getFactId(), null, false); + WT_FlashMessages::addMessage(/* I18N: %s are names of records, such as sources, repositories or individuals */ 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 @@ -37,7 +53,7 @@ class WT_Controller_GedcomRecord extends WT_Controller_Page { // Set a page title if ($this->record) { $this->setCanonicalUrl($this->record->getHtmlUrl()); - if ($this->record->canDisplayName()) { + if ($this->record->canShowName()) { // e.g. "John Doe" or "1881 Census of Wales" $this->setPageTitle($this->record->getFullName()); } else { diff --git a/library/WT/Controller/Hourglass.php b/library/WT/Controller/Hourglass.php index 7dee4869e3..01285b296b 100644 --- a/library/WT/Controller/Hourglass.php +++ b/library/WT/Controller/Hourglass.php @@ -2,7 +2,7 @@ // Controller for the hourglass chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -90,7 +90,7 @@ class WT_Controller_Hourglass extends WT_Controller_Chart { $bhalfheight = (int)($bheight / 2); // Validate parameters - $this->hourPerson = WT_Person::getInstance($this->pid); + $this->hourPerson = WT_Individual::getInstance($this->pid); if (!$this->hourPerson) { $this->hourPerson=$this->getSignificantIndividual(); $this->pid=$this->hourPerson->getXref(); @@ -347,7 +347,7 @@ class WT_Controller_Hourglass extends WT_Controller_Chart { // For the root person, print a down arrow that allows changing the root of tree if ($showNav && $count==1) { // NOTE: If statement OK - if ($person->canDisplayName()) { + if ($person->canShowName()) { // -- print left arrow for decendants so that we can move down the tree $famids = $person->getSpouseFamilies(); //-- make sure there is more than 1 child in the family with parents @@ -435,7 +435,7 @@ class WT_Controller_Hourglass extends WT_Controller_Chart { */ function max_descendency_generations($pid, $depth) { if ($depth > $this->generations) return $depth; - $person = WT_Person::getInstance($pid); + $person = WT_Individual::getInstance($pid); if (is_null($person)) return $depth; $maxdc = $depth; foreach ($person->getSpouseFamilies() as $family) { diff --git a/library/WT/Controller/Individual.php b/library/WT/Controller/Individual.php index 26cf33b4ec..c09304fa32 100644 --- a/library/WT/Controller/Individual.php +++ b/library/WT/Controller/Individual.php @@ -32,58 +32,29 @@ require_once WT_ROOT.'includes/functions/functions_print_facts.php'; require_once WT_ROOT.'includes/functions/functions_import.php'; class WT_Controller_Individual extends WT_Controller_GedcomRecord { - var $name_count = 0; - var $total_names = 0; - var $SEX_COUNT = 0; - var $Fam_Navigator = 'YES'; - var $NAME_LINENUM = null; - var $SEX_LINENUM = null; - var $globalfacts = null; + public $name_count = 0; + public $total_names = 0; + public $tabs; function __construct() { - global $USE_RIN, $MAX_ALIVE_AGE, $SEARCH_SPIDER; - global $DEFAULT_PIN_STATE, $DEFAULT_SB_CLOSED_STATE; - global $Fam_Navigator; - - $xref = safe_GET_xref('pid'); - - $gedrec = find_person_record($xref, WT_GED_ID); - - if ($USE_RIN && $gedrec==false) { - $xref = find_rin_id($xref); - $gedrec = find_person_record($xref, WT_GED_ID); - } - if (empty($gedrec)) { - $gedrec = "0 @".$xref."@ INDI\n"; - } + global $USE_RIN; - if (find_person_record($xref, WT_GED_ID) || find_updated_record($xref, WT_GED_ID)!==null) { - $this->record = new WT_Person($gedrec); - $this->record->ged_id=WT_GED_ID; // This record is from a file - } else if (!$this->record) { - parent::__construct(); - return; - } + $xref = safe_GET_xref('pid'); + $this->record = WT_Individual::getInstance($xref); - //-- if the user can edit and there are changes then get the new changes - if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { - $newrec = find_updated_record($xref, WT_GED_ID); - if (!empty($newrec)) { - $diff_record = new WT_Person($newrec); - $diff_record->setChanged(true); - $this->record->diffMerge($diff_record); - } + if (!$this->record && $USE_RIN) { + $rin = find_rin_id($xref); + $this->record = WT_Individual::getInstance($rin); } - $this->tabs=WT_Module::getActiveTabs(); - - // Our parent needs $this->record parent::__construct(); + $this->tabs = WT_Module::getActiveTabs(); + // If we can display the details, add them to the page header - if ($this->record && $this->record->canDisplayDetails()) { - $this->setPageTitle($this->record->getFullName().' '.$this->record->getLifespan()); + if ($this->record && $this->record->canShow()) { + $this->setPageTitle($this->record->getFullName() . ' ' . $this->record->getLifespan()); } } @@ -147,29 +118,33 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { * @see individual.php * @param Event $event the event object */ - function print_name_record(WT_Event $event) { + function print_name_record(WT_Fact $event) { if (!$event->canShow()) { return false; } - $factrec = $event->getGedComRecord(); - $linenum = $event->getLineNumber(); + $factrec = $event->getGedcom(); // Create a dummy record, so we can extract the formatted NAME value from the event. - $dummy=new WT_Person('0 @'.$event->getParentObject()->getXref()."@ INDI\n1 DEAT Y\n".$factrec); + $dummy=new WT_Individual( + 'xref', + "0 @xref@ INDI\n1 DEAT Y\n".$factrec, + null, + WT_GED_ID + ); $all_names=$dummy->getAllNames(); $primary_name=$all_names[0]; $this->name_count++; if ($this->name_count >1) { echo '<h3 class="name_two">',$dummy->getFullName(), '</h3>'; } //Other names accordion element - echo '<div class="indi_name_details"'; - if ($event->getIsOld()) { - echo " class=\"namered\""; + echo '<div class="indi_name_details'; + if ($event->isOld()) { + echo ' old'; } - if ($event->getIsNew()) { - echo " class=\"nameblue\""; + if ($event->isNew()) { + echo ' new'; } - echo ">"; + echo '">'; echo '<div class="name1">'; echo '<dl><dt class="label">', WT_I18N::translate('Name'), '</dt>'; @@ -184,9 +159,9 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { } } } - if ($this->record->canEdit() && !$event->getIsOld()) { - echo "<div class=\"deletelink\"><a class=\"font9 deleteicon\" href=\"#\" onclick=\"return delete_fact('".$this->record->getXref()."', ".$linenum.", '', '".WT_I18N::translate('Are you sure you want to delete this fact?')."');\" title=\"".WT_I18N::translate('Delete name')."\"><span class=\"link_text\">".WT_I18N::translate('Delete name')."</span></a></div>"; - echo "<div class=\"editlink\"><a href=\"#\" class=\"font9 editicon\" onclick=\"edit_name('".$this->record->getXref()."', ".$linenum."); return false;\" title=\"".WT_I18N::translate('Edit name')."\"><span class=\"link_text\">".WT_I18N::translate('Edit name')."</span></a></div>"; + if ($this->record->canEdit() && !$event->isOld()) { + echo "<div class=\"deletelink\"><a class=\"font9 deleteicon\" href=\"#\" onclick=\"return delete_fact('".WT_I18N::translate('Are you sure you want to delete this fact?')."', '".$this->record->getXref()."', '".$event->getFactId()."');\" title=\"".WT_I18N::translate('Delete name')."\"><span class=\"link_text\">".WT_I18N::translate('Delete name')."</span></a></div>"; + echo "<div class=\"editlink\"><a href=\"#\" class=\"font9 editicon\" onclick=\"edit_name('".$this->record->getXref()."', '".$event->getFactId()."'); return false;\" title=\"".WT_I18N::translate('Edit name')."\"><span class=\"link_text\">".WT_I18N::translate('Edit name')."</span></a></div>"; } echo '</dd>'; echo '</dl>'; @@ -243,50 +218,45 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { * @see individual.php * @param Event $event the Event object */ - function print_sex_record(WT_Event $event) { - global $sex; - - if (!$event->canShow()) return false; - $factrec = $event->getGedComRecord(); - $sex = $event->getDetail(); + function print_sex_record(WT_Fact $event) { + $sex = $event->getValue(); if (empty($sex)) $sex = 'U'; - echo '<span id="sex"'; - echo ' class="'; - if ($event->getIsOld()) { - echo 'namered '; - } - if ($event->getIsNew()) { - echo 'nameblue '; - } - switch ($sex) { - case 'M': - echo 'male_gender"'; - if ($this->record->canEdit() && !$event->getIsOld()) { - echo ' title="', WT_I18N::translate('Male'), ' - ', WT_I18N::translate('Edit'), '"'; - echo ' onclick="edit_record(\''.$this->record->getXref().'\', '.$event->getLineNumber().'); return false;"> '; - } else { - echo ' title="', WT_I18N::translate('Male'), '"> '; - } - break; - case 'F': - echo 'female_gender"'; - if ($this->record->canEdit() && !$event->getIsOld()) { - echo ' title="', WT_I18N::translate('Female'), ' - ', WT_I18N::translate('Edit'), '"'; - echo ' onclick="edit_record(\''.$this->record->getXref().'\', '.$event->getLineNumber().'); return false;"> '; - } else { - echo ' title="', WT_I18N::translate('Female'), '"> '; - } - break; - case 'U': - echo 'unknown_gender"'; - if ($this->record->canEdit() && !$event->getIsOld()) { - echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), ' - ', WT_I18N::translate('Edit'), '"'; - echo ' onclick="edit_record(\''.$this->record->getXref().'\', '.$event->getLineNumber().'); return false;"> '; - } else { - echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), '"> '; - } - break; - } + echo '<span id="sex" class="'; + if ($event->isOld()) { + echo 'old'; + } + if ($event->isNew()) { + echo 'new'; + } + switch ($sex) { + case 'M': + echo ' male_gender"'; + if ($event->canEdit()) { + echo ' title="', WT_I18N::translate('Male'), ' - ', WT_I18N::translate('Edit'), '"'; + echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">'; + } else { + echo ' title="', WT_I18N::translate('Male'), '">'; + } + break; + case 'F': + echo ' female_gender"'; + if ($event->canEdit()) { + echo ' title="', WT_I18N::translate('Female'), ' - ', WT_I18N::translate('Edit'), '"'; + echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">'; + } else { + echo ' title="', WT_I18N::translate('Female'), '">'; + } + break; + case 'U': + echo ' unknown_gender"'; + if ($event->canEdit()) { + echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), ' - ', WT_I18N::translate('Edit'), '"'; + echo ' onclick="edit_record(\''.$this->record->getXref().'\', \''.$event->getFactId().'\'); return false;">'; + } else { + echo ' title="', WT_I18N::translate_c('unknown gender', 'Unknown'), '">'; + } + break; + } echo '</span>'; } /** @@ -295,39 +265,41 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->record || $this->record->isMarkedDeleted()) { + if (!$this->record || $this->record->isOld()) { return null; } // edit menu $menu = new WT_Menu(WT_I18N::translate('Edit'), '#', 'menu-indi'); $menu->addLabel($menu->label, 'down'); - $this->getGlobalFacts(); // sets NAME_LINENUM and SEX_LINENUM. individual.php doesn't do it early enough for us.... - // What behaviour shall we give the main menu? If we leave it blank, the framework // will copy the first submenu - which may be edit-raw or delete. // As a temporary solution, make it edit the name - if (WT_USER_CAN_EDIT && $this->NAME_LINENUM) { - $menu->addOnclick("return edit_name('".$this->record->getXref()."', ".$this->NAME_LINENUM.");"); - } else { - $menu->addOnclick("return false;"); - } - + $menu->addOnclick("return false;"); if (WT_USER_CAN_EDIT) { - //--make sure the totals are correct + foreach ($this->record->getFacts() as $fact) { + if ($fact->getTag()=='NAME' && $fact->canShow() && $fact->canEdit()) + $menu->addOnclick("return edit_name('".$this->record->getXref() . "', '" . $fact->getFactId() . "');"); + break; + } + $submenu = new WT_Menu(WT_I18N::translate('Add new Name'), '#', 'menu-indi-addname'); $submenu->addOnclick("return add_name('".$this->record->getXref()."');"); $menu->addSubmenu($submenu); - if ($this->SEX_COUNT<2) { - $submenu = new WT_Menu(WT_I18N::translate('Edit gender'), '#', 'menu-indi-editsex'); - if ($this->SEX_LINENUM=="new") { - $submenu->addOnclick("return add_new_record('".$this->record->getXref()."', 'SEX');"); - } else { - $submenu->addOnclick("return edit_record('".$this->record->getXref()."', ".$this->SEX_LINENUM.");"); + $has_sex_record = false; + $submenu = new WT_Menu(WT_I18N::translate('Edit gender'), '#', 'menu-indi-editsex'); + foreach ($this->record->getFacts() as $fact) { + if ($fact->getTag()=='SEX' && $fact->canShow() && $fact->canEdit()) { + $submenu->addOnclick("return edit_record('" . $this->record->getXref() . "', '" . $fact->getFactId() . "');"); + $has_sex_record = true; + break; } - $menu->addSubmenu($submenu); } + if (!$has_sex_record) { + $submenu->addOnclick("return add_new_record('" . $this->record->getXref() . "', 'SEX');"); + } + $menu->addSubmenu($submenu); if (count($this->record->getSpouseFamilies())>1) { $submenu = new WT_Menu(WT_I18N::translate('Re-order families'), '#', 'menu-indi-orderfam'); @@ -336,21 +308,6 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { } } - // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-indi-editraw'); - $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); - $menu->addSubmenu($submenu); - } elseif ($SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('View GEDCOM Record'), '#', 'menu-indi-viewraw'); - if (WT_USER_CAN_EDIT) { - $submenu->addOnclick("return show_gedcom_record('new');"); - } else { - $submenu->addOnclick("return show_gedcom_record();"); - } - $menu->addSubmenu($submenu); - } - // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-indi-del'); @@ -372,48 +329,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { return $menu; } - /** - * get global facts - * global facts are NAME and SEX - * @return array return the array of global facts - */ - function getGlobalFacts() { - if ($this->globalfacts==null) { - $this->globalfacts = $this->record->getGlobalFacts(); - foreach ($this->globalfacts as $key => $value) { - $fact = $value->getTag(); - if ($fact=="SEX") { - $this->SEX_COUNT++; - $this->SEX_LINENUM = $value->getLineNumber(); - } - if ($fact=="NAME") { - $this->total_names++; - if ($this->NAME_LINENUM==null && !$value->getIsOld()) { - // This is the "primary" name and is edited from the menu - // Subsequent names get their own edit links - $this->NAME_LINENUM = $value->getLineNumber(); - } - } - } - } - return $this->globalfacts; - } - /** - * get the individual facts shown on tab 1 - * @return array - */ - function getIndiFacts() { - $indifacts = $this->record->getIndiFacts(); - sort_facts($indifacts); - return $indifacts; - } - /** - * get the other facts shown on tab 2 - * @return array - */ - function getOtherFacts() { - $otherfacts = $this->record->getOtherFacts(); - return $otherfacts; + function add_asso_facts() { } /** @@ -514,22 +430,10 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { $newwife = null; $newchildren = array(); $delchildren = array(); - $children = array(); - $husb = null; - $wife = null; - if (!$family->getChanged()) { - $husb = $family->getHusband(); - $wife = $family->getWife(); - $children = $family->getChildren(); - } - //-- step families : set the label for the common parent - if ($type=="step-parents") { - $fams = $this->record->getChildFamilies(); - foreach ($fams as $key=>$fam) { - if ($fam->hasParent($husb)) $labels["father"] = get_relationship_name_from_path('fat', null, null); - if ($fam->hasParent($wife)) $labels["mother"] = get_relationship_name_from_path('mot', null, null); - } - } + $husb = $family->getHusband(); + $wife = $family->getWife(); + $children = $family->getChildren(); + //-- set the label for the husband if (!is_null($husb)) { $label = $labels["parent"]; @@ -560,80 +464,6 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { } $wife->setLabel($label); } - if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { - $newfamily = $family->getUpdatedFamily(); - if (!is_null($newfamily)) { - $newhusb = $newfamily->getHusband(); - //-- check if the husband in the family has changed - if (!is_null($newhusb) && !$newhusb->equals($husb)) { - $label = $labels["parent"]; - $sex = $newhusb->getSex(); - if ($sex=="F") { - $label = $labels["mother"]; - } - if ($sex=="M") { - $label = $labels["father"]; - } - if ($newhusb->getXref()==$this->record->getXref()) { - $label = '<i class="icon-selected"></i>'; - } - $newhusb->setLabel($label); - } - else $newhusb = null; - $newwife = $newfamily->getWife(); - //-- check if the wife in the family has changed - if (!is_null($newwife) && !$newwife->equals($wife)) { - $label = $labels["parent"]; - $sex = $newwife->getSex(); - if ($sex=="F") { - $label = $labels["mother"]; - } - if ($sex=="M") { - $label = $labels["father"]; - } - if ($newwife->getXref()==$this->record->getXref()) { - $label = '<i class="icon-selected"></i>'; - } - $newwife->setLabel($label); - } - else $newwife = null; - //-- check for any new children - $merged_children = array(); - $new_children = $newfamily->getChildren(); - $num = count($children); - for ($i=0; $i<$num; $i++) { - $child = $children[$i]; - if (!is_null($child)) { - $found = false; - foreach ($new_children as $key=>$newchild) { - if (!is_null($newchild)) { - if ($child->equals($newchild)) { - $found = true; - break; - } - } - } - if (!$found) $delchildren[] = $child; - else $merged_children[] = $child; - } - } - foreach ($new_children as $key=>$newchild) { - if (!is_null($newchild)) { - $found = false; - foreach ($children as $key1=>$child) { - if (!is_null($child)) { - if ($child->equals($newchild)) { - $found = true; - break; - } - } - } - if (!$found) $newchildren[] = $newchild; - } - } - $children = $merged_children; - } - } //-- set the labels for the children $num = count($children); for ($i=0; $i<$num; $i++) { @@ -650,7 +480,7 @@ class WT_Controller_Individual extends WT_Controller_GedcomRecord { $label = '<i class="icon-selected"></i>'; } if ($include_pedi==true) { - $famcrec = get_sub_record(1, "1 FAMC @".$family->getXref()."@", $children[$i]->getGedcomRecord()); + $famcrec = get_sub_record(1, "1 FAMC @".$family->getXref()."@", $children[$i]->getGedcom()); $pedi = get_gedcom_value("PEDI", 2, $famcrec); if ($pedi) { $label.='<br>('.WT_Gedcom_Code_Pedi::getValue($pedi, $children[$i]).')'; diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php index 60c6664289..4c4f325d30 100644 --- a/library/WT/Controller/Lifespan.php +++ b/library/WT/Controller/Lifespan.php @@ -122,7 +122,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page { } } } elseif ($newpid) { - $person=WT_Person::getInstance($newpid); + $person=WT_Individual::getInstance($newpid); $this->addFamily($person, $addfam); } elseif (!$this->pids) { $this->addFamily($this->getSignificantIndividual(), false); @@ -138,13 +138,13 @@ class WT_Controller_Lifespan extends WT_Controller_Page { foreach ($this->pids as $key => $value) { if ($value != $remove) { $this->pids[$key] = $value; - $person = WT_Person::getInstance($value); + $person = WT_Individual::getInstance($value); // list of linked records includes families as well as individuals. if ($person) { $bdate = $person->getEstimatedBirthDate(); $ddate = $person->getEstimatedDeathDate(); //--Checks to see if the details of that person can be viewed - if ($bdate->isOK() && $person->canDisplayDetails()) { + if ($bdate->isOK() && $person->canShow()) { $this->people[] = $person; } } @@ -169,7 +169,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page { $bdate = $person->getEstimatedBirthDate(); $ddate = $person->getEstimatedDeathDate(); //--Checks to see if the details of that person can be viewed - if ($bdate->isOK() && $person->canDisplayDetails()) { + if ($bdate->isOK() && $person->canShow()) { $this->people[] = $person; } } @@ -424,7 +424,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page { $evntwdth = $eventwidth."%"; //-- if the fact is a generic EVENt then get the qualifying TYPE if ($fact=="EVEN") { - $fact = $val->getType(); + $fact = $val->getAttribute('TYPE'); } $place = $val->getPlace(); $trans = WT_Gedcom_Tag::getLabel($fact); @@ -532,18 +532,18 @@ class WT_Controller_Lifespan extends WT_Controller_Page { $endjd =WT_Date_Gregorian::YMDtoJD($endyear+1, 1, 1)-1; $sql= - "SELECT DISTINCT 'INDI' AS type, i_id AS xref, i_file AS ged_id, i_gedcom AS gedrec". + "SELECT DISTINCT i_id AS xref, i_file AS gedcom_id, i_gedcom AS gedcom". " FROM `##individuals`". " JOIN `##dates` ON i_id=d_gid AND i_file=d_file". " WHERE i_file=? AND d_julianday1 BETWEEN ? AND ?"; $rows=WT_DB::prepare($sql) ->execute(array(WT_GED_ID, $startjd, $endjd)) - ->fetchAll(PDO::FETCH_ASSOC); + ->fetchAll(); $list=array(); foreach ($rows as $row) { - $list[]=WT_Person::getInstance($row); + $list[]=WT_Individual::getInstance($row->xref, $row->gedcom_id, $row->gedcom); } return $list; } diff --git a/library/WT/Controller/Media.php b/library/WT/Controller/Media.php index 562bf8aabe..c9fbf39547 100644 --- a/library/WT/Controller/Media.php +++ b/library/WT/Controller/Media.php @@ -2,7 +2,7 @@ // Controller for the media page // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -34,35 +34,8 @@ require_once WT_ROOT.'includes/functions/functions_import.php'; class WT_Controller_Media extends WT_Controller_GedcomRecord { public function __construct() { - $xref = safe_GET_xref('mid'); - - $gedrec=find_media_record($xref, WT_GED_ID); - if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($xref, WT_GED_ID); - } else { - $newrec=null; - } - - if ($gedrec===null) { - if ($newrec===null) { - // Nothing to see here. - parent::__construct(); - return; - } else { - // Create a dummy record from the first line of the new record. - // We need it for diffMerge(), getXref(), etc. - list($gedrec)=explode("\n", $newrec); - } - } - - $this->record = new WT_Media($gedrec); - - // If there are pending changes, merge them in. - if ($newrec!==null) { - $diff_record=new WT_Media($newrec); - $diff_record->setChanged(true); - $this->record->diffMerge($diff_record); - } + $xref = safe_GET_xref('mid'); + $this->record = WT_Media::getInstance($xref); parent::__construct(); } @@ -73,7 +46,7 @@ class WT_Controller_Media extends WT_Controller_GedcomRecord { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->record || $this->record->isMarkedDeleted()) { + if (!$this->record || $this->record->isOld()) { return null; } @@ -107,21 +80,6 @@ class WT_Controller_Media extends WT_Controller_GedcomRecord { $menu->addSubmenu($submenu); } - // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-obje-editraw'); - $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); - $menu->addSubmenu($submenu); - } elseif ($SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('View GEDCOM Record'), '#', 'menu-obje-viewraw'); - if (WT_USER_CAN_EDIT || WT_USER_CAN_ACCEPT) { - $submenu->addOnclick("return show_gedcom_record('new');"); - } else { - $submenu->addOnclick("return show_gedcom_record();"); - } - $menu->addSubmenu($submenu); - } - // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-obje-del'); @@ -153,17 +111,17 @@ class WT_Controller_Media extends WT_Controller_GedcomRecord { * @return array */ function getFacts($includeFileName=true) { - $facts = $this->record->getFacts(array()); + $facts = $this->record->getFacts(); // Add some dummy facts to show additional information if ($this->record->fileExists()) { // get height and width of image, when available $imgsize = $this->record->getImageAttributes(); if (!empty($imgsize['WxH'])) { - $facts[] = new WT_Event('1 __IMAGE_SIZE__ '.$imgsize['WxH'], $this->record, 0); + $facts[] = new WT_Fact('1 __IMAGE_SIZE__ '.$imgsize['WxH'], $this->record, 0); } //Prints the file size - $facts[] = new WT_Event('1 __FILE_SIZE__ '.$this->record->getFilesize(), $this->record, 0); + $facts[] = new WT_Fact('1 __FILE_SIZE__ '.$this->record->getFilesize(), $this->record, 0); } sort_facts($facts); diff --git a/library/WT/Controller/Note.php b/library/WT/Controller/Note.php index 01fad484c8..003fd45acd 100644 --- a/library/WT/Controller/Note.php +++ b/library/WT/Controller/Note.php @@ -2,7 +2,7 @@ // Controller for the shared note page // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2009 PGV Development Team. All rights reserved. @@ -33,35 +33,8 @@ require_once WT_ROOT.'includes/functions/functions_import.php'; class WT_Controller_Note extends WT_Controller_GedcomRecord { public function __construct() { - $xref=safe_GET_xref('nid'); - - $gedrec=find_other_record($xref, WT_GED_ID); - if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($xref, WT_GED_ID); - } else { - $newrec=null; - } - - if ($gedrec===null) { - if ($newrec===null) { - // Nothing to see here. - parent::__construct(); - return; - } else { - // Create a dummy record from the first line of the new record. - // We need it for diffMerge(), getXref(), etc. - list($gedrec)=explode("\n", $newrec); - } - } - - $this->record = new WT_Note($gedrec); - - // If there are pending changes, merge them in. - if ($newrec!==null) { - $diff_record=new WT_Note($newrec); - $diff_record->setChanged(true); - $this->record->diffMerge($diff_record); - } + $xref = safe_GET_xref('nid'); + $this->record = WT_Note::getInstance($xref); parent::__construct(); } @@ -72,7 +45,7 @@ class WT_Controller_Note extends WT_Controller_GedcomRecord { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->record || $this->record->isMarkedDeleted()) { + if (!$this->record || $this->record->isOld()) { return null; } @@ -85,21 +58,6 @@ class WT_Controller_Note extends WT_Controller_GedcomRecord { $menu->addSubmenu($submenu); } - // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-note-editraw'); - $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); - $menu->addSubmenu($submenu); - } elseif ($SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('View GEDCOM Record'), '#', 'menu-note-viewraw'); - if (WT_USER_CAN_EDIT) { - $submenu->addOnclick("return show_gedcom_record('new');"); - } else { - $submenu->addOnclick("return show_gedcom_record();"); - } - $menu->addSubmenu($submenu); - } - // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-note-del'); diff --git a/library/WT/Controller/Page.php b/library/WT/Controller/Page.php index 55a6b55cdc..d2fe6031db 100644 --- a/library/WT/Controller/Page.php +++ b/library/WT/Controller/Page.php @@ -163,7 +163,6 @@ class WT_Controller_Page extends WT_Controller_Base { var browserType = "'.$BROWSERTYPE.'"; var WT_SCRIPT_NAME = "'.WT_SCRIPT_NAME.'"; var WT_LOCALE = "'.WT_LOCALE.'"; - var accesstime = '.WT_TIMESTAMP.'; ', self::JS_PRIORITY_HIGH); // Temporary fix for access to main menu hover elements on android/blackberry touch devices @@ -220,16 +219,16 @@ class WT_Controller_Page extends WT_Controller_Base { static $individual; // Only query the DB once. if (!$individual && WT_USER_ROOT_ID) { - $individual=WT_Person::getInstance(WT_USER_ROOT_ID); + $individual=WT_Individual::getInstance(WT_USER_ROOT_ID); } if (!$individual && WT_USER_GEDCOM_ID) { - $individual=WT_Person::getInstance(WT_USER_GEDCOM_ID); + $individual=WT_Individual::getInstance(WT_USER_GEDCOM_ID); } if (!$individual) { - $individual=WT_Person::getInstance(get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID')); + $individual=WT_Individual::getInstance(get_gedcom_setting(WT_GED_ID, 'PEDIGREE_ROOT_ID')); } if (!$individual) { - $individual=WT_Person::getInstance( + $individual=WT_Individual::getInstance( WT_DB::prepare( "SELECT MIN(i_id) FROM `##individuals` WHERE i_file=?" )->execute(array(WT_GED_ID))->fetchOne() @@ -237,7 +236,7 @@ class WT_Controller_Page extends WT_Controller_Base { } if (!$individual) { // always return a record - $individual=new WT_Person('0 @I@ INDI'); + $individual=new WT_Individual('I', '0 @I@ INDI', null, WT_GED_ID); } return $individual; } @@ -252,7 +251,7 @@ class WT_Controller_Page extends WT_Controller_Base { } } // always return a record - return new WT_Family('0 @F@ FAM'); + return new WT_Family('F', '0 @F@ FAM', null, WT_GED_ID); } public function getSignificantSurname() { return ''; diff --git a/library/WT/Controller/Pedigree.php b/library/WT/Controller/Pedigree.php index 65bb3174f0..5133aea959 100644 --- a/library/WT/Controller/Pedigree.php +++ b/library/WT/Controller/Pedigree.php @@ -2,7 +2,7 @@ // Controller for the pedigree chart // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -85,7 +85,7 @@ class WT_Controller_Pedigree extends WT_Controller_Chart { $show_full = $this->show_full; $talloffset = $this->talloffset; - if ($this->root && $this->root->canDisplayName()) { + if ($this->root && $this->root->canShowName()) { $this->setPageTitle( /* I18N: %s is an individual’s name */ WT_I18N::translate('Pedigree tree of %s', $this->root->getFullName()) diff --git a/library/WT/Controller/Repository.php b/library/WT/Controller/Repository.php index 7af4c8c139..2c409a6110 100644 --- a/library/WT/Controller/Repository.php +++ b/library/WT/Controller/Repository.php @@ -2,7 +2,7 @@ // Controller for the repository page // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved. @@ -33,35 +33,8 @@ require_once WT_ROOT.'includes/functions/functions_import.php'; class WT_Controller_Repository extends WT_Controller_GedcomRecord { public function __construct() { - $xref = safe_GET_xref('rid'); - - $gedrec=find_other_record($xref, WT_GED_ID); - if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($xref, WT_GED_ID); - } else { - $newrec=null; - } - - if ($gedrec===null) { - if ($newrec===null) { - // Nothing to see here. - parent::__construct(); - return; - } else { - // Create a dummy record from the first line of the new record. - // We need it for diffMerge(), getXref(), etc. - list($gedrec)=explode("\n", $newrec); - } - } - - $this->record = new WT_Repository($gedrec); - - // If there are pending changes, merge them in. - if ($newrec!==null) { - $diff_record=new WT_Repository($newrec); - $diff_record->setChanged(true); - $this->record->diffMerge($diff_record); - } + $xref = safe_GET_xref('rid'); + $this->record = WT_Repository::getInstance($xref); parent::__construct(); } @@ -72,7 +45,7 @@ class WT_Controller_Repository extends WT_Controller_GedcomRecord { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->record || $this->record->isMarkedDeleted()) { + if (!$this->record || $this->record->isOld()) { return null; } @@ -85,21 +58,6 @@ class WT_Controller_Repository extends WT_Controller_GedcomRecord { $menu->addSubmenu($submenu); } - // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-repo-editraw'); - $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); - $menu->addSubmenu($submenu); - } elseif ($SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('View GEDCOM Record'), '#', 'menu-repo-viewraw'); - if (WT_USER_CAN_EDIT) { - $submenu->addOnclick("return show_gedcom_record('new');"); - } else { - $submenu->addOnclick("return show_gedcom_record();"); - } - $menu->addSubmenu($submenu); - } - // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-repo-del'); diff --git a/library/WT/Controller/Search.php b/library/WT/Controller/Search.php index 90a83891a1..ac67d6a0c7 100644 --- a/library/WT/Controller/Search.php +++ b/library/WT/Controller/Search.php @@ -285,7 +285,7 @@ class WT_Controller_Search extends WT_Controller_Page { // Then see if an ID is typed in. If so, we might want to jump there. if (isset ($this->query)) { $record=WT_GedcomRecord::getInstance($this->query); - if ($record && $record->canDisplayDetails()) { + if ($record && $record->canShow()) { header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.$record->getRawUrl()); exit; } @@ -357,7 +357,7 @@ class WT_Controller_Search extends WT_Controller_Page { // If ID cannot be displayed, continue to the search page. if (count($this->myindilist)==1 && !$this->myfamlist && !$this->mysourcelist && !$this->mynotelist) { $indi=$this->myindilist[0]; - if ($indi->canDisplayName()) { + if ($indi->canShowName()) { Zend_Session::writeClose(); header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.$indi->getRawUrl()); exit; @@ -365,7 +365,7 @@ class WT_Controller_Search extends WT_Controller_Page { } if (!$this->myindilist && count($this->myfamlist)==1 && !$this->mysourcelist && !$this->mynotelist) { $fam=$this->myfamlist[0]; - if ($fam->canDisplayName()) { + if ($fam->canShowName()) { Zend_Session::writeClose(); header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.$fam->getRawUrl()); exit; @@ -373,7 +373,7 @@ class WT_Controller_Search extends WT_Controller_Page { } if (!$this->myindilist && !$this->myfamlist && count($this->mysourcelist)==1 && !$this->mynotelist) { $sour=$this->mysourcelist[0]; - if ($sour->canDisplayName()) { + if ($sour->canShowName()) { Zend_Session::writeClose(); header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.$sour->getRawUrl()); exit; @@ -381,7 +381,7 @@ class WT_Controller_Search extends WT_Controller_Page { } if (!$this->myindilist && !$this->myfamlist && !$this->mysourcelist && count($this->mynotelist)==1) { $note=$this->mynotelist[0]; - if ($note->canDisplayName()) { + if ($note->canShowName()) { Zend_Session::writeClose(); header('Location: '.WT_SERVER_NAME.WT_SCRIPT_PATH.$note->getRawUrl()); exit; @@ -443,7 +443,7 @@ class WT_Controller_Search extends WT_Controller_Page { } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { - replace_gedrec($individual->getXref(), WT_GED_ID, $newRecord); + $individual->updateRecord($newRecord, true); } else { unset($this->myindilist[$id]); } @@ -465,7 +465,7 @@ class WT_Controller_Search extends WT_Controller_Page { } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { - replace_gedrec($family->getXref(), WT_GED_ID, $newRecord); + $family->updateRecord($newRecord, true); } else { unset($this->myfamlist[$id]); } @@ -490,7 +490,7 @@ class WT_Controller_Search extends WT_Controller_Page { } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { - replace_gedrec($source->getXref(), WT_GED_ID, $newRecord); + $source->updateRecord($newRecord, true); } else { unset($this->mysourcelist[$id]); } @@ -506,7 +506,7 @@ class WT_Controller_Search extends WT_Controller_Page { } //-- if the record changed replace the record otherwise remove it from the search results if ($newRecord != $oldRecord) { - replace_gedrec($note->getXref(), WT_GED_ID, $newRecord); + $noteource->updateRecord($newRecord, true); } else { unset($this->mynotelist[$id]); } @@ -557,10 +557,10 @@ class WT_Controller_Search extends WT_Controller_Page { if ($this->showasso == "on") { foreach ($this->myindilist as $indi) { - foreach (fetch_linked_indi($indi->getXref(), 'ASSO', $indi->getGedId()) as $asso) { + foreach (fetch_linked_indi($indi->getXref(), 'ASSO', $indi->getGedcomId()) as $asso) { $this->myindilist[]=$asso; } - foreach (fetch_linked_fam($indi->getXref(), 'ASSO', $indi->getGedId()) as $asso) { + foreach (fetch_linked_fam($indi->getXref(), 'ASSO', $indi->getGedcomId()) as $asso) { $this->myfamlist[]=$asso; } } @@ -603,7 +603,7 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->sgeds as $ged_id=>$gedcom) { $datalist = array(); foreach ($this->myindilist as $individual) { - if ($individual->getGedId()==$ged_id) { + if ($individual->getGedcomId()==$ged_id) { $datalist[]=$individual; } } @@ -627,7 +627,7 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->sgeds as $ged_id=>$gedcom) { $datalist = array(); foreach ($this->myfamlist as $family) { - if ($family->getGedId()==$ged_id) { + if ($family->getGedcomId()==$ged_id) { $datalist[]=$family; } } @@ -651,7 +651,7 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->sgeds as $ged_id=>$gedcom) { $datalist = array(); foreach ($this->mysourcelist as $source) { - if ($source->getGedId()==$ged_id) { + if ($source->getGedcomId()==$ged_id) { $datalist[]=$source; } } @@ -675,7 +675,7 @@ class WT_Controller_Search extends WT_Controller_Page { foreach ($this->sgeds as $ged_id=>$gedcom) { $datalist = array(); foreach ($this->mynotelist as $note) { - if ($note->getGedId()==$ged_id) { + if ($note->getGedcomId()==$ged_id) { $datalist[]=$note; } } diff --git a/library/WT/Controller/Source.php b/library/WT/Controller/Source.php index f2825493d4..dff23a7558 100644 --- a/library/WT/Controller/Source.php +++ b/library/WT/Controller/Source.php @@ -2,7 +2,7 @@ // Controller for the source page // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2010 PGV Development Team. All rights reserved. @@ -33,35 +33,8 @@ require_once WT_ROOT.'includes/functions/functions_import.php'; class WT_Controller_Source extends WT_Controller_GedcomRecord { public function __construct() { - $xref=safe_GET_xref('sid'); - - $gedrec=find_source_record($xref, WT_GED_ID); - if (WT_USER_CAN_EDIT) { - $newrec=find_updated_record($xref, WT_GED_ID); - } else { - $newrec=null; - } - - if ($gedrec===null) { - if ($newrec===null) { - // Nothing to see here. - parent::__construct(); - return; - } else { - // Create a dummy record from the first line of the new record. - // We need it for diffMerge(), getXref(), etc. - list($gedrec)=explode("\n", $newrec); - } - } - - $this->record = new WT_Source($gedrec); - - // If there are pending changes, merge them in. - if ($newrec!==null) { - $diff_record=new WT_Source($newrec); - $diff_record->setChanged(true); - $this->record->diffMerge($diff_record); - } + $xref = safe_GET_xref('sid'); + $this->record = WT_Source::getInstance($xref); parent::__construct(); } @@ -72,7 +45,7 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord { function getEditMenu() { $SHOW_GEDCOM_RECORD=get_gedcom_setting(WT_GED_ID, 'SHOW_GEDCOM_RECORD'); - if (!$this->record || $this->record->isMarkedDeleted()) { + if (!$this->record || $this->record->isOld()) { return null; } @@ -85,21 +58,6 @@ class WT_Controller_Source extends WT_Controller_GedcomRecord { $menu->addSubmenu($submenu); } - // edit/view raw gedcom - if (WT_USER_IS_ADMIN || $SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('Edit raw GEDCOM record'), '#', 'menu-sour-editraw'); - $submenu->addOnclick("return edit_raw('".$this->record->getXref()."');"); - $menu->addSubmenu($submenu); - } elseif ($SHOW_GEDCOM_RECORD) { - $submenu = new WT_Menu(WT_I18N::translate('View GEDCOM Record'), '#', 'menu-sour-viewraw'); - if (WT_USER_CAN_EDIT) { - $submenu->addOnclick("return show_gedcom_record('new');"); - } else { - $submenu->addOnclick("return show_gedcom_record();"); - } - $menu->addSubmenu($submenu); - } - // delete if (WT_USER_CAN_EDIT) { $submenu = new WT_Menu(WT_I18N::translate('Delete'), '#', 'menu-sour-del'); diff --git a/library/WT/Controller/Timeline.php b/library/WT/Controller/Timeline.php index 85f82ea2f7..349a843561 100644 --- a/library/WT/Controller/Timeline.php +++ b/library/WT/Controller/Timeline.php @@ -71,7 +71,7 @@ class WT_Controller_Timeline extends WT_Controller_Page { foreach ($this->pids as $value) { if ($value!=$remove) { $newpids[] = $value; - $person = WT_Person::getInstance($value); + $person = WT_Individual::getInstance($value); if ($person) { $this->people[] = $person; } @@ -81,7 +81,7 @@ class WT_Controller_Timeline extends WT_Controller_Page { $this->pidlinks = ""; /* @var $indi Person */ foreach ($this->people as $p=>$indi) { - if (!is_null($indi) && $indi->canDisplayDetails()) { + if (!is_null($indi) && $indi->canShow()) { //-- setup string of valid pids for links $this->pidlinks .= "pids%5B%5D=".$indi->getXref()."&"; $bdate = $indi->getBirthDate(); @@ -95,8 +95,14 @@ class WT_Controller_Timeline extends WT_Controller_Page { } } // find all the fact information - $indi->add_family_facts(false); - foreach ($indi->getIndiFacts() as $event) { + $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)) { @@ -137,8 +143,8 @@ class WT_Controller_Timeline extends WT_Controller_Page { $printed = false; for ($i=0; $i<count($this->people); $i++) { if (!is_null($this->people[$i])) { - if (!$this->people[$i]->canDisplayDetails()) { - if ($this->people[$i]->canDisplayName()) { + if (!$this->people[$i]->canShow()) { + if ($this->people[$i]->canShowName()) { echo " <a href=\"".$this->people[$i]->getHtmlUrl()."\">".$this->people[$i]->getFullName()."</a>"; print_privacy_error(); echo "<br>"; @@ -153,15 +159,15 @@ class WT_Controller_Timeline extends WT_Controller_Page { } } - function print_time_fact(WT_Event $event) { + function print_time_fact(WT_Fact $event) { global $basexoffset, $baseyoffset, $factcount, $TEXT_DIRECTION, $WT_IMAGES, $SHOW_PEDIGREE_PLACES, $placements; /* @var $event Event */ - $factrec = $event->getGedComRecord(); + $factrec = $event->getGedcom(); $fact = $event->getTag(); - $desc = $event->getDetail(); + $desc = $event->getValue(); if ($fact=="EVEN" || $fact=="FACT") { - $fact = $event->getType(); + $fact = $event->getAttribute('TYPE'); } //-- check if this is a family fact $gdate=$event->getDate(); @@ -201,11 +207,11 @@ class WT_Controller_Timeline extends WT_Controller_Page { echo ": 3px;\">"; $col = $event->temp % 6; echo "</td><td valign=\"top\" class=\"person".$col."\">"; - if (count($this->pids) > 6) echo $event->getParentObject()->getFullName()." - "; - $record=$event->getParentObject(); + if (count($this->pids) > 6) echo $event->getParent()->getFullName()." - "; + $record=$event->getParent(); echo $event->getLabel(); echo " -- "; - if ($record instanceof WT_Person) { + if ($record instanceof WT_Individual) { echo format_fact_date($event, $record, false, false); } elseif ($record instanceof WT_Family) { echo $gdate->Display(false); @@ -242,7 +248,11 @@ class WT_Controller_Timeline extends WT_Controller_Page { } } //-- print spouse name for marriage events - $spouse = $event->getSpouse(); + if (isset($event->spouse)) { + $spouse = $event->spouse; + } else { + $spouse = null; + } if ($spouse) { for ($p=0; $p<count($this->pids); $p++) { if ($this->pids[$p]==$spouse->getXref()) break; @@ -252,7 +262,7 @@ class WT_Controller_Timeline extends WT_Controller_Page { if ($spouse->getXref()!=$this->pids[$p]) { echo ' <a href="', $spouse->getHtmlUrl(), '">', $spouse->getFullName(), '</a>'; } else { - echo ' <a href="', $event->getParentObject()->getHtmlUrl(), '">', $event->getParentObject()->getFullName(), '</a>'; + echo ' <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>'; } } echo "</td></tr></table>"; @@ -284,7 +294,7 @@ class WT_Controller_Timeline extends WT_Controller_Page { public function getSignificantIndividual() { if ($this->pids) { - return WT_Person::getInstance($this->pids[0]); + return WT_Individual::getInstance($this->pids[0]); } else { return parent::getSignificantIndividual(); } |
