CSSResourceLocator.php 1.8 KB

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