cssresourcelocator.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 CSSResourceLocator extends ResourceLocator {
  26. /**
  27. * @param string $style
  28. */
  29. public function doFind($style) {
  30. if (strpos($style, '3rdparty') === 0
  31. && $this->appendIfExist($this->thirdpartyroot, $style.'.css')
  32. || $this->appendIfExist($this->serverroot, $style.'.css')
  33. || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css')
  34. ) {
  35. return;
  36. }
  37. $app = substr($style, 0, strpos($style, '/'));
  38. $style = substr($style, strpos($style, '/')+1);
  39. $app_path = \OC_App::getAppPath($app);
  40. $app_url = \OC_App::getAppWebPath($app);
  41. $this->append($app_path, $style.'.css', $app_url);
  42. }
  43. /**
  44. * @param string $style
  45. */
  46. public function doFindTheme($style) {
  47. $theme_dir = 'themes/'.$this->theme.'/';
  48. $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$style.'.css')
  49. || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css')
  50. || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css');
  51. }
  52. }