-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option whether to crop thumbnails.
- Loading branch information
Showing
8 changed files
with
406 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Fisharebest\Webtrees\Auth; | ||
use Fisharebest\Webtrees\Fact; | ||
use Fisharebest\Webtrees\Gedcom; | ||
use Fisharebest\Webtrees\I18N; | ||
use Fisharebest\Webtrees\Individual; | ||
use Fisharebest\Webtrees\Menu; | ||
use Fisharebest\Webtrees\Module\ModuleChartInterface; | ||
use Fisharebest\Webtrees\Services\ModuleService; | ||
use Illuminate\Support\Collection; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
/** | ||
* @var Individual|null $individual | ||
* @var ModuleService $module_service | ||
* @var Collection|Menu[] $menus | ||
*/ | ||
|
||
if ($individual === null) { | ||
echo '<div class="wt-chart-box"></div>'; | ||
|
||
return; | ||
} | ||
|
||
$module_service = app(ModuleService::class); | ||
|
||
$menus = $module_service->findByComponent(ModuleChartInterface::class, $individual->tree(), Auth::user())->map(static function (ModuleChartInterface $module) use ($individual): ?Menu { | ||
return $module->chartBoxMenu($individual); | ||
})->filter(); | ||
|
||
foreach ($individual->spouseFamilies() as $family) { | ||
$menus->push(new Menu('<strong>' . I18N::translate('Family with spouse') . '</strong>', $family->url())); | ||
$spouse = $family->spouse($individual); | ||
if ($spouse && $spouse->canShow()) { | ||
$menus->push(new Menu($spouse->fullName(), $spouse->url())); | ||
} | ||
foreach ($family->children() as $child) { | ||
if ($child->canShow()) { | ||
$menus->push(new Menu($child->fullName(), $child->url())); | ||
} | ||
} | ||
} | ||
|
||
// Do not show these facts in the expanded chart boxes. | ||
$exclude = [ | ||
'ADDR', | ||
'ALIA', | ||
'ASSO', | ||
'CHAN', | ||
'CHIL', | ||
'EMAIL', | ||
'FAMC', | ||
'FAMS', | ||
'HUSB', | ||
'NAME', | ||
'NOTE', | ||
'OBJE', | ||
'PHON', | ||
'RESI', | ||
'RESN', | ||
'SEX', | ||
'SOUR', | ||
'SSN', | ||
'SUBM', | ||
'TITL', | ||
'URL', | ||
'WIFE', | ||
'WWW', | ||
'_EMAIL', | ||
'_TODO', | ||
'_UID', | ||
'_WT_OBJE_SORT', | ||
]; | ||
|
||
/** @var Collection|Fact[] $all_facts */ | ||
$all_facts = $individual->facts(); | ||
foreach ($individual->spouseFamilies() as $family) { | ||
foreach ($family->facts() as $fact) { | ||
$all_facts->push($fact); | ||
} | ||
} | ||
|
||
$all_facts = $all_facts->filter(static function (Fact $fact) use ($exclude): bool { | ||
return !in_array($fact->getTag(), $exclude, true); | ||
}); | ||
|
||
$all_facts = Fact::sortFacts($all_facts); | ||
|
||
$id = Uuid::uuid4()->toString(); | ||
?> | ||
|
||
<div class="wt-chart-box wt-chart-box-<?= strtolower($individual->sex()) ?> <?= $individual->isPendingAddition() ? 'wt-new' : '' ?> <?= $individual->isPendingDeletion() ? 'wt-old' : '' ?> overflow-hidden" data-xref="<?= e($individual->xref()) ?>" data-tree="<?= e($individual->tree()->name()) ?>"> | ||
<?php if ($individual->canShow() && $individual->tree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) : ?> | ||
<div class="wt-chart-box-thumbnail float-left mr-1"> | ||
<?php | ||
//[RC] adjusted: do not 'crop' | ||
?> | ||
<?= $individual->displayImage(40, 50, 'contain', ['class' => 'wt-chart-box-thumbnail']) ?> | ||
</div> | ||
<?php endif ?> | ||
|
||
<?php if ($individual->canShow()) : ?> | ||
<div class="wt-chart-box-extra d-print-none float-right ml-1"> | ||
<div class="dropdown position-static wt-chart-box-zoom"> | ||
<a class="wt-chart-box-icon" href="#" role="button" id="chart-box-zoom-<?= $id ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
<div ><?= view('icons/zoom-in') ?></div> | ||
<div class="d-none"><?= view('icons/zoom-out') ?></div> | ||
<span class="sr-only"><?= I18N::translate('Links') ?></span> | ||
</a> | ||
|
||
<div class="dropdown-menu dropdown-menu-right wt-chart-box-dropdown wt-chart-box-zoom-dropdown" style="position: inherit" aria-labelledby="#chart-box-zoom-<?= $id ?>"> | ||
<?php foreach ($all_facts as $fact) : ?> | ||
<?= $fact->summary() ?> | ||
<?php endforeach ?> | ||
</div> | ||
</div> | ||
|
||
<div class="dropdown position-static wt-chart-box-links"> | ||
<a class="wt-chart-box-icon" href="#" role="button" id="chart-box-menu-<?= $id ?>" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> | ||
<i class="icon-pedigree" title="<?= I18N::translate('Links') ?>"></i> | ||
<span class="sr-only"><?= I18N::translate('Links') ?></span> | ||
</a> | ||
|
||
<div class="dropdown-menu dropdown-menu-right wt-chart-box-dropdown wt-chart-box-links-dropdown" style="position: inherit" aria-labelledby="#chart-box-menu-<?= $id ?>"> | ||
<?php foreach ($menus as $menu) : ?> | ||
<a class="dropdown-item p-1 <?= e($menu->getClass()) ?>" href="<?= e($menu->getLink()) ?>"> | ||
<?= $menu->getLabel() ?> | ||
</a> | ||
<?php endforeach ?> | ||
</div> | ||
</div> | ||
</div> | ||
<?php endif ?> | ||
|
||
<div class="wt-chart-box-name font-weight-bold"> | ||
<?php if ($individual->canShow()) : ?> | ||
<a href="<?= e($individual->url()) ?>" class="wt-chart-box-name"><?= $individual->fullName() ?></a> | ||
<?php else : ?> | ||
<span class="wt-chart-box-name"><?= $individual->fullName() ?></span> | ||
<?php endif ?> | ||
</div> | ||
|
||
<div class="wt-chart-box-name font-weight-bold"> | ||
<?= $individual->alternateName() ?> | ||
</div> | ||
|
||
<div class="wt-chart-box-lifespan"> | ||
<?= $individual->lifespan() ?> | ||
</div> | ||
|
||
<div class="wt-chart-box-facts"> | ||
<div class="wt-chart-box-fact small"> | ||
<?php | ||
$opt_tags = preg_split('/\W/', $individual->tree()->getPreference('CHART_BOX_TAGS'), 0, PREG_SPLIT_NO_EMPTY); | ||
// Show BIRT or equivalent event | ||
|
||
foreach (Gedcom::BIRTH_EVENTS as $birttag) { | ||
if (!in_array($birttag, $opt_tags, true)) { | ||
$event = $individual->facts([$birttag])->first(); | ||
if ($event instanceof Fact) { | ||
echo $event->summary(); | ||
break; | ||
} | ||
} | ||
} | ||
// Show optional events (before death) | ||
foreach ($opt_tags as $key => $tag) { | ||
if (!in_array($tag, Gedcom::DEATH_EVENTS, true)) { | ||
$event = $individual->facts([$tag])->first(); | ||
if ($event instanceof Fact) { | ||
echo $event->summary(); | ||
unset($opt_tags[$key]); | ||
} | ||
} | ||
} | ||
// Show DEAT or equivalent event | ||
foreach (Gedcom::DEATH_EVENTS as $deattag) { | ||
$event = $individual->facts([$deattag])->first(); | ||
if ($event instanceof Fact) { | ||
echo $event->summary(); | ||
if (in_array($deattag, $opt_tags, true)) { | ||
unset($opt_tags[array_search($deattag, $opt_tags, true)]); | ||
} | ||
break; | ||
} | ||
} | ||
// Show remaining optional events (after death) | ||
foreach ($opt_tags as $tag) { | ||
$event = $individual->facts([$tag])->first(); | ||
if ($event instanceof Fact) { | ||
echo $event->summary(); | ||
} | ||
} | ||
?> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.