nonDateFacts() public static method

Tags that don't require a DATE subtag
public static nonDateFacts ( ) : string[]
return string[]
Esempio n. 1
0
 /**
  * Populates the global $tags array with any missing sub-tags.
  *
  * @param string $level1tag the type of the level 1 gedcom record
  * @param bool $add_date
  */
 public static function insertMissingSubtags($level1tag, $add_date = false)
 {
     global $tags, $WT_TREE;
     // handle  MARRiage TYPE
     $type_val = '';
     if (substr($level1tag, 0, 5) === 'MARR_') {
         $type_val = substr($level1tag, 5);
         $level1tag = 'MARR';
     }
     foreach (Config::levelTwoTags() as $key => $value) {
         if ($key === 'DATE' && in_array($level1tag, Config::nonDateFacts()) || $key === 'PLAC' && in_array($level1tag, Config::nonPlaceFacts())) {
             continue;
         }
         if (in_array($level1tag, $value) && !in_array($key, $tags)) {
             if ($key === 'TYPE') {
                 self::addSimpleTag('2 TYPE ' . $type_val, $level1tag);
             } elseif ($level1tag === '_TODO' && $key === 'DATE') {
                 self::addSimpleTag('2 ' . $key . ' ' . strtoupper(date('d M Y')), $level1tag);
             } elseif ($level1tag === '_TODO' && $key === '_WT_USER') {
                 self::addSimpleTag('2 ' . $key . ' ' . Auth::user()->getUserName(), $level1tag);
             } elseif ($level1tag === 'TITL' && strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $key) !== false) {
                 self::addSimpleTag('2 ' . $key, $level1tag);
             } elseif ($level1tag === 'NAME' && strstr($WT_TREE->getPreference('ADVANCED_NAME_FACTS'), $key) !== false) {
                 self::addSimpleTag('2 ' . $key, $level1tag);
             } elseif ($level1tag !== 'TITL' && $level1tag !== 'NAME') {
                 self::addSimpleTag('2 ' . $key, $level1tag);
             }
             // Add level 3/4 tags as appropriate
             switch ($key) {
                 case 'PLAC':
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
                         foreach ($match[1] as $tag) {
                             self::addSimpleTag('3 ' . $tag, '', GedcomTag::getLabel($level1tag . ':PLAC:' . $tag));
                         }
                     }
                     self::addSimpleTag('3 MAP');
                     self::addSimpleTag('4 LATI');
                     self::addSimpleTag('4 LONG');
                     break;
                 case 'FILE':
                     self::addSimpleTag('3 FORM');
                     break;
                 case 'EVEN':
                     self::addSimpleTag('3 DATE');
                     self::addSimpleTag('3 PLAC');
                     break;
                 case 'STAT':
                     if (GedcomCodeTemp::isTagLDS($level1tag)) {
                         self::addSimpleTag('3 DATE', '', GedcomTag::getLabel('STAT:DATE'));
                     }
                     break;
                 case 'DATE':
                     // TIME is NOT a valid 5.5.1 tag
                     if (in_array($level1tag, Config::dateAndTime())) {
                         self::addSimpleTag('3 TIME');
                     }
                     break;
                 case 'HUSB':
                 case 'WIFE':
                     self::addSimpleTag('3 AGE');
                     break;
                 case 'FAMC':
                     if ($level1tag === 'ADOP') {
                         self::addSimpleTag('3 ADOP BOTH');
                     }
                     break;
             }
         } elseif ($key === 'DATE' && $add_date) {
             self::addSimpleTag('2 DATE', $level1tag, GedcomTag::getLabel($level1tag . ':DATE'));
         }
     }
     // Do something (anything!) with unrecognized custom tags
     if (substr($level1tag, 0, 1) === '_' && $level1tag !== '_UID' && $level1tag !== '_TODO') {
         foreach (array('DATE', 'PLAC', 'ADDR', 'AGNC', 'TYPE', 'AGE') as $tag) {
             if (!in_array($tag, $tags)) {
                 self::addSimpleTag('2 ' . $tag);
                 if ($tag === 'PLAC') {
                     if (preg_match_all('/(' . WT_REGEX_TAG . ')/', $WT_TREE->getPreference('ADVANCED_PLAC_FACTS'), $match)) {
                         foreach ($match[1] as $ptag) {
                             self::addSimpleTag('3 ' . $ptag, '', GedcomTag::getLabel($level1tag . ':PLAC:' . $ptag));
                         }
                     }
                     self::addSimpleTag('3 MAP');
                     self::addSimpleTag('4 LATI');
                     self::addSimpleTag('4 LONG');
                 }
             }
         }
     }
 }