Passed
Push — master ( 6b9c5b...5cfcde )
by Roeland
09:52 queued 11s
created
lib/private/Template/TemplateFileLocator.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -26,37 +26,37 @@
 block discarded – undo
26 26
 namespace OC\Template;
27 27
 
28 28
 class TemplateFileLocator {
29
-	protected $dirs;
30
-	private $path;
29
+    protected $dirs;
30
+    private $path;
31 31
 
32
-	/**
33
-	 * @param string[] $dirs
34
-	 */
35
-	public function __construct($dirs) {
36
-		$this->dirs = $dirs;
37
-	}
32
+    /**
33
+     * @param string[] $dirs
34
+     */
35
+    public function __construct($dirs) {
36
+        $this->dirs = $dirs;
37
+    }
38 38
 
39
-	/**
40
-	 * @param string $template
41
-	 * @return string
42
-	 * @throws \Exception
43
-	 */
44
-	public function find($template) {
45
-		if ($template === '') {
46
-			throw new \InvalidArgumentException('Empty template name');
47
-		}
39
+    /**
40
+     * @param string $template
41
+     * @return string
42
+     * @throws \Exception
43
+     */
44
+    public function find($template) {
45
+        if ($template === '') {
46
+            throw new \InvalidArgumentException('Empty template name');
47
+        }
48 48
 
49
-		foreach ($this->dirs as $dir) {
50
-			$file = $dir.$template.'.php';
51
-			if (is_file($file)) {
52
-				$this->path = $dir;
53
-				return $file;
54
-			}
55
-		}
56
-		throw new \Exception('template file not found: template:'.$template);
57
-	}
49
+        foreach ($this->dirs as $dir) {
50
+            $file = $dir.$template.'.php';
51
+            if (is_file($file)) {
52
+                $this->path = $dir;
53
+                return $file;
54
+            }
55
+        }
56
+        throw new \Exception('template file not found: template:'.$template);
57
+    }
58 58
 
59
-	public function getPath() {
60
-		return $this->path;
61
-	}
59
+    public function getPath() {
60
+        return $this->path;
61
+    }
62 62
 }
Please login to merge, or discard this patch.
lib/private/Template/ResourceLocator.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
 				$this->doFind($resource);
76 76
 			} catch (ResourceNotFoundException $e) {
77 77
 				$resourceApp = substr($resource, 0, strpos($resource, '/'));
78
-				$this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
78
+				$this->logger->debug('Could not find resource file "'.$e->getResourcePath().'"', ['app' => $resourceApp]);
79 79
 			}
80 80
 		}
81 81
 		if (!empty($this->theme)) {
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 					$this->doFindTheme($resource);
85 85
 				} catch (ResourceNotFoundException $e) {
86 86
 					$resourceApp = substr($resource, 0, strpos($resource, '/'));
87
-					$this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
87
+					$this->logger->debug('Could not find resource file in theme "'.$e->getResourcePath().'"', ['app' => $resourceApp]);
88 88
 				}
89 89
 			}
90 90
 		}
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 		}
159 159
 		$this->resources[] = [$root, $webRoot, $file];
160 160
 
161
-		if ($throw && !is_file($root . '/' . $file)) {
161
+		if ($throw && !is_file($root.'/'.$file)) {
162 162
 			throw new ResourceNotFoundException($file, $webRoot);
163 163
 		}
164 164
 	}
Please login to merge, or discard this patch.
Indentation   +168 added lines, -168 removed lines patch added patch discarded remove patch
@@ -31,172 +31,172 @@
 block discarded – undo
31 31
 namespace OC\Template;
32 32
 
