diff options
25 files changed, 120 insertions, 213 deletions
diff --git a/autocomplete.php b/autocomplete.php index ff5fd6b0e8..31c7e35afd 100644 --- a/autocomplete.php +++ b/autocomplete.php @@ -53,13 +53,13 @@ case 'ASSO': // Associates of an individuals, whose name contains the search ter $event_jd=$tmp->JD(); // INDI $indi_birth_jd = 0; - if ($record && $record->getType()=="INDI") { + if ($record instanceof WT_Person) { $indi_birth_jd=$record->getEstimatedBirthDate()->minJD(); } // HUSB & WIFE $husb_birth_jd = 0; $wife_birth_jd = 0; - if ($record && $record->getType()=="FAM") { + if ($record instanceof WT_Family) { $husb=$record->getHusband(); if ($husb) { $husb_birth_jd = $husb->getEstimatedBirthDate()->minJD(); diff --git a/calendar.php b/calendar.php index b3b8c87e34..c8d640912a 100644 --- a/calendar.php +++ b/calendar.php @@ -572,7 +572,7 @@ function calendar_list_text($list, $tag1, $tag2, $show_sex_symbols) { foreach ($list as $id=>$facts) { $tmp=WT_GedcomRecord::GetInstance($id); echo $tag1, '<a href="', $tmp->getHtmlUrl(), '">', $tmp->getFullName(), '</a> '; - if ($show_sex_symbols && $tmp->getType()=='INDI') + if ($show_sex_symbols && $tmp instanceof WT_Person) switch ($tmp->getSex()) { case 'M': echo '<i class="icon-sex_m_9x9" title="', WT_I18N::translate('Male'), '"></i>'; diff --git a/includes/functions/functions_db.php b/includes/functions/functions_db.php index 3d7678a217..9eb06f476c 100644 --- a/includes/functions/functions_db.php +++ b/includes/functions/functions_db.php @@ -250,29 +250,6 @@ function find_updated_record($xref, $ged_id) { return $gedcom=$statement->execute(array($ged_id, $xref))->fetchOne(); } -// Find the type of a gedcom record. Check the cache before querying the database. -// Returns 'INDI', 'FAM', etc., or null if the record does not exist. -function gedcom_record_type($xref, $ged_id) { - global $gedcom_record_cache; - static $statement=null; - - if (is_null($statement)) { - $statement=WT_DB::prepare( - "SELECT 'INDI' FROM `##individuals` WHERE i_id=? AND i_file=? UNION ALL ". - "SELECT 'FAM' FROM `##families` WHERE f_id=? AND f_file=? UNION ALL ". - "SELECT 'SOUR' FROM `##sources` WHERE s_id=? AND s_file=? UNION ALL ". - "SELECT 'OBJE' FROM `##media` WHERE m_id=? AND m_file=? UNION ALL ". - "SELECT o_type FROM `##other` WHERE o_id=? AND o_file=?" - ); - } - - if (isset($gedcom_record_cache[$xref][$ged_id])) { - return $gedcom_record_cache[$xref][$ged_id]->getType(); - } else { - return $statement->execute(array($xref, $ged_id, $xref, $ged_id, $xref, $ged_id, $xref, $ged_id, $xref, $ged_id))->fetchOne(); - } -} - // Find out if there are any pending changes that a given user may accept function exists_pending_change($user_id=WT_USER_ID, $ged_id=WT_GED_ID) { return diff --git a/includes/functions/functions_edit.php b/includes/functions/functions_edit.php index 374a61cb0a..323d53cf62 100644 --- a/includes/functions/functions_edit.php +++ b/includes/functions/functions_edit.php @@ -1647,7 +1647,7 @@ function add_simple_tag($tag, $upperlevel='', $label='', $readOnly='', $noClose= // Check if a CENS event --------------------------- if ($event_add=='census_add') { $type_pid=WT_GedcomRecord::getInstance($pid); - if ($type_pid->getType()=='INDI' ) { + if ($type_pid instanceof WT_Person) { echo '<br>', print_addnewnote_assisted_link($element_id, $pid); } } diff --git a/includes/functions/functions_import.php b/includes/functions/functions_import.php index 5145112534..b1f5d7648d 100644 --- a/includes/functions/functions_import.php +++ b/includes/functions/functions_import.php @@ -897,7 +897,7 @@ function update_names($xref, $ged_id, $record) { } foreach ($record->getAllNames() as $n=>$name) { - if ($record->getType()=='INDI') { + if ($record instanceof WT_Person) { if ($name['givn']=='@P.N.') { $soundex_givn_std=null; $soundex_givn_dm=null; diff --git a/includes/functions/functions_print_facts.php b/includes/functions/functions_print_facts.php index a44d5538f6..65a87e6c53 100644 --- a/includes/functions/functions_print_facts.php +++ b/includes/functions/functions_print_facts.php @@ -45,8 +45,10 @@ function print_fact(WT_Event $fact, WT_GedcomRecord $record) { return; } - if ($fact->getParentObject()) { - $pid = $fact->getParentObject()->getXref(); + $parent = $fact->getParentObject(); + + if ($parent) { + $pid = $parent->getXref(); } else { $pid = ''; } @@ -90,16 +92,16 @@ function print_fact(WT_Event $fact, WT_GedcomRecord $record) { } else if (preg_match('/2 _WTS @('.WT_REGEX_XREF.')@/', $fact->getGedcomRecord(), $match)) { // Event of close relative $label_person=WT_Person::getInstance($match[1]); - } else if ($fact->getParentObject() instanceof WT_Family) { + } else if ($parent instanceof WT_Family) { // Family event - $husb = $fact->getParentObject()->getHusband(); - $wife = $fact->getParentObject()->getWife(); + $husb = $parent->getHusband(); + $wife = $parent->getWife(); if (empty($wife) && !empty($husb)) $label_person=$husb; else if (empty($husb) && !empty($wife)) $label_person=$wife; - else $label_person=$fact->getParentObject(); + else $label_person=$parent; } else { // The actual person - $label_person=$fact->getParentObject(); + $label_person=$parent; } $styleadd=""; @@ -166,7 +168,7 @@ function print_fact(WT_Event $fact, WT_GedcomRecord $record) { '<a onclick="return edit_record(\'', $pid, '\', ', $fact->getLineNumber(), ');" href="#" title="', WT_I18N::translate('Edit'), '">', $label, '</a>', '<div class="editfacts">', '<div class="editlink"><a class="editicon" onclick="return edit_record(\'', $pid, '\', ', $fact->getLineNumber(), ');" href="#" title="', WT_I18N::translate('Edit'), '"><span class="link_text">', WT_I18N::translate('Edit'), '</span></a></div>', - '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\''.$fact->getParentObject()->getType().'\',factgedcom:\''.rawurlencode($fact->getGedcomRecord()).'\'},function(){location.reload();})" title="', WT_I18N::translate('Copy'), '"><span class="link_text">', WT_I18N::translate('Copy'), '</span></a></div>', + '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\''.$parent::RECORD_TYPE.'\',factgedcom:\''.rawurlencode($fact->getGedcomRecord()).'\'},function(){location.reload();})" title="', WT_I18N::translate('Copy'), '"><span class="link_text">', WT_I18N::translate('Copy'), '</span></a></div>', '<div class="deletelink"><a class="deleteicon" onclick="return delete_fact(\'', $pid, '\', ', $fact->getLineNumber(), ', \'\', \' ', WT_I18N::translate('Are you sure you want to delete this fact?'), '\');" href="#" title="', WT_I18N::translate('Delete'), '"><span class="link_text">', WT_I18N::translate('Delete'), '</span></a></div>', '</div>'; } else { @@ -191,9 +193,9 @@ function print_fact(WT_Event $fact, WT_GedcomRecord $record) { // The significant spouse is set on family events of close relatives echo '<a href="', $fact->getSpouse()->getHtmlUrl(), '">', $fact->getSpouse()->getFullName(), '</a> - '; } - if ($fact->getParentObject() instanceof WT_Family && $record instanceof WT_Person) { + if ($parent instanceof WT_Family && $record instanceof WT_Person) { // Family events on an individual page - echo '<a href="', $fact->getParentObject()->getHtmlUrl(), '">', WT_I18N::translate('View Family'), '</a><br>'; + echo '<a href="', $parent->getHtmlUrl(), '">', WT_I18N::translate('View Family'), '</a><br>'; } // Print the value of this fact/event diff --git a/includes/functions/functions_print_lists.php b/includes/functions/functions_print_lists.php index cdec05cd53..191cbb196e 100644 --- a/includes/functions/functions_print_lists.php +++ b/includes/functions/functions_print_lists.php @@ -244,7 +244,6 @@ function format_indi_table($datalist, $option='') { $person = WT_Person::getInstance($gid); } if (is_null($person)) continue; - if ($person->getType() !== 'INDI') continue; if (!$person->canDisplayName()) { continue; } @@ -658,7 +657,6 @@ function format_fam_table($datalist, $option='') { else $family = WT_Family::getInstance($gid); } if (is_null($family)) continue; - if ($family->getType() !== 'FAM') continue; //-- Retrieve husband and wife $husb = $family->getHusband(); if (is_null($husb)) $husb = new WT_Person(''); @@ -1565,7 +1563,7 @@ function print_changes_list($change_ids, $sort) { foreach ($arr as $value) { $html .= '<a href="' . $value['record']->getHtmlUrl() . '" class="list_item name2">' . $value['record']->getFullName() . '</a>'; $html .= '<div class="indent" style="margin-bottom:5px">'; - if ($value['record']->getType() == 'INDI') { + if ($value['record'] instanceof WT_Person) { if ($value['record']->getAddName()) { $html .= '<a href="' . $value['record']->getHtmlUrl() . '" class="list_item">' . $value['record']->getAddName() . '</a>'; } @@ -1638,25 +1636,23 @@ function print_changes_table($change_ids, $sort) { continue; } $html .= '<tr><td>'; - $indi = false; - switch ($record->getType()) { - case "INDI": + switch ($record::RECORD_TYPE) { + case 'INDI': $icon = $record->getSexImage('small', '', '', false); - $indi = true; break; - case "FAM": + case 'FAM': $icon = '<i class="icon-button_family"></i>'; break; - case "OBJE": + case 'OBJE': $icon = '<i class="icon-button_media"></i>'; break; - case "NOTE": + case 'NOTE': $icon = '<i class="icon-button_note"></i>'; break; - case "SOUR": + case 'SOUR': $icon = '<i class="icon-button_source"></i>'; break; - case "REPO": + case 'REPO': $icon = '<i class="icon-button_repository"></i>'; break; default: @@ -1670,7 +1666,7 @@ function print_changes_table($change_ids, $sort) { $name = $record->getFullName(); $html .= '<td class="wrap">'; $html .= '<a href="'. $record->getHtmlUrl() .'">'. $name . '</a>'; - if ($indi) { + if ($record instanceof WT_Person) { $addname = $record->getAddName(); if ($addname) { $html .= '<div class="indent"><a href="'. $record->getHtmlUrl() .'">'. $addname . '</a></div>'; @@ -1731,11 +1727,11 @@ function print_events_table($startjd, $endjd, $events='BIRT MARR DEAT', $only_li $record=$value['record']; //-- only living people ? if ($only_living) { - if ($record->getType()=="INDI" && $record->isDead()) { + if ($record instanceof WT_Person && $record->isDead()) { $filter ++; continue; } - if ($record->getType()=="FAM") { + if ($record instanceof WT_Family) { $husb = $record->getHusband(); if (is_null($husb) || $husb->isDead()) { $filter ++; @@ -1772,7 +1768,7 @@ function print_events_table($startjd, $endjd, $events='BIRT MARR DEAT', $only_li $value['name'] = $record->getFullName(); $value['url'] = $record->getHtmlUrl(); - if ($record->getType()=="INDI") { + if ($record instanceof WT_Person) { $value['sex'] = $record->getSexImage(); } else { $value['sex'] = ''; @@ -1786,7 +1782,7 @@ function print_events_table($startjd, $endjd, $events='BIRT MARR DEAT', $only_li $name = $value['name']; $html .= '<td class="wrap">'; $html .= '<a href="'.$value['url'].'">'.$name.'</a>'; - if ($value['record']->getType()=="INDI") { + if ($value['record'] instanceof WT_Person) { $html .= $value['sex']; } $html .= '</td>'; @@ -1870,11 +1866,11 @@ function print_events_list($startjd, $endjd, $events='BIRT MARR DEAT', $only_liv $record = WT_GedcomRecord::getInstance($value['id']); //-- only living people ? if ($only_living) { - if ($record->getType()=="INDI" && $record->isDead()) { + if ($record instanceof WT_Person && $record->isDead()) { $filter ++; continue; } - if ($record->getType()=="FAM") { + if ($record instanceof WT_Family) { $husb = $record->getHusband(); if (is_null($husb) || $husb->isDead()) { $filter ++; @@ -1896,7 +1892,7 @@ function print_events_list($startjd, $endjd, $events='BIRT MARR DEAT', $only_liv $value['name'] = $record->getFullName(); $value['url'] = $record->getHtmlUrl(); - if ($record->getType()=="INDI") { + if ($record instanceof WT_Person) { $value['sex'] = $record->getSexImage(); } else { $value['sex'] = ''; diff --git a/library/WT/Controller/GedcomRecord.php b/library/WT/Controller/GedcomRecord.php index e024736626..18c64bd9fa 100644 --- a/library/WT/Controller/GedcomRecord.php +++ b/library/WT/Controller/GedcomRecord.php @@ -42,7 +42,8 @@ class WT_Controller_GedcomRecord extends WT_Controller_Page { $this->setPageTitle($this->record->getFullName()); } else { // e.g. "Individual" or "Source" - $this->setPageTitle(WT_Gedcom_Tag::getLabel($this->record->getType())); + $record = $this->record; + $this->setPageTitle(WT_Gedcom_Tag::getLabel($record::RECORD_TYPE)); } } else { // No such record diff --git a/library/WT/Controller/Lifespan.php b/library/WT/Controller/Lifespan.php index a124e4948b..60c6664289 100644 --- a/library/WT/Controller/Lifespan.php +++ b/library/WT/Controller/Lifespan.php @@ -140,7 +140,7 @@ class WT_Controller_Lifespan extends WT_Controller_Page { $this->pids[$key] = $value; $person = WT_Person::getInstance($value); // list of linked records includes families as well as individuals. - if ($person && $person->getType()=='INDI') { + if ($person) { $bdate = $person->getEstimatedBirthDate(); $ddate = $person->getEstimatedDeathDate(); //--Checks to see if the details of that person can be viewed diff --git a/library/WT/Family.php b/library/WT/Family.php index 9dc61b7abd..cc7876451c 100644 --- a/library/WT/Family.php +++ b/library/WT/Family.php @@ -2,7 +2,7 @@ // Class file for a Family // // webtrees: Web based Family History software -// Copyright (C) 2011 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_Family extends WT_GedcomRecord { + const RECORD_TYPE = 'FAM'; + const URL_PREFIX = 'family.php?famid='; + private $husb = null; private $wife = null; private $marriage = null; @@ -330,15 +333,6 @@ class WT_Family extends WT_GedcomRecord { return array(); } - // Generate a URL to this record, suitable for use in HTML - public function getHtmlUrl() { - return parent::_getLinkUrl('family.php?famid=', '&'); - } - // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. - public function getRawUrl() { - return parent::_getLinkUrl('family.php?famid=', '&'); - } - // Get an array of structures containing all the names in the record public function getAllNames() { if (is_null($this->_getAllNames)) { diff --git a/library/WT/GedcomRecord.php b/library/WT/GedcomRecord.php index 5b2bb76d6c..5e75369e62 100644 --- a/library/WT/GedcomRecord.php +++ b/library/WT/GedcomRecord.php @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_GedcomRecord { + const RECORD_TYPE = 'UNKNOWN'; + const URL_PREFIX = 'gedrecord.php?pid='; + protected $xref =null; // The record identifier protected $type =null; // INDI, FAM, etc. public $ged_id =null; // The gedcom file, only set if this record comes from the database @@ -223,13 +226,7 @@ class WT_GedcomRecord { public function getGedId() { return $this->ged_id; } - /** - * get the object type - * @return string returns the type of this object 'INDI','FAM', etc. - */ - public function getType() { - return $this->type; - } + /** * get gedcom record */ @@ -270,14 +267,14 @@ class WT_GedcomRecord { // Generate a URL to this record, suitable for use in HTML public function getHtmlUrl() { - return self::_getLinkUrl('gedrecord.php?pid=', '&'); + return self::_getLinkUrl(static::URL_PREFIX, '&'); } // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. public function getRawUrl() { - return self::_getLinkUrl('gedrecord.php?pid=', '&'); + return self::_getLinkUrl(static::URL_PREFIX, '&'); } - protected function _getLinkUrl($link, $separator) { + private function _getLinkUrl($link, $separator) { if ($this->ged_id) { // If the record was created from the database, we know the gedcom return $link.$this->getXref().$separator.'ged='.rawurlencode(get_gedcom_from_id($this->ged_id)); @@ -356,9 +353,9 @@ class WT_GedcomRecord { protected function _canDisplayDetailsByType($access_level) { global $global_facts; - if (isset($global_facts[$this->getType()])) { + if (isset($global_facts[static::RECORD_TYPE])) { // Restriction found - return $global_facts[$this->getType()]>=$access_level; + return $global_facts[static::RECORD_TYPE]>=$access_level; } else { // No restriction found - must be public: return true; @@ -486,10 +483,10 @@ class WT_GedcomRecord { } } } else { - $this->_addName($this->getType(), $this->getFallBackName(), null); + $this->_addName(static::RECORD_TYPE, $this->getFallBackName(), null); } } else { - $this->_addName($this->getType(), WT_I18N::translate('Private'), null); + $this->_addName(static::RECORD_TYPE, WT_I18N::translate('Private'), null); } } return $this->_getAllNames; @@ -694,22 +691,22 @@ class WT_GedcomRecord { // Fetch the records that link to this one public function fetchLinkedIndividuals() { - return fetch_linked_indi($this->getXref(), $this->getType(), $this->ged_id); + return fetch_linked_indi($this->getXref(), static::RECORD_TYPE, $this->ged_id); } public function fetchLinkedFamilies() { - return fetch_linked_fam($this->getXref(), $this->getType(), $this->ged_id); + return fetch_linked_fam($this->getXref(), static::RECORD_TYPE, $this->ged_id); } public function fetchLinkedNotes() { - return fetch_linked_note($this->getXref(), $this->getType(), $this->ged_id); + return fetch_linked_note($this->getXref(), static::RECORD_TYPE, $this->ged_id); } public function fetchLinkedSources() { - return fetch_linked_sour($this->getXref(), $this->getType(), $this->ged_id); + return fetch_linked_sour($this->getXref(), static::RECORD_TYPE, $this->ged_id); } public function fetchLinkedRepositories() { - return fetch_linked_repo($this->getXref(), $this->getType(), $this->ged_id); + return fetch_linked_repo($this->getXref(), static::RECORD_TYPE, $this->ged_id); } public function fetchLinkedMedia() { - return fetch_linked_obje($this->getXref(), $this->getType(), $this->ged_id); + return fetch_linked_obje($this->getXref(), static::RECORD_TYPE, $this->ged_id); } // Get all attributes (e.g. DATE or PLAC) from an event (e.g. BIRT or MARR). diff --git a/library/WT/Media.php b/library/WT/Media.php index ee744979ea..e370da631b 100644 --- a/library/WT/Media.php +++ b/library/WT/Media.php @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_Media extends WT_GedcomRecord { + const RECORD_TYPE = 'OBJE'; + const URL_PREFIX = 'mediaviewer.php?mid='; + public $title = null; // TODO: these should be private, with getTitle() and getFilename() functions public $file = null; @@ -330,15 +333,6 @@ class WT_Media extends WT_GedcomRecord { return $this->$var; } - // Generate a URL to this record, suitable for use in HTML - public function getHtmlUrl() { - return parent::_getLinkUrl('mediaviewer.php?mid=', '&'); - } - // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. - public function getRawUrl() { - return parent::_getLinkUrl('mediaviewer.php?mid=', '&'); - } - // Generate a URL directly to the media file public function getHtmlUrlDirect($which='main', $download=false) { // “cb” is “cache buster”, so clients will make new request if anything significant about the user or the file changes diff --git a/library/WT/Note.php b/library/WT/Note.php index 7cf671322f..a97f87e542 100644 --- a/library/WT/Note.php +++ b/library/WT/Note.php @@ -2,7 +2,7 @@ // Class file for a Shared Note (NOTE) object // // webtrees: Web based Family History software -// Copyright (C) 2011 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2009 PGV Development Team. All rights reserved. @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_Note extends WT_GedcomRecord { + const RECORD_TYPE = 'NOTE'; + const URL_PREFIX = 'note.php?nid='; + // Implement note-specific privacy logic protected function _canDisplayDetailsByType($access_level) { // Hide notes if they are attached to private records @@ -64,15 +67,6 @@ class WT_Note extends WT_GedcomRecord { return $statement->execute(array($xref, $ged_id))->fetchOneRow(PDO::FETCH_ASSOC); } - // Generate a URL to this record, suitable for use in HTML - public function getHtmlUrl() { - return parent::_getLinkUrl('note.php?nid=', '&'); - } - // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. - public function getRawUrl() { - return parent::_getLinkUrl('note.php?nid=', '&'); - } - // The 'name' of a note record is the first line. This can be // somewhat unwieldy if lots of CONC records are used. Limit to 100 chars protected function _addName($type, $value, $gedrec) { diff --git a/library/WT/Person.php b/library/WT/Person.php index 5b82ed467e..a2ab1229af 100644 --- a/library/WT/Person.php +++ b/library/WT/Person.php @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_Person extends WT_GedcomRecord { + const RECORD_TYPE = 'INDI'; + const URL_PREFIX = 'individual.php?pid='; + var $indifacts = array(); var $otherfacts = array(); var $globalfacts = array(); @@ -1647,15 +1650,6 @@ class WT_Person extends WT_GedcomRecord { return $txt; } - // Generate a URL to this record, suitable for use in HTML - public function getHtmlUrl() { - return parent::_getLinkUrl('individual.php?pid=', '&'); - } - // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. - public function getRawUrl() { - return parent::_getLinkUrl('individual.php?pid=', '&'); - } - // If this object has no name, what do we call it? function getFallBackName() { return '@P.N. /@N.N./'; diff --git a/library/WT/Report/Base.php b/library/WT/Report/Base.php index b0d1dc874e..30e3cd9828 100644 --- a/library/WT/Report/Base.php +++ b/library/WT/Report/Base.php @@ -4,7 +4,7 @@ // used by the SAX parser to generate reports from the XML report file. // // 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. @@ -2350,23 +2350,6 @@ function FactsSHandler($attrs) { } } else { $record = new WT_GedcomRecord($gedrec); - switch ($record->getType()) { - case "INDI": - $record=new WT_Person($gedrec); - break; - case "FAM": - $record=new WT_Family($gedrec); - break; - case "SOUR": - $record=new WT_Source($gedrec); - break; - case "REPO": - $record=new WT_Repository($gedrec); - break; - case "NOTE": - $record=new WT_Note($gedrec); - break; - } $oldrecord = WT_GedcomRecord::getInstance($record->getXref()); $oldrecord->diffMerge($record); $facts = $oldrecord->getFacts(); diff --git a/library/WT/Repository.php b/library/WT/Repository.php index d50d8f9036..3959c1a840 100644 --- a/library/WT/Repository.php +++ b/library/WT/Repository.php @@ -2,7 +2,7 @@ // Class file for a Repository (REPO) object // // webtrees: Web based Family History software -// Copyright (C) 2011 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_Repository extends WT_GedcomRecord { + const RECORD_TYPE = 'REPO'; + const URL_PREFIX = 'repo.php?rid='; + // Fetch the record from the database protected static function fetchGedcomRecord($xref, $ged_id) { static $statement=null; @@ -36,22 +39,12 @@ class WT_Repository extends WT_GedcomRecord { if ($statement===null) { $statement=WT_DB::prepare( "SELECT o_type AS type, o_id AS xref, o_file AS ged_id, o_gedcom AS gedrec ". - "FROM `##other` WHERE o_id=? AND o_file=? AND o_type='REPO'" + "FROM `##other` WHERE o_id=? AND o_file=?" ); } return $statement->execute(array($xref, $ged_id))->fetchOneRow(PDO::FETCH_ASSOC); } - // Generate a URL to this record, suitable for use in HTML - public function getHtmlUrl() { - return parent::_getLinkUrl('repo.php?rid=', '&'); - } - - // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. - public function getRawUrl() { - return parent::_getLinkUrl('repo.php?rid=', '&'); - } - // Generate a private version of this record protected function createPrivateGedcomRecord($access_level) { return "0 @".$this->xref."@ REPO\n1 NAME ".WT_I18N::translate('Private'); diff --git a/library/WT/Source.php b/library/WT/Source.php index daf24f4f09..3e1c2db595 100644 --- a/library/WT/Source.php +++ b/library/WT/Source.php @@ -2,7 +2,7 @@ // Class file for a Source (SOUR) object // // webtrees: Web based Family History software -// Copyright (C) 2011 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2002 to 2009 PGV Development Team. All rights reserved. @@ -21,7 +21,7 @@ // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// @version $Id$ +// $Id$ if (!defined('WT_WEBTREES')) { header('HTTP/1.0 403 Forbidden'); @@ -29,6 +29,9 @@ if (!defined('WT_WEBTREES')) { } class WT_Source extends WT_GedcomRecord { + const RECORD_TYPE = 'SOUR'; + const URL_PREFIX = 'source.php?sid='; + // Implement source-specific privacy logic protected function _canDisplayDetailsByType($access_level) { // Hide sources if they are attached to private repositories ... @@ -66,15 +69,6 @@ class WT_Source extends WT_GedcomRecord { return get_gedcom_value('AUTH', 1, $this->getGedcomRecord()); } - // Generate a URL to this record, suitable for use in HTML - public function getHtmlUrl() { - return parent::_getLinkUrl('source.php?sid=', '&'); - } - // Generate a URL to this record, suitable for use in javascript, HTTP headers, etc. - public function getRawUrl() { - return parent::_getLinkUrl('source.php?sid=', '&'); - } - // Get an array of structures containing all the names in the record public function getAllNames() { return parent::_getAllNames('TITL', 1); diff --git a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php index 0ed585a5e8..3ec3cb93ba 100644 --- a/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php +++ b/modules_v3/GEDFact_assistant/_MEDIA/media_0_inverselink.php @@ -139,11 +139,11 @@ if ($action == 'choose' && $paramok) { echo "<td align='center'><input alt='", WT_I18N::translate('Keep Link in list'), "', title='", WT_I18N::translate('Keep Link in list'), "' type='radio' id='", $record->getXref(), "_off' name='", $record->getXref(), "' checked></td>"; echo "<td align='center'><input alt='", WT_I18N::translate('Remove Link from list'), "', title='", WT_I18N::translate('Remove Link from list'), "' type='radio' id='", $record->getXref(), "_on' name='", $record->getXref(), "'></td>"; - if ($record->getType()=='INDI') { + if ($record instanceof WT_Person) { ?> <td align="center"><a href="#" class="icon-button_family" title="<?php echo WT_I18N::translate('Family navigator'); ?>" name="family_'<?php echo $record->getXref(); ?>'" onclick="openFamNav('<?php echo $record->getXref(); ?>'); return false;"></a></td> <?php - } elseif ($record->getType()=='FAM') { + } elseif ($record instanceof WT_Family) { if ($record->getHusband()) { $head=$record->getHusband()->getXref(); } elseif ($record->getWife()) { diff --git a/modules_v3/GEDFact_assistant/module.php b/modules_v3/GEDFact_assistant/module.php index 61f40cd640..1a7da95c02 100644 --- a/modules_v3/GEDFact_assistant/module.php +++ b/modules_v3/GEDFact_assistant/module.php @@ -180,7 +180,7 @@ class GEDFact_assistant_WT_Module extends WT_Module { $record=WT_GedcomRecord::getInstance($iid2); if ($record) { $headjs=''; - if ($record->getType()=='FAM') { + if ($record instanceof WT_Family) { if ($record->getHusband()) { $headjs=$record->getHusband()->getXref(); } elseif ($record->getWife()) { diff --git a/modules_v3/clippings/clippings_ctrl.php b/modules_v3/clippings/clippings_ctrl.php index 2f01fc6bae..21f5d286c8 100644 --- a/modules_v3/clippings/clippings_ctrl.php +++ b/modules_v3/clippings/clippings_ctrl.php @@ -100,7 +100,7 @@ class WT_Controller_Clippings { $this->id=""; $this->action=""; } - else $this->type = strtolower($obj->getType()); + else $this->type = strtolower($obj::RECORD_TYPE); } else if (empty($this->id)) $this->action=""; if (!empty($this->id) && $this->type != 'fam' && $this->type != 'indi' && $this->type != 'sour') @@ -220,7 +220,7 @@ class WT_Controller_Clippings { if ($convert=='yes') { $record=utf8_decode($record); } - switch ($object->getType()) { + switch ($object::RECORD_TYPE) { case 'INDI': $filetext .= $record."\n"; $filetext .= "1 SOUR @WEBTREES@\n"; @@ -396,7 +396,7 @@ class WT_Controller_Clippings { $a=WT_GedcomRecord::getInstance($a); $b=WT_GedcomRecord::getInstance($b); if ($a && $b) { - switch ($a->getType()) { + switch ($a::RECORD_TYPE) { case 'INDI': $t1=1; break; case 'FAM': $t1=2; break; case 'SOUR': $t1=3; break; @@ -405,7 +405,7 @@ class WT_Controller_Clippings { case 'NOTE': $t1=6; break; default: $t1=7; break; } - switch ($b->getType()) { + switch ($b::RECORD_TYPE) { case 'INDI': $t2=1; break; case 'FAM': $t2=2; break; case 'SOUR': $t2=3; break; diff --git a/modules_v3/clippings/module.php b/modules_v3/clippings/module.php index 4c159820ad..32bdd50c8c 100644 --- a/modules_v3/clippings/module.php +++ b/modules_v3/clippings/module.php @@ -282,14 +282,14 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { $record=WT_GedcomRecord::getInstance($xref); if ($record) { - switch ($tag = $record->getType()) { - case 'INDI': $icon='icon-indis'; break; - case 'FAM': $icon='icon-sfamily'; break; - case 'SOUR': $icon='icon-source'; break; + switch ($record::RECORD_TYPE) { + case 'INDI': $icon='icon-indis'; break; + case 'FAM': $icon='icon-sfamily'; break; + case 'SOUR': $icon='icon-source'; break; case 'REPO': $icon='icon-repository'; break; - case 'NOTE': $icon='icon-note'; break; - case 'OBJE': $icon='icon-media'; break; - default: $icon='icon-clippings'; break; + case 'NOTE': $icon='icon-note'; break; + case 'OBJE': $icon='icon-media'; break; + default: $icon='icon-clippings'; break; } ?> <tr><td class="list_value"> @@ -388,7 +388,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module $record = WT_GedcomRecord::getInstance($add); if ($record) { $clip_ctrl->id=$record->getXref(); - $clip_ctrl->type=$record->getType(); + $clip_ctrl->type=$record::RECORD_TYPE; $ret = $clip_ctrl->add_clipping($record); if ($ret) return $this->askAddOptions($record); } @@ -396,7 +396,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module $record = WT_Person::getInstance($add1); if ($record) { $clip_ctrl->id=$record->getXref(); - $clip_ctrl->type=strtolower($record->getType()); + $clip_ctrl->type=strtolower($record::RECORD_TYPE); if ($others == 'parents') { foreach ($record->getChildFamilies() as $family) { $clip_ctrl->add_clipping($family); @@ -442,24 +442,21 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module $out='<ul>'; foreach (array_keys($WT_SESSION->cart[WT_GED_ID]) as $xref) { $record=WT_GedcomRecord::getInstance($xref); - if ($record && ($record->getType()=='INDI' || $record->getType()=='FAM')) { // Just show INDI/FAM in the sidbar - switch ($tag = $record->getType()) { - case 'INDI': $icon='icon-indis'; break; + if ($record && ($record::RECORD_TYPE=='INDI' || $record::RECORD_TYPE=='FAM')) { // Just show INDI/FAM in the sidbar + switch ($record::RECORD_TYPE) { + case 'INDI': $icon='icon-indis'; break; case 'FAM': $icon='icon-sfamily'; break; - case 'SOUR': $icon='icon-source'; break; - case 'REPO': $icon='icon-repository'; break; - case 'NOTE': $icon='icon-note'; break; - case 'OBJE': $icon='icon-media'; break; - default: $icon='icon-clippings'; break; } $out .= '<li>'; if (!empty($icon)) { $out .= '<i class="'.$icon.'"></i>'; } $out .= '<a href="'.$record->getHtmlUrl().'">'; - if ($record->getType()=="INDI") $out .=$record->getSexImage(); + if ($record::RECORD_TYPE == 'INDI') { + $out .=$record->getSexImage(); + } $out .= ' '.$record->getFullName().' '; - if ($record->getType()=="INDI" && $record->canDisplayDetails()) { + if ($record::RECORD_TYPE == 'INDI' && $record->canDisplayDetails()) { $out .= ' ('.$record->getLifeSpan().')'; } $out .= '</a>'; @@ -497,7 +494,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module jQuery("#sb_clippings_content").load(link); }'; $out .= '</script>'; - if ($person->getType()=='FAM') { + if ($person::RECORD_TYPE=='FAM') { $out .= '<form action="module.php" method="get" onsubmit="continueAjax(this); return false;"> <input type="hidden" name="mod" value="clippings"> @@ -505,7 +502,7 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module <table> <tr><td class="topbottombar">'.WT_I18N::translate('Which other links from this family would you like to add?').' <input type="hidden" name="pid" value="'.$person->getXref().'"> - <input type="hidden" name="type" value="'.$person->getType().'"> + <input type="hidden" name="type" value="'.$person::RECORD_TYPE.'"> <input type="hidden" name="action" value="add1"></td></tr> <tr><td class="optionbox"><input type="radio" name="others" checked value="none">'.WT_I18N::translate('Add just this family record.').'</td></tr> <tr><td class="optionbox"><input type="radio" name="others" value="parents">'.WT_I18N::translate('Add parents\' records together with this family record.').'</td></tr> @@ -515,13 +512,13 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module </table> </form>'; } - else if ($person->getType()=='INDI') { + else if ($person::RECORD_TYPE=='INDI') { $out .= '<form action="module.php" method="get" onsubmit="continueAjax(this); return false;"> <input type="hidden" name="mod" value="clippings"> <input type="hidden" name="mod_action" value="index"> '.WT_I18N::translate('Which links from this person would you also like to add?').' <input type="hidden" name="pid" value="'.$person->getXref().'"> - <input type="hidden" name="type" value="'.$person->getType().'"> + <input type="hidden" name="type" value="'.$person::RECORD_TYPE.'"> <input type="hidden" name="action" value="add1"> <ul> <li><input type="radio" name="others" checked value="none">'.WT_I18N::translate('Add just this person.').'</li> @@ -536,14 +533,14 @@ class clippings_WT_Module extends WT_Module implements WT_Module_Menu, WT_Module </ul> <input type="submit" value="'.WT_I18N::translate('Continue Adding').'"> </form>'; - } else if ($person->getType()=='SOUR') { + } else if ($person::RECORD_TYPE == 'SOUR') { $out .= '<form action="module.php" method="get" onsubmit="continueAjax(this); return false;"> <input type="hidden" name="mod" value="clippings"> <input type="hidden" name="mod_action" value="index"> <table> <tr><td class="topbottombar">'.WT_I18N::translate('Which records linked to this source should be added?').' <input type="hidden" name="pid" value="'.$person->getXref().'"> - <input type="hidden" name="type" value="'.$person->getType().'"> + <input type="hidden" name="type" value="'.$person::RECORD_TYPE.'"> <input type="hidden" name="action" value="add1"></td></tr> <tr><td class="optionbox"><input type="radio" name="others" checked value="none">'.WT_I18N::translate('Add just this source.').'</td></tr> <tr><td class="optionbox"><input type="radio" name="others" value="linked">'.WT_I18N::translate('Add this source and families/people linked to it.').'</td></tr> diff --git a/modules_v3/gedcom_favorites/module.php b/modules_v3/gedcom_favorites/module.php index 2d1795f625..d65769338e 100644 --- a/modules_v3/gedcom_favorites/module.php +++ b/modules_v3/gedcom_favorites/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -69,7 +69,7 @@ class gedcom_favorites_WT_Module extends WT_Module implements WT_Module_Block { 'user_id' =>$ctype=='user' ? WT_USER_ID : null, 'gedcom_id'=>WT_GED_ID, 'gid' =>$record->getXref(), - 'type' =>$record->getType(), + 'type' =>$record::RECORD_TYPE, 'url' =>null, 'note' =>$favnote, 'title' =>$favtitle, @@ -132,7 +132,7 @@ class gedcom_favorites_WT_Module extends WT_Module implements WT_Module_Block { } else { $record=WT_GedcomRecord::getInstance($favorite['gid']); if ($record && $record->canDisplayDetails()) { - if ($record->getType()=='INDI') { + if ($record instanceof WT_Person) { $content .= '<div id="box'.$favorite["gid"].'.0" class="person_box action_header'; switch($record->getsex()) { case 'M': diff --git a/modules_v3/review_changes/module.php b/modules_v3/review_changes/module.php index d365775988..3d6e3206c2 100644 --- a/modules_v3/review_changes/module.php +++ b/modules_v3/review_changes/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2012 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -121,15 +121,8 @@ class review_changes_WT_Module extends WT_Module implements WT_Module_Block { $record=WT_GedcomRecord::getInstance($change->xref); if ($record->canDisplayDetails()) { $content.='<b>'.$record->getFullName().'</b>'; - switch ($record->getType()) { - case 'INDI': - case 'FAM': - case 'SOUR': - case 'OBJE': - $content.=$block ? '<br>' : ' '; - $content.='<a href="'.$record->getHtmlUrl().'">'.WT_I18N::translate('View the changes').'</a>'; - break; - } + $content.=$block ? '<br>' : ' '; + $content.='<a href="'.$record->getHtmlUrl().'">'.WT_I18N::translate('View the changes').'</a>'; $content.='<br>'; } } diff --git a/modules_v3/user_favorites/module.php b/modules_v3/user_favorites/module.php index 04a0a52bf6..662a359678 100644 --- a/modules_v3/user_favorites/module.php +++ b/modules_v3/user_favorites/module.php @@ -2,7 +2,7 @@ // Classes and libraries for module system // // webtrees: Web based Family History software -// Copyright (C) 2011 webtrees development team. +// Copyright (C) 2013 webtrees development team. // // Derived from PhpGedView // Copyright (C) 2010 John Finlay @@ -72,7 +72,7 @@ class user_favorites_WT_Module extends gedcom_favorites_WT_Module { 'user_id' =>WT_USER_ID, 'gedcom_id'=>$record->getGedId(), 'gid' =>$record->getXref(), - 'type' =>$record->getType(), + 'type' =>$record::RECORD_TYPE, 'url' =>null, 'note' =>null, 'title' =>null, diff --git a/placelist.php b/placelist.php index 94f98248a1..5c75015b37 100644 --- a/placelist.php +++ b/placelist.php @@ -205,13 +205,11 @@ case 'hierarchy': foreach ($positions as $position) { $record=WT_GedcomRecord::getInstance($position); if ($record && $record->canDisplayDetails()) { - switch ($record->getType()) { - case 'INDI': + if ($record instanceof WT_Person) { $myindilist[]=$record; - break; - case 'FAM': + } + if ($record instanceof WT_Family) { $myfamlist[]=$record; - break; } } } |
