Files

95 lines
2.9 KiB
PHP

<?php
use humhub\modules\space\models\Space;
use humhub\modules\space\widgets\Sidebar as SpaceSidebar;
use humhub\modules\space_profiles\components\TemplateRegistry;
use humhub\modules\space_profiles\models\SpaceProfile;
use humhub\modules\space_profiles\widgets\RescueInfoSidebar;
use yii\web\View;
use yii\helpers\Html;
/* @var Space $space */
/* @var SpaceProfile|null $profile */
/* @var bool $isPublicRoute */
$backgroundStyle = '';
if ($profile && !empty($profile->background_image_path)) {
$backgroundStyle = 'background-image:url(' . Html::encode($profile->background_image_path) . ');background-size:cover;background-position:center;';
}
$searchBlockWidget = '\\humhub\\modules\\animal_management\\widgets\\SearchAnimalProfilesBlock';
$templateView = TemplateRegistry::resolveView($profile ? $profile->template_key : null);
?>
<div class="panel panel-default rescue-profile-scope" style="<?= $backgroundStyle ?>">
<div class="panel-body" style="background:rgba(255,255,255,0.93);border-radius:8px;">
<?php if (!empty($isPublicRoute) && $space->visibility !== Space::VISIBILITY_ALL): ?>
<div class="alert alert-warning">
<?= Yii::t('SpaceProfilesModule.base', 'This profile is visible to signed-in users based on the space privacy setting.') ?>
</div>
<?php endif; ?>
<?php if (!$profile): ?>
<div class="alert alert-info">
<?= Yii::t('SpaceProfilesModule.base', 'This rescue has not published its profile yet.') ?>
</div>
<?php else: ?>
<?= $this->render($templateView, [
'space' => $space,
'profile' => $profile,
]) ?>
<?php endif; ?>
</div>
</div>
<?php $this->beginBlock('sidebar'); ?>
<?php
$sidebarWidgets = [];
if ($profile && class_exists($searchBlockWidget)) {
$sidebarWidgets[] = [$searchBlockWidget, ['contentContainer' => $space], ['sortOrder' => 20]];
}
echo SpaceSidebar::widget([
'space' => $space,
'widgets' => $sidebarWidgets,
]);
?>
<?php $this->endBlock(); ?>
<?php if ($profile): ?>
<div id="space-profile-left-rescue-info" style="display:none;">
<?= RescueInfoSidebar::widget(['space' => $space]) ?>
</div>
<?php
$this->registerJs(<<<JS
(function() {
var panel = document.getElementById('space-profile-left-rescue-info');
if (!panel) {
return;
}
var navContainer = document.querySelector('.layout-nav-container');
if (!navContainer) {
return;
}
var menu = navContainer.querySelector('#space-main-menu');
panel.style.display = 'block';
panel.style.marginTop = '12px';
if (menu && menu.parentNode === navContainer) {
if (menu.nextSibling) {
navContainer.insertBefore(panel, menu.nextSibling);
} else {
navContainer.appendChild(panel);
}
} else {
navContainer.appendChild(panel);
}
})();
JS
, View::POS_END);
?>
<?php endif; ?>