Ejemplo n.º 1
0
 /**
  * print information for a name record
  *
  * @param Fact $event the event object
  */
 public function printNameRecord(Fact $event)
 {
     $factrec = $event->getGedcom();
     // Create a dummy record, so we can extract the formatted NAME value from the event.
     $dummy = new Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, $event->getParent()->getTree());
     $all_names = $dummy->getAllNames();
     $primary_name = $all_names[0];
     $this->name_count++;
     if ($this->name_count > 1) {
         echo '<h3 class="name_two">', $dummy->getFullName(), '</h3>';
     }
     //Other names accordion element
     echo '<div class="indi_name_details';
     if ($event->isPendingDeletion()) {
         echo ' old';
     }
     if ($event->isPendingAddition()) {
         echo ' new';
     }
     echo '">';
     echo '<div class="name1">';
     echo '<dl><dt class="label">', I18N::translate('Name'), '</dt>';
     $dummy->setPrimaryName(0);
     echo '<dd class="field">', $dummy->getFullName();
     if ($this->name_count == 1) {
         if (Auth::isAdmin()) {
             $user = User::findByGenealogyRecord($this->record);
             if ($user) {
                 echo '<span> - <a class="warning" href="admin_users.php?filter=' . Filter::escapeHtml($user->getUserName()) . '">' . Filter::escapeHtml($user->getUserName()) . '</a></span>';
             }
         }
     }
     if ($this->record->canEdit() && !$event->isPendingDeletion()) {
         echo "<div class=\"deletelink\"><a class=\"deleteicon\" href=\"#\" onclick=\"return delete_fact('" . I18N::translate('Are you sure you want to delete this fact?') . "', '" . $this->record->getXref() . "', '" . $event->getFactId() . "');\" title=\"" . I18N::translate('Delete this name') . "\"><span class=\"link_text\">" . I18N::translate('Delete this name') . "</span></a></div>";
         echo "<div class=\"editlink\"><a href=\"#\" class=\"editicon\" onclick=\"edit_name('" . $this->record->getXref() . "', '" . $event->getFactId() . "'); return false;\" title=\"" . I18N::translate('Edit name') . "\"><span class=\"link_text\">" . I18N::translate('Edit name') . "</span></a></div>";
     }
     echo '</dd>';
     echo '</dl>';
     echo '</div>';
     $ct = preg_match_all('/\\n2 (\\w+) (.*)/', $factrec, $nmatch, PREG_SET_ORDER);
     for ($i = 0; $i < $ct; $i++) {
         echo '<div>';
         $fact = $nmatch[$i][1];
         if ($fact != 'SOUR' && $fact != 'NOTE' && $fact != 'SPFX') {
             echo '<dl><dt class="label">', GedcomTag::getLabel($fact, $this->record), '</dt>';
             echo '<dd class="field">';
             // Before using dir="auto" on this field, note that Gecko treats this as an inline element but WebKit treats it as a block element
             if (isset($nmatch[$i][2])) {
                 $name = Filter::escapeHtml($nmatch[$i][2]);
                 $name = str_replace('/', '', $name);
                 $name = preg_replace('/(\\S*)\\*/', '<span class="starredname">\\1</span>', $name);
                 switch ($fact) {
                     case 'TYPE':
                         echo GedcomCodeName::getValue($name, $this->record);
                         break;
                     case 'SURN':
                         // The SURN field is not necessarily the surname.
                         // Where it is not a substring of the real surname, show it after the real surname.
                         $surname = Filter::escapeHtml($primary_name['surname']);
                         if (strpos($primary_name['surname'], str_replace(',', ' ', $nmatch[$i][2])) !== false) {
                             echo '<span dir="auto">' . $surname . '</span>';
                         } else {
                             echo I18N::translate('%1$s (%2$s)', '<span dir="auto">' . $surname . '</span>', '<span dir="auto">' . $name . '</span>');
                         }
                         break;
                     default:
                         echo '<span dir="auto">' . $name . '</span>';
                         break;
                 }
             }
             echo '</dd>';
             echo '</dl>';
         }
         echo '</div>';
     }
     if (preg_match("/\n2 SOUR/", $factrec)) {
         echo '<div id="indi_sour" class="clearfloat">', FunctionsPrintFacts::printFactSources($factrec, 2), '</div>';
     }
     if (preg_match("/\n2 NOTE/", $factrec)) {
         echo '<div id="indi_note" class="clearfloat">', FunctionsPrint::printFactNotes($factrec, 2), '</div>';
     }
     echo '</div>';
 }
