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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, Roeland Jago Douma <roeland@famdouma.nl>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  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
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OC\Core\Controller;
  27. use bantu\IniGetWrapper\IniGetWrapper;
  28. use OC\CapabilitiesManager;
  29. use OC\Template\JSConfigHelper;
  30. use OCP\App\IAppManager;
  31. use OCP\AppFramework\Controller;
  32. use OCP\AppFramework\Http;
  33. use OCP\AppFramework\Http\DataDisplayResponse;
  34. use OCP\Defaults;
  35. use OCP\IConfig;
  36. use OCP\IGroupManager;
  37. use OCP\IRequest;
  38. use OCP\ISession;
  39. use OCP\IURLGenerator;
  40. use OCP\IUserSession;
  41. use OCP\L10N\IFactory;
  42. class OCJSController extends Controller {
  43. /** @var JSConfigHelper */
  44. private $helper;
  45. /**
  46. * OCJSController constructor.
  47. *
  48. * @param string $appName
  49. * @param IRequest $request
  50. * @param IFactory $l10nFactory
  51. * @param Defaults $defaults
  52. * @param IAppManager $appManager
  53. * @param ISession $session
  54. * @param IUserSession $userSession
  55. * @param IConfig $config
  56. * @param IGroupManager $groupManager
  57. * @param IniGetWrapper $iniWrapper
  58. * @param IURLGenerator $urlGenerator
  59. * @param CapabilitiesManager $capabilitiesManager
  60. */
  61. public function __construct($appName,
  62. IRequest $request,
  63. IFactory $l10nFactory,
  64. Defaults $defaults,
  65. IAppManager $appManager,
  66. ISession $session,
  67. IUserSession $userSession,
  68. IConfig $config,
  69. IGroupManager $groupManager,
  70. IniGetWrapper $iniWrapper,
  71. IURLGenerator $urlGenerator,
  72. CapabilitiesManager $capabilitiesManager) {
  73. parent::__construct($appName, $request);
  74. $this->helper = new JSConfigHelper(
  75. $l10nFactory->get('lib'),
  76. $defaults,
  77. $appManager,
  78. $session,
  79. $userSession->getUser(),
  80. $config,
  81. $groupManager,
  82. $iniWrapper,
  83. $urlGenerator,
  84. $capabilitiesManager
  85. );
  86. }
  87. /**
  88. * @NoCSRFRequired
  89. * @PublicPage
  90. *
  91. * @return DataDisplayResponse
  92. */
  93. public function getConfig() {
  94. $data = $this->helper->getConfig();
  95. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  96. }
  97. }