Properly emit Viewer event on files and files_sharing

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
John Molakvoæ (skjnldsv) 2020-03-04 13:51:40 +01:00
parent 0f9fe74020
commit 134cbbfad5
No known key found for this signature in database
GPG key ID: 60C25B8C072916CF
4 changed files with 15 additions and 7 deletions

View file

@ -39,6 +39,7 @@ namespace OCA\Files\Controller;
use OCA\Files\Activity\Helper; use OCA\Files\Activity\Helper;
use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar; use OCA\Files\Event\LoadSidebar;
use OCA\Viewer\Event\LoadViewer;
use OCP\App\IAppManager; use OCP\App\IAppManager;
use OCP\AppFramework\Controller; use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\ContentSecurityPolicy; use OCP\AppFramework\Http\ContentSecurityPolicy;
@ -281,6 +282,7 @@ class ViewController extends Controller {
$this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event); $this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);
$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); $this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
$params = []; $params = [];
$params['usedSpacePercent'] = (int) $storageInfo['relative']; $params['usedSpacePercent'] = (int) $storageInfo['relative'];

View file

@ -41,11 +41,12 @@
namespace OCA\Files_Sharing\Controller; namespace OCA\Files_Sharing\Controller;
use OC\Security\CSP\ContentSecurityPolicy;
use OC_Files; use OC_Files;
use OC_Util; use OC_Util;
use OC\Security\CSP\ContentSecurityPolicy;
use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Files_Sharing\Activity\Providers\Downloads; use OCA\Files_Sharing\Activity\Providers\Downloads;
use OCA\Viewer\Event\LoadViewer;
use OCP\AppFramework\AuthPublicShareController; use OCP\AppFramework\AuthPublicShareController;
use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Template\ExternalShareMenuAction; 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\Template\SimpleMenuAction;
use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\TemplateResponse;
use OCP\Defaults; use OCP\Defaults;
use OCP\EventDispatcher\GenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\IConfig; use OCP\IConfig;
@ -68,8 +71,6 @@ use OCP\Share;
use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager as ShareManager; use OCP\Share\IManager as ShareManager;
use OCP\Template; use OCP\Template;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\GenericEvent;
/** /**
* Class ShareController * Class ShareController
@ -92,7 +93,7 @@ class ShareController extends AuthPublicShareController {
protected $rootFolder; protected $rootFolder;
/** @var FederatedShareProvider */ /** @var FederatedShareProvider */
protected $federatedShareProvider; protected $federatedShareProvider;
/** @var EventDispatcherInterface */ /** @var IEventDispatcher */
protected $eventDispatcher; protected $eventDispatcher;
/** @var IL10N */ /** @var IL10N */
protected $l10n; protected $l10n;
@ -117,7 +118,7 @@ class ShareController extends AuthPublicShareController {
* @param IPreview $previewManager * @param IPreview $previewManager
* @param IRootFolder $rootFolder * @param IRootFolder $rootFolder
* @param FederatedShareProvider $federatedShareProvider * @param FederatedShareProvider $federatedShareProvider
* @param EventDispatcherInterface $eventDispatcher * @param IEventDispatcher $eventDispatcher
* @param IL10N $l10n * @param IL10N $l10n
* @param Defaults $defaults * @param Defaults $defaults
*/ */
@ -133,7 +134,7 @@ class ShareController extends AuthPublicShareController {
IPreview $previewManager, IPreview $previewManager,
IRootFolder $rootFolder, IRootFolder $rootFolder,
FederatedShareProvider $federatedShareProvider, FederatedShareProvider $federatedShareProvider,
EventDispatcherInterface $eventDispatcher, IEventDispatcher $eventDispatcher,
IL10N $l10n, IL10N $l10n,
Defaults $defaults) { Defaults $defaults) {
parent::__construct($appName, $request, $session, $urlGenerator); parent::__construct($appName, $request, $session, $urlGenerator);
@ -370,6 +371,7 @@ class ShareController extends AuthPublicShareController {
$maxUploadFilesize = $freeSpace; $maxUploadFilesize = $freeSpace;
$folder = new Template('files', 'list', ''); $folder = new Template('files', 'list', '');
$folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath())); $folder->assign('dir', $shareNode->getRelativePath($folderNode->getPath()));
$folder->assign('dirToken', $this->getToken()); $folder->assign('dirToken', $this->getToken());
$folder->assign('permissions', \OCP\Constants::PERMISSION_READ); $folder->assign('permissions', \OCP\Constants::PERMISSION_READ);
@ -452,6 +454,8 @@ class ShareController extends AuthPublicShareController {
\OCP\Util::addScript('files', 'filelist'); \OCP\Util::addScript('files', 'filelist');
\OCP\Util::addScript('files', 'keyboardshortcuts'); \OCP\Util::addScript('files', 'keyboardshortcuts');
\OCP\Util::addScript('files', 'operationprogressbar'); \OCP\Util::addScript('files', 'operationprogressbar');
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
} }
// OpenGraph Support: http://ogp.me/ // OpenGraph Support: http://ogp.me/

View file

@ -23,6 +23,7 @@
*/ */
use OCA\Files\Event\LoadAdditionalScriptsEvent; use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files\Event\LoadSidebar; use OCA\Files\Event\LoadSidebar;
use OCA\Viewer\Event\LoadViewer;
use OCP\EventDispatcher\GenericEvent; use OCP\EventDispatcher\GenericEvent;
// Check if we are a user // 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('\OCP\Collaboration\Resources::loadAdditionalScripts', new GenericEvent());
$eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent()); $eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent());
$eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar()); $eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
$eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
$tmpl->printPage(); $tmpl->printPage();

View file

@ -27,7 +27,7 @@ $urlGenerator = \OC::$server->getURLGenerator();
$token = isset($_GET['t']) ? $_GET['t'] : ''; $token = isset($_GET['t']) ? $_GET['t'] : '';
$route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare'; $route = isset($_GET['download']) ? 'files_sharing.sharecontroller.downloadShare' : 'files_sharing.sharecontroller.showShare';
if($token !== '') { if ($token !== '') {
$protocol = \OC::$server->getRequest()->getHttpProtocol(); $protocol = \OC::$server->getRequest()->getHttpProtocol();
if ($protocol == 'HTTP/1.0') { if ($protocol == 'HTTP/1.0') {
http_response_code(302); http_response_code(302);