Ejemplo n.º 2
0
 /**
  * print fact PLACe TEMPle STATus
  *
  * @param Fact $event gedcom fact record
  * @param bool $anchor to print a link to placelist
  * @param bool $sub_records to print place subrecords
  * @param bool $lds to print LDS TEMPle and STATus
  *
  * @return string HTML
  */
 public static function formatFactPlace(Fact $event, $anchor = false, $sub_records = false, $lds = false)
 {
     if ($anchor) {
         // Show the full place name, for facts/events tab
         $html = '<a href="' . $event->getPlace()->getURL() . '">' . $event->getPlace()->getFullName() . '</a>';
     } else {
         // Abbreviate the place name, for chart boxes
         return ' - ' . $event->getPlace()->getShortName();
     }
     if ($sub_records) {
         $placerec = Functions::getSubRecord(2, '2 PLAC', $event->getGedcom());
         if (!empty($placerec)) {
             if (preg_match_all('/\\n3 (?:_HEB|ROMN) (.+)/', $placerec, $matches)) {
                 foreach ($matches[1] as $match) {
                     $wt_place = new Place($match, $event->getParent()->getTree());
                     $html .= ' - ' . $wt_place->getFullName();
                 }
             }
             $map_lati = "";
             $cts = preg_match('/\\d LATI (.*)/', $placerec, $match);
             if ($cts > 0) {
                 $map_lati = $match[1];
                 $html .= '<br><span class="label">' . GedcomTag::getLabel('LATI') . ': </span>' . $map_lati;
             }
             $map_long = '';
             $cts = preg_match('/\\d LONG (.*)/', $placerec, $match);
             if ($cts > 0) {
                 $map_long = $match[1];
                 $html .= ' <span class="label">' . GedcomTag::getLabel('LONG') . ': </span>' . $map_long;
             }
             if ($map_lati && $map_long) {
                 $map_lati = trim(strtr($map_lati, "NSEW,�", " - -. "));
                 // S5,6789 ==> -5.6789
                 $map_long = trim(strtr($map_long, "NSEW,�", " - -. "));
                 // E3.456� ==> 3.456
                 $html .= ' <a rel="nofollow" href="https://maps.google.com/maps?q=' . $map_lati . ',' . $map_long . '" class="icon-googlemaps" title="' . I18N::translate('Google Maps™') . '"></a>';
                 $html .= ' <a rel="nofollow" href="https://www.bing.com/maps/?lvl=15&cp=' . $map_lati . '~' . $map_long . '" class="icon-bing" title="' . I18N::translate('Bing Maps™') . '"></a>';
                 $html .= ' <a rel="nofollow" href="https://www.openstreetmap.org/#map=15/' . $map_lati . '/' . $map_long . '" class="icon-osm" title="' . I18N::translate('OpenStreetMap™') . '"></a>';
             }
             if (preg_match('/\\d NOTE (.*)/', $placerec, $match)) {
                 $html .= '<br>' . self::printFactNotes($placerec, 3);
             }
         }
     }
     if ($lds) {
         if (preg_match('/2 TEMP (.*)/', $event->getGedcom(), $match)) {
             $html .= '<br>' . I18N::translate('LDS temple') . ': ' . GedcomCodeTemp::templeName($match[1]);
         }
         if (preg_match('/2 STAT (.*)/', $event->getGedcom(), $match)) {
             $html .= '<br>' . I18N::translate('Status') . ': ' . GedcomCodeStat::statusName($match[1]);
             if (preg_match('/3 DATE (.*)/', $event->getGedcom(), $match)) {
                 $date = new Date($match[1]);
                 $html .= ', ' . GedcomTag::getLabel('STAT:DATE') . ': ' . $date->display();
             }
         }
     }
     return $html;
 }
