|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author Bart Visscher <[email protected]> |
|
4
|
|
|
* @author Joas Schilling <[email protected]> |
|
5
|
|
|
* @author Michael Jobst <[email protected]> |
|
6
|
|
|
* @author Morris Jobke <[email protected]> |
|
7
|
|
|
* @author Philipp Schaffrath <[email protected]> |
|
8
|
|
|
* @author Thomas Müller <[email protected]> |
|
9
|
|
|
* |
|
10
|
|
|
* @copyright Copyright (c) 2018, ownCloud GmbH |
|
11
|
|
|
* @license AGPL-3.0 |
|
12
|
|
|
* |
|
13
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
14
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
15
|
|
|
* as published by the Free Software Foundation. |
|
16
|
|
|
* |
|
17
|
|
|
* This program is distributed in the hope that it will be useful, |
|
18
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
19
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
20
|
|
|
* GNU Affero General Public License for more details. |
|
21
|
|
|
* |
|
22
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
23
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
24
|
|
|
* |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
namespace OC\Template; |
|
28
|
|
|
|
|
29
|
|
|
class JSResourceLocator extends ResourceLocator { |
|
30
|
|
|
/** |
|
31
|
|
|
* @param string $script |
|
32
|
|
|
*/ |
|
33
|
|
|
public function doFind($script) { |
|
34
|
|
|
$themeDirectory = $this->theme->getDirectory(); |
|
35
|
|
|
|
|
36
|
|
|
if (strpos($script, '/l10n/') !== false) { |
|
37
|
|
|
// For language files we try to load them all, so themes can overwrite |
|
38
|
|
|
// single l10n strings without having to translate all of them. |
|
39
|
|
|
$found = 0; |
|
40
|
|
|
$found += $this->appendOnceIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
41
|
|
|
$found += $this->appendOnceIfExist($this->serverroot, $themeDirectory.'/core/'.$script.'.js'); |
|
42
|
|
|
$found += $this->appendOnceIfExist($this->serverroot, $script.'.js'); |
|
43
|
|
|
$found += $this->appendOnceIfExist($this->serverroot, $themeDirectory.'/'.$script.'.js'); |
|
44
|
|
|
$found += $this->appendOnceIfExist($this->serverroot, $themeDirectory.'/apps/'.$script.'.js'); |
|
45
|
|
|
|
|
46
|
|
|
if ($found) { |
|
47
|
|
|
return; |
|
48
|
|
|
} |
|
49
|
|
|
} else if ($this->appendOnceIfExist($this->serverroot, $themeDirectory.'/apps/'.$script.'.js') |
|
50
|
|
|
|| $this->appendOnceIfExist($this->serverroot, $themeDirectory.'/'.$script.'.js') |
|
51
|
|
|
|| $this->appendOnceIfExist($this->serverroot, $script.'.js') |
|
52
|
|
|
|| $this->appendOnceIfExist($this->serverroot, $themeDirectory.'/core/'.$script.'.js') |
|
53
|
|
|
|| $this->appendOnceIfExist($this->serverroot, 'core/'.$script.'.js') |
|
54
|
|
|
) { |
|
55
|
|
|
return; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$app = substr($script, 0, strpos($script, '/')); |
|
59
|
|
|
$script = substr($script, strpos($script, '/')+1); |
|
60
|
|
|
$app_path = \OC_App::getAppPath($app); |
|
61
|
|
|
if( $app_path === false ) { return; } |
|
62
|
|
|
$app_url = \OC_App::getAppWebPath($app); |
|
63
|
|
|
$app_url = ($app_url !== false) ? $app_url : null; |
|
64
|
|
|
|
|
65
|
|
|
// missing translations files fill be ignored |
|
66
|
|
|
$this->appendOnceIfExist($app_path, $script . '.js', $app_url); |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param string $script |
|
71
|
|
|
*/ |
|
72
|
|
|
public function doFindTheme($script) { |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|