33 33
 abstract class ResourceLocator {
34
-	protected $theme;
35
-
36
-	protected $mapping;
37
-	protected $serverroot;
38
-	protected $thirdpartyroot;
39
-	protected $webroot;
40
-
41
-	protected $resources = [];
42
-
43
-	/** @var \OCP\ILogger */
44
-	protected $logger;
45
-
46
-	/**
47
-	 * @param \OCP\ILogger $logger
48
-	 * @param string $theme
49
-	 * @param array $core_map
50
-	 * @param array $party_map
51
-	 */
52
-	public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) {
53
-		$this->logger = $logger;
54
-		$this->theme = $theme;
55
-		$this->mapping = $core_map + $party_map;
56
-		$this->serverroot = key($core_map);
57
-		$this->thirdpartyroot = key($party_map);
58
-		$this->webroot = $this->mapping[$this->serverroot];
59
-	}
60
-
61
-	/**
62
-	 * @param string $resource
63
-	 */
64
-	abstract public function doFind($resource);
65
-
66
-	/**
67
-	 * @param string $resource
68
-	 */
69
-	abstract public function doFindTheme($resource);
70
-
71
-	/**
72
-	 * Finds the resources and adds them to the list
73
-	 *
74
-	 * @param array $resources
75
-	 */
76
-	public function find($resources) {
77
-		foreach ($resources as $resource) {
78
-			try {
79
-				$this->doFind($resource);
80
-			} catch (ResourceNotFoundException $e) {
81
-				$resourceApp = substr($resource, 0, strpos($resource, '/'));
82
-				$this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
83
-			}
84
-		}
85
-		if (!empty($this->theme)) {
86
-			foreach ($resources as $resource) {
87
-				try {
88
-					$this->doFindTheme($resource);
89
-				} catch (ResourceNotFoundException $e) {
90
-					$resourceApp = substr($resource, 0, strpos($resource, '/'));
91
-					$this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
92
-				}
93
-			}
94
-		}
95
-	}
96
-
97
-	/**
98
-	 * append the $file resource if exist at $root
99
-	 *
100
-	 * @param string $root path to check
101
-	 * @param string $file the filename
102
-	 * @param string|null $webRoot base for path, default map $root to $webRoot
103
-	 * @return bool True if the resource was found, false otherwise
104
-	 */
105
-	protected function appendIfExist($root, $file, $webRoot = null) {
106
-		if (is_file($root.'/'.$file)) {
107
-			$this->append($root, $file, $webRoot, false);
108
-			return true;
109
-		}
110
-		return false;
111
-	}
112
-
113
-	/**
114
-	 * Attempt to find the webRoot
115
-	 *
116
-	 * traverse the potential web roots upwards in the path
117
-	 *
118
-	 * example:
119
-	 *   - root: /srv/www/apps/myapp
120
-	 *   - available mappings: ['/srv/www']
121
-	 *
122
-	 * First we check if a mapping for /srv/www/apps/myapp is available,
123
-	 * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
124
-	 * valid web root
125
-	 *
126
-	 * @param string $root
127
-	 * @return string|null The web root or null on failure
128
-	 */
129
-	protected function findWebRoot($root) {
130
-		$webRoot = null;
131
-		$tmpRoot = $root;
132
-
133
-		while ($webRoot === null) {
134
-			if (isset($this->mapping[$tmpRoot])) {
135
-				$webRoot = $this->mapping[$tmpRoot];
136
-				break;
137
-			}
138
-
139
-			if ($tmpRoot === '/') {
140
-				break;
141
-			}
142
-
143
-			$tmpRoot = dirname($tmpRoot);
144
-		}
145
-
146
-		if ($webRoot === null) {
147
-			$realpath = realpath($root);
148
-
149
-			if ($realpath && ($realpath !== $root)) {
150
-				return $this->findWebRoot($realpath);
151
-			}
152
-		}
153
-
154
-		return $webRoot;
155
-	}
156
-
157
-	/**
158
-	 * append the $file resource at $root
159
-	 *
160
-	 * @param string $root path to check
161
-	 * @param string $file the filename
162
-	 * @param string|null $webRoot base for path, default map $root to $webRoot
163
-	 * @param bool $throw Throw an exception, when the route does not exist
164
-	 * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
165
-	 */
166
-	protected function append($root, $file, $webRoot = null, $throw = true) {
167
-		if (!is_string($root)) {
168
-			if ($throw) {
169
-				throw new ResourceNotFoundException($file, $webRoot);
170
-			}
171
-			return;
172
-		}
173
-
174
-		if (!$webRoot) {
175
-			$webRoot = $this->findWebRoot($root);
176
-
177
-			if ($webRoot === null) {
178
-				$webRoot = '';
179
-				$this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
180
-					'app' => 'lib',
181
-					'root' => $root,
182
-					'file' => $file,
183
-					'webRoot' => $webRoot,
184
-					'throw' => $throw ? 'true' : 'false'
185
-				]);
186
-			}
187
-		}
188
-		$this->resources[] = [$root, $webRoot, $file];
189
-
190
-		if ($throw && !is_file($root . '/' . $file)) {
191
-			throw new ResourceNotFoundException($file, $webRoot);
192
-		}
193
-	}
194
-
195
-	/**
196
-	 * Returns the list of all resources that should be loaded
197
-	 * @return array
198
-	 */
199
-	public function getResources() {
200
-		return $this->resources;
201
-	}
34
+    protected $theme;
35
+
36
+    protected $mapping;
37
+    protected $serverroot;
38
+    protected $thirdpartyroot;
39
+    protected $webroot;
40
+
41
+    protected $resources = [];
42
+
43
+    /** @var \OCP\ILogger */
44
+    protected $logger;
45
+
46
+    /**
47
+     * @param \OCP\ILogger $logger
48
+     * @param string $theme
49
+     * @param array $core_map
50
+     * @param array $party_map
51
+     */
52
+    public function __construct(\OCP\ILogger $logger, $theme, $core_map, $party_map) {
53
+        $this->logger = $logger;
54
+        $this->theme = $theme;
55
+        $this->mapping = $core_map + $party_map;
56
+        $this->serverroot = key($core_map);
57
+        $this->thirdpartyroot = key($party_map);
58
+        $this->webroot = $this->mapping[$this->serverroot];
59
+    }
60
+
61
+    /**
62
+     * @param string $resource
63
+     */
64
+    abstract public function doFind($resource);
65
+
66
+    /**
67
+     * @param string $resource
68
+     */
69
+    abstract public function doFindTheme($resource);
70
+
71
+    /**
72
+     * Finds the resources and adds them to the list
73
+     *
74
+     * @param array $resources
75
+     */
76
+    public function find($resources) {
77
+        foreach ($resources as $resource) {
78
+            try {
79
+                $this->doFind($resource);
80
+            } catch (ResourceNotFoundException $e) {
81
+                $resourceApp = substr($resource, 0, strpos($resource, '/'));
82
+                $this->logger->debug('Could not find resource file "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
83
+            }
84
+        }
85
+        if (!empty($this->theme)) {
86
+            foreach ($resources as $resource) {
87
+                try {
88
+                    $this->doFindTheme($resource);
89
+                } catch (ResourceNotFoundException $e) {
90
+                    $resourceApp = substr($resource, 0, strpos($resource, '/'));
91
+                    $this->logger->debug('Could not find resource file in theme "' . $e->getResourcePath() . '"', ['app' => $resourceApp]);
92
+                }
93
+            }
94
+        }
95
+    }
96
+
97
+    /**
98
+     * append the $file resource if exist at $root
99
+     *
100
+     * @param string $root path to check
101
+     * @param string $file the filename
102
+     * @param string|null $webRoot base for path, default map $root to $webRoot
103
+     * @return bool True if the resource was found, false otherwise
104
+     */
105
+    protected function appendIfExist($root, $file, $webRoot = null) {
106
+        if (is_file($root.'/'.$file)) {
107
+            $this->append($root, $file, $webRoot, false);
108
+            return true;
109
+        }
110
+        return false;
111
+    }
112
+
113
+    /**
114
+     * Attempt to find the webRoot
115
+     *
116
+     * traverse the potential web roots upwards in the path
117
+     *
118
+     * example:
119
+     *   - root: /srv/www/apps/myapp
120
+     *   - available mappings: ['/srv/www']
121
+     *
122
+     * First we check if a mapping for /srv/www/apps/myapp is available,
123
+     * then /srv/www/apps, /srv/www/apps, /srv/www, ... until we find a
124
+     * valid web root
125
+     *
126
+     * @param string $root
127
+     * @return string|null The web root or null on failure
128
+     */
129
+    protected function findWebRoot($root) {
130
+        $webRoot = null;
131
+        $tmpRoot = $root;
132
+
133
+        while ($webRoot === null) {
134
+            if (isset($this->mapping[$tmpRoot])) {
135
+                $webRoot = $this->mapping[$tmpRoot];
136
+                break;
137
+            }
138
+
139
+            if ($tmpRoot === '/') {
140
+                break;
141
+            }
142
+
143
+            $tmpRoot = dirname($tmpRoot);
144
+        }
145
+
146
+        if ($webRoot === null) {
147
+            $realpath = realpath($root);
148
+
149
+            if ($realpath && ($realpath !== $root)) {
150
+                return $this->findWebRoot($realpath);
151
+            }
152
+        }
153
+
154
+        return $webRoot;
155
+    }
156
+
157
+    /**
158
+     * append the $file resource at $root
159
+     *
160
+     * @param string $root path to check
161
+     * @param string $file the filename
162
+     * @param string|null $webRoot base for path, default map $root to $webRoot
163
+     * @param bool $throw Throw an exception, when the route does not exist
164
+     * @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
165
+     */
166
+    protected function append($root, $file, $webRoot = null, $throw = true) {
167
+        if (!is_string($root)) {
168
+            if ($throw) {
169
+                throw new ResourceNotFoundException($file, $webRoot);
170
+            }
171
+            return;
172
+        }
173
+
174
+        if (!$webRoot) {
175
+            $webRoot = $this->findWebRoot($root);
176
+
177
+            if ($webRoot === null) {
178
+                $webRoot = '';
179
+                $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [
180
+                    'app' => 'lib',
181
+                    'root' => $root,
182
+                    'file' => $file,
183
+                    'webRoot' => $webRoot,
184
+                    'throw' => $throw ? 'true' : 'false'
185
+                ]);
186
+            }
187
+        }
188
+        $this->resources[] = [$root, $webRoot, $file];
189
+
190
+        if ($throw && !is_file($root . '/' . $file)) {
191
+            throw new ResourceNotFoundException($file, $webRoot);
192
+        }
193
+    }
194
+
195
+    /**
196
+     * Returns the list of all resources that should be loaded
197
+     * @return array
198
+     */
199
+    public function getResources() {
200
+        return $this->resources;
201
+    }
202 202
 }