Ejemplo n.º 3
0
 /**
  * Print a fact for an individual.
  *
  * @param Fact $event
  */
 public function printTimeFact(Fact $event)
 {
     global $basexoffset, $baseyoffset, $factcount, $placements;
     $desc = $event->getValue();
     // check if this is a family fact
     $gdate = $event->getDate();
     $date = $gdate->minimumDate();
     $date = $date->convertToCalendar('gregorian');
     $year = $date->y;
     $month = max(1, $date->m);
     $day = max(1, $date->d);
     $xoffset = $basexoffset + 22;
     $yoffset = $baseyoffset + ($year - $this->baseyear) * $this->scale - $this->scale;
     $yoffset = $yoffset + $month / 12 * $this->scale;
     $yoffset = $yoffset + $day / 30 * ($this->scale / 12);
     $yoffset = (int) $yoffset;
     $place = (int) ($yoffset / $this->bheight);
     $i = 1;
     $j = 0;
     $tyoffset = 0;
     while (isset($placements[$place])) {
         if ($i === $j) {
             $tyoffset = $this->bheight * $i;
             $i++;
         } else {
             $tyoffset = -1 * $this->bheight * $j;
             $j++;
         }
         $place = (int) (($yoffset + $tyoffset) / $this->bheight);
     }
     $yoffset += $tyoffset;
     $xoffset += abs($tyoffset);
     $placements[$place] = $yoffset;
     echo "<div id=\"fact{$factcount}\" style=\"position:absolute; " . (I18N::direction() === 'ltr' ? 'left: ' . $xoffset : 'right: ' . $xoffset) . 'px; top:' . $yoffset . "px; font-size: 8pt; height: " . $this->bheight . "px;\" onmousedown=\"factMouseDown(this, '" . $factcount . "', " . ($yoffset - $tyoffset) . ");\">";
     echo '<table cellspacing="0" cellpadding="0" border="0" style="cursor: hand;"><tr><td>';
     echo '<img src="' . Theme::theme()->parameter('image-hline') . '" name="boxline' . $factcount . '" id="boxline' . $factcount . '" height="3" width="10" style="padding-';
     if (I18N::direction() === 'ltr') {
         echo 'left: 3px;">';
     } else {
         echo 'right: 3px;">';
     }
     $col = array_search($event->getParent(), $this->people);
     if ($col === false) {
         // Marriage event - use the color of the husband
         $col = array_search($event->getParent()->getHusband(), $this->people);
     }
     if ($col === false) {
         // Marriage event - use the color of the wife
         $col = array_search($event->getParent()->getWife(), $this->people);
     }
     $col = $col % 6;
     echo '</td><td class="person' . $col . '">';
     if (count($this->people) > 6) {
         // We only have six colours, so show naes if more than this number
         echo $event->getParent()->getFullName() . ' — ';
     }
     $record = $event->getParent();
     echo $event->getLabel();
     echo ' — ';
     if ($record instanceof Individual) {
         echo FunctionsPrint::formatFactDate($event, $record, false, false);
     } elseif ($record instanceof Family) {
         echo $gdate->display();
         if ($record->getHusband() && $record->getHusband()->getBirthDate()->isOK()) {
             $ageh = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getHusband()->getBirthDate(), $gdate));
         } else {
             $ageh = null;
         }
         if ($record->getWife() && $record->getWife()->getBirthDate()->isOK()) {
             $agew = FunctionsDate::getAgeAtEvent(Date::getAgeGedcom($record->getWife()->getBirthDate(), $gdate));
         } else {
             $agew = null;
         }
         if ($ageh && $agew) {
             echo '<span class="age"> ', I18N::translate('Husband’s age'), ' ', $ageh, ' ', I18N::translate('Wife’s age'), ' ', $agew, '</span>';
         } elseif ($ageh) {
             echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>';
         } elseif ($agew) {
             echo '<span class="age"> ', I18N::translate('Age'), ' ', $ageh, '</span>';
         }
     }
     echo ' ' . Filter::escapeHtml($desc);
     if (!$event->getPlace()->isEmpty()) {
         echo ' — ' . $event->getPlace()->getShortName();
     }
     // Print spouses names for family events
     if ($event->getParent() instanceof Family) {
         echo ' — <a href="', $event->getParent()->getHtmlUrl(), '">', $event->getParent()->getFullName(), '</a>';
     }
     echo '</td></tr></table>';
     echo '</div>';
     if (I18N::direction() === 'ltr') {
         $img = 'image-dline2';
         $ypos = '0%';
     } else {
         $img = 'image-dline';
         $ypos = '100%';
     }
     $dyoffset = $yoffset - $tyoffset + $this->bheight / 3;
     if ($tyoffset < 0) {
         $dyoffset = $yoffset + $this->bheight / 3;
         if (I18N::direction() === 'ltr') {
             $img = 'image-dline';
             $ypos = '100%';
         } else {
             $img = 'image-dline2';
             $ypos = '0%';
         }
     }
     // Print the diagonal line
     echo '<div id="dbox' . $factcount . '" style="position:absolute; ' . (I18N::direction() === 'ltr' ? 'left: ' . ($basexoffset + 25) : 'right: ' . ($basexoffset + 25)) . 'px; top:' . $dyoffset . 'px; font-size: 8pt; height: ' . abs($tyoffset) . 'px; width: ' . abs($tyoffset) . 'px;';
     echo ' background-image: url(\'' . Theme::theme()->parameter($img) . '\');';
     echo ' background-position: 0% ' . $ypos . ';">';
     echo '</div>';
 }
