OCJSController.php 2.9 KB

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