Please login to merge, or discard this patch.
lib/private/Template/Base.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -117,7 +117,7 @@
 block discarded – undo
117 117
 		if (array_key_exists($key, $this->vars)) {
118 118
 			$this->vars[$key][] = $value;
119 119
 		} else {
120
-			$this->vars[$key] = [ $value ];
120
+			$this->vars[$key] = [$value];
121 121
 		}
122 122
 	}
123 123
 
Please login to merge, or discard this patch.
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -33,157 +33,157 @@
 block discarded – undo
33 33
 use OCP\Defaults;
34 34
 
35 35
 class Base {
36
-	private $template; // The template
37
-	private $vars; // Vars
38
-
39
-	/** @var \OCP\IL10N */
40
-	private $l10n;
41
-
42
-	/** @var Defaults */
43
-	private $theme;
44
-
45
-	/**
46
-	 * @param string $template
47
-	 * @param string $requestToken
48
-	 * @param \OCP\IL10N $l10n
49
-	 * @param Defaults $theme
50
-	 */
51
-	public function __construct($template, $requestToken, $l10n, $theme) {
52
-		$this->vars = [];
53
-		$this->vars['requesttoken'] = $requestToken;
54
-		$this->l10n = $l10n;
55
-		$this->template = $template;
56
-		$this->theme = $theme;
57
-	}
58
-
59
-	/**
60
-	 * @param string $serverRoot
61
-	 * @param string|false $app_dir
62
-	 * @param string $theme
63
-	 * @param string $app
64
-	 * @return string[]
65
-	 */
66
-	protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
67
-		// Check if the app is in the app folder or in the root
68
-		if (file_exists($app_dir.'/templates/')) {
69
-			return [
70
-				$serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
71
-				$app_dir.'/templates/',
72
-			];
73
-		}
74
-		return [
75
-			$serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
76
-			$serverRoot.'/'.$app.'/templates/',
77
-		];
78
-	}
79
-
80
-	/**
81
-	 * @param string $serverRoot
82
-	 * @param string $theme
83
-	 * @return string[]
84
-	 */
85
-	protected function getCoreTemplateDirs($theme, $serverRoot) {
86
-		return [
87
-			$serverRoot.'/themes/'.$theme.'/core/templates/',
88
-			$serverRoot.'/core/templates/',
89
-		];
90
-	}
91
-
92
-	/**
93
-	 * Assign variables
94
-	 * @param string $key key
95
-	 * @param array|bool|integer|string $value value
96
-	 * @return bool
97
-	 *
98
-	 * This function assigns a variable. It can be accessed via $_[$key] in
99
-	 * the template.
100
-	 *
101
-	 * If the key existed before, it will be overwritten
102
-	 */
103
-	public function assign($key, $value) {
104
-		$this->vars[$key] = $value;
105
-		return true;
106
-	}
107
-
108
-	/**
109
-	 * Appends a variable
110
-	 * @param string $key key
111
-	 * @param mixed $value value
112
-	 *
113
-	 * This function assigns a variable in an array context. If the key already
114
-	 * exists, the value will be appended. It can be accessed via
115
-	 * $_[$key][$position] in the template.
116
-	 */
117
-	public function append($key, $value) {
118
-		if (array_key_exists($key, $this->vars)) {
119
-			$this->vars[$key][] = $value;
120
-		} else {
121
-			$this->vars[$key] = [ $value ];
122
-		}
123
-	}
124
-
125
-	/**
126
-	 * Prints the proceeded template
127
-	 * @return bool
128
-	 *
129
-	 * This function proceeds the template and prints its output.
130
-	 */
131
-	public function printPage() {
132
-		$data = $this->fetchPage();
133
-		if ($data === false) {
134
-			return false;
135
-		} else {
136
-			print $data;
137
-			return true;
138
-		}
139
-	}
140
-
141
-	/**
142
-	 * Process the template
143
-	 *
144
-	 * @param array|null $additionalParams
145
-	 * @return string This function processes the template.
146
-	 *
147
-	 * This function processes the template.
148
-	 */
149
-	public function fetchPage($additionalParams = null) {
150
-		return $this->load($this->template, $additionalParams);
151
-	}
152
-
153
-	/**
154
-	 * doing the actual work
155
-	 *
156
-	 * @param string $file
157
-	 * @param array|null $additionalParams
158
-	 * @return string content
159
-	 *
160
-	 * Includes the template file, fetches its output
161
-	 */
162
-	protected function load($file, $additionalParams = null) {
163
-		// Register the variables
164
-		$_ = $this->vars;
165
-		$l = $this->l10n;
166
-		$theme = $this->theme;
167
-
168
-		if (!is_null($additionalParams)) {
169
-			$_ = array_merge($additionalParams, $this->vars);
170
-			foreach ($_ as $var => $value) {
171
-				${$var} = $value;
172
-			}
173
-		}
174
-
175
-		// Include
176
-		ob_start();
177
-		try {
178
-			include $file;
179
-			$data = ob_get_contents();
180
-		} catch (\Exception $e) {
181
-			@ob_end_clean();
182
-			throw $e;
183
-		}
184
-		@ob_end_clean();
185
-
186
-		// Return data
187
-		return $data;
188
-	}
36
+    private $template; // The template
37
+    private $vars; // Vars
38
+
39
+    /** @var \OCP\IL10N */
40
+    private $l10n;
41
+
42
+    /** @var Defaults */
43
+    private $theme;
44
+
45
+    /**
46
+     * @param string $template
47
+     * @param string $requestToken
48
+     * @param \OCP\IL10N $l10n
49
+     * @param Defaults $theme
50
+     */
51
+    public function __construct($template, $requestToken, $l10n, $theme) {
52
+        $this->vars = [];
53
+        $this->vars['requesttoken'] = $requestToken;
54
+        $this->l10n = $l10n;
55
+        $this->template = $template;
56
+        $this->theme = $theme;
57
+    }
58
+
59
+    /**
60
+     * @param string $serverRoot
61
+     * @param string|false $app_dir
62
+     * @param string $theme
63
+     * @param string $app
64
+     * @return string[]
65
+     */
66
+    protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
67
+        // Check if the app is in the app folder or in the root
68
+        if (file_exists($app_dir.'/templates/')) {
69
+            return [
70
+                $serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
71
+                $app_dir.'/templates/',
72
+            ];
73
+        }
74
+        return [
75
+            $serverRoot.'/themes/'.$theme.'/'.$app.'/templates/',
76
+            $serverRoot.'/'.$app.'/templates/',
77
+        ];
78
+    }
79
+
80
+    /**
81
+     * @param string $serverRoot
82
+     * @param string $theme
83
+     * @return string[]
84
+     */
85
+    protected function getCoreTemplateDirs($theme, $serverRoot) {
86
+        return [
87
+            $serverRoot.'/themes/'.$theme.'/core/templates/',
88
+            $serverRoot.'/core/templates/',
89
+        ];
90
+    }
91
+
92
+    /**
93
+     * Assign variables
94
+     * @param string $key key
95
+     * @param array|bool|integer|string $value value
96
+     * @return bool
97
+     *
98
+     * This function assigns a variable. It can be accessed via $_[$key] in
99
+     * the template.
100
+     *
101
+     * If the key existed before, it will be overwritten
102
+     */
103
+    public function assign($key, $value) {
104
+        $this->vars[$key] = $value;
105
+        return true;
106
+    }
107
+
108
+    /**
109
+     * Appends a variable
110
+     * @param string $key key
111
+     * @param mixed $value value
112
+     *
113
+     * This function assigns a variable in an array context. If the key already
114
+     * exists, the value will be appended. It can be accessed via
115
+     * $_[$key][$position] in the template.
116
+     */
117
+    public function append($key, $value) {
118
+        if (array_key_exists($key, $this->vars)) {
119
+            $this->vars[$key][] = $value;
120
+        } else {
121
+            $this->vars[$key] = [ $value ];
122
+        }
123
+    }
124
+
125
+    /**
126
+     * Prints the proceeded template
127
+     * @return bool
128
+     *
129
+     * This function proceeds the template and prints its output.
130
+     */
131
+    public function printPage() {
132
+        $data = $this->fetchPage();
133
+        if ($data === false) {
134
+            return false;
135
+        } else {
136
+            print $data;
137
+            return true;
138
+        }
139
+    }
140
+
141
+    /**
142
+     * Process the template
143
+     *
144
+     * @param array|null $additionalParams
145
+     * @return string This function processes the template.
146
+     *
147
+     * This function processes the template.
148
+     */
149
+    public function fetchPage($additionalParams = null) {
150
+        return $this->load($this->template, $additionalParams);
151
+    }
152
+
153
+    /**
154
+     * doing the actual work
155
+     *
156
+     * @param string $file
157
+     * @param array|null $additionalParams
158
+     * @return string content
159
+     *
160
+     * Includes the template file, fetches its output
161
+     */
162
+    protected function load($file, $additionalParams = null) {
163
+        // Register the variables
164
+        $_ = $this->vars;
165
+        $l = $this->l10n;
166
+        $theme = $this->theme;
167
+
168
+        if (!is_null($additionalParams)) {
169
+            $_ = array_merge($additionalParams, $this->vars);
170
+            foreach ($_ as $var => $value) {
171
+                ${$var} = $value;
172
+            }
173
+        }
174
+
175
+        // Include
176
+        ob_start();
177
+        try {
178
+            include $file;
179
+            $data = ob_get_contents();
180
+        } catch (\Exception $e) {
181
+            @ob_end_clean();
182
+            throw $e;
183
+        }
184
+        @ob_end_clean();
185
+
186
+        // Return data
187
+        return $data;
188
+    }
189 189
 }
