You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

app.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Vincent Petry <pvince81@owncloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. use OCP\SystemTag\ManagerEvent;
  27. use OCP\SystemTag\MapperEvent;
  28. use OCA\SystemTags\Activity\Listener;
  29. $eventDispatcher = \OC::$server->getEventDispatcher();
  30. $eventDispatcher->addListener(
  31. 'OCA\Files::loadAdditionalScripts',
  32. function() {
  33. // FIXME: no public API for these ?
  34. \OCP\Util::addScript('dist/systemtags');
  35. \OCP\Util::addScript('systemtags', 'systemtags');
  36. }
  37. );
  38. $managerListener = function(ManagerEvent $event) {
  39. $application = new \OCP\AppFramework\App('systemtags');
  40. /** @var \OCA\SystemTags\Activity\Listener $listener */
  41. $listener = $application->getContainer()->query(Listener::class);
  42. $listener->event($event);
  43. };
  44. $eventDispatcher->addListener(ManagerEvent::EVENT_CREATE, $managerListener);
  45. $eventDispatcher->addListener(ManagerEvent::EVENT_DELETE, $managerListener);
  46. $eventDispatcher->addListener(ManagerEvent::EVENT_UPDATE, $managerListener);
  47. $mapperListener = function(MapperEvent $event) {
  48. $application = new \OCP\AppFramework\App('systemtags');
  49. /** @var \OCA\SystemTags\Activity\Listener $listener */
  50. $listener = $application->getContainer()->query(Listener::class);
  51. $listener->mapperEvent($event);
  52. };
  53. $eventDispatcher->addListener(MapperEvent::EVENT_ASSIGN, $mapperListener);
  54. $eventDispatcher->addListener(MapperEvent::EVENT_UNASSIGN, $mapperListener);
  55. \OCA\Files\App::getNavigationManager()->add(function () {
  56. $l = \OC::$server->getL10N('systemtags');
  57. return [
  58. 'id' => 'systemtagsfilter',
  59. 'appname' => 'systemtags',
  60. 'script' => 'list.php',
  61. 'order' => 25,
  62. 'name' => $l->t('Tags'),
  63. ];
  64. });