OCJSController.php 2.5 KB

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