app/Report/ReportParserGenerate.php
private function getGedcomValue($tag, $level, $gedrec): string
    {
        if (empty($gedrec)) {
            return '';
        }
        $tags      = explode(':', $tag);
        $origlevel = $level;
        if ($level == 0) {
            $level = $gedrec[0] + 1;
        }

        $subrec = $gedrec;
        foreach ($tags as $t) {
            $lastsubrec = $subrec;
            $subrec     = Functions::getSubRecord($level, "$level $t", $subrec);
            if (empty($subrec) && $origlevel == 0) {
                $level--;
                $subrec = Functions::getSubRecord($level, "$level $t", $lastsubrec);
            }
            if (empty($subrec)) {
                if ($t === 'TITL') {
                    $subrec = Functions::getSubRecord($level, "$level ABBR", $lastsubrec);
                    if (!empty($subrec)) {
                        $t = 'ABBR';
                    }
                }
                if (empty($subrec)) {
                    if ($level > 0) {
                        $level--;
                    }
                    $subrec = Functions::getSubRecord($level, "@ $t", $gedrec);
                    if (empty($subrec)) {
                        return '';
                    }
                }
            }
            $level++;
        }
        $level--;
        $ct = preg_match("/$level $t(.*)/", $subrec, $match);
        if ($ct == 0) {
            $ct = preg_match("/$level @.+@ (.+)/", $subrec, $match);
        }
        if ($ct == 0) {
            $ct = preg_match("/@ $t (.+)/", $subrec, $match);
        }
        if ($ct > 0) {
            $value = trim($match[1]);
            if ($t === 'NOTE' && preg_match('/^@(.+)@$/', $value, $match)) {
                $note = Note::getInstance($match[1], $this->tree);
                if ($note instanceof Note) {
                    $value = $note->getNote();
                } else {
                    //-- set the value to the id without the @
                    $value = $match[1];
                }
            }
            if ($level != 0 || $t != 'NOTE') {
                $value .= Functions::getCont($level + 1, $subrec);
            }

            return $value;
        }

        return '';
    }
private function getGedcomValue($tag, $level, $gedrec): string
    {
        if (empty($gedrec)) {
            return '';
        }
        $tags      = explode(':', $tag);
        $origlevel = $level;
        if ($level == 0) {
            $level = $gedrec[0] + 1;
        }

        $subrec = $gedrec;
        foreach ($tags as $t) {
            $lastsubrec = $subrec;
            $subrec     = Functions::getSubRecord($level, "$level $t", $subrec);
            if (empty($subrec) && $origlevel == 0) {
                $level--;
                $subrec = Functions::getSubRecord($level, "$level $t", $lastsubrec);
            }
            if (empty($subrec)) {
                if ($t === 'TITL') {
                    $subrec = Functions::getSubRecord($level, "$level ABBR", $lastsubrec);
                    if (!empty($subrec)) {
                        $t = 'ABBR';
                    }
                }
                if (empty($subrec)) {
                    if ($level > 0) {
                        $level--;
                    }
                    $subrec = Functions::getSubRecord($level, "@ $t", $gedrec);
                    if (empty($subrec)) {
                        return '';
                    }
                }
            }
            $level++;
        }
        $level--;
        $ct = preg_match("/$level $t(.*)/", $subrec, $match);
        if ($ct == 0) {
            $ct = preg_match("/$level @.+@ (.+)/", $subrec, $match);
        }
        if ($ct == 0) {
            $ct = preg_match("/@ $t (.+)/", $subrec, $match);
        }
        if ($ct > 0) {
            $value = trim($match[1]);
            if ($t === 'NOTE' && preg_match('/^@(.+)@$/', $value, $match)) {
                $note = Note::getInstance($match[1], $this->tree);
                if ($note instanceof Note) {
                    $value = $note->getNote();
                } else {
                    //-- set the value to the id without the @
                    $value = $match[1];
                }
            }
            if ($level != 0 || $t != 'NOTE') {
                $value .= Functions::getCont($level + 1, $subrec);
            }

            return $value;
        }

        return '';
    }
private function getGedcomValue ( $ tag , $ level , $ gedrec ) : string { if ( empty ( $ gedrec ) ) { return '' ; } $ tags = explode ( ':' , $ tag ) ; $ origlevel = $ level ; if ( $ level == 0 ) { $ level = $ gedrec [ 0 ] + 1 ; } $ subrec = $ gedrec ; foreach ( $ tags as $ t ) { $ lastsubrec = $ subrec ; $ subrec = Functions :: getSubRecord ( $ level , "$level $t" , $ subrec ) ; if ( empty ( $ subrec ) && $ origlevel == 0 ) { $ level -- ; $ subrec = Functions :: getSubRecord ( $ level , "$level $t" , $ lastsubrec ) ; } if ( empty ( $ subrec ) ) { if ( $ t === 'TITL' ) { $ subrec = Functions :: getSubRecord ( $ level , "$level ABBR" , $ lastsubrec ) ; if ( ! empty ( $ subrec ) ) { $ t = 'ABBR' ; } } if ( empty ( $ subrec ) ) { if ( $ level > 0 ) { $ level -- ; } $ subrec = Functions :: getSubRecord ( $ level , "@ $t" , $ gedrec ) ; if ( empty ( $ subrec ) ) { return '' ; } } } $ level ++ ; } $ level -- ; $ ct = preg_match ( "/$level $t(.*)/" , $ subrec , $ match ) ; if ( $ ct == 0 ) { $ ct = preg_match ( "/$level @.+@ (.+)/" , $ subrec , $ match ) ; } if ( $ ct == 0 ) { $ ct = preg_match ( "/@ $t (.+)/" , $ subrec , $ match ) ; } if ( $ ct > 0 ) { $ value = trim ( $ match [ 1 ] ) ; if ( $ t === 'NOTE' && preg_match ( '/^@(.+)@$/' , $ value , $ match ) ) { $ note = Note :: getInstance ( $ match [ 1 ] , $ this -> tree ) ; if ( $ note instanceof Note ) { $ value = $ note -> getNote ( ) ; } else { //-- set the value to the id without the @ $ value = $ match [ 1 ] ; } } if ( $ level != 0 || $ t != 'NOTE' ) { $ value .= Functions :: getCont ( $ level + 1 , $ subrec ) ; } return $ value ; } return '' ; }
get gedcom tag value

@param string $tag    The tag to find, use : to delineate subtags
@param int    $level  The gedcom line level of the first tag to find, setting level to 0 will cause it to use 1+ the level of the incoming record
@param string $gedrec The gedcom record to get the value from

@return string the value of a gedcom tag from the given gedcom record
get gedcom tag value