Use event dispatcher

Registers the JS via event dispatchers. Otherwise the JS is not loaded when somebody has pretty URLs configured.
This commit is contained in:
Lukas Reschke 2016-07-18 23:47:01 +02:00
parent e906c47ef5
commit 294274adc6
No known key found for this signature in database
GPG Key ID: B9F6980CF6E759B1

View File

@ -43,15 +43,14 @@ $navigationEntry = function () use ($c) {
$c->getServer()->getNavigationManager()->add($navigationEntry); $c->getServer()->getNavigationManager()->add($navigationEntry);
//Script for registering file actions //Script for registering file actions
$request = \OC::$server->getRequest(); $eventDispatcher = \OC::$server->getEventDispatcher();
if (isset($request->server['REQUEST_URI'])) { $eventDispatcher->addListener(
$url = $request->server['REQUEST_URI']; 'OCA\Files::loadAdditionalScripts',
function() {
if (preg_match('%index.php/apps/files(/.*)?%', $url)) {
\OCP\Util::addScript('richdocuments', 'viewer/viewer'); \OCP\Util::addScript('richdocuments', 'viewer/viewer');
\OCP\Util::addStyle('richdocuments', 'viewer/odfviewer'); \OCP\Util::addStyle('richdocuments', 'viewer/odfviewer');
} }
} );
//Listen to delete file signal //Listen to delete file signal
\OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete"); \OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Richdocuments\Storage", "onDelete");