Please login to merge, or discard this patch.
lib/private/Diagnostics/EventLogger.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -28,56 +28,56 @@
 block discarded – undo
28 28
 use OCP\Diagnostics\IEventLogger;
29 29
 
30 30
 class EventLogger implements IEventLogger {
31
-	/**
32
-	 * @var \OC\Diagnostics\Event[]
33
-	 */
34
-	private $events = [];
31
+    /**
32
+     * @var \OC\Diagnostics\Event[]
33
+     */
34
+    private $events = [];
35 35
 	
36
-	/**
37
-	 * @var bool - Module needs to be activated by some app
38
-	 */
39
-	private $activated = false;
36
+    /**
37
+     * @var bool - Module needs to be activated by some app
38
+     */
39
+    private $activated = false;
40 40
 
41
-	/**
42
-	 * @inheritdoc
43
-	 */
44
-	public function start($id, $description) {
45
-		if ($this->activated) {
46
-			$this->events[$id] = new Event($id, $description, microtime(true));
47
-		}
48
-	}
41
+    /**
42
+     * @inheritdoc
43
+     */
44
+    public function start($id, $description) {
45
+        if ($this->activated) {
46
+            $this->events[$id] = new Event($id, $description, microtime(true));
47
+        }
48
+    }
49 49
 
50
-	/**
51
-	 * @inheritdoc
52
-	 */
53
-	public function end($id) {
54
-		if ($this->activated && isset($this->events[$id])) {
55
-			$timing = $this->events[$id];
56
-			$timing->end(microtime(true));
57
-		}
58
-	}
50
+    /**
51
+     * @inheritdoc
52
+     */
53
+    public function end($id) {
54
+        if ($this->activated && isset($this->events[$id])) {
55
+            $timing = $this->events[$id];
56
+            $timing->end(microtime(true));
57
+        }
58
+    }
59 59
 
60
-	/**
61
-	 * @inheritdoc
62
-	 */
63
-	public function log($id, $description, $start, $end) {
64
-		if ($this->activated) {
65
-			$this->events[$id] = new Event($id, $description, $start);
66
-			$this->events[$id]->end($end);
67
-		}
68
-	}
60
+    /**
61
+     * @inheritdoc
62
+     */
63
+    public function log($id, $description, $start, $end) {
64
+        if ($this->activated) {
65
+            $this->events[$id] = new Event($id, $description, $start);
66
+            $this->events[$id]->end($end);
67
+        }
68
+    }
69 69
 
70
-	/**
71
-	 * @inheritdoc
72
-	 */
73
-	public function getEvents() {
74
-		return $this->events;
75
-	}
70
+    /**
71
+     * @inheritdoc
72
+     */
73
+    public function getEvents() {
74
+        return $this->events;
75
+    }
76 76
 	
77
-	/**
78
-	 * @inheritdoc
79
-	 */
80
-	public function activate() {
81
-		$this->activated = true;
82
-	}
77
+    /**
78
+     * @inheritdoc
79
+     */
80
+    public function activate() {
81
+        $this->activated = true;
82
+    }
83 83
 }
