jsresourcelocator.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * @author Bart Visscher <bartv@thisnet.nl>
  4. * @author Joas Schilling <nickvergessen@owncloud.com>
  5. * @author Morris Jobke <hey@morrisjobke.de>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @copyright Copyright (c) 2015, ownCloud, Inc.
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace OC\Template;
  25. class JSResourceLocator extends ResourceLocator {
  26. /**
  27. * @param string $script
  28. */
  29. public function doFind($script) {
  30. $theme_dir = 'themes/'.$this->theme.'/';
  31. if (strpos($script, '3rdparty') === 0
  32. && $this->appendIfExist($this->thirdpartyroot, $script.'.js')
  33. || $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js')
  34. || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js')
  35. || $this->appendIfExist($this->serverroot, $script.'.js')
  36. || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js')
  37. || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js')
  38. ) {
  39. return;
  40. }
  41. $app = substr($script, 0, strpos($script, '/'));
  42. $script = substr($script, strpos($script, '/')+1);
  43. $app_path = \OC_App::getAppPath($app);
  44. $app_url = \OC_App::getAppWebPath($app);
  45. // missing translations files fill be ignored
  46. if (strpos($script, 'l10n/') === 0) {
  47. $this->appendIfExist($app_path, $script . '.js', $app_url);
  48. return;
  49. }
  50. $this->append($app_path, $script . '.js', $app_url);
  51. }
  52. /**
  53. * @param string $script
  54. */
  55. public function doFindTheme($script) {
  56. }
  57. }