-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c045cfe
commit 38f2a42
Showing
9 changed files
with
638 additions
and
3 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
<!-- A nice orange border around the existing chart box --> | ||
<div style="outline: dashed thick orange"> | ||
<!-- The "::" allows us to use the original view, without being redirected to this file. --> | ||
<?= view('::chart-box', ['individual' => $individual]) ?> | ||
</div> |
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,174 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use Fisharebest\Webtrees\Auth; | ||
use Fisharebest\Webtrees\Elements\UnknownElement; | ||
use Fisharebest\Webtrees\Elements\XrefAssociate; | ||
use Fisharebest\Webtrees\Fact; | ||
use Fisharebest\Webtrees\Family; | ||
use Fisharebest\Webtrees\Gedcom; | ||
use Fisharebest\Webtrees\GedcomRecord; | ||
use Fisharebest\Webtrees\I18N; | ||
use Fisharebest\Webtrees\Individual; | ||
use Fisharebest\Webtrees\Media; | ||
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; | ||
|
||
use Fisharebest\Webtrees\Tree; | ||
|
||
/** | ||
* @var Fact $fact | ||
* @var GedcomRecord $record | ||
*/ | ||
|
||
$parent = $fact->record(); | ||
$tree = $parent->tree(); | ||
[, $tag] = explode(':', $fact->tag()); | ||
$label = $fact->label(); | ||
$value = $fact->value(); | ||
$type = $fact->attribute('TYPE'); | ||
$id = $fact->id(); | ||
|
||
$element = Registry::elementFactory()->make($fact->tag()); | ||
|
||
// New or deleted facts need different styling | ||
$styles = []; | ||
if ($fact->isPendingAddition()) { | ||
$styles[] = 'wt-new'; | ||
} | ||
if ($fact->isPendingDeletion()) { | ||
$styles[] = 'wt-old'; | ||
} | ||
|
||
// Event of close relative | ||
if ($tag === 'EVEN' && $value === 'CLOSE_RELATIVE') { | ||
$value = ''; | ||
$styles[] = 'wt-relation-fact collapse'; | ||
} | ||
|
||
// Event of close associates | ||
if ($id === 'asso') { | ||
$styles[] = 'wt-associate-fact collapse'; | ||
} | ||
|
||
if ($element instanceof UnknownElement && $tree->getPreference('HIDE_GEDCOM_ERRORS') === '0') { | ||
$styles[] = 'd-none'; | ||
} | ||
|
||
|
||
// historical facts | ||
if ($id === 'histo') { | ||
$styles[] = 'wt-historic-fact collapse'; | ||
} | ||
|
||
// Use marriage type as the label. e.g. "Civil partnership" | ||
if ($tag === 'MARR') { | ||
$label = $fact->label(); | ||
$type = ''; | ||
} | ||
|
||
?> | ||
<tr class="<?= implode(' ', $styles) ?>"> | ||
<th scope="row"> | ||
<div class="wt-fact-label ut"><?= $label?></div> | ||
|
||
<?php if ($id !== 'histo' && $id !== 'asso' && $fact->canEdit() && !in_array($tag, ['HUSB', 'WIFE', 'CHIL', 'FAMC', 'FAMS'], true)) : ?> | ||
<?= view('fact-edit-links', ['fact' => $fact, 'url' => $record->url()]) ?> | ||
<?php endif ?> | ||
|
||
<?php if ($tree->getPreference('SHOW_FACT_ICONS') === '1') : ?> | ||
<span class="wt-fact-icon wt-fact-icon-<?= e($tag) ?>" title="<?= strip_tags($label) ?>"></span> | ||
<?php endif ?> | ||
</th> | ||
|
||
<td> | ||
<?php if ($fact->target() instanceof Media) : ?> | ||
<div class="d-flex flex-wrap"> | ||
<?php foreach ($fact->target()->mediaFiles() as $media_file) : ?> | ||
<div class="me-1 mb-1"> | ||
<?= $media_file->displayImage(100, 100, 'contain', []) ?> | ||
</div> | ||
<?php endforeach ?> | ||
</div> | ||
|
||
<a href="<?= e($fact->target()->url()) ?>"><?= $fact->target()->fullName() ?></a> | ||
|
||
<?php foreach ($fact->target()->facts(['NOTE']) as $note) : ?> | ||
<?= view('fact-gedcom-fields', ['gedcom' => $note->gedcom(), 'parent' => $fact->target()->tag(), 'tree' => $fact->record()->tree()]) ?> | ||
<?php endforeach ?> | ||
<?php else : ?> | ||
<div class="wt-fact-main-attributes"> | ||
<?php if ($parent !== $record) : ?> | ||
<div class="wt-fact-record"> | ||
<?php if ($parent instanceof Family) : ?> | ||
<?php foreach ($parent->spouses()->filter(static fn ($individual): bool => $individual !== $record) as $spouse) : ?> | ||
<?php if ($spouse->tree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) : ?> | ||
<div class="wt-chart-box-thumbnail float-start me-1"> | ||
<?= $spouse->displayImage(40, 50, 'crop', ['class' => 'wt-chart-box-thumbnail']) ?> | ||
</div> | ||
<?php endif ?> | ||
<a href="<?= e($spouse->url()) ?>"><?= $spouse->fullName() ?></a> — | ||
<?php endforeach ?> | ||
<a href="<?= e($parent->url()) ?>"><?= I18N::translate('View this family') ?></a> | ||
<?php elseif ($parent instanceof Individual) : ?> | ||
<?php if ($parent->tree()->getPreference('SHOW_HIGHLIGHT_IMAGES')) : ?> | ||
<div class="wt-chart-box-thumbnail float-start me-1"> | ||
<?= $parent->displayImage(40, 50, 'crop', ['class' => 'wt-chart-box-thumbnail']) ?> | ||
</div> | ||
<?php endif ?> | ||
<a href="<?= e($parent->url()) ?>"><?= $parent->fullName() ?></a> | ||
<?php endif ?> | ||
</div> | ||
<?php endif ?> | ||
|
||
<div class="wt-fact-value"> | ||
<?= $element->value($value, $tree) ?> | ||
<?php if ($element instanceof XrefAssociate && $fact->target() instanceof Individual) : ?> | ||
<?php | ||
$module = Registry::container()->get(ModuleService::class)->findByComponent(ModuleChartInterface::class, $tree, Auth::user()) | ||
->first(static fn (ModuleInterface $module): bool => $module instanceof RelationshipsChartModule) | ||
?> | ||
|
||
<?php if ($module instanceof RelationshipsChartModule && $record instanceof Individual) : ?> | ||
— <a href="<?= $module->chartUrl($fact->target(), ['xref2' => $record->xref()]) ?>" rel="nofollow"> | ||
<?= Registry::container()->get(RelationshipService::class)->getCloseRelationshipName($record, $fact->target()) ?> | ||
</a> | ||
<?php endif ?> | ||
<?php endif ?> | ||
</div> | ||
|
||
<!-- Type of this fact/event (allow user-translations) --> | ||
<?php if ($type !== '' && $tag !== 'EVEN' && $tag !== 'FACT') : ?> | ||
<div class="wt-fact-type"> | ||
<?= Registry::elementFactory()->make($fact->tag() . ':TYPE')->labelValue(I18N::translate($type), $tree) ?> | ||
</div> | ||
<?php endif ?> | ||
|
||
<?= view('fact-date', ['cal_link' => 'true', 'fact' => $fact, 'record' => $record, 'time' => true]) ?> | ||
<?= view('fact-place', ['fact' => $fact, 'record' => $record]) ?> | ||
</div> | ||
|
||
<div class="wt-fact-other-attributes mt-2"> | ||
<?php preg_match_all('/\n2 (' . Gedcom::REGEX_TAG . ')( .*)?((\n[3-9].*)*)/', $fact->gedcom(), $matches, PREG_SET_ORDER) ?> | ||
<?php foreach ($matches as $match) : ?> | ||
<?php if (!in_array($match[1], ['DATE', 'AGE', 'HUSB', 'WIFE', 'PLAC', 'ASSO', '_ASSO', 'STAT', 'TEMP', 'TYPE', 'CONT', 'NOTE', 'OBJE', 'SOUR'], true)) : ?> | ||
<?= view('fact-gedcom-fields', ['gedcom' => $match[0], 'parent' => $fact->tag() . ':' . $match[1], 'tree' => $tree]) ?> | ||
<?php endif ?> | ||
<?php endforeach; ?> | ||
</div> | ||
|
||
<?php if ($id !== 'asso') : ?> | ||
<?= view('fact-associates', ['fact' => $fact]) ?> | ||
<?php endif ?> | ||
|
||
<?= view('fact-sources', ['fact' => $fact]) ?> | ||
<?= view('fact-notes', ['fact' => $fact]) ?> | ||
<?= view('fact-media', ['fact' => $fact]) ?> | ||
<?php endif ?> | ||
</td> | ||
</tr> |
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,148 @@ | ||
<?php | ||
$view = view('::individual-page', get_defined_vars()); | ||
|
||
// Extract the image | ||
$pattern = '/<div[^>]*>\s*<a class="gallery".*?<\/div>/s'; | ||
preg_match($pattern, $view, $matches); | ||
$galleryDiv = $matches[0] ?? ''; | ||
|
||
// Extract the image link | ||
$imageLinkPattern = '/src="([^"]+)"/'; | ||
preg_match($imageLinkPattern, $galleryDiv, $imageLinkMatches); | ||
$imageLink = $imageLinkMatches[1] ?? ''; | ||
|
||
// Extract the link URL and text | ||
$linkPattern = '/<div class="text-center">\s*<a href="([^"]+)">\s*(.*?)\s*<\/a>/s'; | ||
preg_match($linkPattern, $galleryDiv, $linkMatches); | ||
$linkURL = $linkMatches[1] ?? ''; | ||
$linkText = $linkMatches[2] ?? ''; | ||
|
||
// Extract the title | ||
$pattern = '/<h2 class="wt-page-title.*?<\/h2>/s'; | ||
preg_match($pattern, $view, $matches); | ||
$pageTitleDiv = $matches[0] ?? ''; | ||
|
||
// Modify the view to place the image and title in a grid | ||
$view = preg_replace($pattern, '<div class="navbar-grid mx-auto">' . | ||
'<div class="grid-title" style="font-size: 50%; padding-left: 15px">' . $pageTitleDiv . '</div>' . | ||
'</div>', $view); | ||
|
||
// Pass the $imageLink variable to the modified view | ||
$view = str_replace('$imageLink', $imageLink, $view); | ||
|
||
// Extract the original navbar background color and box shadow | ||
$originalNavbar = '<header class="wt-header-wrapper'; | ||
preg_match('/<header class="wt-header-wrapper[^"]+" style="background-color:(#[^"]+);[^"]+box-shadow:([^"]+)"/', $view, $matches); | ||
$navbarBackgroundColor = $matches[1] ?? ''; | ||
$navbarBoxShadow = $matches[2] ?? ''; | ||
|
||
// Display the modified view | ||
echo $view; | ||
?> | ||
|
||
|
||
<style> | ||
.fixed-navbar h2 { | ||
font-size: 16px; | ||
} | ||
|
||
.navbar-grid { | ||
display: grid; | ||
grid-template-columns: auto auto; | ||
align-items: center; | ||
} | ||
|
||
.navbar-grid .grid-image img { | ||
width: 150px; | ||
} | ||
|
||
.fixed-navbar { | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
z-index: 99; /* Lower z-index to position the fixed navbar below the original navbar */ | ||
opacity: 0; | ||
transition: opacity 0.3s ease; | ||
background-color: <?= $navbarBackgroundColor ?>; | ||
box-shadow: <?= $navbarBoxShadow ?>; | ||
} | ||
|
||
.navbar-content { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
padding: 10px; | ||
background-color: #ffffff; | ||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.navbar-content .grid-image { | ||
margin-right: 10px; | ||
} | ||
|
||
.grid-title { | ||
font-size: 50%; | ||
} | ||
|
||
.wt-page-title.mx-auto { | ||
margin-bottom: auto; | ||
} | ||
|
||
.wt-header-wrapper { | ||
pointer-events: auto; | ||
} | ||
|
||
/* #individual-names { | ||
display: none; | ||
} */ | ||
|
||
/* div:has(> a.gallery) { | ||
display: none; | ||
} */ | ||
|
||
@media (min-width: 768px) { | ||
main { | ||
padding-top: 20px; | ||
} | ||
.wt-header-container { | ||
margin-top: 1rem; | ||
} | ||
} | ||
@media (max-width: 767px) { | ||
main { | ||
padding-top: 0px; | ||
} | ||
[dir] .wt-header-container { | ||
margin-top: 0px; | ||
} | ||
} | ||
</style> | ||
|
||
<script> | ||
window.addEventListener('scroll', function() { | ||
var navbarGrid = document.querySelector('.navbar-grid'); | ||
var navbar = document.querySelector('.wt-header-wrapper'); | ||
var fixedNavbar = document.querySelector('.fixed-navbar'); | ||
|
||
if (navbarGrid && navbar && fixedNavbar) { | ||
var navbarGridOffsetTop = navbarGrid.offsetTop + 75; // Adjust the offset value here | ||
var scrollTop = window.pageYOffset || document.documentElement.scrollTop; | ||
|
||
if (scrollTop >= navbarGridOffsetTop && fixedNavbar.style.opacity !== '1') { | ||
navbar.style.opacity = '0'; | ||
fixedNavbar.style.opacity = '1'; | ||
} else if (scrollTop < navbarGridOffsetTop && fixedNavbar.style.opacity !== '0') { | ||
navbar.style.opacity = '1'; | ||
fixedNavbar.style.opacity = '0'; | ||
} | ||
} | ||
}); | ||
</script> | ||
|
||
<div class="fixed-navbar"> | ||
<div class="navbar-content mx-auto"> | ||
<div class="grid-image"><img src="<?= $imageLink ?>" alt="Image" height="40px"></div> | ||
<div class="grid-title"><?= $pageTitleDiv ?></div> | ||
</div> | ||
</div> |
Oops, something went wrong.