Please login to merge, or discard this patch.
lib/private/Cache/CappedMemoryCache.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -30,66 +30,66 @@
 block discarded – undo
30 30
  * Uses a simple FIFO expiry mechanism
31 31
  */
32 32
 class CappedMemoryCache implements ICache, \ArrayAccess {
33
-	private $capacity;
34
-	private $cache = [];
35
-
36
-	public function __construct($capacity = 512) {
37
-		$this->capacity = $capacity;
38
-	}
39
-
40
-	public function hasKey($key) {
41
-		return isset($this->cache[$key]);
42
-	}
43
-
44
-	public function get($key) {
45
-		return isset($this->cache[$key]) ? $this->cache[$key] : null;
46
-	}
47
-
48
-	public function set($key, $value, $ttl = 0) {
49
-		if (is_null($key)) {
50
-			$this->cache[] = $value;
51
-		} else {
52
-			$this->cache[$key] = $value;
53
-		}
54
-		$this->garbageCollect();
55
-	}
56
-
57
-	public function remove($key) {
58
-		unset($this->cache[$key]);
59
-		return true;
60
-	}
61
-
62
-	public function clear($prefix = '') {
63
-		$this->cache = [];
64
-		return true;
65
-	}
66
-
67
-	public function offsetExists($offset) {
68
-		return $this->hasKey($offset);
69
-	}
70
-
71
-	public function &offsetGet($offset) {
72
-		return $this->cache[$offset];
73
-	}
74
-
75
-	public function offsetSet($offset, $value) {
76
-		$this->set($offset, $value);
77
-	}
78
-
79
-	public function offsetUnset($offset) {
80
-		$this->remove($offset);
81
-	}
82
-
83
-	public function getData() {
84
-		return $this->cache;
85
-	}
86
-
87
-
88
-	private function garbageCollect() {
89
-		while (count($this->cache) > $this->capacity) {
90
-			reset($this->cache);
91
-			$key = key($this->cache);
92
-			$this->remove($key);
93
-		}
94
-	}
33
+    private $capacity;
34
+    private $cache = [];
35
+
36
+    public function __construct($capacity = 512) {
37
+        $this->capacity = $capacity;
38
+    }
39
+
40
+    public function hasKey($key) {
41
+        return isset($this->cache[$key]);
42
+    }
43
+
44
+    public function get($key) {
45
+        return isset($this->cache[$key]) ? $this->cache[$key] : null;
46
+    }
47
+
48
+    public function set($key, $value, $ttl = 0) {
49
+        if (is_null($key)) {
50
+            $this->cache[] = $value;
51
+        } else {
52
+            $this->cache[$key] = $value;
53
+        }
54
+        $this->garbageCollect();
55
+    }
56
+
57
+    public function remove($key) {
58
+        unset($this->cache[$key]);
59
+        return true;
60
+    }
61
+
62
+    public function clear($prefix = '') {
63
+        $this->cache = [];
64
+        return true;
65
+    }
66
+
67
+    public function offsetExists($offset) {
68
+        return $this->hasKey($offset);
69
+    }
70
+
71
+    public function &offsetGet($offset) {
72
+        return $this->cache[$offset];
73
+    }
74
+
75
+    public function offsetSet($offset, $value) {
76
+        $this->set($offset, $value);
77
+    }
78
+
79
+    public function offsetUnset($offset) {
80
+        $this->remove($offset);
81
+    }
82
+
83
+    public function getData() {
84
+        return $this->cache;
85
+    }
86
+
87
+
88
+    private function garbageCollect() {
89
+        while (count($this->cache) > $this->capacity) {
90
+            reset($this->cache);
91
+            $key = key($this->cache);
92
+            $this->remove($key);
93
+        }
94
+    }
95 95
 }
