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.

OCJSController.php 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author John Molakvoæ <skjnldsv@protonmail.com>
  8. * @author Lukas Reschke <lukas@statuscode.ch>
  9. * @author Morris Jobke <hey@morrisjobke.de>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. * @author Kate Döen <kate.doeen@nextcloud.com>
  12. *
  13. * @license GNU AGPL version 3 or any later version
  14. *
  15. * This program is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License as
  17. * published by the Free Software Foundation, either version 3 of the
  18. * License, or (at your option) any later version.
  19. *
  20. * This program is distributed in the hope that it will be useful,
  21. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  22. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  23. * GNU Affero General Public License for more details.
  24. *
  25. * You should have received a copy of the GNU Affero General Public License
  26. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. *
  28. */
  29. namespace OC\Core\Controller;
  30. use bantu\IniGetWrapper\IniGetWrapper;
  31. use OC\CapabilitiesManager;
  32. use OC\Template\JSConfigHelper;
  33. use OCP\App\IAppManager;
  34. use OCP\AppFramework\Controller;
  35. use OCP\AppFramework\Http;
  36. use OCP\AppFramework\Http\Attribute\FrontpageRoute;
  37. use OCP\AppFramework\Http\Attribute\OpenAPI;
  38. use OCP\AppFramework\Http\DataDisplayResponse;
  39. use OCP\Defaults;
  40. use OCP\IConfig;
  41. use OCP\IGroupManager;
  42. use OCP\IInitialStateService;
  43. use OCP\IRequest;
  44. use OCP\ISession;
  45. use OCP\IURLGenerator;
  46. use OCP\IUserSession;
  47. use OCP\L10N\IFactory;
  48. #[OpenAPI(scope: OpenAPI::SCOPE_IGNORE)]
  49. class OCJSController extends Controller {
  50. private JSConfigHelper $helper;
  51. public function __construct(
  52. string $appName,
  53. IRequest $request,
  54. IFactory $l10nFactory,
  55. Defaults $defaults,
  56. IAppManager $appManager,
  57. ISession $session,
  58. IUserSession $userSession,
  59. IConfig $config,
  60. IGroupManager $groupManager,
  61. IniGetWrapper $iniWrapper,
  62. IURLGenerator $urlGenerator,
  63. CapabilitiesManager $capabilitiesManager,
  64. IInitialStateService $initialStateService,
  65. ) {
  66. parent::__construct($appName, $request);
  67. $this->helper = new JSConfigHelper(
  68. $l10nFactory->get('lib'),
  69. $defaults,
  70. $appManager,
  71. $session,
  72. $userSession->getUser(),
  73. $config,
  74. $groupManager,
  75. $iniWrapper,
  76. $urlGenerator,
  77. $capabilitiesManager,
  78. $initialStateService
  79. );
  80. }
  81. /**
  82. * @NoCSRFRequired
  83. * @NoTwoFactorRequired
  84. * @PublicPage
  85. */
  86. #[FrontpageRoute(verb: 'GET', url: '/core/js/oc.js')]
  87. public function getConfig(): DataDisplayResponse {
  88. $data = $this->helper->getConfig();
  89. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  90. }
  91. }