示例#1
0
 /**
  * Create a GedcomRecord object from raw GEDCOM data.
  *
  * @param string      $xref
  * @param string      $gedcom  an empty string for new/pending records
  * @param string|null $pending null for a record with no pending edits,
  *                             empty string for records with pending deletions
  * @param Tree        $tree
  */
 public function __construct($xref, $gedcom, $pending, $tree)
 {
     parent::__construct($xref, $gedcom, $pending, $tree);
     // Fetch family members
     if (preg_match_all('/^1 (?:HUSB|WIFE|CHIL) @(.+)@/m', $gedcom . $pending, $match)) {
         Individual::load($tree, $match[1]);
     }
     if (preg_match('/^1 HUSB @(.+)@/m', $gedcom . $pending, $match)) {
         $this->husb = Individual::getInstance($match[1], $tree);
     }
     if (preg_match('/^1 WIFE @(.+)@/m', $gedcom . $pending, $match)) {
         $this->wife = Individual::getInstance($match[1], $tree);
     }
     // Make sure husb/wife are the right way round.
     if ($this->husb && $this->husb->getSex() === 'F' || $this->wife && $this->wife->getSex() === 'M') {
         list($this->husb, $this->wife) = array($this->wife, $this->husb);
     }
 }