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

[stable18] Properly emit Viewer event on files and files_sharing #19897

Merged
merged 3 commits into from
Mar 13, 2020
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
5 changes: 5 additions & 0 deletions apps/files/lib/Controller/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
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;
Expand Down Expand Up @@ -281,6 +282,10 @@ public function index($dir = '', $view = '', $fileid = null, $fileNotFound = fal
$this->eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, $event);

$this->eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());
// Load Viewer scripts
if (class_exists(LoadViewer::class)) {
$this->eventDispatcher->dispatchTyped(new LoadViewer());
}

$params = [];
$params['usedSpacePercent'] = (int) $storageInfo['relative'];
Expand Down
9 changes: 8 additions & 1 deletion apps/files_sharing/lib/Controller/ShareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -370,6 +371,7 @@ public function showShare($path = ''): TemplateResponse {
$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);
Expand Down Expand Up @@ -452,6 +454,11 @@ public function showShare($path = ''): TemplateResponse {
\OCP\Util::addScript('files', 'filelist');
\OCP\Util::addScript('files', 'keyboardshortcuts');
\OCP\Util::addScript('files', 'operationprogressbar');

// Load Viewer scripts
if (class_exists(LoadViewer::class)) {
$this->eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
}
}

// OpenGraph Support: http://ogp.me/
Expand Down
6 changes: 6 additions & 0 deletions apps/files_sharing/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -44,4 +45,9 @@
$eventDispatcher->dispatch(LoadAdditionalScriptsEvent::class, new LoadAdditionalScriptsEvent());
$eventDispatcher->dispatch(LoadSidebar::class, new LoadSidebar());

// Load Viewer scripts
if (class_exists(LoadViewer::class)) {
$eventDispatcher->dispatch(LoadViewer::class, new LoadViewer());
}

$tmpl->printPage();
2 changes: 1 addition & 1 deletion apps/files_sharing/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
$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);
Expand Down