/** * Creates the date elements used throughout the GRAMPS XML file. * The function will parse the date record and determine the type of date * (regular, range). * * @param DOMObject $eParent - The parent element the date should be attached to * @param string $dateRec - the entire GEDCOM date record to be parsed * @param int $level - the level the date record was found on in the GEDCOM * @param int $done - whether the method is called from the GrampsExport($done=1) or a sub-class */ function create_date($eParent, $dateRec, $level) { if (empty($dateRec)) { return; } $date = new GedcomDate(get_gedcom_value("DATE", $level, $dateRec, '', false)); //checks to see if there's is a 2nd date value and creates the daterange element if (!empty($date->qual2)) { $eDateRange = $this->dom->createElement("daterange"); $eDateRange = $eParent->appendChild($eDateRange); //sets the start date $eDateRange->setAttribute("start", $this->create_date_value($date->MinDate())); //sets the stop date $eDateRange->setAttribute("stop", $this->create_date_value($date->MaxDate())); } else { //if there's no dateRange, this creates the normal dateval Element $eDateVal = $this->dom->createElement("dateval"); $eDateVal = $eParent->appendChild($eDateVal); //checks for the Type attribute values switch ($date->qual1) { case 'bef': $eDateVal->setAttribute("type", "before"); break; case 'aft': $eDateVal->setAttribute("type", "after"); break; case 'abt': $eDateVal->setAttribute("type", "about"); break; } //sets the date value $eDateVal->setAttribute("val", $this->create_date_value($date->MinDate())); } }