From 134cbbfad5e3f3a521821556516a67a23d7053bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Molakvo=C3=A6=20=28skjnldsv=29?= Date: Wed, 4 Mar 2020 13:51:40 +0100 Subject: [PATCH] Properly emit Viewer event on files and files_sharing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: John Molakvoæ (skjnldsv) --- apps/files/lib/Controller/ViewController.php | 2 ++ .../lib/Controller/ShareController.php | 16 ++++++++++------ apps/files_sharing/list.php | 2 ++ apps/files_sharing/public.php | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 688db41f8b..e059b72f47 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -39,6 +39,7 @@ namespace OCA\Files\Controller; use OCA\Files\Activity\Helper; use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSidebar; +use OCA\Viewer\Event\LoadViewer; use OCP\App\IAppManager; use OCP\AppFramework\Controller; use OCP\AppFramework\Http\ContentSecurityPolicy; @@ -281,6 +282,7 @@ class ViewController extends Controller { $this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event); $this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); + $this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); $params = []; $params['usedSpacePercent'] = (int) $storageInfo['relative']; diff --git a/apps/files_sharing/lib/Controller/ShareController.php b/apps/files_sharing/lib/Controller/ShareController.php index 72168b3c31..42086722a1 100644 --- a/apps/files_sharing/lib/Controller/ShareController.php +++ b/apps/files_sharing/lib/Controller/ShareController.php @@ -41,11 +41,12 @@ namespace OCA\Files_Sharing\Controller; -use OC\Security\CSP\ContentSecurityPolicy; use OC_Files; use OC_Util; +use OC\Security\CSP\ContentSecurityPolicy; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Activity\Providers\Downloads; +use OCA\Viewer\Event\LoadViewer; use OCP\AppFramework\AuthPublicShareController; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\Template\ExternalShareMenuAction; @@ -54,6 +55,8 @@ use OCP\AppFramework\Http\Template\PublicTemplateResponse; use OCP\AppFramework\Http\Template\SimpleMenuAction; use OCP\AppFramework\Http\TemplateResponse; use OCP\Defaults; +use OCP\EventDispatcher\GenericEvent; +use OCP\EventDispatcher\IEventDispatcher; use OCP\Files\IRootFolder; use OCP\Files\NotFoundException; use OCP\IConfig; @@ -68,8 +71,6 @@ use OCP\Share; use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\IManager as ShareManager; use OCP\Template; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; /** * Class ShareController @@ -92,7 +93,7 @@ class ShareController extends AuthPublicShareController { protected $rootFolder; /** @var FederatedShareProvider */ protected $federatedShareProvider; - /** @var EventDispatcherInterface */ + /** @var IEventDispatcher */ protected $eventDispatcher; /** @var IL10N */ protected $l10n; @@ -117,7 +118,7 @@ class ShareController extends AuthPublicShareController { * @param IPreview $previewManager * @param IRootFolder $rootFolder * @param FederatedShareProvider $federatedShareProvider - * @param EventDispatcherInterface $eventDispatcher + * @param IEventDispatcher $eventDispatcher * @param IL10N $l10n * @param Defaults $defaults */ @@ -133,7 +134,7 @@ class ShareController extends AuthPublicShareController { IPreview $previewManager, IRootFolder $rootFolder, FederatedShareProvider $federatedShareProvider, - EventDispatcherInterface $eventDispatcher, + IEventDispatcher $eventDispatcher, IL10N $l10n, Defaults $defaults) { parent::__construct($appName, $request, $session, $urlGenerator); @@ -370,6 +371,7 @@ class ShareController extends AuthPublicShareController { $maxUploadFilesize = $freeSpace; $folder = new Template('files', 'list', ''); + $folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath())); $folder->assign('dirToken', $this->getToken()); $folder->assign('permissions', \OCP\Constants::PERMISSION_READ); @@ -452,6 +454,8 @@ class ShareController extends AuthPublicShareController { \OCP\Util::addScript('files', 'filelist'); \OCP\Util::addScript('files', 'keyboardshortcuts'); \OCP\Util::addScript('files', 'operationprogressbar'); + + $this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); } // OpenGraph Support: http://ogp.me/ diff --git a/apps/files_sharing/list.php b/apps/files_sharing/list.php index 8197224af5..dd2d18cbf7 100644 --- a/apps/files_sharing/list.php +++ b/apps/files_sharing/list.php @@ -23,6 +23,7 @@ */ use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadSidebar; +use OCA\Viewer\Event\LoadViewer; use OCP\EventDispatcher\GenericEvent; // Check if we are a user @@ -43,5 +44,6 @@ $tmpl->assign('showgridview', $showgridview && !$isIE); $eventDispatcher->dispatch('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent()); $eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent()); $eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); +$eventDispatcher->dispatch(LoadViewer::class, new LoadViewer()); $tmpl->printPage(); diff --git a/apps/files_sharing/public.php b/apps/files_sharing/public.php index b72d3a9dd9..1fcdf2fe50 100644 --- a/apps/files_sharing/public.php +++ b/apps/files_sharing/public.php @@ -27,7 +27,7 @@ $urlGenerator = \OC::$server->getURLGenerator(); $token = isset($_GET['t']) ? $_GET['t'] : ''; $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare'; -if($token !== '') { +if ($token !== '') { $protocol = \OC::$server->getRequest()->getHttpProtocol(); if ($protocol == 'HTTP/1.0') { http_response_code(302);