OCJSController.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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\IConfig;
  31. use OCP\IGroupManager;
  32. use OCP\IL10N;
  33. use OCP\IRequest;
  34. use OCP\ISession;
  35. use OCP\IURLGenerator;
  36. use OCP\IUserSession;
  37. class OCJSController extends Controller {
  38. /** @var JSConfigHelper */
  39. private $helper;
  40. /**
  41. * OCJSController constructor.
  42. *
  43. * @param string $appName
  44. * @param IRequest $request
  45. * @param IL10N $l
  46. * @param \OC_Defaults $defaults
  47. * @param IAppManager $appManager
  48. * @param ISession $session
  49. * @param IUserSession $userSession
  50. * @param IConfig $config
  51. * @param IGroupManager $groupManager
  52. * @param IniGetWrapper $iniWrapper
  53. * @param IURLGenerator $urlGenerator
  54. */
  55. public function __construct($appName,
  56. IRequest $request,
  57. IL10N $l,
  58. \OC_Defaults $defaults,
  59. IAppManager $appManager,
  60. ISession $session,
  61. IUserSession $userSession,
  62. IConfig $config,
  63. IGroupManager $groupManager,
  64. IniGetWrapper $iniWrapper,
  65. IURLGenerator $urlGenerator) {
  66. parent::__construct($appName, $request);
  67. $this->helper = new JSConfigHelper(
  68. $l,
  69. $defaults,
  70. $appManager,
  71. $session,
  72. $userSession->getUser(),
  73. $config,
  74. $groupManager,
  75. $iniWrapper,
  76. $urlGenerator
  77. );
  78. }
  79. /**
  80. * @NoCSRFRequired
  81. * @PublicPage
  82. *
  83. * @return DataDisplayResponse
  84. */
  85. public function getConfig() {
  86. $data = $this->helper->getConfig();
  87. return new DataDisplayResponse($data, Http::STATUS_OK, ['Content-type' => 'text/javascript']);
  88. }
  89. }