Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(theming): Make sure the footer is hidden if no content is rendered #40597

Merged
merged 2 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions apps/theming/lib/ThemingDefaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,16 @@ public function getDocBaseUrl() {
public function getShortFooter() {
$slogan = $this->getSlogan();
$baseUrl = $this->getBaseUrl();
if ($baseUrl !== '') {
$footer = '<a href="' . $baseUrl . '" target="_blank"' .
' rel="noreferrer noopener" class="entity-name">' . $this->getEntity() . '</a>';
} else {
$footer = '<span class="entity-name">' .$this->getEntity() . '</span>';
$entity = $this->getEntity();
$footer = '';

if ($entity !== '') {
if ($baseUrl !== '') {
$footer = '<a href="' . $baseUrl . '" target="_blank"' .
' rel="noreferrer noopener" class="entity-name">' . $entity . '</a>';
} else {
$footer = '<span class="entity-name">' .$entity . '</span>';
}
}
$footer .= ($slogan !== '' ? ' – ' . $slogan : '');

Expand Down
2 changes: 1 addition & 1 deletion core/css/guest.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/css/guest.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions core/css/guest.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ body {
.wrapper {
width: 100%;
max-width: 700px;
margin-top: 10vh;
margin-block: 10vh auto;
}

/* Default FORM */
Expand Down Expand Up @@ -736,7 +736,6 @@ img.icon-loading-small-dark, object.icon-loading-small-dark, video.icon-loading-

/* FOOTER */
footer {
margin-top: auto;
.info .entity-name {
font-weight: bold;
}
Expand Down
9 changes: 7 additions & 2 deletions core/templates/layout.guest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,14 @@
</main>
</div>
</div>
<footer class="guest-box">
<?php
$longFooter = $theme->getLongFooter();
?>
<footer class="guest-box <?php if ($longFooter === '') {
p('hidden');
} ?>">
<p class="info">
<?php print_unescaped($theme->getLongFooter()); ?>
<?php print_unescaped($longFooter); ?>
</p>
</footer>
</body>
Expand Down
2 changes: 1 addition & 1 deletion core/templates/layout.public.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</h1>
<?php print_unescaped($_['content']); ?>
</main>
<?php if (isset($template) && $template->getFooterVisible()) { ?>
<?php if (isset($template) && $template->getFooterVisible() && ($theme->getLongFooter() !== '' || $_['showSimpleSignUpLink'])) { ?>

Check notice

Code scanning / Psalm

RedundantConditionGivenDocblockType

Docblock-defined type OCP\AppFramework\Http\Template\PublicTemplateResponse for $template is never null
<footer>
<p><?php print_unescaped($theme->getLongFooter()); ?></p>
<?php
Expand Down
12 changes: 10 additions & 2 deletions themes/example/defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,16 @@ public function getSlogan(): string {
* @return string short footer
*/
public function getShortFooter(): string {
$footer = '© ' . date('Y') . ' <a href="' . $this->getBaseUrl() . '" target="_blank">' . $this->getEntity() . '</a>' .
'<br/>' . $this->getSlogan();
$entity = $this->getEntity();

$footer = '© ' . date('Y');

// Add link if entity name is not empty
if ($entity !== '') {
$footer .= ' <a href="' . $this->getBaseUrl() . '" target="_blank">' . $entity . '</a>' . '<br/>';
}

$footer .= $this->getSlogan();

return $footer;
}
Expand Down