jsresourcelocator.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Bart Visscher <bartv@thisnet.nl>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace OC\Template;
  9. class JSResourceLocator extends ResourceLocator {
  10. public function doFind( $script ) {
  11. $theme_dir = 'themes/'.$this->theme.'/';
  12. if (strpos($script, '3rdparty') === 0
  13. && $this->appendIfExist($this->thirdpartyroot, $script.'.js')
  14. || $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js')
  15. || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js')
  16. || $this->appendIfExist($this->serverroot, $script.'.js')
  17. || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js')
  18. || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js')
  19. ) {
  20. return;
  21. }
  22. $app = substr($script, 0, strpos($script, '/'));
  23. $script = substr($script, strpos($script, '/')+1);
  24. $app_path = \OC_App::getAppPath($app);
  25. $app_url = \OC_App::getAppWebPath($app);
  26. if ($this->appendIfExist($app_path, $script.'.js', $app_url)) {
  27. return;
  28. }
  29. // missing translations files fill be ignored
  30. if (strpos($script, "l10n/") === 0) {
  31. return;
  32. }
  33. throw new \Exception('js file not found: script:'.$script);
  34. }
  35. public function doFindTheme( $script ) {
  36. }
  37. }