/**
  * 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::NOTE;
         if (isset($this->text) && $this->text != '') {
             $ged_rec .= ' ' . parent::to_con_tag($this->text, null, $lvl);
         }
         $lvl2 = $lvl + 1;
         $ged_rec = $this->user_ref_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->cite_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
  */
 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::SOURCE;
         $lvl2 = $lvl + 1;
         for ($i = 0; $i < count($this->source_data); $i++) {
             $ged_rec .= "\n" . $this->source_data[$i]->to_gedcom($lvl2, $ver);
         }
         if (isset($this->author) && $this->author != '') {
             $ged_rec .= "\n" . parent::to_con_tag($this->author, Rp_Tags::AUTHOR, $lvl2);
         }
         if (isset($this->title) && $this->title != '') {
             $ged_rec .= "\n" . parent::to_con_tag($this->title, Rp_Tags::TITLE, $lvl2);
         }
         if (isset($this->abbreviated_title) && $this->abbreviated_title != '') {
             $ged_rec .= "\n" . parent::to_con_tag($this->abbreviated_title, Rp_Tags::ABBR, $lvl2);
         }
         if (isset($this->publication_facts) && $this->publication_facts != '') {
             $ged_rec .= "\n" . parent::to_con_tag($this->publication_facts, Rp_Tags::PUBLICATION, $lvl2);
         }
         if (isset($this->text) && $this->text != '') {
             $ged_rec .= "\n" . parent::to_con_tag($this->text, Rp_Tags::TEXT, $lvl2);
         }
         for ($i = 0; $i < count($this->repository_citations); $i++) {
             $ged_rec .= "\n" . $this->repository_citations[$i]->to_gedcom($lvl2, $ver);
         }
         $ged_rec = $this->user_ref_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);
         $ged_rec = $this->media_to_gedcom($ged_rec, $lvl2, $ver);
     }
     return $ged_rec;
 }