@@ -77,20 +77,20 @@ |
||
77 | 77 | |
78 | 78 | // missing translations files fill be ignored |
79 | 79 | if (strpos($script, 'l10n/') === 0) { |
80 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
80 | + $this->appendIfExist($app_path, $script.'.js', $app_url); |
|
81 | 81 | return; |
82 | 82 | } |
83 | 83 | |
84 | 84 | if ($app_path === false && $app_url === false) { |
85 | 85 | $this->logger->error('Could not find resource {resource} to load', [ |
86 | - 'resource' => $app . '/' . $script . '.js', |
|
86 | + 'resource' => $app.'/'.$script.'.js', |
|
87 | 87 | 'app' => 'jsresourceloader', |
88 | 88 | ]); |
89 | 89 | return; |
90 | 90 | } |
91 | 91 | |
92 | 92 | if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
93 | - $this->append($app_path, $script . '.js', $app_url); |
|
93 | + $this->append($app_path, $script.'.js', $app_url); |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 |
@@ -30,103 +30,103 @@ |
||
30 | 30 | |
31 | 31 | class JSResourceLocator extends ResourceLocator { |
32 | 32 | |
33 | - /** @var JSCombiner */ |
|
34 | - protected $jsCombiner; |
|
35 | - |
|
36 | - public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
37 | - parent::__construct($logger, $theme, $core_map, $party_map); |
|
38 | - |
|
39 | - $this->jsCombiner = $JSCombiner; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * @param string $script |
|
44 | - */ |
|
45 | - public function doFind($script) { |
|
46 | - $theme_dir = 'themes/'.$this->theme.'/'; |
|
47 | - if (strpos($script, '3rdparty') === 0 |
|
48 | - && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
49 | - return; |
|
50 | - } |
|
51 | - |
|
52 | - if (strpos($script, '/l10n/') !== false) { |
|
53 | - // For language files we try to load them all, so themes can overwrite |
|
54 | - // single l10n strings without having to translate all of them. |
|
55 | - $found = 0; |
|
56 | - $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
57 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
58 | - $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
59 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
60 | - $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); |
|
61 | - $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
62 | - |
|
63 | - if ($found) { |
|
64 | - return; |
|
65 | - } |
|
66 | - } elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
67 | - || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
68 | - || $this->appendIfExist($this->serverroot, $script.'.js') |
|
69 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
70 | - || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
71 | - || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
72 | - || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
73 | - ) { |
|
74 | - return; |
|
75 | - } |
|
76 | - |
|
77 | - $app = substr($script, 0, strpos($script, '/')); |
|
78 | - $script = substr($script, strpos($script, '/') + 1); |
|
79 | - $app_path = \OC_App::getAppPath($app); |
|
80 | - $app_url = \OC_App::getAppWebPath($app); |
|
81 | - |
|
82 | - if ($app_path !== false) { |
|
83 | - // Account for the possibility of having symlinks in app path. Only |
|
84 | - // do this if $app_path is set, because an empty argument to realpath |
|
85 | - // gets turned into cwd. |
|
86 | - $app_path = realpath($app_path); |
|
87 | - } |
|
88 | - |
|
89 | - // missing translations files fill be ignored |
|
90 | - if (strpos($script, 'l10n/') === 0) { |
|
91 | - $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
92 | - return; |
|
93 | - } |
|
94 | - |
|
95 | - if ($app_path === false && $app_url === false) { |
|
96 | - $this->logger->error('Could not find resource {resource} to load', [ |
|
97 | - 'resource' => $app . '/' . $script . '.js', |
|
98 | - 'app' => 'jsresourceloader', |
|
99 | - ]); |
|
100 | - return; |
|
101 | - } |
|
102 | - |
|
103 | - if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
104 | - $this->append($app_path, $script . '.js', $app_url); |
|
105 | - } |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * @param string $script |
|
110 | - */ |
|
111 | - public function doFindTheme($script) { |
|
112 | - } |
|
113 | - |
|
114 | - protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
115 | - if (is_file($root.'/'.$file)) { |
|
116 | - if ($this->jsCombiner->process($root, $file, $app)) { |
|
117 | - $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
118 | - } else { |
|
119 | - // Add all the files from the json |
|
120 | - $files = $this->jsCombiner->getContent($root, $file); |
|
121 | - $app_url = \OC_App::getAppWebPath($app); |
|
122 | - |
|
123 | - foreach ($files as $jsFile) { |
|
124 | - $this->append($root, $jsFile, $app_url); |
|
125 | - } |
|
126 | - } |
|
127 | - return true; |
|
128 | - } |
|
129 | - |
|
130 | - return false; |
|
131 | - } |
|
33 | + /** @var JSCombiner */ |
|
34 | + protected $jsCombiner; |
|
35 | + |
|
36 | + public function __construct(\OCP\ILogger $logger, $theme, array $core_map, array $party_map, JSCombiner $JSCombiner) { |
|
37 | + parent::__construct($logger, $theme, $core_map, $party_map); |
|
38 | + |
|
39 | + $this->jsCombiner = $JSCombiner; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * @param string $script |
|
44 | + */ |
|
45 | + public function doFind($script) { |
|
46 | + $theme_dir = 'themes/'.$this->theme.'/'; |
|
47 | + if (strpos($script, '3rdparty') === 0 |
|
48 | + && $this->appendIfExist($this->thirdpartyroot, $script.'.js')) { |
|
49 | + return; |
|
50 | + } |
|
51 | + |
|
52 | + if (strpos($script, '/l10n/') !== false) { |
|
53 | + // For language files we try to load them all, so themes can overwrite |
|
54 | + // single l10n strings without having to translate all of them. |
|
55 | + $found = 0; |
|
56 | + $found += $this->appendIfExist($this->serverroot, 'core/'.$script.'.js'); |
|
57 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js'); |
|
58 | + $found += $this->appendIfExist($this->serverroot, $script.'.js'); |
|
59 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js'); |
|
60 | + $found += $this->appendIfExist($this->serverroot, 'apps/'.$script.'.js'); |
|
61 | + $found += $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js'); |
|
62 | + |
|
63 | + if ($found) { |
|
64 | + return; |
|
65 | + } |
|
66 | + } elseif ($this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$script.'.js') |
|
67 | + || $this->appendIfExist($this->serverroot, $theme_dir.$script.'.js') |
|
68 | + || $this->appendIfExist($this->serverroot, $script.'.js') |
|
69 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, $script.'.json') |
|
70 | + || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$script.'.js') |
|
71 | + || $this->appendIfExist($this->serverroot, 'core/'.$script.'.js') |
|
72 | + || $this->cacheAndAppendCombineJsonIfExist($this->serverroot, 'core/'.$script.'.json') |
|
73 | + ) { |
|
74 | + return; |
|
75 | + } |
|
76 | + |
|
77 | + $app = substr($script, 0, strpos($script, '/')); |
|
78 | + $script = substr($script, strpos($script, '/') + 1); |
|
79 | + $app_path = \OC_App::getAppPath($app); |
|
80 | + $app_url = \OC_App::getAppWebPath($app); |
|
81 | + |
|
82 | + if ($app_path !== false) { |
|
83 | + // Account for the possibility of having symlinks in app path. Only |
|
84 | + // do this if $app_path is set, because an empty argument to realpath |
|
85 | + // gets turned into cwd. |
|
86 | + $app_path = realpath($app_path); |
|
87 | + } |
|
88 | + |
|
89 | + // missing translations files fill be ignored |
|
90 | + if (strpos($script, 'l10n/') === 0) { |
|
91 | + $this->appendIfExist($app_path, $script . '.js', $app_url); |
|
92 | + return; |
|
93 | + } |
|
94 | + |
|
95 | + if ($app_path === false && $app_url === false) { |
|
96 | + $this->logger->error('Could not find resource {resource} to load', [ |
|
97 | + 'resource' => $app . '/' . $script . '.js', |
|
98 | + 'app' => 'jsresourceloader', |
|
99 | + ]); |
|
100 | + return; |
|
101 | + } |
|
102 | + |
|
103 | + if (!$this->cacheAndAppendCombineJsonIfExist($app_path, $script.'.json', $app)) { |
|
104 | + $this->append($app_path, $script . '.js', $app_url); |
|
105 | + } |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * @param string $script |
|
110 | + */ |
|
111 | + public function doFindTheme($script) { |
|
112 | + } |
|
113 | + |
|
114 | + protected function cacheAndAppendCombineJsonIfExist($root, $file, $app = 'core') { |
|
115 | + if (is_file($root.'/'.$file)) { |
|
116 | + if ($this->jsCombiner->process($root, $file, $app)) { |
|
117 | + $this->append($this->serverroot, $this->jsCombiner->getCachedJS($app, $file), false, false); |
|
118 | + } else { |
|
119 | + // Add all the files from the json |
|
120 | + $files = $this->jsCombiner->getContent($root, $file); |
|
121 | + $app_url = \OC_App::getAppWebPath($app); |
|
122 | + |
|
123 | + foreach ($files as $jsFile) { |
|
124 | + $this->append($root, $jsFile, $app_url); |
|
125 | + } |
|
126 | + } |
|
127 | + return true; |
|
128 | + } |
|
129 | + |
|
130 | + return false; |
|
131 | + } |
|
132 | 132 | } |
@@ -65,7 +65,7 @@ |
||
65 | 65 | |
66 | 66 | if ($app_path === false && $app_url === false) { |
67 | 67 | $this->logger->error('Could not find resource {resource} to load', [ |
68 | - 'resource' => $app . '/' . $style . '.css', |
|
68 | + 'resource' => $app.'/'.$style.'.css', |
|
69 | 69 | 'app' => 'cssresourceloader', |
70 | 70 | ]); |
71 | 71 | return; |
@@ -36,116 +36,116 @@ |
||
36 | 36 | |
37 | 37 | class CSSResourceLocator extends ResourceLocator { |
38 | 38 | |
39 | - /** @var SCSSCacher */ |
|
40 | - protected $scssCacher; |
|
41 | - |
|
42 | - /** |
|
43 | - * @param ILogger $logger |
|
44 | - * @param string $theme |
|
45 | - * @param array $core_map |
|
46 | - * @param array $party_map |
|
47 | - * @param SCSSCacher $scssCacher |
|
48 | - */ |
|
49 | - public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) { |
|
50 | - $this->scssCacher = $scssCacher; |
|
51 | - |
|
52 | - parent::__construct($logger, $theme, $core_map, $party_map); |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * @param string $style |
|
57 | - */ |
|
58 | - public function doFind($style) { |
|
59 | - $app = substr($style, 0, strpos($style, '/')); |
|
60 | - if (strpos($style, '3rdparty') === 0 |
|
61 | - && $this->appendIfExist($this->thirdpartyroot, $style.'.css') |
|
62 | - || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $app) |
|
63 | - || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss') |
|
64 | - || $this->appendIfExist($this->serverroot, $style.'.css') |
|
65 | - || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css') |
|
66 | - ) { |
|
67 | - return; |
|
68 | - } |
|
69 | - $style = substr($style, strpos($style, '/') + 1); |
|
70 | - $app_path = \OC_App::getAppPath($app); |
|
71 | - $app_url = \OC_App::getAppWebPath($app); |
|
72 | - |
|
73 | - if ($app_path === false && $app_url === false) { |
|
74 | - $this->logger->error('Could not find resource {resource} to load', [ |
|
75 | - 'resource' => $app . '/' . $style . '.css', |
|
76 | - 'app' => 'cssresourceloader', |
|
77 | - ]); |
|
78 | - return; |
|
79 | - } |
|
80 | - |
|
81 | - // Account for the possibility of having symlinks in app path. Doing |
|
82 | - // this here instead of above as an empty argument to realpath gets |
|
83 | - // turned into cwd. |
|
84 | - $app_path = realpath($app_path); |
|
85 | - |
|
86 | - if (!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) { |
|
87 | - $this->append($app_path, $style.'.css', $app_url); |
|
88 | - } |
|
89 | - } |
|
90 | - |
|
91 | - /** |
|
92 | - * @param string $style |
|
93 | - */ |
|
94 | - public function doFindTheme($style) { |
|
95 | - $theme_dir = 'themes/'.$this->theme.'/'; |
|
96 | - $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$style.'.css') |
|
97 | - || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css') |
|
98 | - || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css'); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * cache and append the scss $file if exist at $root |
|
103 | - * |
|
104 | - * @param string $root path to check |
|
105 | - * @param string $file the filename |
|
106 | - * @return bool True if the resource was found and cached, false otherwise |
|
107 | - */ |
|
108 | - protected function cacheAndAppendScssIfExist($root, $file, $app = 'core') { |
|
109 | - if (is_file($root.'/'.$file)) { |
|
110 | - if ($this->scssCacher !== null) { |
|
111 | - if ($this->scssCacher->process($root, $file, $app)) { |
|
112 | - $this->append($this->serverroot, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true); |
|
113 | - return true; |
|
114 | - } else { |
|
115 | - $this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); |
|
116 | - return false; |
|
117 | - } |
|
118 | - } else { |
|
119 | - return true; |
|
120 | - } |
|
121 | - } |
|
122 | - return false; |
|
123 | - } |
|
124 | - |
|
125 | - public function append($root, $file, $webRoot = null, $throw = true, $scss = false) { |
|
126 | - if (!$scss) { |
|
127 | - parent::append($root, $file, $webRoot, $throw); |
|
128 | - } else { |
|
129 | - if (!$webRoot) { |
|
130 | - $webRoot = $this->findWebRoot($root); |
|
131 | - |
|
132 | - if ($webRoot === null) { |
|
133 | - $webRoot = ''; |
|
134 | - $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [ |
|
135 | - 'app' => 'lib', |
|
136 | - 'root' => $root, |
|
137 | - 'file' => $file, |
|
138 | - 'webRoot' => $webRoot, |
|
139 | - 'throw' => $throw ? 'true' : 'false' |
|
140 | - ]); |
|
141 | - |
|
142 | - if ($throw && $root === '/') { |
|
143 | - throw new ResourceNotFoundException($file, $webRoot); |
|
144 | - } |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - $this->resources[] = [$webRoot ?: \OC::$WEBROOT, $webRoot, $file]; |
|
149 | - } |
|
150 | - } |
|
39 | + /** @var SCSSCacher */ |
|
40 | + protected $scssCacher; |
|
41 | + |
|
42 | + /** |
|
43 | + * @param ILogger $logger |
|
44 | + * @param string $theme |
|
45 | + * @param array $core_map |
|
46 | + * @param array $party_map |
|
47 | + * @param SCSSCacher $scssCacher |
|
48 | + */ |
|
49 | + public function __construct(ILogger $logger, $theme, $core_map, $party_map, $scssCacher) { |
|
50 | + $this->scssCacher = $scssCacher; |
|
51 | + |
|
52 | + parent::__construct($logger, $theme, $core_map, $party_map); |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * @param string $style |
|
57 | + */ |
|
58 | + public function doFind($style) { |
|
59 | + $app = substr($style, 0, strpos($style, '/')); |
|
60 | + if (strpos($style, '3rdparty') === 0 |
|
61 | + && $this->appendIfExist($this->thirdpartyroot, $style.'.css') |
|
62 | + || $this->cacheAndAppendScssIfExist($this->serverroot, $style.'.scss', $app) |
|
63 | + || $this->cacheAndAppendScssIfExist($this->serverroot, 'core/'.$style.'.scss') |
|
64 | + || $this->appendIfExist($this->serverroot, $style.'.css') |
|
65 | + || $this->appendIfExist($this->serverroot, 'core/'.$style.'.css') |
|
66 | + ) { |
|
67 | + return; |
|
68 | + } |
|
69 | + $style = substr($style, strpos($style, '/') + 1); |
|
70 | + $app_path = \OC_App::getAppPath($app); |
|
71 | + $app_url = \OC_App::getAppWebPath($app); |
|
72 | + |
|
73 | + if ($app_path === false && $app_url === false) { |
|
74 | + $this->logger->error('Could not find resource {resource} to load', [ |
|
75 | + 'resource' => $app . '/' . $style . '.css', |
|
76 | + 'app' => 'cssresourceloader', |
|
77 | + ]); |
|
78 | + return; |
|
79 | + } |
|
80 | + |
|
81 | + // Account for the possibility of having symlinks in app path. Doing |
|
82 | + // this here instead of above as an empty argument to realpath gets |
|
83 | + // turned into cwd. |
|
84 | + $app_path = realpath($app_path); |
|
85 | + |
|
86 | + if (!$this->cacheAndAppendScssIfExist($app_path, $style.'.scss', $app)) { |
|
87 | + $this->append($app_path, $style.'.css', $app_url); |
|
88 | + } |
|
89 | + } |
|
90 | + |
|
91 | + /** |
|
92 | + * @param string $style |
|
93 | + */ |
|
94 | + public function doFindTheme($style) { |
|
95 | + $theme_dir = 'themes/'.$this->theme.'/'; |
|
96 | + $this->appendIfExist($this->serverroot, $theme_dir.'apps/'.$style.'.css') |
|
97 | + || $this->appendIfExist($this->serverroot, $theme_dir.$style.'.css') |
|
98 | + || $this->appendIfExist($this->serverroot, $theme_dir.'core/'.$style.'.css'); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * cache and append the scss $file if exist at $root |
|
103 | + * |
|
104 | + * @param string $root path to check |
|
105 | + * @param string $file the filename |
|
106 | + * @return bool True if the resource was found and cached, false otherwise |
|
107 | + */ |
|
108 | + protected function cacheAndAppendScssIfExist($root, $file, $app = 'core') { |
|
109 | + if (is_file($root.'/'.$file)) { |
|
110 | + if ($this->scssCacher !== null) { |
|
111 | + if ($this->scssCacher->process($root, $file, $app)) { |
|
112 | + $this->append($this->serverroot, $this->scssCacher->getCachedSCSS($app, $file), \OC::$WEBROOT, true, true); |
|
113 | + return true; |
|
114 | + } else { |
|
115 | + $this->logger->warning('Failed to compile and/or save '.$root.'/'.$file, ['app' => 'core']); |
|
116 | + return false; |
|
117 | + } |
|
118 | + } else { |
|
119 | + return true; |
|
120 | + } |
|
121 | + } |
|
122 | + return false; |
|
123 | + } |
|
124 | + |
|
125 | + public function append($root, $file, $webRoot = null, $throw = true, $scss = false) { |
|
126 | + if (!$scss) { |
|
127 | + parent::append($root, $file, $webRoot, $throw); |
|
128 | + } else { |
|
129 | + if (!$webRoot) { |
|
130 | + $webRoot = $this->findWebRoot($root); |
|
131 | + |
|
132 | + if ($webRoot === null) { |
|
133 | + $webRoot = ''; |
|
134 | + $this->logger->error('ResourceLocator can not find a web root (root: {root}, file: {file}, webRoot: {webRoot}, throw: {throw})', [ |
|
135 | + 'app' => 'lib', |
|
136 | + 'root' => $root, |
|
137 | + 'file' => $file, |
|
138 | + 'webRoot' => $webRoot, |
|
139 | + 'throw' => $throw ? 'true' : 'false' |
|
140 | + ]); |
|
141 | + |
|
142 | + if ($throw && $root === '/') { |
|
143 | + throw new ResourceNotFoundException($file, $webRoot); |
|
144 | + } |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + $this->resources[] = [$webRoot ?: \OC::$WEBROOT, $webRoot, $file]; |
|
149 | + } |
|
150 | + } |
|
151 | 151 | } |
@@ -75,7 +75,7 @@ discard block |
||
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 |
||
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 |
||
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 | } |
@@ -31,172 +31,172 @@ |
||
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 | } |
@@ -117,7 +117,7 @@ |
||
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 |
@@ -33,159 +33,159 @@ |
||
33 | 33 | use Throwable; |
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|Throwable $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 | - if (!isset(${$var})) { |
|
172 | - ${$var} = $value; |
|
173 | - } |
|
174 | - } |
|
175 | - } |
|
176 | - |
|
177 | - // Include |
|
178 | - ob_start(); |
|
179 | - try { |
|
180 | - include $file; |
|
181 | - $data = ob_get_contents(); |
|
182 | - } catch (\Exception $e) { |
|
183 | - @ob_end_clean(); |
|
184 | - throw $e; |
|
185 | - } |
|
186 | - @ob_end_clean(); |
|
187 | - |
|
188 | - // Return data |
|
189 | - return $data; |
|
190 | - } |
|
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|Throwable $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 | + if (!isset(${$var})) { |
|
172 | + ${$var} = $value; |
|
173 | + } |
|
174 | + } |
|
175 | + } |
|
176 | + |
|
177 | + // Include |
|
178 | + ob_start(); |
|
179 | + try { |
|
180 | + include $file; |
|
181 | + $data = ob_get_contents(); |
|
182 | + } catch (\Exception $e) { |
|
183 | + @ob_end_clean(); |
|
184 | + throw $e; |
|
185 | + } |
|
186 | + @ob_end_clean(); |
|
187 | + |
|
188 | + // Return data |
|
189 | + return $data; |
|
190 | + } |
|
191 | 191 | } |
@@ -28,56 +28,56 @@ |
||
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 | } |
@@ -30,66 +30,66 @@ |
||
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 | } |
@@ -65,8 +65,8 @@ |
||
65 | 65 | |
66 | 66 | $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
67 | 67 | $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
68 | - $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
69 | - $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
68 | + $this->issueDate = new \DateTime('@'.$info['validFrom_time_t'], $gmt); |
|
69 | + $this->expireDate = new \DateTime('@'.$info['validTo_time_t'], $gmt); |
|
70 | 70 | $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
71 | 71 | $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
72 | 72 | } |
@@ -31,104 +31,104 @@ |
||
31 | 31 | use OCP\ICertificate; |
32 | 32 | |
33 | 33 | class Certificate implements ICertificate { |
34 | - protected $name; |
|
35 | - |
|
36 | - protected $commonName; |
|
37 | - |
|
38 | - protected $organization; |
|
39 | - |
|
40 | - protected $serial; |
|
41 | - |
|
42 | - protected $issueDate; |
|
43 | - |
|
44 | - protected $expireDate; |
|
45 | - |
|
46 | - protected $issuerName; |
|
47 | - |
|
48 | - protected $issuerOrganization; |
|
49 | - |
|
50 | - /** |
|
51 | - * @param string $data base64 encoded certificate |
|
52 | - * @param string $name |
|
53 | - * @throws \Exception If the certificate could not get parsed |
|
54 | - */ |
|
55 | - public function __construct(string $data, string $name) { |
|
56 | - $this->name = $name; |
|
57 | - $gmt = new \DateTimeZone('GMT'); |
|
58 | - |
|
59 | - // If string starts with "file://" ignore the certificate |
|
60 | - $query = 'file://'; |
|
61 | - if (strtolower(substr($data, 0, strlen($query))) === $query) { |
|
62 | - throw new \Exception('Certificate could not get parsed.'); |
|
63 | - } |
|
64 | - |
|
65 | - $info = openssl_x509_parse($data); |
|
66 | - if (!is_array($info)) { |
|
67 | - throw new \Exception('Certificate could not get parsed.'); |
|
68 | - } |
|
69 | - |
|
70 | - $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
|
71 | - $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
|
72 | - $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
73 | - $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
74 | - $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
|
75 | - $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
|
76 | - } |
|
77 | - |
|
78 | - /** |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function getName(): string { |
|
82 | - return $this->name; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * @return string|null |
|
87 | - */ |
|
88 | - public function getCommonName(): ?string { |
|
89 | - return $this->commonName; |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * @return string|null |
|
94 | - */ |
|
95 | - public function getOrganization(): ?string { |
|
96 | - return $this->organization; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * @return \DateTime |
|
101 | - */ |
|
102 | - public function getIssueDate(): \DateTime { |
|
103 | - return $this->issueDate; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * @return \DateTime |
|
108 | - */ |
|
109 | - public function getExpireDate(): \DateTime { |
|
110 | - return $this->expireDate; |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * @return bool |
|
115 | - */ |
|
116 | - public function isExpired(): bool { |
|
117 | - $now = new \DateTime(); |
|
118 | - return $this->issueDate > $now or $now > $this->expireDate; |
|
119 | - } |
|
120 | - |
|
121 | - /** |
|
122 | - * @return string|null |
|
123 | - */ |
|
124 | - public function getIssuerName(): ?string { |
|
125 | - return $this->issuerName; |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * @return string|null |
|
130 | - */ |
|
131 | - public function getIssuerOrganization(): ?string { |
|
132 | - return $this->issuerOrganization; |
|
133 | - } |
|
34 | + protected $name; |
|
35 | + |
|
36 | + protected $commonName; |
|
37 | + |
|
38 | + protected $organization; |
|
39 | + |
|
40 | + protected $serial; |
|
41 | + |
|
42 | + protected $issueDate; |
|
43 | + |
|
44 | + protected $expireDate; |
|
45 | + |
|
46 | + protected $issuerName; |
|
47 | + |
|
48 | + protected $issuerOrganization; |
|
49 | + |
|
50 | + /** |
|
51 | + * @param string $data base64 encoded certificate |
|
52 | + * @param string $name |
|
53 | + * @throws \Exception If the certificate could not get parsed |
|
54 | + */ |
|
55 | + public function __construct(string $data, string $name) { |
|
56 | + $this->name = $name; |
|
57 | + $gmt = new \DateTimeZone('GMT'); |
|
58 | + |
|
59 | + // If string starts with "file://" ignore the certificate |
|
60 | + $query = 'file://'; |
|
61 | + if (strtolower(substr($data, 0, strlen($query))) === $query) { |
|
62 | + throw new \Exception('Certificate could not get parsed.'); |
|
63 | + } |
|
64 | + |
|
65 | + $info = openssl_x509_parse($data); |
|
66 | + if (!is_array($info)) { |
|
67 | + throw new \Exception('Certificate could not get parsed.'); |
|
68 | + } |
|
69 | + |
|
70 | + $this->commonName = isset($info['subject']['CN']) ? $info['subject']['CN'] : null; |
|
71 | + $this->organization = isset($info['subject']['O']) ? $info['subject']['O'] : null; |
|
72 | + $this->issueDate = new \DateTime('@' . $info['validFrom_time_t'], $gmt); |
|
73 | + $this->expireDate = new \DateTime('@' . $info['validTo_time_t'], $gmt); |
|
74 | + $this->issuerName = isset($info['issuer']['CN']) ? $info['issuer']['CN'] : null; |
|
75 | + $this->issuerOrganization = isset($info['issuer']['O']) ? $info['issuer']['O'] : null; |
|
76 | + } |
|
77 | + |
|
78 | + /** |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function getName(): string { |
|
82 | + return $this->name; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * @return string|null |
|
87 | + */ |
|
88 | + public function getCommonName(): ?string { |
|
89 | + return $this->commonName; |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * @return string|null |
|
94 | + */ |
|
95 | + public function getOrganization(): ?string { |
|
96 | + return $this->organization; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * @return \DateTime |
|
101 | + */ |
|
102 | + public function getIssueDate(): \DateTime { |
|
103 | + return $this->issueDate; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * @return \DateTime |
|
108 | + */ |
|
109 | + public function getExpireDate(): \DateTime { |
|
110 | + return $this->expireDate; |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * @return bool |
|
115 | + */ |
|
116 | + public function isExpired(): bool { |
|
117 | + $now = new \DateTime(); |
|
118 | + return $this->issueDate > $now or $now > $this->expireDate; |
|
119 | + } |
|
120 | + |
|
121 | + /** |
|
122 | + * @return string|null |
|
123 | + */ |
|
124 | + public function getIssuerName(): ?string { |
|
125 | + return $this->issuerName; |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * @return string|null |
|
130 | + */ |
|
131 | + public function getIssuerOrganization(): ?string { |
|
132 | + return $this->issuerOrganization; |
|
133 | + } |
|
134 | 134 | } |
@@ -89,7 +89,7 @@ |
||
89 | 89 | $user = $this->userManager->get($userId); |
90 | 90 | if ($user !== null) { |
91 | 91 | $key = $this->keyManager->getKey($user); |
92 | - return (bool)openssl_verify( |
|
92 | + return (bool) openssl_verify( |
|
93 | 93 | json_encode($data['message']), |
94 | 94 | base64_decode($data['signature']), |
95 | 95 | $key->getPublic(), |
@@ -32,76 +32,76 @@ |
||
32 | 32 | use OCP\IUserManager; |
33 | 33 | |
34 | 34 | class Signer { |
35 | - /** @var Manager */ |
|
36 | - private $keyManager; |
|
37 | - /** @var ITimeFactory */ |
|
38 | - private $timeFactory; |
|
39 | - /** @var IUserManager */ |
|
40 | - private $userManager; |
|
35 | + /** @var Manager */ |
|
36 | + private $keyManager; |
|
37 | + /** @var ITimeFactory */ |
|
38 | + private $timeFactory; |
|
39 | + /** @var IUserManager */ |
|
40 | + private $userManager; |
|
41 | 41 | |
42 | - /** |
|
43 | - * @param Manager $keyManager |
|
44 | - * @param ITimeFactory $timeFactory |
|
45 | - * @param IUserManager $userManager |
|
46 | - */ |
|
47 | - public function __construct(Manager $keyManager, |
|
48 | - ITimeFactory $timeFactory, |
|
49 | - IUserManager $userManager) { |
|
50 | - $this->keyManager = $keyManager; |
|
51 | - $this->timeFactory = $timeFactory; |
|
52 | - $this->userManager = $userManager; |
|
53 | - } |
|
42 | + /** |
|
43 | + * @param Manager $keyManager |
|
44 | + * @param ITimeFactory $timeFactory |
|
45 | + * @param IUserManager $userManager |
|
46 | + */ |
|
47 | + public function __construct(Manager $keyManager, |
|
48 | + ITimeFactory $timeFactory, |
|
49 | + IUserManager $userManager) { |
|
50 | + $this->keyManager = $keyManager; |
|
51 | + $this->timeFactory = $timeFactory; |
|
52 | + $this->userManager = $userManager; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns a signed blob for $data |
|
57 | - * |
|
58 | - * @param string $type |
|
59 | - * @param array $data |
|
60 | - * @param IUser $user |
|
61 | - * @return array ['message', 'signature'] |
|
62 | - */ |
|
63 | - public function sign(string $type, array $data, IUser $user): array { |
|
64 | - $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
65 | - $data = [ |
|
66 | - 'data' => $data, |
|
67 | - 'type' => $type, |
|
68 | - 'signer' => $user->getCloudId(), |
|
69 | - 'timestamp' => $this->timeFactory->getTime(), |
|
70 | - ]; |
|
71 | - openssl_sign(json_encode($data), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
55 | + /** |
|
56 | + * Returns a signed blob for $data |
|
57 | + * |
|
58 | + * @param string $type |
|
59 | + * @param array $data |
|
60 | + * @param IUser $user |
|
61 | + * @return array ['message', 'signature'] |
|
62 | + */ |
|
63 | + public function sign(string $type, array $data, IUser $user): array { |
|
64 | + $privateKey = $this->keyManager->getKey($user)->getPrivate(); |
|
65 | + $data = [ |
|
66 | + 'data' => $data, |
|
67 | + 'type' => $type, |
|
68 | + 'signer' => $user->getCloudId(), |
|
69 | + 'timestamp' => $this->timeFactory->getTime(), |
|
70 | + ]; |
|
71 | + openssl_sign(json_encode($data), $signature, $privateKey, OPENSSL_ALGO_SHA512); |
|
72 | 72 | |
73 | - return [ |
|
74 | - 'message' => $data, |
|
75 | - 'signature' => base64_encode($signature), |
|
76 | - ]; |
|
77 | - } |
|
73 | + return [ |
|
74 | + 'message' => $data, |
|
75 | + 'signature' => base64_encode($signature), |
|
76 | + ]; |
|
77 | + } |
|
78 | 78 | |
79 | - /** |
|
80 | - * Whether the data is signed properly |
|
81 | - * |
|
82 | - * @param array $data |
|
83 | - * @return bool |
|
84 | - */ |
|
85 | - public function verify(array $data): bool { |
|
86 | - if (isset($data['message']) |
|
87 | - && isset($data['signature']) |
|
88 | - && isset($data['message']['signer']) |
|
89 | - ) { |
|
90 | - $location = strrpos($data['message']['signer'], '@'); |
|
91 | - $userId = substr($data['message']['signer'], 0, $location); |
|
79 | + /** |
|
80 | + * Whether the data is signed properly |
|
81 | + * |
|
82 | + * @param array $data |
|
83 | + * @return bool |
|
84 | + */ |
|
85 | + public function verify(array $data): bool { |
|
86 | + if (isset($data['message']) |
|
87 | + && isset($data['signature']) |
|
88 | + && isset($data['message']['signer']) |
|
89 | + ) { |
|
90 | + $location = strrpos($data['message']['signer'], '@'); |
|
91 | + $userId = substr($data['message']['signer'], 0, $location); |
|
92 | 92 | |
93 | - $user = $this->userManager->get($userId); |
|
94 | - if ($user !== null) { |
|
95 | - $key = $this->keyManager->getKey($user); |
|
96 | - return (bool)openssl_verify( |
|
97 | - json_encode($data['message']), |
|
98 | - base64_decode($data['signature']), |
|
99 | - $key->getPublic(), |
|
100 | - OPENSSL_ALGO_SHA512 |
|
101 | - ); |
|
102 | - } |
|
103 | - } |
|
93 | + $user = $this->userManager->get($userId); |
|
94 | + if ($user !== null) { |
|
95 | + $key = $this->keyManager->getKey($user); |
|
96 | + return (bool)openssl_verify( |
|
97 | + json_encode($data['message']), |
|
98 | + base64_decode($data['signature']), |
|
99 | + $key->getPublic(), |
|
100 | + OPENSSL_ALGO_SHA512 |
|
101 | + ); |
|
102 | + } |
|
103 | + } |
|
104 | 104 | |
105 | - return false; |
|
106 | - } |
|
105 | + return false; |
|
106 | + } |
|
107 | 107 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | use OCP\Encryption\Exceptions\GenericEncryptionException; |
28 | 28 | |
29 | 29 | class EncryptionHeaderToLargeException extends GenericEncryptionException { |
30 | - public function __construct() { |
|
31 | - parent::__construct('max header size exceeded'); |
|
32 | - } |
|
30 | + public function __construct() { |
|
31 | + parent::__construct('max header size exceeded'); |
|
32 | + } |
|
33 | 33 | } |