summaryrefslogtreecommitdiffstats
path: root/lib/private/Template
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-10 14:19:56 +0200
commitcaff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch)
tree186d494c2aea5dea7255d3584ef5d595fc6e6194 /lib/private/Template
parentedf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff)
downloadnextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz
nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds unified formatting for control structures like if and loops as well as classes, their methods and anonymous functions. This basically forces the constructs to start on the same line. This is not exactly what PSR2 wants, but I think we can have a few exceptions with "our" style. The starting of braces on the same line is pracrically standard for our code. This also removes and empty lines from method/function bodies at the beginning and end. Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/private/Template')
-rw-r--r--lib/private/Template/Base.php15
-rw-r--r--lib/private/Template/CSSResourceLocator.php7
-rw-r--r--lib/private/Template/IconsCacher.php5
-rw-r--r--lib/private/Template/JSCombiner.php10
-rw-r--r--lib/private/Template/JSConfigHelper.php5
-rwxr-xr-xlib/private/Template/ResourceLocator.php1
-rw-r--r--lib/private/Template/TemplateFileLocator.php2
7 files changed, 18 insertions, 27 deletions
diff --git a/lib/private/Template/Base.php b/lib/private/Template/Base.php
index d07cf2249f7..04d03b6e6f5 100644
--- a/lib/private/Template/Base.php
+++ b/lib/private/Template/Base.php
@@ -65,7 +65,7 @@ class Base {
*/
protected function getAppTemplateDirs($theme, $app, $serverRoot, $app_dir) {
// Check if the app is in the app folder or in the root
- if(file_exists($app_dir.'/templates/')) {
+ if (file_exists($app_dir.'/templates/')) {
return [
$serverRoot.'/themes/'.$theme.'/apps/'.$app.'/templates/',
$app_dir.'/templates/',
@@ -115,10 +115,9 @@ class Base {
* $_[$key][$position] in the template.
*/
public function append($key, $value) {
- if(array_key_exists($key, $this->vars)) {
+ if (array_key_exists($key, $this->vars)) {
$this->vars[$key][] = $value;
- }
- else{
+ } else {
$this->vars[$key] = [ $value ];
}
}
@@ -131,10 +130,9 @@ class Base {
*/
public function printPage() {
$data = $this->fetchPage();
- if($data === false) {
+ if ($data === false) {
return false;
- }
- else{
+ } else {
print $data;
return true;
}
@@ -167,7 +165,7 @@ class Base {
$l = $this->l10n;
$theme = $this->theme;
- if(!is_null($additionalParams)) {
+ if (!is_null($additionalParams)) {
$_ = array_merge($additionalParams, $this->vars);
foreach ($_ as $var => $value) {
${$var} = $value;
@@ -188,5 +186,4 @@ class Base {
// Return data
return $data;
}
-
}
diff --git a/lib/private/Template/CSSResourceLocator.php b/lib/private/Template/CSSResourceLocator.php
index c931a62420a..750d33fd726 100644
--- a/lib/private/Template/CSSResourceLocator.php
+++ b/lib/private/Template/CSSResourceLocator.php
@@ -83,7 +83,7 @@ class CSSResourceLocator extends ResourceLocator {
// turned into cwd.
$app_path = realpath($app_path);
- if(!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
+ if (!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) {
$this->append($app_path, $style.'.css', $app_url);
}
}
@@ -107,9 +107,8 @@ class CSSResourceLocator extends ResourceLocator {
*/
protected function cacheAndAppendScssIfExist($root, $file, $app = 'core') {
if (is_file($root.'/'.$file)) {
- if($this->scssCacher !== null) {
- if($this->scssCacher->process($root, $file, $app)) {
-
+ if ($this->scssCacher !== null) {
+ if ($this->scssCacher->process($root, $file, $app)) {
$this->append($root, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true);
return true;
} else {
diff --git a/lib/private/Template/IconsCacher.php b/lib/private/Template/IconsCacher.php
index 3315f29d98f..00654b5f8fc 100644
--- a/lib/private/Template/IconsCacher.php
+++ b/lib/private/Template/IconsCacher.php
@@ -107,7 +107,6 @@ class IconsCacher {
* @throws \OCP\Files\NotPermittedException
*/
public function setIconsCss(string $css): string {
-
$cachedFile = $this->getCachedList();
if (!$cachedFile) {
$currentData = '';
@@ -169,14 +168,13 @@ class IconsCacher {
$location = \OC::$SERVERROOT . '/core/img/' . $cleanUrl . '.svg';
}
} elseif (\strpos($url, $base) === 0) {
- if(\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
+ if (\preg_match('/([A-z0-9\_\-]+)\/([a-zA-Z0-9-_\~\/\.\=\:\;\+\,]+)\?color=([0-9a-fA-F]{3,6})/', $cleanUrl, $matches)) {
list(,$app,$cleanUrl, $color) = $matches;
$location = \OC_App::getAppPath($app) . '/img/' . $cleanUrl . '.svg';
if ($app === 'settings') {
$location = \OC::$SERVERROOT . '/settings/img/' . $cleanUrl . '.svg';
}
}
-
}
return [
$location,
@@ -265,5 +263,4 @@ class IconsCacher {
$linkToCSS = $this->urlGenerator->linkToRoute('core.Css.getCss', ['appName' => 'icons', 'fileName' => $this->fileName, 'v' => $mtime]);
\OC_Util::addHeader('link', ['rel' => 'stylesheet', 'href' => $linkToCSS], null, true);
}
-
}
diff --git a/lib/private/Template/JSCombiner.php b/lib/private/Template/JSCombiner.php
index 96d5a1e7779..48f6dadfd6a 100644
--- a/lib/private/Template/JSCombiner.php
+++ b/lib/private/Template/JSCombiner.php
@@ -95,12 +95,12 @@ class JSCombiner {
try {
$folder = $this->appData->getFolder($app);
- } catch(NotFoundException $e) {
+ } catch (NotFoundException $e) {
// creating css appdata folder
$folder = $this->appData->newFolder($app);
}
- if($this->isCached($fileName, $folder)) {
+ if ($this->isCached($fileName, $folder)) {
return true;
}
return $this->cache($path, $fileName, $folder);
@@ -145,7 +145,7 @@ class JSCombiner {
}
return true;
- } catch(NotFoundException $e) {
+ } catch (NotFoundException $e) {
return false;
}
}
@@ -176,7 +176,7 @@ class JSCombiner {
$fileName = str_replace('.json', '.js', $fileName);
try {
$cachedfile = $folder->getFile($fileName);
- } catch(NotFoundException $e) {
+ } catch (NotFoundException $e) {
$cachedfile = $folder->newFile($fileName);
}
@@ -228,7 +228,7 @@ class JSCombiner {
public function getContent($root, $file) {
/** @var array $data */
$data = json_decode(file_get_contents($root . '/' . $file));
- if(!is_array($data)) {
+ if (!is_array($data)) {
return [];
}
diff --git a/lib/private/Template/JSConfigHelper.php b/lib/private/Template/JSConfigHelper.php
index 24573d71fe0..70d6f73628d 100644
--- a/lib/private/Template/JSConfigHelper.php
+++ b/lib/private/Template/JSConfigHelper.php
@@ -113,7 +113,6 @@ class JSConfigHelper {
}
public function getConfig() {
-
$userBackendAllowsPasswordConfirmation = true;
if ($this->currentUser !== null) {
$uid = $this->currentUser->getUID();
@@ -137,7 +136,7 @@ class JSConfigHelper {
$apps = $this->appManager->getEnabledAppsForUser($this->currentUser);
}
- foreach($apps as $app) {
+ foreach ($apps as $app) {
$apps_paths[$app] = \OC_App::getAppWebPath($app);
}
@@ -161,7 +160,7 @@ class JSConfigHelper {
$countOfDataLocation = 0;
$dataLocation = str_replace(\OC::$SERVERROOT .'/', '', $this->config->getSystemValue('datadirectory', ''), $countOfDataLocation);
- if($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) {
+ if ($countOfDataLocation !== 1 || !$this->groupManager->isAdmin($uid)) {
$dataLocation = false;
}
diff --git a/lib/private/Template/ResourceLocator.php b/lib/private/Template/ResourceLocator.php
index c99df063588..1d9f60cf5dd 100755
--- a/lib/private/Template/ResourceLocator.php
+++ b/lib/private/Template/ResourceLocator.php
@@ -164,7 +164,6 @@ abstract class ResourceLocator {
* @throws ResourceNotFoundException Only thrown when $throw is true and the resource is missing
*/
protected function append($root, $file, $webRoot = null, $throw = true) {
-
if (!is_string($root)) {
if ($throw) {
throw new ResourceNotFoundException($file, $webRoot);
diff --git a/lib/private/Template/TemplateFileLocator.php b/lib/private/Template/TemplateFileLocator.php
index afeddd6b544..3c7631ba2b5 100644
--- a/lib/private/Template/TemplateFileLocator.php
+++ b/lib/private/Template/TemplateFileLocator.php
@@ -46,7 +46,7 @@ class TemplateFileLocator {
throw new \InvalidArgumentException('Empty template name');
}
- foreach($this->dirs as $dir) {
+ foreach ($this->dirs as $dir) {
$file = $dir.$template.'.php';
if (is_file($file)) {
$this->path = $dir;