Ejemplo n.º 4
0
 /**
  * Print a row for the media tab on the individual page.
  *
  * @param Fact $fact
  * @param int $level
  */
 public static function printMainMedia(Fact $fact, $level)
 {
     $factrec = $fact->getGedcom();
     $parent = $fact->getParent();
     if ($fact->isPendingAddition()) {
         $styleadd = 'new';
         $can_edit = $level == 1 && $fact->canEdit();
     } elseif ($fact->isPendingDeletion()) {
         $styleadd = 'old';
         $can_edit = false;
     } else {
         $styleadd = '';
         $can_edit = $level == 1 && $fact->canEdit();
     }
     // -- find source for each fact
     preg_match_all('/(?:^|\\n)' . $level . ' OBJE @(.*)@/', $factrec, $matches);
     foreach ($matches[1] as $xref) {
         $media = Media::getInstance($xref, $fact->getParent()->getTree());
         // Allow access to "1 OBJE @non_existent_source@", so it can be corrected/deleted
         if (!$media || $media->canShow()) {
             if ($level > 1) {
                 echo '<tr class="row_obje2">';
             } else {
                 echo '<tr>';
             }
             echo '<td class="descriptionbox';
             if ($level > 1) {
                 echo ' rela';
             }
             echo ' ', $styleadd, ' width20">';
             preg_match("/^\\d (\\w*)/", $factrec, $factname);
             $factlines = explode("\n", $factrec);
             // 1 BIRT Y\n2 SOUR ...
             $factwords = explode(" ", $factlines[0]);
             // 1 BIRT Y
             $factname = $factwords[1];
             // BIRT
             if ($factname == 'EVEN' || $factname == 'FACT') {
                 // Add ' EVEN' to provide sensible output for an event with an empty TYPE record
                 $ct = preg_match("/2 TYPE (.*)/", $factrec, $ematch);
                 if ($ct > 0) {
                     $factname = $ematch[1];
                     echo $factname;
                 } else {
                     echo GedcomTag::getLabel($factname, $parent);
                 }
             } elseif ($can_edit) {
                 echo '<a onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '">';
                 echo GedcomTag::getLabel($factname, $parent), '</a>';
                 echo '<div class="editfacts">';
                 echo '<div class="editlink"><a class="editicon" onclick="window.open(\'addmedia.php?action=editmedia&amp;pid=', $media->getXref(), '\', \'_blank\', edit_window_specs); return false;" href="#" title="', I18N::translate('Edit'), '"><span class="link_text">', I18N::translate('Edit'), '</span></a></div>';
                 echo '<div class="copylink"><a class="copyicon" href="#" onclick="jQuery.post(\'action.php\',{action:\'copy-fact\', type:\'\', factgedcom:\'' . rawurlencode($factrec) . '\'},function(){location.reload();})" title="' . I18N::translate('Copy') . '"><span class="link_text">' . I18N::translate('Copy') . '</span></a></div>';
                 echo '<div class="deletelink"><a class="deleteicon" onclick="return delete_fact(\'', I18N::translate('Are you sure you want to delete this fact?'), '\', \'', $parent->getXref(), '\', \'', $fact->getFactId(), '\');" href="#" title="', I18N::translate('Delete'), '"><span class="link_text">', I18N::translate('Delete'), '</span></a></div>';
                 echo '</div>';
             } else {
                 echo GedcomTag::getLabel($factname, $parent);
             }
             echo '</td>';
             echo '<td class="optionbox ', $styleadd, ' wrap">';
             if ($media) {
                 echo '<span class="field">';
                 echo $media->displayImage();
                 echo '<a href="' . $media->getHtmlUrl() . '">';
                 echo '<em>';
                 foreach ($media->getAllNames() as $name) {
                     if ($name['type'] != 'TITL') {
                         echo '<br>';
                     }
                     echo $name['full'];
                 }
                 echo '</em>';
                 echo '</a>';
                 echo '</span>';
                 echo GedcomTag::getLabelValue('FORM', $media->mimeType());
                 $imgsize = $media->getImageAttributes('main');
                 if (!empty($imgsize['WxH'])) {
                     echo GedcomTag::getLabelValue('__IMAGE_SIZE__', $imgsize['WxH']);
                 }
                 if ($media->getFilesizeraw() > 0) {
                     echo GedcomTag::getLabelValue('__FILE_SIZE__', $media->getFilesize());
                 }
                 $mediatype = $media->getMediaType();
                 if ($mediatype) {
                     echo GedcomTag::getLabelValue('TYPE', GedcomTag::getFileFormTypeValue($mediatype));
                 }
                 switch ($media->isPrimary()) {
                     case 'Y':
                         echo GedcomTag::getLabelValue('_PRIM', I18N::translate('yes'));
                         break;
                     case 'N':
                         echo GedcomTag::getLabelValue('_PRIM', I18N::translate('no'));
                         break;
                 }
                 echo FunctionsPrint::printFactNotes($media->getGedcom(), 1);
                 echo self::printFactSources($media->getGedcom(), 1);
             } else {
                 echo $xref;
             }
             echo '</td></tr>';
         }
     }
 }
 /**
  * Based on function print_name_record() in /app/Controller/IndividualController.php
  * 
  * @param Fact $event
  * @return array
  */
 protected function getPrimaryName(Fact $event)
 {
     $factrec = $event->getGedCom();
     // Create a dummy record, so we can extract the formatted NAME value from the event.
     $dummy = new Individual('xref', "0 @xref@ INDI\n1 DEAT Y\n" . $factrec, null, $event->getParent()->getTree());
     $all_names = $dummy->getAllNames();
     return $all_names[0];
 }
