From 4d9d617c840431568fc17540937b231b1bc2d698 Mon Sep 17 00:00:00 2001 From: skjnldsv Date: Fri, 8 Nov 2024 08:57:22 +0100 Subject: [PATCH] feat(files_sharing): use share node or label as page title Signed-off-by: skjnldsv --- .../files_sharing/lib/DefaultPublicShareTemplateProvider.php | 4 ++++ apps/files_sharing/tests/Controller/ShareControllerTest.php | 3 +++ core/templates/layout.public.php | 5 +++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php index dad1f332458..0c76f0e1742 100644 --- a/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php +++ b/apps/files_sharing/lib/DefaultPublicShareTemplateProvider.php @@ -130,12 +130,16 @@ class DefaultPublicShareTemplateProvider implements IPublicShareTemplateProvider 'index', ); $response->setContentSecurityPolicy($csp); + // If the share has a label, use it as the title if ($share->getLabel() !== '') { $response->setHeaderTitle($share->getLabel()); + $response->setParams(['pageTitle' => $share->getLabel()]); } else { $response->setHeaderTitle($shareNode->getName()); + $response->setParams(['pageTitle' => $shareNode->getName()]); } + if ($ownerName !== '') { $response->setHeaderDetails($this->l10n->t('shared by %s', [$ownerName])); } diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 5d962dff4c0..bc8e5dede63 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -338,6 +338,7 @@ class ShareControllerTest extends \Test\TestCase { $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $expectedResponse = new PublicTemplateResponse('files', 'index'); + $expectedResponse->setParams(['pageTitle' => $filename]); $expectedResponse->setContentSecurityPolicy($csp); $expectedResponse->setHeaderTitle($filename); $expectedResponse->setHeaderDetails('shared by ownerDisplay'); @@ -477,6 +478,7 @@ class ShareControllerTest extends \Test\TestCase { $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $expectedResponse = new PublicTemplateResponse('files', 'index'); + $expectedResponse->setParams(['pageTitle' => $filename]); $expectedResponse->setContentSecurityPolicy($csp); $expectedResponse->setHeaderTitle($filename); $expectedResponse->setHeaderDetails('shared by ownerDisplay'); @@ -604,6 +606,7 @@ class ShareControllerTest extends \Test\TestCase { $csp = new ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); $expectedResponse = new PublicTemplateResponse('files', 'index'); + $expectedResponse->setParams(['pageTitle' => $filename]); $expectedResponse->setContentSecurityPolicy($csp); $expectedResponse->setHeaderTitle($filename); $expectedResponse->setHeaderDetails(''); diff --git a/core/templates/layout.public.php b/core/templates/layout.public.php index e2ed47d0716..bd46ee4f7fc 100644 --- a/core/templates/layout.public.php +++ b/core/templates/layout.public.php @@ -9,8 +9,9 @@ - <?php - p(!empty($_['application']) ? $_['application'] . ' - ' : ''); + <?php + p(!empty($_['pageTitle']) && $_['pageTitle'] !== $_['application'] ? $_['pageTitle'] . ' - ' : ''); +p(!empty($_['application']) ? $_['application'] . ' - ' : ''); p($theme->getTitle()); ?> -- 2.39.5