Passed
Push — master ( e8872f...ec4280 )
by John
16:02 queued 12s
created
lib/private/Template/JSResourceLocator.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -29,109 +29,109 @@
 block discarded – undo
29 29
 
30 30
 class JSResourceLocator extends ResourceLocator {
31 31
 
32
-	/** @var JSCombiner */
33
-	protected $jsCombiner;
34
-
35
-	public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) {
36
-		parent::__construct($logger, $theme, $core_map, $party_map);
37
-
38
-		$this->jsCombiner = $JSCombiner;
39
-	}
40
-
41
-	/**
42
-	 * @param string $script
43
-	 */
44
-	public function doFind($script) {
45
-		$theme_dir = 'themes/'.$this->theme.'/';
46
-		if (strpos($script, '3rdparty') === 0
47
-			&& $this->appendIfExist($this->thirdpartyroot, $script.'.js')) {
48
-			return;
49
-		}
50
-
51
-		// Extracting the appId and the script file name
52
-		$app = substr($script, 0, strpos($script, '/'));
53
-		$scriptName = basename($script);
54
-
55
-		if (strpos($script, '/l10n/') !== false) {
56
-			// For language files we try to load them all, so themes can overwrite
57
-			// single l10n strings without having to translate all of them.
58
-			$found = 0;
59
-			$found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js');
60
-			$found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js');
61
-			$found += $this->appendIfExist($this->serverroot, $script.'.js');
62
-			$found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js');
63
-			$found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js');
64
-			$found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js');
65
-
66
-			if ($found) {
67
-				return;
68
-			}
69
-		} elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js')
70
-			|| $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js')
71
-			|| $this->appendIfExist($this->serverroot, $script.'.js')
72
-			|| $this->appendIfExist($this->serverroot, "dist/$app-$scriptName.js")
73
-			|| $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js')
74
-			|| $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json')
75
-			|| $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js')
76
-			|| $this->appendIfExist($this->serverroot, 'core/'.$script.'.js')
77
-			|| (strpos($scriptName, '/') === -1 && $this->appendIfExist($this->serverroot, "dist/core-$scriptName.js"))
78
-			|| $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json')
79
-		) {
80
-			return;
81
-		}
82
-
83
-		$script = substr($script, strpos($script, '/') + 1);
84
-		$app_path = \OC_App::getAppPath($app);
85
-		$app_url = \OC_App::getAppWebPath($app);
86
-
87
-		if ($app_path !== false) {
88
-			// Account for the possibility of having symlinks in app path. Only
89
-			// do this if $app_path is set, because an empty argument to realpath
90
-			// gets turned into cwd.
91
-			$app_path = realpath($app_path);
92
-		}
93
-
94
-		// missing translations files fill be ignored
95
-		if (strpos($script, 'l10n/') === 0) {
96
-			$this->appendIfExist($app_path, $script . '.js', $app_url);
97
-			return;
98
-		}
99
-
100
-		if ($app_path === false && $app_url === false) {
101
-			$this->logger->error('Could not find resource {resource} to load', [
102
-				'resource' => $app . '/' . $script . '.js',
103
-				'app' => 'jsresourceloader',
104
-			]);
105
-			return;
106
-		}
107
-
108
-		if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) {
109
-			$this->append($app_path, $script . '.js', $app_url);
110
-		}
111
-	}
112
-
113
-	/**
114
-	 * @param string $script
115
-	 */
116
-	public function doFindTheme($script) {
117
-	}
118
-
119
-	protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') {
120
-		if (is_file($root.'/'.$file)) {
121
-			if ($this->jsCombiner->process($root, $file, $app)) {
122
-				$this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false);
123
-			} else {
124
-				// Add all the files from the json
125
-				$files = $this->jsCombiner->getContent($root, $file);
126
-				$app_url = \OC_App::getAppWebPath($app);
127
-
128
-				foreach ($files as $jsFile) {
129
-					$this->append($root, $jsFile, $app_url);
130
-				}
131
-			}
132
-			return true;
133
-		}
134
-
135
-		return false;
136
-	}
32
+    /** @var JSCombiner */
33
+    protected $jsCombiner;
34
+
35
+    public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) {
36
+        parent::__construct($logger, $theme, $core_map, $party_map);
37
+
38
+        $this->jsCombiner = $JSCombiner;
39
+    }
40
+
41
+    /**
42
+     * @param string $script
43
+     */
44
+    public function doFind($script) {
45
+        $theme_dir = 'themes/'.$this->theme.'/';
46
+        if (strpos($script, '3rdparty') === 0
47
+            && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) {
48
+            return;
49
+        }
50
+
51
+        // Extracting the appId and the script file name
52
+        $app = substr($script, 0, strpos($script, '/'));
53
+        $scriptName = basename($script);
54
+
55
+        if (strpos($script, '/l10n/') !== false) {
56
+            // For language files we try to load them all, so themes can overwrite
57
+            // single l10n strings without having to translate all of them.
58
+            $found = 0;
59
+            $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js');
60
+            $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js');
61
+            $found += $this->appendIfExist($this->serverroot, $script.'.js');
62
+            $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js');
63
+            $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js');
64
+            $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js');
65
+
66
+            if ($found) {
67
+                return;
68
+            }
69
+        } elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js')
70
+            || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js')
71
+            || $this->appendIfExist($this->serverroot, $script.'.js')
72
+            || $this->appendIfExist($this->serverroot, "dist/$app-$scriptName.js")
73
+            || $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js')
74
+            || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json')
75
+            || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js')
76
+            || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js')
77
+            || (strpos($scriptName, '/') === -1 && $this->appendIfExist($this->serverroot, "dist/core-$scriptName.js"))
78
+            || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json')
79
+        ) {
80
+            return;
81
+        }
82
+
83
+        $script = substr($script, strpos($script, '/') + 1);
84
+        $app_path = \OC_App::getAppPath($app);
85
+        $app_url = \OC_App::getAppWebPath($app);
86
+
87
+        if ($app_path !== false) {
88
+            // Account for the possibility of having symlinks in app path. Only
89
+            // do this if $app_path is set, because an empty argument to realpath
90
+            // gets turned into cwd.
91
+            $app_path = realpath($app_path);
92
+        }
93
+
94
+        // missing translations files fill be ignored
95
+        if (strpos($script, 'l10n/') === 0) {
96
+            $this->appendIfExist($app_path, $script . '.js', $app_url);
97
+            return;
98
+        }
99
+
100
+        if ($app_path === false && $app_url === false) {
101
+            $this->logger->error('Could not find resource {resource} to load', [
102
+                'resource' => $app . '/' . $script . '.js',
103
+                'app' => 'jsresourceloader',
104
+            ]);
105
+            return;
106
+        }
107
+
108
+        if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) {
109
+            $this->append($app_path, $script . '.js', $app_url);
110
+        }
111
+    }
112
+
113
+    /**
114
+     * @param string $script
115
+     */
116
+    public function doFindTheme($script) {
117
+    }
118
+
119
+    protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') {
120
+        if (is_file($root.'/'.$file)) {
121
+            if ($this->jsCombiner->process($root, $file, $app)) {
122
+                $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false);
123
+            } else {
124
+                // Add all the files from the json
125
+                $files = $this->jsCombiner->getContent($root, $file);
126
+                $app_url = \OC_App::getAppWebPath($app);
127
+
128
+                foreach ($files as $jsFile) {
129
+                    $this->append($root, $jsFile, $app_url);
130
+                }
131
+            }
132
+            return true;
133
+        }
134
+
135
+        return false;
136
+    }
137 137
 }
Please login to merge, or discard this patch.