Please login to merge, or discard this patch.
lib/private/Search.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
 		$results = [];
62 62
 		foreach ($this->providers as $provider) {
63 63
 			/** @var $provider Provider */
64
-			if (! $provider->providesResultsFor($inApps)) {
64
+			if (!$provider->providesResultsFor($inApps)) {
65 65
 				continue;
66 66
 			}
67 67
 			if ($provider instanceof PagedProvider) {
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	public function removeProvider($provider) {
97 97
 		$this->registeredProviders = array_filter(
98 98
 			$this->registeredProviders,
99
-			function ($element) use ($provider) {
99
+			function($element) use ($provider) {
100 100
 				return ($element['class'] != $provider);
101 101
 			}
102 102
 		);
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 	 * Create instances of all the registered search providers
118 118
 	 */
119 119
 	private function initProviders() {
120
-		if (! empty($this->providers)) {
120
+		if (!empty($this->providers)) {
121 121
 			return;
122 122
 		}
123 123
 		foreach ($this->registeredProviders as $provider) {
Please login to merge, or discard this patch.
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -36,85 +36,85 @@
 block discarded – undo
36 36
  * Provide an interface to all search providers
37 37
  */
38 38
 class Search implements ISearch {
39
-	private $providers = [];
40
-	private $registeredProviders = [];
39
+    private $providers = [];
40
+    private $registeredProviders = [];
41 41
 
42
-	/**
43
-	 * Search all providers for $query
44
-	 * @param string $query
45
-	 * @param string[] $inApps optionally limit results to the given apps
46
-	 * @param int $page pages start at page 1
47
-	 * @param int $size, 0 = all
48
-	 * @return array An array of OC\Search\Result's
49
-	 */
50
-	public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) {
51
-		$this->initProviders();
52
-		$results = [];
53
-		foreach ($this->providers as $provider) {
54
-			/** @var $provider Provider */
55
-			if (! $provider->providesResultsFor($inApps)) {
56
-				continue;
57
-			}
58
-			if ($provider instanceof PagedProvider) {
59
-				$results = array_merge($results, $provider->searchPaged($query, $page, $size));
60
-			} elseif ($provider instanceof Provider) {
61
-				$providerResults = $provider->search($query);
62
-				if ($size > 0) {
63
-					$slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
64
-					$results = array_merge($results, $slicedResults);
65
-				} else {
66
-					$results = array_merge($results, $providerResults);
67
-				}
68
-			} else {
69
-				\OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
70
-			}
71
-		}
72
-		return $results;
73
-	}
42
+    /**
43
+     * Search all providers for $query
44
+     * @param string $query
45
+     * @param string[] $inApps optionally limit results to the given apps
46
+     * @param int $page pages start at page 1
47
+     * @param int $size, 0 = all
48
+     * @return array An array of OC\Search\Result's
49
+     */
50
+    public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) {
51
+        $this->initProviders();
52
+        $results = [];
53
+        foreach ($this->providers as $provider) {
54
+            /** @var $provider Provider */
55
+            if (! $provider->providesResultsFor($inApps)) {
56
+                continue;
57
+            }
58
+            if ($provider instanceof PagedProvider) {
59
+                $results = array_merge($results, $provider->searchPaged($query, $page, $size));
60
+            } elseif ($provider instanceof Provider) {
61
+                $providerResults = $provider->search($query);
62
+                if ($size > 0) {
63
+                    $slicedResults = array_slice($providerResults, ($page - 1) * $size, $size);
64
+                    $results = array_merge($results, $slicedResults);
65
+                } else {
66
+                    $results = array_merge($results, $providerResults);
67
+                }
68
+            } else {
69
+                \OC::$server->getLogger()->warning('Ignoring Unknown search provider', ['provider' => $provider]);
70
+            }
71
+        }
72
+        return $results;
73
+    }
74 74
 
75
-	/**
76
-	 * Remove all registered search providers
77
-	 */
78
-	public function clearProviders() {
79
-		$this->providers = [];
80
-		$this->registeredProviders = [];
81
-	}
75
+    /**
76
+     * Remove all registered search providers
77
+     */
78
+    public function clearProviders() {
79
+        $this->providers = [];
80
+        $this->registeredProviders = [];
81
+    }
82 82
 
83
-	/**
84
-	 * Remove one existing search provider
85
-	 * @param string $provider class name of a OC\Search\Provider
86
-	 */
87
-	public function removeProvider($provider) {
88
-		$this->registeredProviders = array_filter(
89
-			$this->registeredProviders,
90
-			function ($element) use ($provider) {
91
-				return ($element['class'] != $provider);
92
-			}
93
-		);
94
-		// force regeneration of providers on next search
95
-		$this->providers = [];
96
-	}
83
+    /**
84
+     * Remove one existing search provider
85
+     * @param string $provider class name of a OC\Search\Provider
86
+     */
87
+    public function removeProvider($provider) {
88
+        $this->registeredProviders = array_filter(
89
+            $this->registeredProviders,
90
+            function ($element) use ($provider) {
91
+                return ($element['class'] != $provider);
92
+            }
93
+        );
94
+        // force regeneration of providers on next search
95
+        $this->providers = [];
96
+    }
97 97
 
98
-	/**
99
-	 * Register a new search provider to search with
100
-	 * @param string $class class name of a OC\Search\Provider
101
-	 * @param array $options optional
102
-	 */
103
-	public function registerProvider($class, array $options = []) {
104
-		$this->registeredProviders[] = ['class' => $class, 'options' => $options];
105
-	}
98
+    /**
99
+     * Register a new search provider to search with
100
+     * @param string $class class name of a OC\Search\Provider
101
+     * @param array $options optional
102
+     */
103
+    public function registerProvider($class, array $options = []) {
104
+        $this->registeredProviders[] = ['class' => $class, 'options' => $options];
105
+    }
106 106
 
107
-	/**
108
-	 * Create instances of all the registered search providers
109
-	 */
110
-	private function initProviders() {
111
-		if (! empty($this->providers)) {
112
-			return;
113
-		}
114
-		foreach ($this->registeredProviders as $provider) {
115
-			$class = $provider['class'];
116
-			$options = $provider['options'];
117
-			$this->providers[] = new $class($options);
118
-		}
119
-	}
107
+    /**
108
+     * Create instances of all the registered search providers
109
+     */
110
+    private function initProviders() {
111
+        if (! empty($this->providers)) {
112
+            return;
113
+        }
114
+        foreach ($this->registeredProviders as $provider) {
115
+            $class = $provider['class'];
116
+            $options = $provider['options'];
117
+            $this->providers[] = new $class($options);
118
+        }
119
+    }
120 120
 }
Please login to merge, or discard this patch.
lib/private/Search/Result/Audio.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
  */
30 30
 class Audio extends File {
31 31
 
32
-	/**
33
-	 * Type name; translated in templates
34
-	 * @var string
35
-	 */
36
-	public $type = 'audio';
32
+    /**
33
+     * Type name; translated in templates
34
+     * @var string
35
+     */
36
+    public $type = 'audio';
37 37
 	
38
-	/**
39
-	 * @TODO add ID3 information
40
-	 */
38
+    /**
39
+     * @TODO add ID3 information
40
+     */
41 41
 }
Please login to merge, or discard this patch.
lib/private/Search/Result/Image.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@
 block discarded – undo
29 29
  */
30 30
 class Image extends File {
31 31
 
32
-	/**
33
-	 * Type name; translated in templates
34
-	 * @var string
35
-	 */
36
-	public $type = 'image';
32
+    /**
33
+     * Type name; translated in templates
34
+     * @var string
35
+     */
36
+    public $type = 'image';
37 37
 	
38
-	/**
39
-	 * @TODO add EXIF information
40
-	 */
38
+    /**
39
+     * @TODO add EXIF information
40
+     */
41 41
 }
Please login to merge, or discard this patch.
lib/private/Search/Result/Folder.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@
 block discarded – undo
29 29
  */
30 30
 class Folder extends File {
31 31
 
32
-	/**
33
-	 * Type name; translated in templates
34
-	 * @var string
35
-	 */
36
-	public $type = 'folder';
32
+    /**
33
+     * Type name; translated in templates
34
+     * @var string
35
+     */
36
+    public $type = 'folder';
37 37
 }
Please login to merge, or discard this patch.