/**
  * Flattens the object into a GEDCOM compliant format
  *
  * This method guarantees compliance, not re-creation of
  * the original order of the records.
  *
  * @param int    $lvl indicates the level at which this record
  *                    should be generated
  * @param string $ver represents the version of the GEDCOM standard
  *
  * @return string a return character delimited string of gedcom records
  *
  * @access public
  * @since Method available since Release 0.0.1
  */
 public function to_gedcom($lvl, $ver)
 {
     $ged_rec = '';
     if (!isset($ver) || $ver === '') {
         $ver = $this->ver;
     }
     if (strpos($ver, '5.5.1') == 0) {
         $ged_rec = $lvl . ' @' . $this->id . '@ ' . Rp_Tags::SUBMITTER;
         $lvl2 = $lvl + 1;
         if (isset($this->name) && $this->name != '') {
             $ged_rec .= "\n" . $lvl2 . ' ' . Rp_Tags::NAME . ' ' . $this->name;
         }
         $tmp = $this->address->to_gedcom($lvl2, $ver);
         if (isset($tmp) && $tmp != '') {
             $ged_rec .= "\n" . $tmp;
         }
         if (isset($str) && $str != '') {
             $ged_rec .= "\n" . $str;
         }
         $ged_rec = $this->media_to_gedcom($ged_rec, $lvl2, $ver);
         $ged_rec = $this->auto_rec_to_gedcom($ged_rec, $lvl2, $ver);
         $ged_rec = $this->change_date_to_gedcom($ged_rec, $lvl2, $ver);
         $ged_rec = $this->note_to_gedcom($ged_rec, $lvl2, $ver);
     }
     return $ged_rec;
 }
 /**
  * Flattens the object into a GEDCOM compliant format
  *
  * This method guarantees compliance, not re-creation of
  * the original order of the records.
  *
  * @param int    $lvl indicates the level at which this record
  *                    should be generated
  * @param string $ver represents the version of the GEDCOM standard
  *
  * @return string a return character delimited string of gedcom records
  *
  * @access public
  * @since Method available since Release 0.0.1
  */
 protected function to_gedcom_detail($lvl, $ver)
 {
     if (!isset($ver) || $ver === '') {
         $ver = $this->ver;
     }
     $ged_rec = '';
     if (strpos($ver, '5.5.1') == 0) {
         if (isset($this->type) && $this->type != '') {
             $ged_rec .= "\n" . $lvl . ' ' . Rp_Tags::TYPE . ' ' . $this->type;
         }
         if (isset($this->date) && $this->date != '') {
             $ged_rec .= "\n" . $lvl . ' ' . Rp_Tags::DATE . ' ' . $this->date;
         }
         $str = $this->place->to_gedcom($lvl, $ver);
         if (isset($str) && $str != '') {
             $ged_rec .= "\n" . $str;
         }
         $str = $this->address->to_gedcom($lvl, $ver);
         if (isset($str) && $str != '') {
             $ged_rec .= "\n" . $str;
         }
         if (isset($this->age) && $this->age != '') {
             $ged_rec .= $lvl . ' ' . Rp_Tags::AGE . ' ' . $this->age;
         }
         if (isset($this->resp_agency) && $this->resp_agency != '') {
             $ged_rec .= $lvl . ' ' . Rp_Tags::AGENCY . ' ' . $this->resp_agency;
         }
         if (isset($this->religious_affiliation) && $this->religious_affiliation != '') {
             $ged_rec .= $lvl . ' ' . Rp_Tags::RELIGION . ' ' . $this->religious_affiliation;
         }
         if (isset($this->restriction) && $this->restriction != '') {
             $ged_rec .= $lvl . ' ' . Rp_Tags::RESTRICTION . ' ' . $this->restriction;
         }
         if (isset($this->cause) && $this->cause != '') {
             $ged_rec .= $lvl . ' ' . Rp_Tags::CAUSE . ' ' . $this->cause;
         }
         for ($i = 0; $i < count($this->citations); $i++) {
             $str .= "\n" . $this->citations[$i]->to_gedcom($lvl, $ver);
         }
         for ($i = 0; $i < count($this->media_links); $i++) {
             $str .= "\n" . $this->media_links[$i]->to_gedcom($lvl, $ver);
         }
         for ($i = 0; $i < count($this->notes); $i++) {
             $str .= "\n" . $this->notes[$i]->to_gedcom($lvl, $ver);
         }
     }
     return $ged_rec;
 }