cssresourcelocator.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 CSSResourceLocator extends ResourceLocator {
  10. public function doFind( $style ) {
  11. if (strpos($style, '3rdparty') === 0
  12. && $this->appendIfExist($this->thirdpartyroot, $style.'.css')
  13. || $this->appendIfExist($this->serverroot, $style.'.css')
  14. || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
  15. ) {
  16. return;
  17. }
  18. $app = substr($style, 0, strpos($style, '/'));
  19. $style = substr($style, strpos($style, '/')+1);
  20. $app_path = \OC_App::getAppPath($app);
  21. $app_url = \OC_App::getAppWebPath($app);
  22. if ($this->appendIfExist($app_path, $style.'.css', $app_url)
  23. ) {
  24. return;
  25. }
  26. throw new \Exception('css file not found: style:'.$style);
  27. }
  28. public function doFindTheme( $style ) {
  29. $theme_dir = 'themes/'.$this->theme.'/';
  30. $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$style.'.css')
  31. || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css')
  32. || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css');
  33. }
  34. }