2014-08-09 12:39:12 +04:00
|
|
|
<?php
|
2020-06-17 11:16:53 +03:00
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2014-08-09 12:39:12 +04:00
|
|
|
/**
|
2016-07-21 17:49:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
|
|
*
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
2019-12-19 15:16:31 +03:00
|
|
|
* @author Daniel Kesselberg <mail@danielkesselberg.de>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
2019-12-03 21:57:53 +03:00
|
|
|
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
|
|
|
* @author Julius Härtl <jus@bitgrid.net>
|
|
|
|
* @author Morris Jobke <hey@morrisjobke.de>
|
2017-11-06 17:56:42 +03:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
2016-07-21 17:49:16 +03:00
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
2015-03-26 13:44:34 +03:00
|
|
|
* @author Tobias Kaminsky <tobias@kaminsky.me>
|
2020-12-16 16:54:15 +03:00
|
|
|
* @author Vincent Petry <vincent@nextcloud.com>
|
2015-03-26 13:44:34 +03:00
|
|
|
*
|
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2015-03-26 13:44:34 +03:00
|
|
|
*
|
2014-08-09 12:39:12 +04:00
|
|
|
*/
|
2019-11-22 22:52:10 +03:00
|
|
|
|
2015-03-21 22:12:55 +03:00
|
|
|
namespace OCA\Files\AppInfo;
|
2014-08-09 12:39:12 +04:00
|
|
|
|
2020-07-16 18:08:03 +03:00
|
|
|
use Closure;
|
2020-06-17 11:16:53 +03:00
|
|
|
use OC\Search\Provider\File;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCA\Files\Capabilities;
|
2019-02-22 14:21:08 +03:00
|
|
|
use OCA\Files\Collaboration\Resources\Listener;
|
2019-01-24 13:43:18 +03:00
|
|
|
use OCA\Files\Collaboration\Resources\ResourceProvider;
|
2014-08-09 12:39:12 +04:00
|
|
|
use OCA\Files\Controller\ApiController;
|
2019-08-02 21:08:54 +03:00
|
|
|
use OCA\Files\Event\LoadAdditionalScriptsEvent;
|
2019-12-03 20:20:46 +03:00
|
|
|
use OCA\Files\Event\LoadSidebar;
|
2019-08-02 21:08:54 +03:00
|
|
|
use OCA\Files\Listener\LegacyLoadAdditionalScriptsAdapter;
|
2019-12-03 20:20:46 +03:00
|
|
|
use OCA\Files\Listener\LoadSidebarListener;
|
2019-10-29 14:22:15 +03:00
|
|
|
use OCA\Files\Notification\Notifier;
|
2020-06-17 11:29:50 +03:00
|
|
|
use OCA\Files\Search\FilesSearchProvider;
|
2019-11-22 22:52:10 +03:00
|
|
|
use OCA\Files\Service\TagService;
|
2020-07-16 11:26:41 +03:00
|
|
|
use OCP\Activity\IManager as IActivityManager;
|
2014-08-09 12:39:12 +04:00
|
|
|
use OCP\AppFramework\App;
|
2020-06-17 11:16:53 +03:00
|
|
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
|
|
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
|
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
2019-09-29 21:57:00 +03:00
|
|
|
use OCP\Collaboration\Resources\IProviderManager;
|
2020-07-16 11:26:41 +03:00
|
|
|
use OCP\IConfig;
|
2020-06-17 11:16:53 +03:00
|
|
|
use OCP\IL10N;
|
2020-07-16 11:26:41 +03:00
|
|
|
use OCP\IPreview;
|
2020-07-16 18:08:03 +03:00
|
|
|
use OCP\ISearch;
|
2020-07-16 11:26:41 +03:00
|
|
|
use OCP\IRequest;
|
2020-06-17 11:16:53 +03:00
|
|
|
use OCP\IServerContainer;
|
2020-07-16 11:26:41 +03:00
|
|
|
use OCP\ITagManager;
|
|
|
|
use OCP\IUserSession;
|
|
|
|
use OCP\Share\IManager as IShareManager;
|
2020-06-17 11:16:53 +03:00
|
|
|
use OCP\Util;
|
2020-07-16 11:26:41 +03:00
|
|
|
use Psr\Container\ContainerInterface;
|
2014-08-09 12:39:12 +04:00
|
|
|
|
2020-06-17 11:16:53 +03:00
|
|
|
class Application extends App implements IBootstrap {
|
2019-10-29 14:22:15 +03:00
|
|
|
public const APP_ID = 'files';
|
|
|
|
|
2020-10-05 16:12:57 +03:00
|
|
|
public function __construct(array $urlParams = []) {
|
2019-10-29 14:22:15 +03:00
|
|
|
parent::__construct(self::APP_ID, $urlParams);
|
2020-06-17 11:16:53 +03:00
|
|
|
}
|
2014-08-09 12:39:12 +04:00
|
|
|
|
2020-06-17 11:16:53 +03:00
|
|
|
public function register(IRegistrationContext $context): void {
|
2014-08-09 12:39:12 +04:00
|
|
|
/**
|
|
|
|
* Controllers
|
|
|
|
*/
|
2020-07-16 11:26:41 +03:00
|
|
|
$context->registerService('APIController', function (ContainerInterface $c) {
|
2020-06-17 11:16:53 +03:00
|
|
|
/** @var IServerContainer $server */
|
2020-07-16 11:26:41 +03:00
|
|
|
$server = $c->get(IServerContainer::class);
|
2020-06-17 11:16:53 +03:00
|
|
|
|
2014-08-09 12:39:12 +04:00
|
|
|
return new ApiController(
|
2020-07-16 11:26:41 +03:00
|
|
|
$c->get('AppName'),
|
|
|
|
$c->get(IRequest::class),
|
|
|
|
$c->get(IUserSession::class),
|
|
|
|
$c->get(TagService::class),
|
|
|
|
$c->get(IPreview::class),
|
|
|
|
$c->get(IShareManager::class),
|
|
|
|
$c->get(IConfig::class),
|
2016-07-22 15:48:51 +03:00
|
|
|
$server->getUserFolder()
|
2014-11-18 20:53:45 +03:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Services
|
|
|
|
*/
|
2020-08-17 17:55:16 +03:00
|
|
|
$context->registerService(TagService::class, function (ContainerInterface $c) {
|
2020-06-17 11:16:53 +03:00
|
|
|
/** @var IServerContainer $server */
|
2020-07-16 11:26:41 +03:00
|
|
|
$server = $c->get(IServerContainer::class);
|
2020-06-17 11:16:53 +03:00
|
|
|
|
2014-11-18 20:53:45 +03:00
|
|
|
return new TagService(
|
2020-07-16 11:26:41 +03:00
|
|
|
$c->get(IUserSession::class),
|
|
|
|
$c->get(IActivityManager::class),
|
|
|
|
$c->get(ITagManager::class)->load(self::APP_ID),
|
2020-06-17 11:16:53 +03:00
|
|
|
$server->getUserFolder(),
|
2018-01-10 13:20:21 +03:00
|
|
|
$server->getEventDispatcher()
|
2014-11-18 20:53:45 +03:00
|
|
|
);
|
|
|
|
});
|
2015-03-21 22:12:55 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register capabilities
|
|
|
|
*/
|
2020-06-17 11:16:53 +03:00
|
|
|
$context->registerCapability(Capabilities::class);
|
2019-01-24 13:43:18 +03:00
|
|
|
|
2020-06-17 11:16:53 +03:00
|
|
|
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LegacyLoadAdditionalScriptsAdapter::class);
|
|
|
|
$context->registerEventListener(LoadSidebar::class, LoadSidebarListener::class);
|
2020-06-17 11:29:50 +03:00
|
|
|
|
|
|
|
$context->registerSearchProvider(FilesSearchProvider::class);
|
2021-04-16 13:39:08 +03:00
|
|
|
|
|
|
|
$context->registerNotifierService(Notifier::class);
|
2020-06-17 11:16:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function boot(IBootContext $context): void {
|
2020-07-16 18:08:03 +03:00
|
|
|
$context->injectFn(Closure::fromCallable([$this, 'registerCollaboration']));
|
|
|
|
$context->injectFn([Listener::class, 'register']);
|
|
|
|
$context->injectFn(Closure::fromCallable([$this, 'registerSearchProvider']));
|
2020-06-17 11:16:53 +03:00
|
|
|
$this->registerTemplates();
|
2020-07-16 18:08:03 +03:00
|
|
|
$context->injectFn(Closure::fromCallable([$this, 'registerNavigation']));
|
2020-06-17 11:16:53 +03:00
|
|
|
$this->registerHooks();
|
|
|
|
}
|
|
|
|
|
2020-07-16 18:08:03 +03:00
|
|
|
private function registerCollaboration(IProviderManager $providerManager): void {
|
2019-09-29 21:57:00 +03:00
|
|
|
$providerManager->registerResourceProvider(ResourceProvider::class);
|
2020-06-17 11:16:53 +03:00
|
|
|
}
|
2019-10-29 14:22:15 +03:00
|
|
|
|
2020-07-16 18:08:03 +03:00
|
|
|
private function registerSearchProvider(ISearch $search): void {
|
|
|
|
$search->registerProvider(File::class, ['apps' => ['files']]);
|
2020-06-17 11:16:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private function registerTemplates(): void {
|
|
|
|
$templateManager = \OC_Helper::getFileTemplateManager();
|
|
|
|
$templateManager->registerTemplate('application/vnd.oasis.opendocument.presentation', 'core/templates/filetemplates/template.odp');
|
|
|
|
$templateManager->registerTemplate('application/vnd.oasis.opendocument.text', 'core/templates/filetemplates/template.odt');
|
|
|
|
$templateManager->registerTemplate('application/vnd.oasis.opendocument.spreadsheet', 'core/templates/filetemplates/template.ods');
|
|
|
|
}
|
|
|
|
|
2020-07-16 18:08:03 +03:00
|
|
|
private function registerNavigation(IL10N $l10n): void {
|
2020-07-09 10:48:09 +03:00
|
|
|
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
|
|
|
|
return [
|
|
|
|
'id' => 'files',
|
|
|
|
'appname' => 'files',
|
|
|
|
'script' => 'list.php',
|
|
|
|
'order' => 0,
|
|
|
|
'name' => $l10n->t('All files')
|
|
|
|
];
|
|
|
|
});
|
|
|
|
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
|
|
|
|
return [
|
|
|
|
'id' => 'recent',
|
|
|
|
'appname' => 'files',
|
|
|
|
'script' => 'recentlist.php',
|
|
|
|
'order' => 2,
|
|
|
|
'name' => $l10n->t('Recent')
|
|
|
|
];
|
|
|
|
});
|
|
|
|
\OCA\Files\App::getNavigationManager()->add(function () use ($l10n) {
|
|
|
|
return [
|
|
|
|
'id' => 'favorites',
|
|
|
|
'appname' => 'files',
|
|
|
|
'script' => 'simplelist.php',
|
|
|
|
'order' => 5,
|
|
|
|
'name' => $l10n->t('Favorites'),
|
|
|
|
'expandedState' => 'show_Quick_Access'
|
|
|
|
];
|
|
|
|
});
|
2020-06-17 11:16:53 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private function registerHooks(): void {
|
|
|
|
Util::connectHook('\OCP\Config', 'js', '\OCA\Files\App', 'extendJsConfig');
|
|
|
|
}
|
2014-08-09 12:39:12 +04:00
|
|
|
}
|