From 8a13851da8906a4eed3c7b59d01f5a172c90371c Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Thu, 25 Jan 2018 18:53:09 +0100 Subject: Use PublicTemplateResponse for files_sharing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../lib/Controller/ShareController.php | 16 ++++++- .../lib/Template/ExternalShareMenuAction.php | 54 ++++++++++++++++++++++ apps/files_sharing/lib/Template/LinkMenuAction.php | 47 +++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 apps/files_sharing/lib/Template/ExternalShareMenuAction.php create mode 100644 apps/files_sharing/lib/Template/LinkMenuAction.php (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 795d069c1b8..0b0c551a153 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -38,6 +38,10 @@ namespace OCA\Files_Sharing\Controller; use OC_Files; use OC_Util; use OCA\FederatedFileSharing\FederatedShareProvider; +use OCA\Files_Sharing\Template\ExternalShareMenuAction; +use OCA\Files_Sharing\Template\LinkMenuAction; +use OCP\AppFramework\Http\Template\SimpleMenuAction; +use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\Defaults; use OCP\IL10N; use OCP\Template; @@ -435,7 +439,17 @@ class ShareController extends Controller { $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); - $response = new TemplateResponse($this->appName, 'public', $shareTmpl, 'base'); + + $response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl); + $response->setHeaderTitle($share->getNode()->getName()); + $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['displayName']])); + $response->setHeaderActions([ + new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0), + new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $shareTmpl['downloadURL'], 10, $shareTmpl['fileSize']), + new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $shareTmpl['previewURL']), + new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $shareTmpl['owner'], $shareTmpl['displayName'], $shareTmpl['filename']), + ]); + $response->setContentSecurityPolicy($csp); $this->emitAccessShareHook($share); diff --git a/apps/files_sharing/lib/Template/ExternalShareMenuAction.php b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php new file mode 100644 index 00000000000..a81712cb591 --- /dev/null +++ b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php @@ -0,0 +1,54 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Files_Sharing\Template; + +use OCP\AppFramework\Http\Template\SimpleMenuAction; +use OCP\Util; + +class ExternalShareMenuAction extends SimpleMenuAction { + + private $owner; + private $displayname; + private $shareName; + + public function __construct($label, $icon, $owner, $displayname, $shareName) { + parent::__construct('save', $label, $icon); + $this->owner = $owner; + $this->displayname = $displayname; + $this->shareName = $shareName; + } + + public function render(): string { + return '
  • ' . + '' . + '' . + '' . Util::sanitizeHTML($this->getLabel()) . '' . + '' . + '' . + '
  • '; + } +} \ No newline at end of file diff --git a/apps/files_sharing/lib/Template/LinkMenuAction.php b/apps/files_sharing/lib/Template/LinkMenuAction.php new file mode 100644 index 00000000000..af5fda94455 --- /dev/null +++ b/apps/files_sharing/lib/Template/LinkMenuAction.php @@ -0,0 +1,47 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ + +namespace OCA\Files_Sharing\Template; + +use OCP\AppFramework\Http\Template\SimpleMenuAction; + +class LinkMenuAction extends SimpleMenuAction { + + public function __construct($label, $icon, $link) { + parent::__construct('directLink-container', $label, $icon, $link); + } + + /** + * @since 14.0.0 + * @return string + */ + public function render(): string { + return '
  • ' . + '' . + '' . + '' . + '' . + '' . + '
  • '; + } +} \ No newline at end of file -- cgit v1.2.3 From 4f83462f6788b863bdeaa1e29c344dfc7550698c Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 9 Feb 2018 09:20:11 +0100 Subject: Add phpdoc, typehints and sanitize HTML MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../lib/Template/ExternalShareMenuAction.php | 16 ++++- apps/files_sharing/lib/Template/LinkMenuAction.php | 17 +++-- .../Http/Template/SimpleMenuAction.php | 74 ++++++++++++++++++++-- 3 files changed, 96 insertions(+), 11 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Template/ExternalShareMenuAction.php b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php index a81712cb591..f548a3bc6f1 100644 --- a/apps/files_sharing/lib/Template/ExternalShareMenuAction.php +++ b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php @@ -28,11 +28,25 @@ use OCP\Util; class ExternalShareMenuAction extends SimpleMenuAction { + /** @var string */ private $owner; + + /** @var string */ private $displayname; + + /** @var string */ private $shareName; - public function __construct($label, $icon, $owner, $displayname, $shareName) { + /** + * ExternalShareMenuAction constructor. + * + * @param string $label + * @param string $icon + * @param string $owner + * @param string $displayname + * @param string $shareName + */ + public function __construct(string $label, string $icon, string $owner, string $displayname, string $shareName) { parent::__construct('save', $label, $icon); $this->owner = $owner; $this->displayname = $displayname; diff --git a/apps/files_sharing/lib/Template/LinkMenuAction.php b/apps/files_sharing/lib/Template/LinkMenuAction.php index af5fda94455..b75d8c2f790 100644 --- a/apps/files_sharing/lib/Template/LinkMenuAction.php +++ b/apps/files_sharing/lib/Template/LinkMenuAction.php @@ -24,23 +24,30 @@ namespace OCA\Files_Sharing\Template; use OCP\AppFramework\Http\Template\SimpleMenuAction; +use OCP\Util; class LinkMenuAction extends SimpleMenuAction { - public function __construct($label, $icon, $link) { + /** + * LinkMenuAction constructor. + * + * @param string $label + * @param string $icon + * @param string $link + */ + public function __construct(string $label, string $icon, string $link) { parent::__construct('directLink-container', $label, $icon, $link); } /** - * @since 14.0.0 * @return string */ public function render(): string { return '
  • ' . '' . - '' . - '' . - '' . + '' . + '' . + '' . '' . '
  • '; } diff --git a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php index c5cbd9a032c..087887eed51 100644 --- a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php +++ b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php @@ -23,18 +23,43 @@ namespace OCP\AppFramework\Http\Template; -use OCP\AppFramework\Http\Template\IMenuAction; -use Twig_Environment; +use OCP\Util; +/** + * Class SimpleMenuAction + * + * @package OCP\AppFramework\Http\Template + */ class SimpleMenuAction implements IMenuAction { + /** @var string */ private $id; + + /** @var string */ private $label; + + /** @var string */ private $icon; + + /** @var string */ private $link; - private $priority = 100; + + /** @var int */ + private $priority; + + /** @var string */ private $detail; + /** + * SimpleMenuAction constructor. + * + * @param string $id + * @param string $label + * @param string $icon + * @param string $link + * @param int $priority + * @param string $detail + */ public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { $this->id = $id; $this->label = $label; @@ -44,53 +69,92 @@ class SimpleMenuAction implements IMenuAction { $this->detail = $detail; } + /** + * @param string $id + */ public function setId(string $id) { $this->id = $id; } + /** + * @param string $label + */ public function setLabel(string $label) { $this->label = $label; } + /** + * @param string $detail + */ public function setDetail(string $detail) { $this->detail = $detail; } + /** + * @param string $icon + */ public function setIcon(string $icon) { $this->icon = $icon; } + /** + * @param string $link + */ public function setLink(string $link) { $this->link = $link; } + /** + * @param int $priority + */ public function setPriority(int $priority) { $this->priority = $priority; } + /** + * @return string + */ public function getId(): string { return $this->id; } + /** + * @return string + */ public function getLabel(): string { return $this->label; } + /** + * @return string + */ public function getIcon(): string { return $this->icon; } + /** + * @return string + */ public function getLink(): string { return $this->link; } + /** + * @return int + */ public function getPriority(): int { return $this->priority; } + /** + * @return string + */ public function render(): string { - $detailContent = ($this->detail !== '') ? ' (' . $this->detail . ')' : ''; - return sprintf('
  • %s %s
  • ', $this->link, $this->icon, $this->label, $detailContent); + $detailContent = ($this->detail !== '') ? ' (' . Util::sanitizeHTML($this->detail) . ')' : ''; + return sprintf( + '
  • %s %s
  • ', + Util::sanitizeHTML($this->link), Util::sanitizeHTML($this->icon), Util::sanitizeHTML($this->label), Util::sanitizeHTML($detailContent) + ); } } \ No newline at end of file -- cgit v1.2.3 From 038aad73c77468244ed3b50d2d82e9a263dead0e Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 9 Feb 2018 09:41:04 +0100 Subject: Add missing phpdoc for public API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- apps/files_sharing/lib/Template/LinkMenuAction.php | 20 ++++----- .../Http/Template/PublicTemplateResponse.php | 52 +++++++++++++++++++++- .../Http/Template/SimpleMenuAction.php | 14 ++++++ 3 files changed, 75 insertions(+), 11 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Template/LinkMenuAction.php b/apps/files_sharing/lib/Template/LinkMenuAction.php index b75d8c2f790..2fdf83e7026 100644 --- a/apps/files_sharing/lib/Template/LinkMenuAction.php +++ b/apps/files_sharing/lib/Template/LinkMenuAction.php @@ -6,18 +6,18 @@ * * @license GNU AGPL version 3 or any later version * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . * */ diff --git a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php index 2a209c88b9f..2f2d47d7bca 100644 --- a/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php +++ b/lib/public/AppFramework/Http/Template/PublicTemplateResponse.php @@ -25,33 +25,67 @@ namespace OCP\AppFramework\Http\Template; use OCP\AppFramework\Http\TemplateResponse; +/** + * Class PublicTemplateResponse + * + * @package OCP\AppFramework\Http\Template + * @since 14.0.0 + */ class PublicTemplateResponse extends TemplateResponse { private $headerTitle = ''; private $headerDetails = ''; private $headerActions = []; + /** + * PublicTemplateResponse constructor. + * + * @param string $appName + * @param string $templateName + * @param array $params + * @since 14.0.0 + */ public function __construct(string $appName, string $templateName, array $params = array()) { parent::__construct($appName, $templateName, $params, 'public'); \OC_Util::addScript('core', 'public/publicpage'); } + /** + * @param string $title + * @since 14.0.0 + */ public function setHeaderTitle(string $title) { $this->headerTitle = $title; } + /** + * @return string + * @since 14.0.0 + */ public function getHeaderTitle(): string { return $this->headerTitle; } + /** + * @param string $details + * @since 14.0.0 + */ public function setHeaderDetails(string $details) { $this->headerDetails = $details; } + /** + * @return string + * @since 14.0.0 + */ public function getHeaderDetails(): string { return $this->headerDetails; } + /** + * @param array $actions + * @since 14.0.0 + */ public function setHeaderActions(array $actions) { foreach ($actions as $action) { if ($actions instanceof IMenuAction) { @@ -61,10 +95,18 @@ class PublicTemplateResponse extends TemplateResponse { } } + /** + * @param IMenuAction $action + * @since 14.0.0 + */ public function addAction(IMenuAction $action) { $this->headerActions[] = $action; } + /** + * @return IMenuAction + * @since 14.0.0 + */ public function getPrimaryAction(): IMenuAction { $lowest = null; foreach ($this->headerActions as $action) { @@ -75,12 +117,17 @@ class PublicTemplateResponse extends TemplateResponse { return $lowest; } + /** + * @return int + * @since 14.0.0 + */ public function getActionCount(): int { return count($this->headerActions); } /** * @return IMenuAction[] + * @since 14.0.0 */ public function getOtherActions(): array { $list = []; @@ -93,7 +140,10 @@ class PublicTemplateResponse extends TemplateResponse { return $list; } - + /** + * @return string + * @since 14.0.0 + */ public function render() { $params = array_merge($this->getParams(), [ 'template' => $this, diff --git a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php index 087887eed51..b81403c7a53 100644 --- a/lib/public/AppFramework/Http/Template/SimpleMenuAction.php +++ b/lib/public/AppFramework/Http/Template/SimpleMenuAction.php @@ -29,6 +29,7 @@ use OCP\Util; * Class SimpleMenuAction * * @package OCP\AppFramework\Http\Template + * @since 14.0.0 */ class SimpleMenuAction implements IMenuAction { @@ -59,6 +60,7 @@ class SimpleMenuAction implements IMenuAction { * @param string $link * @param int $priority * @param string $detail + * @since 14.0.0 */ public function __construct(string $id, string $label, string $icon, string $link = '', int $priority = 100, string $detail = '') { $this->id = $id; @@ -71,6 +73,7 @@ class SimpleMenuAction implements IMenuAction { /** * @param string $id + * @since 14.0.0 */ public function setId(string $id) { $this->id = $id; @@ -78,6 +81,7 @@ class SimpleMenuAction implements IMenuAction { /** * @param string $label + * @since 14.0.0 */ public function setLabel(string $label) { $this->label = $label; @@ -85,6 +89,7 @@ class SimpleMenuAction implements IMenuAction { /** * @param string $detail + * @since 14.0.0 */ public function setDetail(string $detail) { $this->detail = $detail; @@ -92,6 +97,7 @@ class SimpleMenuAction implements IMenuAction { /** * @param string $icon + * @since 14.0.0 */ public function setIcon(string $icon) { $this->icon = $icon; @@ -99,6 +105,7 @@ class SimpleMenuAction implements IMenuAction { /** * @param string $link + * @since 14.0.0 */ public function setLink(string $link) { $this->link = $link; @@ -106,6 +113,7 @@ class SimpleMenuAction implements IMenuAction { /** * @param int $priority + * @since 14.0.0 */ public function setPriority(int $priority) { $this->priority = $priority; @@ -113,6 +121,7 @@ class SimpleMenuAction implements IMenuAction { /** * @return string + * @since 14.0.0 */ public function getId(): string { return $this->id; @@ -120,6 +129,7 @@ class SimpleMenuAction implements IMenuAction { /** * @return string + * @since 14.0.0 */ public function getLabel(): string { return $this->label; @@ -127,6 +137,7 @@ class SimpleMenuAction implements IMenuAction { /** * @return string + * @since 14.0.0 */ public function getIcon(): string { return $this->icon; @@ -134,6 +145,7 @@ class SimpleMenuAction implements IMenuAction { /** * @return string + * @since 14.0.0 */ public function getLink(): string { return $this->link; @@ -141,6 +153,7 @@ class SimpleMenuAction implements IMenuAction { /** * @return int + * @since 14.0.0 */ public function getPriority(): int { return $this->priority; @@ -148,6 +161,7 @@ class SimpleMenuAction implements IMenuAction { /** * @return string + * @since 14.0.0 */ public function render(): string { $detailContent = ($this->detail !== '') ? ' (' . Util::sanitizeHTML($this->detail) . ')' : ''; -- cgit v1.2.3 From 4a1cbefc909d976d25bb1bb3a7bbeb422b51fb22 Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Fri, 9 Feb 2018 11:34:34 +0100 Subject: Fix files_sharing tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../lib/Controller/ShareController.php | 2 +- .../tests/Controller/ShareControllerTest.php | 34 +++++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'apps/files_sharing/lib') diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 0b0c551a153..1f8864fc5f3 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -441,7 +441,7 @@ class ShareController extends Controller { $csp->addAllowedFrameDomain('\'self\''); $response = new PublicTemplateResponse($this->appName, 'public', $shareTmpl); - $response->setHeaderTitle($share->getNode()->getName()); + $response->setHeaderTitle($shareTmpl['filename']); $response->setHeaderDetails($this->l10n->t('shared by %s', [$shareTmpl['displayName']])); $response->setHeaderActions([ new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $shareTmpl['downloadURL'], 0), diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 6062ff89065..6dc577a354c 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -34,7 +34,11 @@ namespace OCA\Files_Sharing\Tests\Controllers; use OC\Files\Filesystem; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Controller\ShareController; +use OCA\Files_Sharing\Template\ExternalShareMenuAction; +use OCA\Files_Sharing\Template\LinkMenuAction; use OCP\AppFramework\Http\DataResponse; +use OCP\AppFramework\Http\Template\PublicTemplateResponse; +use OCP\AppFramework\Http\Template\SimpleMenuAction; use OCP\IConfig; use OCP\IL10N; use OCP\ILogger; @@ -84,6 +88,8 @@ class ShareControllerTest extends \Test\TestCase { private $federatedShareProvider; /** @var EventDispatcherInterface | \PHPUnit_Framework_MockObject_MockObject */ private $eventDispatcher; + /** @var IL10N */ + private $l10n; protected function setUp() { parent::setUp(); @@ -102,6 +108,7 @@ class ShareControllerTest extends \Test\TestCase { $this->federatedShareProvider->expects($this->any()) ->method('isIncomingServer2serverShareEnabled')->willReturn(true); $this->eventDispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock(); + $this->l10n = $this->createMock(IL10N::class); $this->shareController = new \OCA\Files_Sharing\Controller\ShareController( $this->appName, @@ -117,7 +124,7 @@ class ShareControllerTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(), $this->federatedShareProvider, $this->eventDispatcher, - $this->getMockBuilder(IL10N::class)->getMock(), + $this->l10n, $this->getMockBuilder('\OCP\Defaults')->getMock() ); @@ -348,6 +355,11 @@ class ShareControllerTest extends \Test\TestCase { $this->session->method('exists')->with('public_link_authenticated')->willReturn(true); $this->session->method('get')->with('public_link_authenticated')->willReturn('42'); + $this->urlGenerator->expects($this->at(0)) + ->method('linkToRouteAbsolute') + ->with('files_sharing.sharecontroller.downloadShare', ['token' => 'token']) + ->willReturn('downloadURL'); + $this->previewManager->method('isMimeSupported')->with('text/plain')->willReturn(true); $this->config->method('getSystemValue') @@ -379,6 +391,12 @@ class ShareControllerTest extends \Test\TestCase { ->method('dispatch') ->with('OCA\Files_Sharing::loadAdditionalScripts'); + $this->l10n->expects($this->any()) + ->method('t') + ->will($this->returnCallback(function($text, $parameters) { + return vsprintf($text, $parameters); + })); + $response = $this->shareController->showShare('token'); $sharedTmplParams = array( 'displayName' => 'ownerDisplay', @@ -391,7 +409,7 @@ class ShareControllerTest extends \Test\TestCase { 'server2serversharing' => true, 'protected' => 'true', 'dir' => '', - 'downloadURL' => null, + 'downloadURL' => 'downloadURL', 'fileSize' => '33 B', 'nonHumanFileSize' => 33, 'maxSizeAnimateGif' => 10, @@ -404,13 +422,21 @@ class ShareControllerTest extends \Test\TestCase { 'disclaimer' => 'My disclaimer text', 'shareUrl' => null, 'previewImage' => null, - 'previewURL' => null, + 'previewURL' => 'downloadURL', ); $csp = new \OCP\AppFramework\Http\ContentSecurityPolicy(); $csp->addAllowedFrameDomain('\'self\''); - $expectedResponse = new TemplateResponse($this->appName, 'public', $sharedTmplParams, 'base'); + $expectedResponse = new PublicTemplateResponse($this->appName, 'public', $sharedTmplParams); $expectedResponse->setContentSecurityPolicy($csp); + $expectedResponse->setHeaderTitle($sharedTmplParams['filename']); + $expectedResponse->setHeaderDetails('shared by ' . $sharedTmplParams['displayName']); + $expectedResponse->setHeaderActions([ + new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download-white', $sharedTmplParams['downloadURL'], 0), + new SimpleMenuAction('download', $this->l10n->t('Download'), 'icon-download', $sharedTmplParams['downloadURL'], 10, $sharedTmplParams['fileSize']), + new LinkMenuAction($this->l10n->t('Direct link'), 'icon-public', $sharedTmplParams['previewURL']), + new ExternalShareMenuAction($this->l10n->t('Add to your Nextcloud'), 'icon-external', $sharedTmplParams['owner'], $sharedTmplParams['displayName'], $sharedTmplParams['filename']), + ]); $this->assertEquals($expectedResponse, $response); } -- cgit v1.2.3