@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @param string $opts, additional optional options |
47 | 47 | */ |
48 | 48 | function emit_css_tag($href, $opts = '') { |
49 | - $s='<link rel="stylesheet"'; |
|
49 | + $s = '<link rel="stylesheet"'; |
|
50 | 50 | if (!empty($href)) { |
51 | - $s.=' href="' . $href .'"'; |
|
51 | + $s .= ' href="'.$href.'"'; |
|
52 | 52 | } |
53 | 53 | if (!empty($opts)) { |
54 | - $s.=' '.$opts; |
|
54 | + $s .= ' '.$opts; |
|
55 | 55 | } |
56 | 56 | print_unescaped($s.">\n"); |
57 | 57 | } |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @param array $obj all the script information from template |
62 | 62 | */ |
63 | 63 | function emit_css_loading_tags($obj) { |
64 | - foreach($obj['cssfiles'] as $css) { |
|
64 | + foreach ($obj['cssfiles'] as $css) { |
|
65 | 65 | emit_css_tag($css); |
66 | 66 | } |
67 | - foreach($obj['printcssfiles'] as $css) { |
|
67 | + foreach ($obj['printcssfiles'] as $css) { |
|
68 | 68 | emit_css_tag($css, 'media="print"'); |
69 | 69 | } |
70 | 70 | } |
@@ -74,20 +74,20 @@ discard block |
||
74 | 74 | * @param string $src the source URL, ignored when empty |
75 | 75 | * @param string $script_content the inline script content, ignored when empty |
76 | 76 | */ |
77 | -function emit_script_tag($src, $script_content='') { |
|
78 | - $defer_str=' defer'; |
|
79 | - $s='<script nonce="' . \OC::$server->getContentSecurityPolicyNonceManager()->getNonce() . '"'; |
|
77 | +function emit_script_tag($src, $script_content = '') { |
|
78 | + $defer_str = ' defer'; |
|
79 | + $s = '<script nonce="'.\OC::$server->getContentSecurityPolicyNonceManager()->getNonce().'"'; |
|
80 | 80 | if (!empty($src)) { |
81 | 81 | // emit script tag for deferred loading from $src |
82 | - $s.=$defer_str.' src="' . $src .'">'; |
|
82 | + $s .= $defer_str.' src="'.$src.'">'; |
|
83 | 83 | } else if (!empty($script_content)) { |
84 | 84 | // emit script tag for inline script from $script_content without defer (see MDN) |
85 | - $s.=">\n".$script_content."\n"; |
|
85 | + $s .= ">\n".$script_content."\n"; |
|
86 | 86 | } else { |
87 | 87 | // no $src nor $src_content, really useless empty tag |
88 | - $s.='>'; |
|
88 | + $s .= '>'; |
|
89 | 89 | } |
90 | - $s.='</script>'; |
|
90 | + $s .= '</script>'; |
|
91 | 91 | print_unescaped($s."\n"); |
92 | 92 | } |
93 | 93 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @param array $obj all the script information from template |
97 | 97 | */ |
98 | 98 | function emit_script_loading_tags($obj) { |
99 | - foreach($obj['jsfiles'] as $jsfile) { |
|
99 | + foreach ($obj['jsfiles'] as $jsfile) { |
|
100 | 100 | emit_script_tag($jsfile, ''); |
101 | 101 | } |
102 | 102 | if (!empty($obj['inline_ocjs'])) { |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * if an array is given it will add all scripts |
121 | 121 | */ |
122 | 122 | function script($app, $file = null) { |
123 | - if(is_array($file)) { |
|
124 | - foreach($file as $f) { |
|
123 | + if (is_array($file)) { |
|
124 | + foreach ($file as $f) { |
|
125 | 125 | OC_Util::addScript($app, $f); |
126 | 126 | } |
127 | 127 | } else { |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * if an array is given it will add all scripts |
137 | 137 | */ |
138 | 138 | function vendor_script($app, $file = null) { |
139 | - if(is_array($file)) { |
|
140 | - foreach($file as $f) { |
|
139 | + if (is_array($file)) { |
|
140 | + foreach ($file as $f) { |
|
141 | 141 | OC_Util::addVendorScript($app, $f); |
142 | 142 | } |
143 | 143 | } else { |
@@ -152,8 +152,8 @@ discard block |
||
152 | 152 | * if an array is given it will add all styles |
153 | 153 | */ |
154 | 154 | function style($app, $file = null) { |
155 | - if(is_array($file)) { |
|
156 | - foreach($file as $f) { |
|
155 | + if (is_array($file)) { |
|
156 | + foreach ($file as $f) { |
|
157 | 157 | OC_Util::addStyle($app, $f); |
158 | 158 | } |
159 | 159 | } else { |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * if an array is given it will add all styles |
169 | 169 | */ |
170 | 170 | function vendor_style($app, $file = null) { |
171 | - if(is_array($file)) { |
|
172 | - foreach($file as $f) { |
|
171 | + if (is_array($file)) { |
|
172 | + foreach ($file as $f) { |
|
173 | 173 | OC_Util::addVendorStyle($app, $f); |
174 | 174 | } |
175 | 175 | } else { |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | * if an array is given it will add all components |
194 | 194 | */ |
195 | 195 | function component($app, $file) { |
196 | - if(is_array($file)) { |
|
197 | - foreach($file as $f) { |
|
198 | - $url = link_to($app, 'component/' . $f . '.html'); |
|
196 | + if (is_array($file)) { |
|
197 | + foreach ($file as $f) { |
|
198 | + $url = link_to($app, 'component/'.$f.'.html'); |
|
199 | 199 | OC_Util::addHeader('link', ['rel' => 'import', 'href' => $url]); |
200 | 200 | } |
201 | 201 | } else { |
202 | - $url = link_to($app, 'component/' . $file . '.html'); |
|
202 | + $url = link_to($app, 'component/'.$file.'.html'); |
|
203 | 203 | OC_Util::addHeader('link', ['rel' => 'import', 'href' => $url]); |
204 | 204 | } |
205 | 205 | } |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | * |
214 | 214 | * For further information have a look at \OCP\IURLGenerator::linkTo |
215 | 215 | */ |
216 | -function link_to( $app, $file, $args = [] ) { |
|
216 | +function link_to($app, $file, $args = []) { |
|
217 | 217 | return \OC::$server->getURLGenerator()->linkTo($app, $file, $args); |
218 | 218 | } |
219 | 219 | |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * |
234 | 234 | * For further information have a look at \OCP\IURLGenerator::imagePath |
235 | 235 | */ |
236 | -function image_path( $app, $image ) { |
|
237 | - return \OC::$server->getURLGenerator()->imagePath( $app, $image ); |
|
236 | +function image_path($app, $image) { |
|
237 | + return \OC::$server->getURLGenerator()->imagePath($app, $image); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -242,8 +242,8 @@ discard block |
||
242 | 242 | * @param string $mimetype mimetype |
243 | 243 | * @return string link to the image |
244 | 244 | */ |
245 | -function mimetype_icon( $mimetype ) { |
|
246 | - return \OC::$server->getMimeTypeDetector()->mimeTypeIcon( $mimetype ); |
|
245 | +function mimetype_icon($mimetype) { |
|
246 | + return \OC::$server->getMimeTypeDetector()->mimeTypeIcon($mimetype); |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * @param string $path path of file |
253 | 253 | * @return string link to the preview |
254 | 254 | */ |
255 | -function preview_icon( $path ) { |
|
255 | +function preview_icon($path) { |
|
256 | 256 | return \OC::$server->getURLGenerator()->linkToRoute('core.Preview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path]); |
257 | 257 | } |
258 | 258 | |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | * @param string $token |
262 | 262 | * @return string |
263 | 263 | */ |
264 | -function publicPreview_icon ( $path, $token ) { |
|
264 | +function publicPreview_icon($path, $token) { |
|
265 | 265 | return \OC::$server->getURLGenerator()->linkToRoute('files_sharing.PublicPreview.getPreview', ['x' => 32, 'y' => 32, 'file' => $path, 'token' => $token]); |
266 | 266 | } |
267 | 267 | |
@@ -272,8 +272,8 @@ discard block |
||
272 | 272 | * |
273 | 273 | * For further information have a look at OC_Helper::humanFileSize |
274 | 274 | */ |
275 | -function human_file_size( $bytes ) { |
|
276 | - return OC_Helper::humanFileSize( $bytes ); |
|
275 | +function human_file_size($bytes) { |
|
276 | + return OC_Helper::humanFileSize($bytes); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
@@ -281,10 +281,10 @@ discard block |
||
281 | 281 | * @param int $timestamp UNIX timestamp to strip |
282 | 282 | * @return int timestamp without time value |
283 | 283 | */ |
284 | -function strip_time($timestamp){ |
|
284 | +function strip_time($timestamp) { |
|
285 | 285 | $date = new \DateTime("@{$timestamp}"); |
286 | 286 | $date->setTime(0, 0, 0); |
287 | - return (int)$date->format('U'); |
|
287 | + return (int) $date->format('U'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | /** |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | /** @var \OC\DateTimeFormatter $formatter */ |
300 | 300 | $formatter = \OC::$server->query('DateTimeFormatter'); |
301 | 301 | |
302 | - if ($dateOnly){ |
|
302 | + if ($dateOnly) { |
|
303 | 303 | return $formatter->formatDateSpan($timestamp, $fromTime); |
304 | 304 | } |
305 | 305 | return $formatter->formatTimeSpan($timestamp, $fromTime); |
306 | 306 | } |
307 | 307 | |
308 | -function html_select_options($options, $selected, $params=[]) { |
|
308 | +function html_select_options($options, $selected, $params = []) { |
|
309 | 309 | if (!is_array($selected)) { |
310 | - $selected=[$selected]; |
|
310 | + $selected = [$selected]; |
|
311 | 311 | } |
312 | 312 | if (isset($params['combine']) && $params['combine']) { |
313 | 313 | $options = array_combine($options, $options); |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | $label_name = $params['label']; |
321 | 321 | } |
322 | 322 | $html = ''; |
323 | - foreach($options as $value => $label) { |
|
323 | + foreach ($options as $value => $label) { |
|
324 | 324 | if ($value_name && is_array($label)) { |
325 | 325 | $value = $label[$value_name]; |
326 | 326 | } |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | $label = $label[$label_name]; |
329 | 329 | } |
330 | 330 | $select = in_array($value, $selected) ? ' selected="selected"' : ''; |
331 | - $html .= '<option value="' . \OCP\Util::sanitizeHTML($value) . '"' . $select . '>' . \OCP\Util::sanitizeHTML($label) . '</option>'."\n"; |
|
331 | + $html .= '<option value="'.\OCP\Util::sanitizeHTML($value).'"'.$select.'>'.\OCP\Util::sanitizeHTML($label).'</option>'."\n"; |
|
332 | 332 | } |
333 | 333 | return $html; |
334 | 334 | } |
@@ -55,8 +55,8 @@ discard block |
||
55 | 55 | /** |
56 | 56 | * pass all other function directly to the \Doctrine\DBAL\Driver\Statement |
57 | 57 | */ |
58 | - public function __call($name,$arguments) { |
|
59 | - return call_user_func_array([$this->statement,$name], $arguments); |
|
58 | + public function __call($name, $arguments) { |
|
59 | + return call_user_func_array([$this->statement, $name], $arguments); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | * @param array $input |
66 | 66 | * @return \OC_DB_StatementWrapper|int|bool |
67 | 67 | */ |
68 | - public function execute($input= []) { |
|
68 | + public function execute($input = []) { |
|
69 | 69 | $this->lastArguments = $input; |
70 | 70 | if (count($input) > 0) { |
71 | 71 | $result = $this->statement->execute($input); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | * @param integer|null $length max length when using an OUT bind |
114 | 114 | * @return boolean |
115 | 115 | */ |
116 | - public function bindParam($column, &$variable, $type = null, $length = null){ |
|
116 | + public function bindParam($column, &$variable, $type = null, $length = null) { |
|
117 | 117 | return $this->statement->bindParam($column, $variable, $type, $length); |
118 | 118 | } |
119 | 119 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * "admin". |
73 | 73 | * @param bool $registerCall = true |
74 | 74 | */ |
75 | - public function __construct( $app, $name, $renderAs = "", $registerCall = true ) { |
|
75 | + public function __construct($app, $name, $renderAs = "", $registerCall = true) { |
|
76 | 76 | // Read the selected theme from the config file |
77 | 77 | self::initTemplateEngine($renderAs); |
78 | 78 | |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * @param string $renderAs |
100 | 100 | */ |
101 | 101 | public static function initTemplateEngine($renderAs) { |
102 | - if (self::$initTemplateEngineFirstRun){ |
|
102 | + if (self::$initTemplateEngineFirstRun) { |
|
103 | 103 | |
104 | 104 | //apps that started before the template initialization can load their own scripts/styles |
105 | 105 | //so to make sure this scripts/styles here are loaded first we use OC_Util::addScript() with $prepend=true |
106 | 106 | //meaning the last script/style in this list will be loaded first |
107 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
108 | - if (\OC::$server->getConfig ()->getAppValue ( 'core', 'backgroundjobs_mode', 'ajax' ) == 'ajax') { |
|
109 | - OC_Util::addScript ( 'backgroundjobs', null, true ); |
|
107 | + if (\OC::$server->getSystemConfig()->getValue('installed', false) && $renderAs !== 'error' && !\OCP\Util::needUpgrade()) { |
|
108 | + if (\OC::$server->getConfig()->getAppValue('core', 'backgroundjobs_mode', 'ajax') == 'ajax') { |
|
109 | + OC_Util::addScript('backgroundjobs', null, true); |
|
110 | 110 | } |
111 | 111 | } |
112 | 112 | OC_Util::addStyle('css-variables', null, true); |
113 | 113 | OC_Util::addStyle('server', null, true); |
114 | 114 | OC_Util::addTranslations('core', null, true); |
115 | 115 | |
116 | - if (\OC::$server->getSystemConfig()->getValue ('installed', false)) { |
|
116 | + if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
117 | 117 | OC_Util::addStyle('search', 'results'); |
118 | 118 | OC_Util::addScript('search', 'search', true); |
119 | 119 | OC_Util::addScript('search', 'searchprovider'); |
@@ -146,12 +146,12 @@ discard block |
||
146 | 146 | */ |
147 | 147 | protected function findTemplate($theme, $app, $name) { |
148 | 148 | // Check if it is a app template or not. |
149 | - if( $app !== '' ) { |
|
149 | + if ($app !== '') { |
|
150 | 150 | $dirs = $this->getAppTemplateDirs($theme, $app, OC::$SERVERROOT, OC_App::getAppPath($app)); |
151 | 151 | } else { |
152 | 152 | $dirs = $this->getCoreTemplateDirs($theme, OC::$SERVERROOT); |
153 | 153 | } |
154 | - $locator = new \OC\Template\TemplateFileLocator( $dirs ); |
|
154 | + $locator = new \OC\Template\TemplateFileLocator($dirs); |
|
155 | 155 | $template = $locator->find($name); |
156 | 156 | $path = $locator->getPath(); |
157 | 157 | return [$path, $template]; |
@@ -164,8 +164,8 @@ discard block |
||
164 | 164 | * @param string $text the text content for the element. If $text is null then the |
165 | 165 | * element will be written as empty element. So use "" to get a closing tag. |
166 | 166 | */ |
167 | - public function addHeader($tag, $attributes, $text=null) { |
|
168 | - $this->headers[]= [ |
|
167 | + public function addHeader($tag, $attributes, $text = null) { |
|
168 | + $this->headers[] = [ |
|
169 | 169 | 'tag' => $tag, |
170 | 170 | 'attributes' => $attributes, |
171 | 171 | 'text' => $text |
@@ -182,10 +182,10 @@ discard block |
||
182 | 182 | public function fetchPage($additionalParams = null) { |
183 | 183 | $data = parent::fetchPage($additionalParams); |
184 | 184 | |
185 | - if( $this->renderAs ) { |
|
185 | + if ($this->renderAs) { |
|
186 | 186 | $page = new TemplateLayout($this->renderAs, $this->app); |
187 | 187 | |
188 | - if(is_array($additionalParams)) { |
|
188 | + if (is_array($additionalParams)) { |
|
189 | 189 | foreach ($additionalParams as $key => $value) { |
190 | 190 | $page->assign($key, $value); |
191 | 191 | } |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | |
194 | 194 | // Add custom headers |
195 | 195 | $headers = ''; |
196 | - foreach(OC_Util::$headers as $header) { |
|
196 | + foreach (OC_Util::$headers as $header) { |
|
197 | 197 | $headers .= '<'.\OCP\Util::sanitizeHTML($header['tag']); |
198 | - if ( strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes']))) ) { |
|
198 | + if (strcasecmp($header['tag'], 'script') === 0 && in_array('src', array_map('strtolower', array_keys($header['attributes'])))) { |
|
199 | 199 | $headers .= ' defer'; |
200 | 200 | } |
201 | - foreach($header['attributes'] as $name=>$value) { |
|
201 | + foreach ($header['attributes'] as $name=>$value) { |
|
202 | 202 | $headers .= ' '.\OCP\Util::sanitizeHTML($name).'="'.\OCP\Util::sanitizeHTML($value).'"'; |
203 | 203 | } |
204 | 204 | if ($header['text'] !== null) { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | * Includes another template. use <?php echo $this->inc('template'); ?> to |
228 | 228 | * do this. |
229 | 229 | */ |
230 | - public function inc( $file, $additionalParams = null ) { |
|
230 | + public function inc($file, $additionalParams = null) { |
|
231 | 231 | return $this->load($this->path.$file.'.php', $additionalParams); |
232 | 232 | } |
233 | 233 | |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | * @param array $parameters Parameters for the template |
239 | 239 | * @return boolean|null |
240 | 240 | */ |
241 | - public static function printUserPage( $application, $name, $parameters = [] ) { |
|
242 | - $content = new OC_Template( $application, $name, "user" ); |
|
243 | - foreach( $parameters as $key => $value ) { |
|
244 | - $content->assign( $key, $value ); |
|
241 | + public static function printUserPage($application, $name, $parameters = []) { |
|
242 | + $content = new OC_Template($application, $name, "user"); |
|
243 | + foreach ($parameters as $key => $value) { |
|
244 | + $content->assign($key, $value); |
|
245 | 245 | } |
246 | 246 | print $content->printPage(); |
247 | 247 | } |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | * @param array $parameters Parameters for the template |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public static function printAdminPage( $application, $name, $parameters = [] ) { |
|
257 | - $content = new OC_Template( $application, $name, "admin" ); |
|
258 | - foreach( $parameters as $key => $value ) { |
|
259 | - $content->assign( $key, $value ); |
|
256 | + public static function printAdminPage($application, $name, $parameters = []) { |
|
257 | + $content = new OC_Template($application, $name, "admin"); |
|
258 | + foreach ($parameters as $key => $value) { |
|
259 | + $content->assign($key, $value); |
|
260 | 260 | } |
261 | 261 | return $content->printPage(); |
262 | 262 | } |
@@ -268,10 +268,10 @@ discard block |
||
268 | 268 | * @param array|string $parameters Parameters for the template |
269 | 269 | * @return bool |
270 | 270 | */ |
271 | - public static function printGuestPage( $application, $name, $parameters = [] ) { |
|
271 | + public static function printGuestPage($application, $name, $parameters = []) { |
|
272 | 272 | $content = new OC_Template($application, $name, $name === 'error' ? $name : 'guest'); |
273 | - foreach( $parameters as $key => $value ) { |
|
274 | - $content->assign( $key, $value ); |
|
273 | + foreach ($parameters as $key => $value) { |
|
274 | + $content->assign($key, $value); |
|
275 | 275 | } |
276 | 276 | return $content->printPage(); |
277 | 277 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @param int $statusCode |
284 | 284 | * @suppress PhanAccessMethodInternal |
285 | 285 | */ |
286 | - public static function printErrorPage( $error_msg, $hint = '', $statusCode = 500) { |
|
286 | + public static function printErrorPage($error_msg, $hint = '', $statusCode = 500) { |
|
287 | 287 | if (\OC::$server->getAppManager()->isEnabledForUser('theming') && !\OC_App::isAppLoaded('theming')) { |
288 | 288 | \OC_App::loadApp('theming'); |
289 | 289 | } |
@@ -296,9 +296,9 @@ discard block |
||
296 | 296 | |
297 | 297 | http_response_code($statusCode); |
298 | 298 | try { |
299 | - $content = new \OC_Template( '', 'error', 'error', false ); |
|
299 | + $content = new \OC_Template('', 'error', 'error', false); |
|
300 | 300 | $errors = [['error' => $error_msg, 'hint' => $hint]]; |
301 | - $content->assign( 'errors', $errors ); |
|
301 | + $content->assign('errors', $errors); |
|
302 | 302 | $content->printPage(); |
303 | 303 | } catch (\Exception $e) { |
304 | 304 | $logger = \OC::$server->getLogger(); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | $route = substr($route, 7); |
106 | - $route = '/ocs/v2.php' . $route; |
|
106 | + $route = '/ocs/v2.php'.$route; |
|
107 | 107 | |
108 | 108 | return $this->getAbsoluteURL($route); |
109 | 109 | } |
@@ -121,37 +121,37 @@ discard block |
||
121 | 121 | public function linkTo(string $app, string $file, array $args = []): string { |
122 | 122 | $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
123 | 123 | |
124 | - if( $app !== '' ) { |
|
124 | + if ($app !== '') { |
|
125 | 125 | $app_path = \OC_App::getAppPath($app); |
126 | 126 | // Check if the app is in the app folder |
127 | - if ($app_path && file_exists($app_path . '/' . $file)) { |
|
127 | + if ($app_path && file_exists($app_path.'/'.$file)) { |
|
128 | 128 | if (substr($file, -3) === 'php') { |
129 | 129 | |
130 | - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; |
|
130 | + $urlLinkTo = \OC::$WEBROOT.'/index.php/apps/'.$app; |
|
131 | 131 | if ($frontControllerActive) { |
132 | - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; |
|
132 | + $urlLinkTo = \OC::$WEBROOT.'/apps/'.$app; |
|
133 | 133 | } |
134 | - $urlLinkTo .= ($file !== 'index.php') ? '/' . $file : ''; |
|
134 | + $urlLinkTo .= ($file !== 'index.php') ? '/'.$file : ''; |
|
135 | 135 | } else { |
136 | - $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; |
|
136 | + $urlLinkTo = \OC_App::getAppWebPath($app).'/'.$file; |
|
137 | 137 | } |
138 | 138 | } else { |
139 | - $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; |
|
139 | + $urlLinkTo = \OC::$WEBROOT.'/'.$app.'/'.$file; |
|
140 | 140 | } |
141 | 141 | } else { |
142 | - if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
143 | - $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
142 | + if (file_exists(\OC::$SERVERROOT.'/core/'.$file)) { |
|
143 | + $urlLinkTo = \OC::$WEBROOT.'/core/'.$file; |
|
144 | 144 | } else { |
145 | 145 | if ($frontControllerActive && $file === 'index.php') { |
146 | - $urlLinkTo = \OC::$WEBROOT . '/'; |
|
146 | + $urlLinkTo = \OC::$WEBROOT.'/'; |
|
147 | 147 | } else { |
148 | - $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
148 | + $urlLinkTo = \OC::$WEBROOT.'/'.$file; |
|
149 | 149 | } |
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
153 | 153 | if ($args && $query = http_build_query($args, '', '&')) { |
154 | - $urlLinkTo .= '?' . $query; |
|
154 | + $urlLinkTo .= '?'.$query; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | return $urlLinkTo; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function imagePath(string $app, string $image): string { |
170 | 170 | $cache = $this->cacheFactory->createDistributed('imagePath-'.md5($this->getBaseUrl()).'-'); |
171 | 171 | $cacheKey = $app.'-'.$image; |
172 | - if($key = $cache->get($cacheKey)) { |
|
172 | + if ($key = $cache->get($cacheKey)) { |
|
173 | 173 | return $key; |
174 | 174 | } |
175 | 175 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | $theme = \OC_Util::getTheme(); |
178 | 178 | |
179 | 179 | //if a theme has a png but not an svg always use the png |
180 | - $basename = substr(basename($image),0,-4); |
|
180 | + $basename = substr(basename($image), 0, -4); |
|
181 | 181 | |
182 | 182 | $appPath = \OC_App::getAppPath($app); |
183 | 183 | |
@@ -185,53 +185,53 @@ discard block |
||
185 | 185 | $path = ''; |
186 | 186 | $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
187 | 187 | $themingImagePath = false; |
188 | - if($themingEnabled) { |
|
188 | + if ($themingEnabled) { |
|
189 | 189 | $themingDefaults = \OC::$server->getThemingDefaults(); |
190 | 190 | if ($themingDefaults instanceof ThemingDefaults) { |
191 | 191 | $themingImagePath = $themingDefaults->replaceImagePath($app, $image); |
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
195 | - if (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { |
|
196 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; |
|
197 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") |
|
198 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { |
|
199 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; |
|
200 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { |
|
201 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; |
|
202 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") |
|
203 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { |
|
204 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; |
|
205 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { |
|
206 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; |
|
207 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
208 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
209 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
210 | - } elseif($themingEnabled && $themingImagePath) { |
|
195 | + if (file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image")) { |
|
196 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$image"; |
|
197 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.svg") |
|
198 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.png")) { |
|
199 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$basename.png"; |
|
200 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$image")) { |
|
201 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$image"; |
|
202 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.svg") |
|
203 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.png"))) { |
|
204 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$basename.png"; |
|
205 | + } elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$image")) { |
|
206 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$image"; |
|
207 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.svg") |
|
208 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.png")) { |
|
209 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
210 | + } elseif ($themingEnabled && $themingImagePath) { |
|
211 | 211 | $path = $themingImagePath; |
212 | - } elseif ($appPath && file_exists($appPath . "/img/$image")) { |
|
213 | - $path = \OC_App::getAppWebPath($app) . "/img/$image"; |
|
214 | - } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
215 | - && file_exists($appPath . "/img/$basename.png")) { |
|
216 | - $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; |
|
217 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { |
|
218 | - $path = \OC::$WEBROOT . "/$app/img/$image"; |
|
219 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") |
|
220 | - && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { |
|
221 | - $path = \OC::$WEBROOT . "/$app/img/$basename.png"; |
|
222 | - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { |
|
223 | - $path = \OC::$WEBROOT . "/core/img/$image"; |
|
224 | - } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
225 | - && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
226 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
212 | + } elseif ($appPath && file_exists($appPath."/img/$image")) { |
|
213 | + $path = \OC_App::getAppWebPath($app)."/img/$image"; |
|
214 | + } elseif ($appPath && !file_exists($appPath."/img/$basename.svg") |
|
215 | + && file_exists($appPath."/img/$basename.png")) { |
|
216 | + $path = \OC_App::getAppWebPath($app)."/img/$basename.png"; |
|
217 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/$app/img/$image")) { |
|
218 | + $path = \OC::$WEBROOT."/$app/img/$image"; |
|
219 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/$app/img/$basename.svg") |
|
220 | + && file_exists(\OC::$SERVERROOT."/$app/img/$basename.png"))) { |
|
221 | + $path = \OC::$WEBROOT."/$app/img/$basename.png"; |
|
222 | + } elseif (file_exists(\OC::$SERVERROOT."/core/img/$image")) { |
|
223 | + $path = \OC::$WEBROOT."/core/img/$image"; |
|
224 | + } elseif (!file_exists(\OC::$SERVERROOT."/core/img/$basename.svg") |
|
225 | + && file_exists(\OC::$SERVERROOT."/core/img/$basename.png")) { |
|
226 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
227 | 227 | } |
228 | 228 | |
229 | - if($path !== '') { |
|
229 | + if ($path !== '') { |
|
230 | 230 | $cache->set($cacheKey, $path); |
231 | 231 | return $path; |
232 | 232 | } |
233 | 233 | |
234 | - throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
234 | + throw new RuntimeException('image not found: image:'.$image.' webroot:'.\OC::$WEBROOT.' serverroot:'.\OC::$SERVERROOT); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -244,14 +244,14 @@ discard block |
||
244 | 244 | $separator = strpos($url, '/') === 0 ? '' : '/'; |
245 | 245 | |
246 | 246 | if (\OC::$CLI && !\defined('PHPUNIT_RUN')) { |
247 | - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
247 | + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/').'/'.ltrim($url, '/'); |
|
248 | 248 | } |
249 | 249 | // The ownCloud web root can already be prepended. |
250 | - if(\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) { |
|
250 | + if (\OC::$WEBROOT !== '' && strpos($url, \OC::$WEBROOT) === 0) { |
|
251 | 251 | $url = substr($url, \strlen(\OC::$WEBROOT)); |
252 | 252 | } |
253 | 253 | |
254 | - return $this->getBaseUrl() . $separator . $url; |
|
254 | + return $this->getBaseUrl().$separator.$url; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -267,6 +267,6 @@ discard block |
||
267 | 267 | * @return string base url of the current request |
268 | 268 | */ |
269 | 269 | public function getBaseUrl(): string { |
270 | - return $this->request->getServerProtocol() . '://' . $this->request->getServerHost() . \OC::$WEBROOT; |
|
270 | + return $this->request->getServerProtocol().'://'.$this->request->getServerHost().\OC::$WEBROOT; |
|
271 | 271 | } |
272 | 272 | } |
@@ -51,12 +51,12 @@ discard block |
||
51 | 51 | * @return array An array of Tag objects. |
52 | 52 | */ |
53 | 53 | public function loadTags($owners, $type) { |
54 | - if(!is_array($owners)) { |
|
54 | + if (!is_array($owners)) { |
|
55 | 55 | $owners = [$owners]; |
56 | 56 | } |
57 | 57 | |
58 | - $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
59 | - . 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`'; |
|
58 | + $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `'.$this->getTableName().'` ' |
|
59 | + . 'WHERE `uid` IN ('.str_repeat('?,', count($owners) - 1).'?) AND `type` = ? ORDER BY `category`'; |
|
60 | 60 | return $this->findEntities($sql, array_merge($owners, [$type])); |
61 | 61 | } |
62 | 62 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @return bool |
68 | 68 | */ |
69 | 69 | public function tagExists($tag) { |
70 | - $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
70 | + $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `'.$this->getTableName().'` ' |
|
71 | 71 | . 'WHERE `uid` = ? AND `type` = ? AND `category` = ?'; |
72 | 72 | try { |
73 | 73 | $this->findEntity($sql, [$tag->getOwner(), $tag->getType(), $tag->getName()]); |
@@ -91,20 +91,20 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function addFolder($path) { |
93 | 93 | $tmpBase = \OC::$server->getTempManager()->getTemporaryFolder(); |
94 | - $path = rtrim($path, '/') . '/'; |
|
94 | + $path = rtrim($path, '/').'/'; |
|
95 | 95 | if ($this->fileExists($path)) { |
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | $parts = explode('/', $path); |
99 | 99 | $folder = $tmpBase; |
100 | 100 | foreach ($parts as $part) { |
101 | - $folder .= '/' . $part; |
|
101 | + $folder .= '/'.$part; |
|
102 | 102 | if (!is_dir($folder)) { |
103 | 103 | mkdir($folder); |
104 | 104 | } |
105 | 105 | } |
106 | - $result = $this->tar->addModify([$tmpBase . $path], '', $tmpBase); |
|
107 | - rmdir($tmpBase . $path); |
|
106 | + $result = $this->tar->addModify([$tmpBase.$path], '', $tmpBase); |
|
107 | + rmdir($tmpBase.$path); |
|
108 | 108 | $this->fileList = false; |
109 | 109 | $this->cachedHeaders = false; |
110 | 110 | return $result; |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | //no proper way to delete, rename entire archive, rename file and remake archive |
142 | 142 | $tmp = \OC::$server->getTempManager()->getTemporaryFolder(); |
143 | 143 | $this->tar->extract($tmp); |
144 | - rename($tmp . $source, $tmp . $dest); |
|
144 | + rename($tmp.$source, $tmp.$dest); |
|
145 | 145 | $this->tar = null; |
146 | 146 | unlink($this->path); |
147 | 147 | $types = [null, 'gz', 'bz']; |
148 | 148 | $this->tar = new \Archive_Tar($this->path, $types[self::getTarType($this->path)]); |
149 | - $this->tar->createModify([$tmp], '', $tmp . '/'); |
|
149 | + $this->tar->createModify([$tmp], '', $tmp.'/'); |
|
150 | 150 | $this->fileList = false; |
151 | 151 | $this->cachedHeaders = false; |
152 | 152 | return true; |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | } |
162 | 162 | foreach ($this->cachedHeaders as $header) { |
163 | 163 | if ($file == $header['filename'] |
164 | - or $file . '/' == $header['filename'] |
|
165 | - or '/' . $file . '/' == $header['filename'] |
|
166 | - or '/' . $file == $header['filename'] |
|
164 | + or $file.'/' == $header['filename'] |
|
165 | + or '/'.$file.'/' == $header['filename'] |
|
166 | + or '/'.$file == $header['filename'] |
|
167 | 167 | ) { |
168 | 168 | return $header; |
169 | 169 | } |
@@ -262,13 +262,13 @@ discard block |
||
262 | 262 | if (!$this->fileExists($path)) { |
263 | 263 | return false; |
264 | 264 | } |
265 | - if ($this->fileExists('/' . $path)) { |
|
266 | - $success = $this->tar->extractList(['/' . $path], $tmp); |
|
265 | + if ($this->fileExists('/'.$path)) { |
|
266 | + $success = $this->tar->extractList(['/'.$path], $tmp); |
|
267 | 267 | } else { |
268 | 268 | $success = $this->tar->extractList([$path], $tmp); |
269 | 269 | } |
270 | 270 | if ($success) { |
271 | - rename($tmp . $path, $dest); |
|
271 | + rename($tmp.$path, $dest); |
|
272 | 272 | } |
273 | 273 | \OCP\Files::rmdirr($tmp); |
274 | 274 | return $success; |
@@ -292,10 +292,10 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function fileExists($path) { |
294 | 294 | $files = $this->getFiles(); |
295 | - if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) { |
|
295 | + if ((array_search($path, $files) !== false) or (array_search($path.'/', $files) !== false)) { |
|
296 | 296 | return true; |
297 | 297 | } else { |
298 | - $folderPath = rtrim($path, '/') . '/'; |
|
298 | + $folderPath = rtrim($path, '/').'/'; |
|
299 | 299 | $pathLength = strlen($folderPath); |
300 | 300 | foreach ($files as $file) { |
301 | 301 | if (strlen($file) > $pathLength and substr($file, 0, $pathLength) == $folderPath) { |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | } |
305 | 305 | } |
306 | 306 | if ($path[0] != '/') { //not all programs agree on the use of a leading / |
307 | - return $this->fileExists('/' . $path); |
|
307 | + return $this->fileExists('/'.$path); |
|
308 | 308 | } else { |
309 | 309 | return false; |
310 | 310 | } |
@@ -325,7 +325,7 @@ discard block |
||
325 | 325 | //no proper way to delete, extract entire archive, delete file and remake archive |
326 | 326 | $tmp = \OC::$server->getTempManager()->getTemporaryFolder(); |
327 | 327 | $this->tar->extract($tmp); |
328 | - \OCP\Files::rmdirr($tmp . $path); |
|
328 | + \OCP\Files::rmdirr($tmp.$path); |
|
329 | 329 | $this->tar = null; |
330 | 330 | unlink($this->path); |
331 | 331 | $this->reopen(); |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | return fopen($tmpFile, $mode); |
357 | 357 | } else { |
358 | 358 | $handle = fopen($tmpFile, $mode); |
359 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
359 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
360 | 360 | $this->writeBack($tmpFile, $path); |
361 | 361 | }); |
362 | 362 | } |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | use Icewind\Streams\CallbackWrapper; |
35 | 35 | use OCP\ILogger; |
36 | 36 | |
37 | -class ZIP extends Archive{ |
|
37 | +class ZIP extends Archive { |
|
38 | 38 | /** |
39 | 39 | * @var \ZipArchive zip |
40 | 40 | */ |
41 | - private $zip=null; |
|
41 | + private $zip = null; |
|
42 | 42 | private $path; |
43 | 43 | |
44 | 44 | /** |
45 | 45 | * @param string $source |
46 | 46 | */ |
47 | 47 | public function __construct($source) { |
48 | - $this->path=$source; |
|
49 | - $this->zip=new \ZipArchive(); |
|
50 | - if($this->zip->open($source, \ZipArchive::CREATE)) { |
|
51 | - }else{ |
|
48 | + $this->path = $source; |
|
49 | + $this->zip = new \ZipArchive(); |
|
50 | + if ($this->zip->open($source, \ZipArchive::CREATE)) { |
|
51 | + } else { |
|
52 | 52 | \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, ILogger::WARN); |
53 | 53 | } |
54 | 54 | } |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * @param string $source either a local file or string data |
67 | 67 | * @return bool |
68 | 68 | */ |
69 | - public function addFile($path, $source='') { |
|
70 | - if($source and $source[0]=='/' and file_exists($source)) { |
|
71 | - $result=$this->zip->addFile($source, $path); |
|
72 | - }else{ |
|
73 | - $result=$this->zip->addFromString($path, $source); |
|
69 | + public function addFile($path, $source = '') { |
|
70 | + if ($source and $source[0] == '/' and file_exists($source)) { |
|
71 | + $result = $this->zip->addFile($source, $path); |
|
72 | + } else { |
|
73 | + $result = $this->zip->addFromString($path, $source); |
|
74 | 74 | } |
75 | - if($result) { |
|
76 | - $this->zip->close();//close and reopen to save the zip |
|
75 | + if ($result) { |
|
76 | + $this->zip->close(); //close and reopen to save the zip |
|
77 | 77 | $this->zip->open($this->path); |
78 | 78 | } |
79 | 79 | return $result; |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @return boolean|null |
86 | 86 | */ |
87 | 87 | public function rename($source, $dest) { |
88 | - $source=$this->stripPath($source); |
|
89 | - $dest=$this->stripPath($dest); |
|
88 | + $source = $this->stripPath($source); |
|
89 | + $dest = $this->stripPath($dest); |
|
90 | 90 | $this->zip->renameName($source, $dest); |
91 | 91 | } |
92 | 92 | /** |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return int |
96 | 96 | */ |
97 | 97 | public function filesize($path) { |
98 | - $stat=$this->zip->statName($path); |
|
98 | + $stat = $this->zip->statName($path); |
|
99 | 99 | return $stat['size']; |
100 | 100 | } |
101 | 101 | /** |
@@ -112,13 +112,13 @@ discard block |
||
112 | 112 | * @return array |
113 | 113 | */ |
114 | 114 | public function getFolder($path) { |
115 | - $files=$this->getFiles(); |
|
116 | - $folderContent=[]; |
|
117 | - $pathLength=strlen($path); |
|
118 | - foreach($files as $file) { |
|
119 | - if(substr($file, 0, $pathLength)==$path and $file!=$path) { |
|
120 | - if(strrpos(substr($file, 0, -1), '/')<=$pathLength) { |
|
121 | - $folderContent[]=substr($file, $pathLength); |
|
115 | + $files = $this->getFiles(); |
|
116 | + $folderContent = []; |
|
117 | + $pathLength = strlen($path); |
|
118 | + foreach ($files as $file) { |
|
119 | + if (substr($file, 0, $pathLength) == $path and $file != $path) { |
|
120 | + if (strrpos(substr($file, 0, -1), '/') <= $pathLength) { |
|
121 | + $folderContent[] = substr($file, $pathLength); |
|
122 | 122 | } |
123 | 123 | } |
124 | 124 | } |
@@ -129,10 +129,10 @@ discard block |
||
129 | 129 | * @return array |
130 | 130 | */ |
131 | 131 | public function getFiles() { |
132 | - $fileCount=$this->zip->numFiles; |
|
133 | - $files=[]; |
|
134 | - for($i=0;$i<$fileCount;$i++) { |
|
135 | - $files[]=$this->zip->getNameIndex($i); |
|
132 | + $fileCount = $this->zip->numFiles; |
|
133 | + $files = []; |
|
134 | + for ($i = 0; $i < $fileCount; $i++) { |
|
135 | + $files[] = $this->zip->getNameIndex($i); |
|
136 | 136 | } |
137 | 137 | return $files; |
138 | 138 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * @return bool |
169 | 169 | */ |
170 | 170 | public function fileExists($path) { |
171 | - return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false); |
|
171 | + return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false); |
|
172 | 172 | } |
173 | 173 | /** |
174 | 174 | * remove a file or folder from the archive |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | * @return bool |
177 | 177 | */ |
178 | 178 | public function remove($path) { |
179 | - if($this->fileExists($path.'/')) { |
|
179 | + if ($this->fileExists($path.'/')) { |
|
180 | 180 | return $this->zip->deleteName($path.'/'); |
181 | - }else{ |
|
181 | + } else { |
|
182 | 182 | return $this->zip->deleteName($path); |
183 | 183 | } |
184 | 184 | } |
@@ -189,23 +189,23 @@ discard block |
||
189 | 189 | * @return resource |
190 | 190 | */ |
191 | 191 | public function getStream($path, $mode) { |
192 | - if($mode=='r' or $mode=='rb') { |
|
192 | + if ($mode == 'r' or $mode == 'rb') { |
|
193 | 193 | return $this->zip->getStream($path); |
194 | 194 | } else { |
195 | 195 | //since we can't directly get a writable stream, |
196 | 196 | //make a temp copy of the file and put it back |
197 | 197 | //in the archive when the stream is closed |
198 | - if(strrpos($path, '.')!==false) { |
|
199 | - $ext=substr($path, strrpos($path, '.')); |
|
200 | - }else{ |
|
201 | - $ext=''; |
|
198 | + if (strrpos($path, '.') !== false) { |
|
199 | + $ext = substr($path, strrpos($path, '.')); |
|
200 | + } else { |
|
201 | + $ext = ''; |
|
202 | 202 | } |
203 | 203 | $tmpFile = \OC::$server->getTempManager()->getTemporaryFile($ext); |
204 | - if($this->fileExists($path)) { |
|
204 | + if ($this->fileExists($path)) { |
|
205 | 205 | $this->extractFile($path, $tmpFile); |
206 | 206 | } |
207 | 207 | $handle = fopen($tmpFile, $mode); |
208 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
208 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
209 | 209 | $this->writeBack($tmpFile, $path); |
210 | 210 | }); |
211 | 211 | } |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * @return string |
225 | 225 | */ |
226 | 226 | private function stripPath($path) { |
227 | - if(!$path || $path[0]=='/') { |
|
227 | + if (!$path || $path[0] == '/') { |
|
228 | 228 | return substr($path, 1); |
229 | - }else{ |
|
229 | + } else { |
|
230 | 230 | return $path; |
231 | 231 | } |
232 | 232 | } |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | public function searchPaged($query, array $inApps = [], $page = 1, $size = 30) { |
50 | 50 | $this->initProviders(); |
51 | 51 | $results = []; |
52 | - foreach($this->providers as $provider) { |
|
52 | + foreach ($this->providers as $provider) { |
|
53 | 53 | /** @var $provider Provider */ |
54 | - if ( ! $provider->providesResultsFor($inApps) ) { |
|
54 | + if (!$provider->providesResultsFor($inApps)) { |
|
55 | 55 | continue; |
56 | 56 | } |
57 | 57 | if ($provider instanceof PagedProvider) { |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | public function removeProvider($provider) { |
87 | 87 | $this->registeredProviders = array_filter( |
88 | 88 | $this->registeredProviders, |
89 | - function ($element) use ($provider) { |
|
89 | + function($element) use ($provider) { |
|
90 | 90 | return ($element['class'] != $provider); |
91 | 91 | } |
92 | 92 | ); |
@@ -107,10 +107,10 @@ discard block |
||
107 | 107 | * Create instances of all the registered search providers |
108 | 108 | */ |
109 | 109 | private function initProviders() { |
110 | - if( ! empty($this->providers) ) { |
|
110 | + if (!empty($this->providers)) { |
|
111 | 111 | return; |
112 | 112 | } |
113 | - foreach($this->registeredProviders as $provider) { |
|
113 | + foreach ($this->registeredProviders as $provider) { |
|
114 | 114 | $class = $provider['class']; |
115 | 115 | $options = $provider['options']; |
116 | 116 | $this->providers[] = new $class($options); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | return []; |
92 | 92 | } |
93 | 93 | |
94 | - $path = $this->getPathToCertificates() . 'uploads/'; |
|
94 | + $path = $this->getPathToCertificates().'uploads/'; |
|
95 | 95 | if (!$this->view->is_dir($path)) { |
96 | 96 | return []; |
97 | 97 | } |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | while (false !== ($file = readdir($handle))) { |
104 | 104 | if ($file != '.' && $file != '..') { |
105 | 105 | try { |
106 | - $result[] = new Certificate($this->view->file_get_contents($path . $file), $file); |
|
106 | + $result[] = new Certificate($this->view->file_get_contents($path.$file), $file); |
|
107 | 107 | } catch (\Exception $e) { |
108 | 108 | } |
109 | 109 | } |
@@ -123,20 +123,20 @@ discard block |
||
123 | 123 | $this->view->mkdir($path); |
124 | 124 | } |
125 | 125 | |
126 | - $defaultCertificates = file_get_contents(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); |
|
126 | + $defaultCertificates = file_get_contents(\OC::$SERVERROOT.'/resources/config/ca-bundle.crt'); |
|
127 | 127 | if (strlen($defaultCertificates) < 1024) { // sanity check to verify that we have some content for our bundle |
128 | 128 | // log as exception so we have a stacktrace |
129 | 129 | $this->logger->logException(new \Exception('Shipped ca-bundle is empty, refusing to create certificate bundle')); |
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | - $certPath = $path . 'rootcerts.crt'; |
|
134 | - $tmpPath = $certPath . '.tmp' . $this->random->generate(10, ISecureRandom::CHAR_DIGITS); |
|
133 | + $certPath = $path.'rootcerts.crt'; |
|
134 | + $tmpPath = $certPath.'.tmp'.$this->random->generate(10, ISecureRandom::CHAR_DIGITS); |
|
135 | 135 | $fhCerts = $this->view->fopen($tmpPath, 'w'); |
136 | 136 | |
137 | 137 | // Write user certificates |
138 | 138 | foreach ($certs as $cert) { |
139 | - $file = $path . '/uploads/' . $cert->getName(); |
|
139 | + $file = $path.'/uploads/'.$cert->getName(); |
|
140 | 140 | $data = $this->view->file_get_contents($file); |
141 | 141 | if (strpos($data, 'BEGIN CERTIFICATE')) { |
142 | 142 | fwrite($fhCerts, $data); |
@@ -172,13 +172,13 @@ discard block |
||
172 | 172 | throw new \Exception('Filename is not valid'); |
173 | 173 | } |
174 | 174 | |
175 | - $dir = $this->getPathToCertificates() . 'uploads/'; |
|
175 | + $dir = $this->getPathToCertificates().'uploads/'; |
|
176 | 176 | if (!$this->view->file_exists($dir)) { |
177 | 177 | $this->view->mkdir($dir); |
178 | 178 | } |
179 | 179 | |
180 | 180 | try { |
181 | - $file = $dir . $name; |
|
181 | + $file = $dir.$name; |
|
182 | 182 | $certificateObject = new Certificate($certificate, $name); |
183 | 183 | $this->view->file_put_contents($file, $certificate); |
184 | 184 | $this->createCertificateBundle(); |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | if (!Filesystem::isValidPath($name)) { |
200 | 200 | return false; |
201 | 201 | } |
202 | - $path = $this->getPathToCertificates() . 'uploads/'; |
|
203 | - if ($this->view->file_exists($path . $name)) { |
|
204 | - $this->view->unlink($path . $name); |
|
202 | + $path = $this->getPathToCertificates().'uploads/'; |
|
203 | + if ($this->view->file_exists($path.$name)) { |
|
204 | + $this->view->unlink($path.$name); |
|
205 | 205 | $this->createCertificateBundle(); |
206 | 206 | } |
207 | 207 | return true; |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | if ($uid === '') { |
218 | 218 | $uid = $this->uid; |
219 | 219 | } |
220 | - return $this->getPathToCertificates($uid) . 'rootcerts.crt'; |
|
220 | + return $this->getPathToCertificates($uid).'rootcerts.crt'; |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | /** |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | if ($uid === '') { |
250 | 250 | $uid = $this->uid; |
251 | 251 | } |
252 | - return is_null($uid) ? '/files_external/' : '/' . $uid . '/files_external/'; |
|
252 | + return is_null($uid) ? '/files_external/' : '/'.$uid.'/files_external/'; |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | $sourceMTimes[] = $this->view->filemtime($this->getCertificateBundle(null)); |
273 | 273 | } |
274 | 274 | |
275 | - $sourceMTime = array_reduce($sourceMTimes, function ($max, $mtime) { |
|
275 | + $sourceMTime = array_reduce($sourceMTimes, function($max, $mtime) { |
|
276 | 276 | return max($max, $mtime); |
277 | 277 | }, 0); |
278 | 278 | return $sourceMTime > $this->view->filemtime($targetBundle); |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | * @return int |
285 | 285 | */ |
286 | 286 | protected function getFilemtimeOfCaBundle() { |
287 | - return filemtime(\OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); |
|
287 | + return filemtime(\OC::$SERVERROOT.'/resources/config/ca-bundle.crt'); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | } |