/** * Check if the element is in the cart * */ function items_in_cart($elementName) { $passed = true; $people = $this->dom->getElementsByTagName($elementName); foreach ($people as $person) { $id = $person->attributes->item(0)->nodeValue; if (!id_in_cart($id)) { $passed = false; } } return $passed; }
function add_family_descendancy($famid, $level = "") { global $cart; if (!$famid) { return; } $famrec = find_family_record($famid); if ($famrec) { $parents = find_parents_in_record($famrec); if (!empty($parents["HUSB"])) { $clipping = array(); $clipping['type'] = "indi"; $clipping['id'] = $parents["HUSB"]; $this->add_clipping($clipping); } if (!empty($parents["WIFE"])) { $clipping = array(); $clipping['type'] = "indi"; $clipping['id'] = $parents["WIFE"]; $this->add_clipping($clipping); } $num = preg_match_all("/1\\s*CHIL\\s*@(.*)@/", $famrec, $smatch, PREG_SET_ORDER); for ($i = 0; $i < $num; $i++) { $cfamids = find_sfamily_ids($smatch[$i][1]); if (count($cfamids) > 0) { foreach ($cfamids as $indexval => $cfamid) { if (!id_in_cart($cfamid)) { $clipping = array(); $clipping['type'] = "fam"; $clipping['id'] = $cfamid; $ret = $this->add_clipping($clipping); // add the childs family if ($level == "" || $level > 0) { if ($level != "") { $level--; } $this->add_family_descendancy($cfamid, $level); // recurse on the childs family } } } } else { $clipping = array(); $clipping['type'] = "indi"; $clipping['id'] = $smatch[$i][1]; $this->add_clipping($clipping); } } } }
/** * Creates the lds_ord element and appends the correct information depending * on the type of lds_ord (Endowment, Sealing, Baptism). If there is a sealing, * the function will search if the family is in the clippings cart and if the * family is created or not. If the family is not created yet, it will be created * and added to the DOMDocument * * @param $indirec - The full INDI GEDCOM record of the person the lds_ord is being created * @param $eventName - the name of the LDS event (Baptism, Sealing, Endowment, etc...) * @param $eventABV - the event abbreviation in the GEDCOM (ie. SLGC, BAPL, ENDL) * @param $eParent - The parent element the lds event is attached to */ function create_lds_event($indirec, $eventName, $eventABV, $eParent) { global $ePerson, $TEMPLE_CODES, $clipping, $eRoot; require_once "includes/classes/class_person.php"; if (($hasldsevent = get_sub_record(1, "1 " . $eventABV, $indirec)) != null) { // Create <lds_ord> and attaches the type attribute $eLdsEvent = $this->dom->createElement("lds_ord"); $eLdsEvent->setAttribute("type", $eventName); if (($dateRec = get_sub_record(1, "2 DATE", $hasldsevent)) != null) { $this->create_date($eLdsEvent, $dateRec, 2); } // Create <temple>, this element is common with all lds ords if (($temple = get_gedcom_value($eventABV . ":TEMP", 1, $indirec)) != null) { $eTemple = $this->dom->createElement("temple"); $eTemple->setAttribute("val", $temple); $eTemple = $eLdsEvent->appendChild($eTemple); } if (($place = get_gedcom_value($eventABV . ":PLAC", 1, $indirec)) != null) { $hlink = $this->query_dom("./places/placeobj[@title=\"{$place}\"]/@handle"); if ($hlink == null) { $hlink = $this->generateHandle(); $this->create_placeobj($place, $hlink); $this->create_place($eLdsEvent, $hlink); } else { $this->create_place($eLdsEvent, $hlink); } } // Check to see if the STAT of the ordinance is set and add it to the // <lds_ord> element if (($stat = get_gedcom_value($eventABV . ":STAT", 1, $indirec)) != null) { $eStatus = $this->dom->createElement("status"); $stat = get_gedcom_value($eventABV . ":STAT", 1, $indirec); $eStatus->setAttribute("val", isset($stat)); $eStatus = $eLdsEvent->appendChild($eStatus); } // If the event is a sealing if ($eventABV == "SLGC") { // Create an instance of person and look for their family record $person = Person::getInstance($clipping["id"]); $famId = $person->getChildFamilyIds(); $famrec = find_family_record($famId[0]); $fid = $famId[0]; $handle = $this->query_dom("./families/family[@id=\"{$fid}\"]/@handle"); if ($handle == null && id_in_cart($fid)) { /* * If the family does not exist and their ID is in the clippings cart, * you must create the family before you can query them in the dom to get * their hlink. The hlink is generated when the person element is created. * This causes overhead creating objects that are never added to the XML file * perhaps there is some other way this can be done reducing the overhead? * */ $this->create_family($famrec, $famId[0]); $handle = $this->query_dom("./families/family[@id=\"{$fid}\"]/@handle"); $eFam = $this->dom->createElement("sealed_to"); $eFam->setAttribute("hlink", $handle); $eFam = $eLdsEvent->appendChild($eFam); $person = null; } else { if ($handle != null && id_in_cart($fid)) { $eFam = $this->dom->createElement("sealed_to"); $eFam->setAttribute("hlink", $handle); $eFam = $eLdsEvent->appendChild($eFam); $person = null; } } } if (($note = get_sub_record(1, "2 NOTE", $hasldsevent)) != null) { $this->create_note($eLdsEvent, $note, 2); } $num = 1; while (($sourcerefRec = get_sub_record(2, "2 SOUR", $hasldsevent, $num)) != null) { $this->create_sourceref($eLdsEvent, $sourcerefRec, 2, 0); $num++; } $eLdsEvent = $eParent->appendChild($eLdsEvent); } }