Ejemplo n.º 6
0
 /**
  * Create a form to edit a Fact object.
  *
  * @param GedcomRecord $record
  * @param Fact $fact
  *
  * @return string
  */
 public static function createEditForm(GedcomRecord $record, Fact $fact)
 {
     global $tags, $WT_TREE;
     $pid = $record->getXref();
     $tags = array();
     $gedlines = explode("\n", $fact->getGedcom());
     $linenum = 0;
     $fields = explode(' ', $gedlines[$linenum]);
     $glevel = $fields[0];
     $level = $glevel;
     $type = $fact->getTag();
     $parent = $fact->getParent();
     $level0type = $parent::RECORD_TYPE;
     $level1type = $type;
     $i = $linenum;
     $inSource = false;
     $levelSource = 0;
     $add_date = true;
     // List of tags we would expect at the next level
     // NB add_missing_subtags() already takes care of the simple cases
     // where a level 1 tag is missing a level 2 tag. Here we only need to
     // handle the more complicated cases.
     $expected_subtags = array('SOUR' => array('PAGE', 'DATA'), 'DATA' => array('TEXT'), 'PLAC' => array('MAP'), 'MAP' => array('LATI', 'LONG'));
     if ($record->getTree()->getPreference('FULL_SOURCES')) {
         $expected_subtags['SOUR'][] = 'QUAY';
         $expected_subtags['DATA'][] = 'DATE';
     }
     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $record->getTree()->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
         $expected_subtags['PLAC'] = array_merge($match[1], $expected_subtags['PLAC']);
     }
     $stack = array(0 => $level0type);
     // Loop on existing tags :
     while (true) {
         // Keep track of our hierarchy, e.g. 1=>BIRT, 2=>PLAC, 3=>FONE
         $stack[(int) $level] = $type;
         // Merge them together, e.g. BIRT:PLAC:FONE
         $label = implode(':', array_slice($stack, 1, $level));
         $text = '';
         for ($j = 2; $j < count($fields); $j++) {
             if ($j > 2) {
                 $text .= ' ';
             }
             $text .= $fields[$j];
         }
         $text = rtrim($text);
         while ($i + 1 < count($gedlines) && preg_match("/" . ($level + 1) . ' CONT ?(.*)/', $gedlines[$i + 1], $cmatch) > 0) {
             $text .= "\n" . $cmatch[1];
             $i++;
         }
         if ($type === 'SOUR') {
             $inSource = true;
             $levelSource = $level;
         } elseif ($levelSource >= $level) {
             $inSource = false;
         }
         if ($type !== 'DATA' && $type !== 'CONT') {
             $tags[] = $type;
             $person = Individual::getInstance($pid, $WT_TREE);
             $subrecord = $level . ' ' . $type . ' ' . $text;
             if ($inSource && $type === 'DATE') {
                 self::addSimpleTag($subrecord, '', GedcomTag::getLabel($label, $person));
             } elseif (!$inSource && $type === 'DATE') {
                 self::addSimpleTag($subrecord, $level1type, GedcomTag::getLabel($label, $person));
                 if ($level === '2') {
                     // We already have a date - no need to add one.
                     $add_date = false;
                 }
             } elseif ($type === 'STAT') {
                 self::addSimpleTag($subrecord, $level1type, GedcomTag::getLabel($label, $person));
             } elseif ($level0type === 'REPO') {
                 $repo = Repository::getInstance($pid, $WT_TREE);
                 self::addSimpleTag($subrecord, $level0type, GedcomTag::getLabel($label, $repo));
             } else {
                 self::addSimpleTag($subrecord, $level0type, GedcomTag::getLabel($label, $person));
             }
         }
         // Get a list of tags present at the next level
         $subtags = array();
         for ($ii = $i + 1; isset($gedlines[$ii]) && preg_match('/^\\s*(\\d+)\\s+(\\S+)/', $gedlines[$ii], $mm) && $mm[1] > $level; ++$ii) {
             if ($mm[1] == $level + 1) {
                 $subtags[] = $mm[2];
             }
         }
         // Insert missing tags
         if (!empty($expected_subtags[$type])) {
             foreach ($expected_subtags[$type] as $subtag) {
                 if (!in_array($subtag, $subtags)) {
                     if (!$inSource || $subtag !== 'DATA') {
                         self::addSimpleTag($level + 1 . ' ' . $subtag, '', GedcomTag::getLabel($label . ':' . $subtag));
                     }
                     if (!empty($expected_subtags[$subtag])) {
                         foreach ($expected_subtags[$subtag] as $subsubtag) {
                             self::addSimpleTag($level + 2 . ' ' . $subsubtag, '', GedcomTag::getLabel($label . ':' . $subtag . ':' . $subsubtag));
                         }
                     }
                 }
             }
         }
         // Awkward special cases
         if ($level == 2 && $type === 'DATE' && in_array($level1type, Config::dateAndTime()) && !in_array('TIME', $subtags)) {
             self::addSimpleTag('3 TIME');
             // TIME is NOT a valid 5.5.1 tag
         }
         if ($level == 2 && $type === 'STAT' && GedcomCodeTemp::isTagLDS($level1type) && !in_array('DATE', $subtags)) {
             self::addSimpleTag('3 DATE', '', GedcomTag::getLabel('STAT:DATE'));
         }
         $i++;
         if (isset($gedlines[$i])) {
             $fields = explode(' ', $gedlines[$i]);
             $level = $fields[0];
             if (isset($fields[1])) {
                 $type = trim($fields[1]);
             } else {
                 $level = 0;
             }
         } else {
             $level = 0;
         }
         if ($level <= $glevel) {
             break;
         }
     }
     if ($level1type !== '_PRIM') {
         self::insertMissingSubtags($level1type, $add_date);
     }
     return $level1type;
 }