@@ -93,40 +93,40 @@ discard block |
||
93 | 93 | * |
94 | 94 | * Returns a url to the given app and file. |
95 | 95 | */ |
96 | - public function linkTo( $app, $file, $args = array() ) { |
|
96 | + public function linkTo($app, $file, $args = array()) { |
|
97 | 97 | $frontControllerActive = ($this->config->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true'); |
98 | 98 | |
99 | - if( $app != '' ) { |
|
99 | + if ($app != '') { |
|
100 | 100 | $app_path = \OC_App::getAppPath($app); |
101 | 101 | // Check if the app is in the app folder |
102 | - if ($app_path && file_exists($app_path . '/' . $file)) { |
|
102 | + if ($app_path && file_exists($app_path.'/'.$file)) { |
|
103 | 103 | if (substr($file, -3) == 'php') { |
104 | 104 | |
105 | - $urlLinkTo = \OC::$WEBROOT . '/index.php/apps/' . $app; |
|
105 | + $urlLinkTo = \OC::$WEBROOT.'/index.php/apps/'.$app; |
|
106 | 106 | if ($frontControllerActive) { |
107 | - $urlLinkTo = \OC::$WEBROOT . '/apps/' . $app; |
|
107 | + $urlLinkTo = \OC::$WEBROOT.'/apps/'.$app; |
|
108 | 108 | } |
109 | - $urlLinkTo .= ($file != 'index.php') ? '/' . $file : ''; |
|
109 | + $urlLinkTo .= ($file != 'index.php') ? '/'.$file : ''; |
|
110 | 110 | } else { |
111 | - $urlLinkTo = \OC_App::getAppWebPath($app) . '/' . $file; |
|
111 | + $urlLinkTo = \OC_App::getAppWebPath($app).'/'.$file; |
|
112 | 112 | } |
113 | 113 | } else { |
114 | - $urlLinkTo = \OC::$WEBROOT . '/' . $app . '/' . $file; |
|
114 | + $urlLinkTo = \OC::$WEBROOT.'/'.$app.'/'.$file; |
|
115 | 115 | } |
116 | 116 | } else { |
117 | - if (file_exists(\OC::$SERVERROOT . '/core/' . $file)) { |
|
118 | - $urlLinkTo = \OC::$WEBROOT . '/core/' . $file; |
|
117 | + if (file_exists(\OC::$SERVERROOT.'/core/'.$file)) { |
|
118 | + $urlLinkTo = \OC::$WEBROOT.'/core/'.$file; |
|
119 | 119 | } else { |
120 | 120 | if ($frontControllerActive && $file === 'index.php') { |
121 | - $urlLinkTo = \OC::$WEBROOT . '/'; |
|
121 | + $urlLinkTo = \OC::$WEBROOT.'/'; |
|
122 | 122 | } else { |
123 | - $urlLinkTo = \OC::$WEBROOT . '/' . $file; |
|
123 | + $urlLinkTo = \OC::$WEBROOT.'/'.$file; |
|
124 | 124 | } |
125 | 125 | } |
126 | 126 | } |
127 | 127 | |
128 | 128 | if ($args && $query = http_build_query($args, '', '&')) { |
129 | - $urlLinkTo .= '?' . $query; |
|
129 | + $urlLinkTo .= '?'.$query; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $urlLinkTo; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | public function imagePath($app, $image) { |
145 | 145 | $cache = $this->cacheFactory->create('imagePath'); |
146 | 146 | $cacheKey = $app.'-'.$image; |
147 | - if($key = $cache->get($cacheKey)) { |
|
147 | + if ($key = $cache->get($cacheKey)) { |
|
148 | 148 | return $key; |
149 | 149 | } |
150 | 150 | |
@@ -152,58 +152,58 @@ discard block |
||
152 | 152 | $theme = \OC_Util::getTheme(); |
153 | 153 | |
154 | 154 | //if a theme has a png but not an svg always use the png |
155 | - $basename = substr(basename($image),0,-4); |
|
155 | + $basename = substr(basename($image), 0, -4); |
|
156 | 156 | |
157 | 157 | $appPath = \OC_App::getAppPath($app); |
158 | 158 | |
159 | 159 | // Check if the app is in the app folder |
160 | 160 | $path = ''; |
161 | 161 | $themingEnabled = $this->config->getSystemValue('installed', false) && \OCP\App::isEnabled('theming') && \OC_App::isAppLoaded('theming'); |
162 | - if($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
162 | + if ($themingEnabled && $image === "favicon.ico" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
163 | 163 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
164 | - if($app==="") { $app = "core"; } |
|
165 | - $path = $this->linkToRoute('theming.Icon.getFavicon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
166 | - } elseif($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
164 | + if ($app === "") { $app = "core"; } |
|
165 | + $path = $this->linkToRoute('theming.Icon.getFavicon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
166 | + } elseif ($themingEnabled && $image === "favicon-touch.png" && \OC::$server->getThemingDefaults()->shouldReplaceIcons()) { |
|
167 | 167 | $cacheBusterValue = $this->config->getAppValue('theming', 'cachebuster', '0'); |
168 | - if($app==="") { $app = "core"; } |
|
169 | - $path = $this->linkToRoute('theming.Icon.getTouchIcon', [ 'app' => $app ]) . '?v='. $cacheBusterValue; |
|
170 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$image")) { |
|
171 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$image"; |
|
172 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.svg") |
|
173 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/apps/$app/img/$basename.png")) { |
|
174 | - $path = \OC::$WEBROOT . "/themes/$theme/apps/$app/img/$basename.png"; |
|
175 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$image")) { |
|
176 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$image"; |
|
177 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.svg") |
|
178 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/$app/img/$basename.png"))) { |
|
179 | - $path = \OC::$WEBROOT . "/themes/$theme/$app/img/$basename.png"; |
|
180 | - } elseif (file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$image")) { |
|
181 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$image"; |
|
182 | - } elseif (!file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.svg") |
|
183 | - && file_exists(\OC::$SERVERROOT . "/themes/$theme/core/img/$basename.png")) { |
|
184 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
185 | - } elseif ($appPath && file_exists($appPath . "/img/$image")) { |
|
186 | - $path = \OC_App::getAppWebPath($app) . "/img/$image"; |
|
187 | - } elseif ($appPath && !file_exists($appPath . "/img/$basename.svg") |
|
188 | - && file_exists($appPath . "/img/$basename.png")) { |
|
189 | - $path = \OC_App::getAppWebPath($app) . "/img/$basename.png"; |
|
190 | - } elseif (!empty($app) and file_exists(\OC::$SERVERROOT . "/$app/img/$image")) { |
|
191 | - $path = \OC::$WEBROOT . "/$app/img/$image"; |
|
192 | - } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT . "/$app/img/$basename.svg") |
|
193 | - && file_exists(\OC::$SERVERROOT . "/$app/img/$basename.png"))) { |
|
194 | - $path = \OC::$WEBROOT . "/$app/img/$basename.png"; |
|
195 | - } elseif (file_exists(\OC::$SERVERROOT . "/core/img/$image")) { |
|
196 | - $path = \OC::$WEBROOT . "/core/img/$image"; |
|
197 | - } elseif (!file_exists(\OC::$SERVERROOT . "/core/img/$basename.svg") |
|
198 | - && file_exists(\OC::$SERVERROOT . "/core/img/$basename.png")) { |
|
199 | - $path = \OC::$WEBROOT . "/themes/$theme/core/img/$basename.png"; |
|
168 | + if ($app === "") { $app = "core"; } |
|
169 | + $path = $this->linkToRoute('theming.Icon.getTouchIcon', ['app' => $app]).'?v='.$cacheBusterValue; |
|
170 | + } elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$image")) { |
|
171 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$image"; |
|
172 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.svg") |
|
173 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/apps/$app/img/$basename.png")) { |
|
174 | + $path = \OC::$WEBROOT."/themes/$theme/apps/$app/img/$basename.png"; |
|
175 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$image")) { |
|
176 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$image"; |
|
177 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.svg") |
|
178 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/$app/img/$basename.png"))) { |
|
179 | + $path = \OC::$WEBROOT."/themes/$theme/$app/img/$basename.png"; |
|
180 | + } elseif (file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$image")) { |
|
181 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$image"; |
|
182 | + } elseif (!file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.svg") |
|
183 | + && file_exists(\OC::$SERVERROOT."/themes/$theme/core/img/$basename.png")) { |
|
184 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
185 | + } elseif ($appPath && file_exists($appPath."/img/$image")) { |
|
186 | + $path = \OC_App::getAppWebPath($app)."/img/$image"; |
|
187 | + } elseif ($appPath && !file_exists($appPath."/img/$basename.svg") |
|
188 | + && file_exists($appPath."/img/$basename.png")) { |
|
189 | + $path = \OC_App::getAppWebPath($app)."/img/$basename.png"; |
|
190 | + } elseif (!empty($app) and file_exists(\OC::$SERVERROOT."/$app/img/$image")) { |
|
191 | + $path = \OC::$WEBROOT."/$app/img/$image"; |
|
192 | + } elseif (!empty($app) and (!file_exists(\OC::$SERVERROOT."/$app/img/$basename.svg") |
|
193 | + && file_exists(\OC::$SERVERROOT."/$app/img/$basename.png"))) { |
|
194 | + $path = \OC::$WEBROOT."/$app/img/$basename.png"; |
|
195 | + } elseif (file_exists(\OC::$SERVERROOT."/core/img/$image")) { |
|
196 | + $path = \OC::$WEBROOT."/core/img/$image"; |
|
197 | + } elseif (!file_exists(\OC::$SERVERROOT."/core/img/$basename.svg") |
|
198 | + && file_exists(\OC::$SERVERROOT."/core/img/$basename.png")) { |
|
199 | + $path = \OC::$WEBROOT."/themes/$theme/core/img/$basename.png"; |
|
200 | 200 | } |
201 | 201 | |
202 | - if($path !== '') { |
|
202 | + if ($path !== '') { |
|
203 | 203 | $cache->set($cacheKey, $path); |
204 | 204 | return $path; |
205 | 205 | } else { |
206 | - throw new RuntimeException('image not found: image:' . $image . ' webroot:' . \OC::$WEBROOT . ' serverroot:' . \OC::$SERVERROOT); |
|
206 | + throw new RuntimeException('image not found: image:'.$image.' webroot:'.\OC::$WEBROOT.' serverroot:'.\OC::$SERVERROOT); |
|
207 | 207 | } |
208 | 208 | } |
209 | 209 | |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | $separator = $url[0] === '/' ? '' : '/'; |
218 | 218 | |
219 | 219 | if (\OC::$CLI && !defined('PHPUNIT_RUN')) { |
220 | - return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/') . '/' . ltrim($url, '/'); |
|
220 | + return rtrim($this->config->getSystemValue('overwrite.cli.url'), '/').'/'.ltrim($url, '/'); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | // The ownCloud web root can already be prepended. |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | : \OC::$WEBROOT; |
227 | 227 | |
228 | 228 | $request = \OC::$server->getRequest(); |
229 | - return $request->getServerProtocol() . '://' . $request->getServerHost() . $webRoot . $separator . $url; |
|
229 | + return $request->getServerProtocol().'://'.$request->getServerHost().$webRoot.$separator.$url; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | * @return array An array of Tag objects. |
51 | 51 | */ |
52 | 52 | public function loadTags($owners, $type) { |
53 | - if(!is_array($owners)) { |
|
53 | + if (!is_array($owners)) { |
|
54 | 54 | $owners = array($owners); |
55 | 55 | } |
56 | 56 | |
57 | - $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
58 | - . 'WHERE `uid` IN (' . str_repeat('?,', count($owners)-1) . '?) AND `type` = ? ORDER BY `category`'; |
|
57 | + $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `'.$this->getTableName().'` ' |
|
58 | + . 'WHERE `uid` IN ('.str_repeat('?,', count($owners) - 1).'?) AND `type` = ? ORDER BY `category`'; |
|
59 | 59 | return $this->findEntities($sql, array_merge($owners, array($type))); |
60 | 60 | } |
61 | 61 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | * @return bool |
67 | 67 | */ |
68 | 68 | public function tagExists($tag) { |
69 | - $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `' . $this->getTableName() . '` ' |
|
69 | + $sql = 'SELECT `id`, `uid`, `type`, `category` FROM `'.$this->getTableName().'` ' |
|
70 | 70 | . 'WHERE `uid` = ? AND `type` = ? AND `category` = ?'; |
71 | 71 | try { |
72 | 72 | $this->findEntity($sql, array($tag->getOwner(), $tag->getType(), $tag->getName())); |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | * @todo migrate existing database columns to the correct names |
63 | 63 | * to be able to drop this direct mapping |
64 | 64 | */ |
65 | - public function columnToProperty($columnName){ |
|
65 | + public function columnToProperty($columnName) { |
|
66 | 66 | if ($columnName === 'category') { |
67 | 67 | return 'name'; |
68 | 68 | } elseif ($columnName === 'uid') { |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param string $property the name of the property |
79 | 79 | * @return string the column name |
80 | 80 | */ |
81 | - public function propertyToColumn($property){ |
|
81 | + public function propertyToColumn($property) { |
|
82 | 82 | if ($property === 'name') { |
83 | 83 | return 'category'; |
84 | 84 | } elseif ($property === 'owner') { |
@@ -52,7 +52,7 @@ |
||
52 | 52 | */ |
53 | 53 | public function generate($name, $parameters = array(), $absolute = false) { |
54 | 54 | asort($parameters); |
55 | - $key = $this->context->getHost() . '#' . $this->context->getBaseUrl() . $name . sha1(json_encode($parameters)) . intval($absolute); |
|
55 | + $key = $this->context->getHost().'#'.$this->context->getBaseUrl().$name.sha1(json_encode($parameters)).intval($absolute); |
|
56 | 56 | $cachedKey = $this->cache->get($key); |
57 | 57 | if ($cachedKey) { |
58 | 58 | return $cachedKey; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | public function __construct(ILogger $logger) { |
73 | 73 | $this->logger = $logger; |
74 | 74 | $baseUrl = \OC::$WEBROOT; |
75 | - if(!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
75 | + if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) { |
|
76 | 76 | $baseUrl = \OC::$server->getURLGenerator()->linkTo('', 'index.php'); |
77 | 77 | } |
78 | 78 | if (!\OC::$CLI) { |
@@ -98,8 +98,8 @@ discard block |
||
98 | 98 | $this->routingFiles = []; |
99 | 99 | foreach (\OC_APP::getEnabledApps() as $app) { |
100 | 100 | $appPath = \OC_App::getAppPath($app); |
101 | - if($appPath !== false) { |
|
102 | - $file = $appPath . '/appinfo/routes.php'; |
|
101 | + if ($appPath !== false) { |
|
102 | + $file = $appPath.'/appinfo/routes.php'; |
|
103 | 103 | if (file_exists($file)) { |
104 | 104 | $this->routingFiles[$app] = $file; |
105 | 105 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * @param null|string $app |
116 | 116 | */ |
117 | 117 | public function loadRoutes($app = null) { |
118 | - if(is_string($app)) { |
|
118 | + if (is_string($app)) { |
|
119 | 119 | $app = \OC_App::cleanAppId($app); |
120 | 120 | } |
121 | 121 | |
@@ -130,14 +130,14 @@ discard block |
||
130 | 130 | if (isset($this->loadedApps[$app])) { |
131 | 131 | return; |
132 | 132 | } |
133 | - $file = \OC_App::getAppPath($app) . '/appinfo/routes.php'; |
|
133 | + $file = \OC_App::getAppPath($app).'/appinfo/routes.php'; |
|
134 | 134 | if ($file !== false && file_exists($file)) { |
135 | 135 | $routingFiles = [$app => $file]; |
136 | 136 | } else { |
137 | 137 | $routingFiles = []; |
138 | 138 | } |
139 | 139 | } |
140 | - \OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes'); |
|
140 | + \OC::$server->getEventLogger()->start('loadroutes'.$requestedApp, 'Loading Routes'); |
|
141 | 141 | foreach ($routingFiles as $app => $file) { |
142 | 142 | if (!isset($this->loadedApps[$app])) { |
143 | 143 | if (!\OC_App::isAppLoaded($app)) { |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $this->useCollection($app); |
151 | 151 | $this->requireRouteFile($file, $app); |
152 | 152 | $collection = $this->getCollection($app); |
153 | - $collection->addPrefix('/apps/' . $app); |
|
153 | + $collection->addPrefix('/apps/'.$app); |
|
154 | 154 | $this->root->addCollection($collection); |
155 | 155 | |
156 | 156 | // Also add the OCS collection |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | if (!isset($this->loadedApps['core'])) { |
163 | 163 | $this->loadedApps['core'] = true; |
164 | 164 | $this->useCollection('root'); |
165 | - require_once __DIR__ . '/../../../settings/routes.php'; |
|
166 | - require_once __DIR__ . '/../../../core/routes.php'; |
|
165 | + require_once __DIR__.'/../../../settings/routes.php'; |
|
166 | + require_once __DIR__.'/../../../core/routes.php'; |
|
167 | 167 | |
168 | 168 | // Also add the OCS collection |
169 | 169 | $collection = $this->getCollection('root.ocs'); |
@@ -172,12 +172,12 @@ discard block |
||
172 | 172 | } |
173 | 173 | if ($this->loaded) { |
174 | 174 | // include ocs routes, must be loaded last for /ocs prefix |
175 | - require_once __DIR__ . '/../../../ocs/routes.php'; |
|
175 | + require_once __DIR__.'/../../../ocs/routes.php'; |
|
176 | 176 | $collection = $this->getCollection('ocs'); |
177 | 177 | $collection->addPrefix('/ocs'); |
178 | 178 | $this->root->addCollection($collection); |
179 | 179 | } |
180 | - \OC::$server->getEventLogger()->end('loadroutes' . $requestedApp); |
|
180 | + \OC::$server->getEventLogger()->end('loadroutes'.$requestedApp); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | public function match($url) { |
249 | 249 | if (substr($url, 0, 6) === '/apps/') { |
250 | 250 | // empty string / 'apps' / $app / rest of the route |
251 | - list(, , $app,) = explode('/', $url, 4); |
|
251 | + list(,, $app,) = explode('/', $url, 4); |
|
252 | 252 | |
253 | 253 | $app = \OC_App::cleanAppId($app); |
254 | 254 | \OC::$REQUESTEDAPP = $app; |
255 | 255 | $this->loadRoutes($app); |
256 | 256 | } else if (substr($url, 0, 13) === '/ocsapp/apps/') { |
257 | 257 | // empty string / 'ocsapp' / 'apps' / $app / rest of the route |
258 | - list(, , , $app,) = explode('/', $url, 5); |
|
258 | + list(,,, $app,) = explode('/', $url, 5); |
|
259 | 259 | |
260 | 260 | $app = \OC_App::cleanAppId($app); |
261 | 261 | \OC::$REQUESTEDAPP = $app; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | // However, since Symfony does not allow empty route names, the route |
280 | 280 | // we need to match is '/', so we need to append the '/' here. |
281 | 281 | try { |
282 | - $parameters = $matcher->match($url . '/'); |
|
282 | + $parameters = $matcher->match($url.'/'); |
|
283 | 283 | } catch (ResourceNotFoundException $newException) { |
284 | 284 | // If we still didn't match a route, we throw the original exception |
285 | 285 | throw $e; |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | if (is_array($routes)) { |
370 | 370 | $appNameSpace = App::buildAppNamespace($appName); |
371 | 371 | |
372 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
372 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
373 | 373 | |
374 | 374 | if (class_exists($applicationClassName)) { |
375 | 375 | $application = new $applicationClassName(); |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | public function search($pattern, $searchProperties = array(), $options = array()) { |
42 | 42 | $this->loadAddressBooks(); |
43 | 43 | $result = array(); |
44 | - foreach($this->addressBooks as $addressBook) { |
|
44 | + foreach ($this->addressBooks as $addressBook) { |
|
45 | 45 | $r = $addressBook->search($pattern, $searchProperties, $options); |
46 | 46 | $contacts = array(); |
47 | - foreach($r as $c){ |
|
47 | + foreach ($r as $c) { |
|
48 | 48 | $c['addressbook-key'] = $addressBook->getKey(); |
49 | 49 | $contacts[] = $c; |
50 | 50 | } |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | public function getAddressBooks() { |
125 | 125 | $this->loadAddressBooks(); |
126 | 126 | $result = array(); |
127 | - foreach($this->addressBooks as $addressBook) { |
|
127 | + foreach ($this->addressBooks as $addressBook) { |
|
128 | 128 | $result[$addressBook->getKey()] = $addressBook->getDisplayName(); |
129 | 129 | } |
130 | 130 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function loadAddressBooks() |
183 | 183 | { |
184 | - foreach($this->addressBookLoaders as $callable) { |
|
184 | + foreach ($this->addressBookLoaders as $callable) { |
|
185 | 185 | $callable($this); |
186 | 186 | } |
187 | 187 | $this->addressBookLoaders = array(); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | |
86 | 86 | // If at least PHP 7.0.0 is used we don't need to disable apps as we catch |
87 | 87 | // fatal errors and exceptions and disable the app just instead. |
88 | - if(version_compare(phpversion(), '7.0.0', '>=')) { |
|
88 | + if (version_compare(phpversion(), '7.0.0', '>=')) { |
|
89 | 89 | $this->skip3rdPartyAppsDisable = true; |
90 | 90 | } |
91 | 91 | } |
@@ -111,43 +111,43 @@ discard block |
||
111 | 111 | $this->logAllEvents(); |
112 | 112 | |
113 | 113 | $logLevel = $this->config->getSystemValue('loglevel', Util::WARN); |
114 | - $this->emit('\OC\Updater', 'setDebugLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
114 | + $this->emit('\OC\Updater', 'setDebugLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]); |
|
115 | 115 | $this->config->setSystemValue('loglevel', Util::DEBUG); |
116 | 116 | |
117 | 117 | $wasMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); |
118 | 118 | |
119 | - if(!$wasMaintenanceModeEnabled) { |
|
119 | + if (!$wasMaintenanceModeEnabled) { |
|
120 | 120 | $this->config->setSystemValue('maintenance', true); |
121 | 121 | $this->emit('\OC\Updater', 'maintenanceEnabled'); |
122 | 122 | } |
123 | 123 | |
124 | 124 | $installedVersion = $this->config->getSystemValue('version', '0.0.0'); |
125 | 125 | $currentVersion = implode('.', \OCP\Util::getVersion()); |
126 | - $this->log->debug('starting upgrade from ' . $installedVersion . ' to ' . $currentVersion, array('app' => 'core')); |
|
126 | + $this->log->debug('starting upgrade from '.$installedVersion.' to '.$currentVersion, array('app' => 'core')); |
|
127 | 127 | |
128 | 128 | $success = true; |
129 | 129 | try { |
130 | 130 | $this->doUpgrade($currentVersion, $installedVersion); |
131 | 131 | } catch (HintException $exception) { |
132 | 132 | $this->log->logException($exception, ['app' => 'core']); |
133 | - $this->emit('\OC\Updater', 'failure', array($exception->getMessage() . ': ' .$exception->getHint())); |
|
133 | + $this->emit('\OC\Updater', 'failure', array($exception->getMessage().': '.$exception->getHint())); |
|
134 | 134 | $success = false; |
135 | 135 | } catch (\Exception $exception) { |
136 | 136 | $this->log->logException($exception, ['app' => 'core']); |
137 | - $this->emit('\OC\Updater', 'failure', array(get_class($exception) . ': ' .$exception->getMessage())); |
|
137 | + $this->emit('\OC\Updater', 'failure', array(get_class($exception).': '.$exception->getMessage())); |
|
138 | 138 | $success = false; |
139 | 139 | } |
140 | 140 | |
141 | 141 | $this->emit('\OC\Updater', 'updateEnd', array($success)); |
142 | 142 | |
143 | - if(!$wasMaintenanceModeEnabled && $success) { |
|
143 | + if (!$wasMaintenanceModeEnabled && $success) { |
|
144 | 144 | $this->config->setSystemValue('maintenance', false); |
145 | 145 | $this->emit('\OC\Updater', 'maintenanceDisabled'); |
146 | 146 | } else { |
147 | 147 | $this->emit('\OC\Updater', 'maintenanceActive'); |
148 | 148 | } |
149 | 149 | |
150 | - $this->emit('\OC\Updater', 'resetLogLevel', [ $logLevel, $this->logLevelNames[$logLevel] ]); |
|
150 | + $this->emit('\OC\Updater', 'resetLogLevel', [$logLevel, $this->logLevelNames[$logLevel]]); |
|
151 | 151 | $this->config->setSystemValue('loglevel', $logLevel); |
152 | 152 | $this->config->setSystemValue('installed', true); |
153 | 153 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | */ |
162 | 162 | private function getAllowedPreviousVersions() { |
163 | 163 | // this should really be a JSON file |
164 | - require \OC::$SERVERROOT . '/version.php'; |
|
164 | + require \OC::$SERVERROOT.'/version.php'; |
|
165 | 165 | /** @var array $OC_VersionCanBeUpgradedFrom */ |
166 | 166 | return $OC_VersionCanBeUpgradedFrom; |
167 | 167 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | private function getVendor() { |
175 | 175 | // this should really be a JSON file |
176 | - require \OC::$SERVERROOT . '/version.php'; |
|
176 | + require \OC::$SERVERROOT.'/version.php'; |
|
177 | 177 | /** @var string $vendor */ |
178 | 178 | return (string) $vendor; |
179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | */ |
188 | 188 | public function isUpgradePossible($oldVersion, $newVersion, array $allowedPreviousVersions) { |
189 | 189 | $version = explode('.', $oldVersion); |
190 | - $majorMinor = $version[0] . '.' . $version[1]; |
|
190 | + $majorMinor = $version[0].'.'.$version[1]; |
|
191 | 191 | |
192 | 192 | $currentVendor = $this->config->getAppValue('core', 'vendor', ''); |
193 | 193 | if ($currentVendor === 'nextcloud') { |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | // create empty file in data dir, so we can later find |
228 | 228 | // out that this is indeed an ownCloud data directory |
229 | 229 | // (in case it didn't exist before) |
230 | - file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data') . '/.ocdata', ''); |
|
230 | + file_put_contents($this->config->getSystemValue('datadirectory', \OC::$SERVERROOT.'/data').'/.ocdata', ''); |
|
231 | 231 | |
232 | 232 | // pre-upgrade repairs |
233 | 233 | $repair = new Repair(Repair::getBeforeUpgradeRepairSteps(), \OC::$server->getEventDispatcher()); |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | foreach ($errors as $appId => $exception) { |
256 | 256 | /** @var \Exception $exception */ |
257 | 257 | $this->log->logException($exception, ['app' => $appId]); |
258 | - $this->emit('\OC\Updater', 'failure', [$appId . ': ' . $exception->getMessage()]); |
|
258 | + $this->emit('\OC\Updater', 'failure', [$appId.': '.$exception->getMessage()]); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | // post-upgrade repairs |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | $this->config->setAppValue('core', 'lastupdatedat', 0); |
267 | 267 | |
268 | 268 | // Check for code integrity if not disabled |
269 | - if(\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
269 | + if (\OC::$server->getIntegrityCodeChecker()->isCodeCheckEnforced()) { |
|
270 | 270 | $this->emit('\OC\Updater', 'startCheckCodeIntegrity'); |
271 | 271 | $this->checker->runInstanceVerification(); |
272 | 272 | $this->emit('\OC\Updater', 'finishedCheckCodeIntegrity'); |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | $this->emit('\OC\Updater', 'dbUpgradeBefore'); |
282 | 282 | |
283 | 283 | // do the real upgrade |
284 | - \OC_DB::updateDbFromStructure(\OC::$SERVERROOT . '/db_structure.xml'); |
|
284 | + \OC_DB::updateDbFromStructure(\OC::$SERVERROOT.'/db_structure.xml'); |
|
285 | 285 | |
286 | 286 | $this->emit('\OC\Updater', 'dbUpgrade'); |
287 | 287 | } |
@@ -305,12 +305,12 @@ discard block |
||
305 | 305 | * @link https://github.com/owncloud/core/issues/10980 |
306 | 306 | * @see \OC_App::updateApp |
307 | 307 | */ |
308 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/preupdate.php')) { |
|
308 | + if (file_exists(\OC_App::getAppPath($appId).'/appinfo/preupdate.php')) { |
|
309 | 309 | $this->includePreUpdate($appId); |
310 | 310 | } |
311 | - if (file_exists(\OC_App::getAppPath($appId) . '/appinfo/database.xml')) { |
|
311 | + if (file_exists(\OC_App::getAppPath($appId).'/appinfo/database.xml')) { |
|
312 | 312 | $this->emit('\OC\Updater', 'appSimulateUpdate', array($appId)); |
313 | - \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId) . '/appinfo/database.xml'); |
|
313 | + \OC_DB::simulateUpdateDbFromStructure(\OC_App::getAppPath($appId).'/appinfo/database.xml'); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | * @param string $appId |
324 | 324 | */ |
325 | 325 | private function includePreUpdate($appId) { |
326 | - include \OC_App::getAppPath($appId) . '/appinfo/preupdate.php'; |
|
326 | + include \OC_App::getAppPath($appId).'/appinfo/preupdate.php'; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -341,7 +341,7 @@ discard block |
||
341 | 341 | foreach ($apps as $appId) { |
342 | 342 | $priorityType = false; |
343 | 343 | foreach ($priorityTypes as $type) { |
344 | - if(!isset($stacks[$type])) { |
|
344 | + if (!isset($stacks[$type])) { |
|
345 | 345 | $stacks[$type] = array(); |
346 | 346 | } |
347 | 347 | if (\OC_App::isType($appId, $type)) { |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | \OC_App::updateApp($appId); |
362 | 362 | $this->emit('\OC\Updater', 'appUpgrade', [$appId, \OC_App::getAppVersion($appId)]); |
363 | 363 | } |
364 | - if($type !== $pseudoOtherType) { |
|
364 | + if ($type !== $pseudoOtherType) { |
|
365 | 365 | // load authentication, filesystem and logging apps after |
366 | 366 | // upgrading them. Other apps my need to rely on modifying |
367 | 367 | // user and/or filesystem aspects. |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | foreach ($apps as $app) { |
389 | 389 | // check if the app is compatible with this version of ownCloud |
390 | 390 | $info = OC_App::getAppInfo($app); |
391 | - if(!OC_App::isAppCompatible($version, $info)) { |
|
391 | + if (!OC_App::isAppCompatible($version, $info)) { |
|
392 | 392 | if (OC_App::isShipped($app)) { |
393 | - throw new \UnexpectedValueException('The files of the app "' . $app . '" were not correctly replaced before running the update'); |
|
393 | + throw new \UnexpectedValueException('The files of the app "'.$app.'" were not correctly replaced before running the update'); |
|
394 | 394 | } |
395 | 395 | OC_App::disable($app); |
396 | 396 | $this->emit('\OC\Updater', 'incompatibleAppDisabled', array($app)); |
@@ -409,9 +409,9 @@ discard block |
||
409 | 409 | } |
410 | 410 | |
411 | 411 | // disable any other 3rd party apps if not overriden |
412 | - if(!$this->skip3rdPartyAppsDisable) { |
|
412 | + if (!$this->skip3rdPartyAppsDisable) { |
|
413 | 413 | \OC_App::disable($app); |
414 | - $disabledApps[]= $app; |
|
414 | + $disabledApps[] = $app; |
|
415 | 415 | $this->emit('\OC\Updater', 'thirdPartyAppDisabled', array($app)); |
416 | 416 | }; |
417 | 417 | } |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | * @throws \Exception |
436 | 436 | */ |
437 | 437 | private function upgradeAppStoreApps(array $disabledApps) { |
438 | - foreach($disabledApps as $app) { |
|
438 | + foreach ($disabledApps as $app) { |
|
439 | 439 | try { |
440 | 440 | $installer = new Installer( |
441 | 441 | \OC::$server->getAppFetcher(), |
@@ -458,22 +458,22 @@ discard block |
||
458 | 458 | */ |
459 | 459 | private function emitRepairEvents() { |
460 | 460 | $dispatcher = \OC::$server->getEventDispatcher(); |
461 | - $dispatcher->addListener('\OC\Repair::warning', function ($event) { |
|
461 | + $dispatcher->addListener('\OC\Repair::warning', function($event) { |
|
462 | 462 | if ($event instanceof GenericEvent) { |
463 | 463 | $this->emit('\OC\Updater', 'repairWarning', $event->getArguments()); |
464 | 464 | } |
465 | 465 | }); |
466 | - $dispatcher->addListener('\OC\Repair::error', function ($event) { |
|
466 | + $dispatcher->addListener('\OC\Repair::error', function($event) { |
|
467 | 467 | if ($event instanceof GenericEvent) { |
468 | 468 | $this->emit('\OC\Updater', 'repairError', $event->getArguments()); |
469 | 469 | } |
470 | 470 | }); |
471 | - $dispatcher->addListener('\OC\Repair::info', function ($event) { |
|
471 | + $dispatcher->addListener('\OC\Repair::info', function($event) { |
|
472 | 472 | if ($event instanceof GenericEvent) { |
473 | 473 | $this->emit('\OC\Updater', 'repairInfo', $event->getArguments()); |
474 | 474 | } |
475 | 475 | }); |
476 | - $dispatcher->addListener('\OC\Repair::step', function ($event) { |
|
476 | + $dispatcher->addListener('\OC\Repair::step', function($event) { |
|
477 | 477 | if ($event instanceof GenericEvent) { |
478 | 478 | $this->emit('\OC\Updater', 'repairStep', $event->getArguments()); |
479 | 479 | } |
@@ -488,13 +488,13 @@ discard block |
||
488 | 488 | if (!$event instanceof GenericEvent) { |
489 | 489 | return; |
490 | 490 | } |
491 | - $log->info('\OC\DB\Migrator::executeSql: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
491 | + $log->info('\OC\DB\Migrator::executeSql: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']); |
|
492 | 492 | }); |
493 | 493 | $dispatcher->addListener('\OC\DB\Migrator::checkTable', function($event) use ($log) { |
494 | 494 | if (!$event instanceof GenericEvent) { |
495 | 495 | return; |
496 | 496 | } |
497 | - $log->info('\OC\DB\Migrator::checkTable: ' . $event->getSubject() . ' (' . $event->getArgument(0) . ' of ' . $event->getArgument(1) . ')', ['app' => 'updater']); |
|
497 | + $log->info('\OC\DB\Migrator::checkTable: '.$event->getSubject().' ('.$event->getArgument(0).' of '.$event->getArgument(1).')', ['app' => 'updater']); |
|
498 | 498 | }); |
499 | 499 | |
500 | 500 | $repairListener = function($event) use ($log) { |
@@ -503,30 +503,30 @@ discard block |
||
503 | 503 | } |
504 | 504 | switch ($event->getSubject()) { |
505 | 505 | case '\OC\Repair::startProgress': |
506 | - $log->info('\OC\Repair::startProgress: Starting ... ' . $event->getArgument(1) . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
506 | + $log->info('\OC\Repair::startProgress: Starting ... '.$event->getArgument(1).' ('.$event->getArgument(0).')', ['app' => 'updater']); |
|
507 | 507 | break; |
508 | 508 | case '\OC\Repair::advance': |
509 | 509 | $desc = $event->getArgument(1); |
510 | 510 | if (empty($desc)) { |
511 | 511 | $desc = ''; |
512 | 512 | } |
513 | - $log->info('\OC\Repair::advance: ' . $desc . ' (' . $event->getArgument(0) . ')', ['app' => 'updater']); |
|
513 | + $log->info('\OC\Repair::advance: '.$desc.' ('.$event->getArgument(0).')', ['app' => 'updater']); |
|
514 | 514 | |
515 | 515 | break; |
516 | 516 | case '\OC\Repair::finishProgress': |
517 | 517 | $log->info('\OC\Repair::finishProgress', ['app' => 'updater']); |
518 | 518 | break; |
519 | 519 | case '\OC\Repair::step': |
520 | - $log->info('\OC\Repair::step: Repair step: ' . $event->getArgument(0), ['app' => 'updater']); |
|
520 | + $log->info('\OC\Repair::step: Repair step: '.$event->getArgument(0), ['app' => 'updater']); |
|
521 | 521 | break; |
522 | 522 | case '\OC\Repair::info': |
523 | - $log->info('\OC\Repair::info: Repair info: ' . $event->getArgument(0), ['app' => 'updater']); |
|
523 | + $log->info('\OC\Repair::info: Repair info: '.$event->getArgument(0), ['app' => 'updater']); |
|
524 | 524 | break; |
525 | 525 | case '\OC\Repair::warning': |
526 | - $log->warning('\OC\Repair::warning: Repair warning: ' . $event->getArgument(0), ['app' => 'updater']); |
|
526 | + $log->warning('\OC\Repair::warning: Repair warning: '.$event->getArgument(0), ['app' => 'updater']); |
|
527 | 527 | break; |
528 | 528 | case '\OC\Repair::error': |
529 | - $log->error('\OC\Repair::error: Repair error: ' . $event->getArgument(0), ['app' => 'updater']); |
|
529 | + $log->error('\OC\Repair::error: Repair error: '.$event->getArgument(0), ['app' => 'updater']); |
|
530 | 530 | break; |
531 | 531 | } |
532 | 532 | }; |
@@ -540,71 +540,71 @@ discard block |
||
540 | 540 | $dispatcher->addListener('\OC\Repair::error', $repairListener); |
541 | 541 | |
542 | 542 | |
543 | - $this->listen('\OC\Updater', 'maintenanceEnabled', function () use($log) { |
|
543 | + $this->listen('\OC\Updater', 'maintenanceEnabled', function() use($log) { |
|
544 | 544 | $log->info('\OC\Updater::maintenanceEnabled: Turned on maintenance mode', ['app' => 'updater']); |
545 | 545 | }); |
546 | - $this->listen('\OC\Updater', 'maintenanceDisabled', function () use($log) { |
|
546 | + $this->listen('\OC\Updater', 'maintenanceDisabled', function() use($log) { |
|
547 | 547 | $log->info('\OC\Updater::maintenanceDisabled: Turned off maintenance mode', ['app' => 'updater']); |
548 | 548 | }); |
549 | - $this->listen('\OC\Updater', 'maintenanceActive', function () use($log) { |
|
549 | + $this->listen('\OC\Updater', 'maintenanceActive', function() use($log) { |
|
550 | 550 | $log->info('\OC\Updater::maintenanceActive: Maintenance mode is kept active', ['app' => 'updater']); |
551 | 551 | }); |
552 | - $this->listen('\OC\Updater', 'updateEnd', function ($success) use($log) { |
|
552 | + $this->listen('\OC\Updater', 'updateEnd', function($success) use($log) { |
|
553 | 553 | if ($success) { |
554 | 554 | $log->info('\OC\Updater::updateEnd: Update successful', ['app' => 'updater']); |
555 | 555 | } else { |
556 | 556 | $log->error('\OC\Updater::updateEnd: Update failed', ['app' => 'updater']); |
557 | 557 | } |
558 | 558 | }); |
559 | - $this->listen('\OC\Updater', 'dbUpgradeBefore', function () use($log) { |
|
559 | + $this->listen('\OC\Updater', 'dbUpgradeBefore', function() use($log) { |
|
560 | 560 | $log->info('\OC\Updater::dbUpgradeBefore: Updating database schema', ['app' => 'updater']); |
561 | 561 | }); |
562 | - $this->listen('\OC\Updater', 'dbUpgrade', function () use($log) { |
|
562 | + $this->listen('\OC\Updater', 'dbUpgrade', function() use($log) { |
|
563 | 563 | $log->info('\OC\Updater::dbUpgrade: Updated database', ['app' => 'updater']); |
564 | 564 | }); |
565 | - $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function () use($log) { |
|
565 | + $this->listen('\OC\Updater', 'dbSimulateUpgradeBefore', function() use($log) { |
|
566 | 566 | $log->info('\OC\Updater::dbSimulateUpgradeBefore: Checking whether the database schema can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
567 | 567 | }); |
568 | - $this->listen('\OC\Updater', 'dbSimulateUpgrade', function () use($log) { |
|
568 | + $this->listen('\OC\Updater', 'dbSimulateUpgrade', function() use($log) { |
|
569 | 569 | $log->info('\OC\Updater::dbSimulateUpgrade: Checked database schema update', ['app' => 'updater']); |
570 | 570 | }); |
571 | - $this->listen('\OC\Updater', 'incompatibleAppDisabled', function ($app) use($log) { |
|
572 | - $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: ' . $app, ['app' => 'updater']); |
|
571 | + $this->listen('\OC\Updater', 'incompatibleAppDisabled', function($app) use($log) { |
|
572 | + $log->info('\OC\Updater::incompatibleAppDisabled: Disabled incompatible app: '.$app, ['app' => 'updater']); |
|
573 | 573 | }); |
574 | - $this->listen('\OC\Updater', 'thirdPartyAppDisabled', function ($app) use ($log) { |
|
575 | - $log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: ' . $app, ['app' => 'updater']); |
|
574 | + $this->listen('\OC\Updater', 'thirdPartyAppDisabled', function($app) use ($log) { |
|
575 | + $log->info('\OC\Updater::thirdPartyAppDisabled: Disabled 3rd-party app: '.$app, ['app' => 'updater']); |
|
576 | 576 | }); |
577 | - $this->listen('\OC\Updater', 'upgradeAppStoreApp', function ($app) use($log) { |
|
578 | - $log->info('\OC\Updater::upgradeAppStoreApp: Update 3rd-party app: ' . $app, ['app' => 'updater']); |
|
577 | + $this->listen('\OC\Updater', 'upgradeAppStoreApp', function($app) use($log) { |
|
578 | + $log->info('\OC\Updater::upgradeAppStoreApp: Update 3rd-party app: '.$app, ['app' => 'updater']); |
|
579 | 579 | }); |
580 | - $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function () use ($log) { |
|
580 | + $this->listen('\OC\Updater', 'appUpgradeCheckBefore', function() use ($log) { |
|
581 | 581 | $log->info('\OC\Updater::appUpgradeCheckBefore: Checking updates of apps', ['app' => 'updater']); |
582 | 582 | }); |
583 | - $this->listen('\OC\Updater', 'appSimulateUpdate', function ($app) use ($log) { |
|
584 | - $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <' . $app . '> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
583 | + $this->listen('\OC\Updater', 'appSimulateUpdate', function($app) use ($log) { |
|
584 | + $log->info('\OC\Updater::appSimulateUpdate: Checking whether the database schema for <'.$app.'> can be updated (this can take a long time depending on the database size)', ['app' => 'updater']); |
|
585 | 585 | }); |
586 | - $this->listen('\OC\Updater', 'appUpgradeCheck', function () use ($log) { |
|
586 | + $this->listen('\OC\Updater', 'appUpgradeCheck', function() use ($log) { |
|
587 | 587 | $log->info('\OC\Updater::appUpgradeCheck: Checked database schema update for apps', ['app' => 'updater']); |
588 | 588 | }); |
589 | - $this->listen('\OC\Updater', 'appUpgradeStarted', function ($app) use ($log) { |
|
590 | - $log->info('\OC\Updater::appUpgradeStarted: Updating <' . $app . '> ...', ['app' => 'updater']); |
|
589 | + $this->listen('\OC\Updater', 'appUpgradeStarted', function($app) use ($log) { |
|
590 | + $log->info('\OC\Updater::appUpgradeStarted: Updating <'.$app.'> ...', ['app' => 'updater']); |
|
591 | 591 | }); |
592 | - $this->listen('\OC\Updater', 'appUpgrade', function ($app, $version) use ($log) { |
|
593 | - $log->info('\OC\Updater::appUpgrade: Updated <' . $app . '> to ' . $version, ['app' => 'updater']); |
|
592 | + $this->listen('\OC\Updater', 'appUpgrade', function($app, $version) use ($log) { |
|
593 | + $log->info('\OC\Updater::appUpgrade: Updated <'.$app.'> to '.$version, ['app' => 'updater']); |
|
594 | 594 | }); |
595 | - $this->listen('\OC\Updater', 'failure', function ($message) use($log) { |
|
596 | - $log->error('\OC\Updater::failure: ' . $message, ['app' => 'updater']); |
|
595 | + $this->listen('\OC\Updater', 'failure', function($message) use($log) { |
|
596 | + $log->error('\OC\Updater::failure: '.$message, ['app' => 'updater']); |
|
597 | 597 | }); |
598 | - $this->listen('\OC\Updater', 'setDebugLogLevel', function () use($log) { |
|
598 | + $this->listen('\OC\Updater', 'setDebugLogLevel', function() use($log) { |
|
599 | 599 | $log->info('\OC\Updater::setDebugLogLevel: Set log level to debug', ['app' => 'updater']); |
600 | 600 | }); |
601 | - $this->listen('\OC\Updater', 'resetLogLevel', function ($logLevel, $logLevelName) use($log) { |
|
602 | - $log->info('\OC\Updater::resetLogLevel: Reset log level to ' . $logLevelName . '(' . $logLevel . ')', ['app' => 'updater']); |
|
601 | + $this->listen('\OC\Updater', 'resetLogLevel', function($logLevel, $logLevelName) use($log) { |
|
602 | + $log->info('\OC\Updater::resetLogLevel: Reset log level to '.$logLevelName.'('.$logLevel.')', ['app' => 'updater']); |
|
603 | 603 | }); |
604 | - $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function () use($log) { |
|
604 | + $this->listen('\OC\Updater', 'startCheckCodeIntegrity', function() use($log) { |
|
605 | 605 | $log->info('\OC\Updater::startCheckCodeIntegrity: Starting code integrity check...', ['app' => 'updater']); |
606 | 606 | }); |
607 | - $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function () use($log) { |
|
607 | + $this->listen('\OC\Updater', 'finishedCheckCodeIntegrity', function() use($log) { |
|
608 | 608 | $log->info('\OC\Updater::finishedCheckCodeIntegrity: Finished code integrity check', ['app' => 'updater']); |
609 | 609 | }); |
610 | 610 |
@@ -101,13 +101,13 @@ discard block |
||
101 | 101 | $parts = explode('/', $path); |
102 | 102 | $folder = $tmpBase; |
103 | 103 | foreach ($parts as $part) { |
104 | - $folder .= '/' . $part; |
|
104 | + $folder .= '/'.$part; |
|
105 | 105 | if (!is_dir($folder)) { |
106 | 106 | mkdir($folder); |
107 | 107 | } |
108 | 108 | } |
109 | - $result = $this->tar->addModify(array($tmpBase . $path), '', $tmpBase); |
|
110 | - rmdir($tmpBase . $path); |
|
109 | + $result = $this->tar->addModify(array($tmpBase.$path), '', $tmpBase); |
|
110 | + rmdir($tmpBase.$path); |
|
111 | 111 | $this->fileList = false; |
112 | 112 | $this->cachedHeaders = false; |
113 | 113 | return $result; |
@@ -144,12 +144,12 @@ discard block |
||
144 | 144 | //no proper way to delete, rename entire archive, rename file and remake archive |
145 | 145 | $tmp = \OCP\Files::tmpFolder(); |
146 | 146 | $this->tar->extract($tmp); |
147 | - rename($tmp . $source, $tmp . $dest); |
|
147 | + rename($tmp.$source, $tmp.$dest); |
|
148 | 148 | $this->tar = null; |
149 | 149 | unlink($this->path); |
150 | 150 | $types = array(null, 'gz', 'bz'); |
151 | 151 | $this->tar = new \Archive_Tar($this->path, $types[self::getTarType($this->path)]); |
152 | - $this->tar->createModify(array($tmp), '', $tmp . '/'); |
|
152 | + $this->tar->createModify(array($tmp), '', $tmp.'/'); |
|
153 | 153 | $this->fileList = false; |
154 | 154 | $this->cachedHeaders = false; |
155 | 155 | return true; |
@@ -164,9 +164,9 @@ discard block |
||
164 | 164 | } |
165 | 165 | foreach ($this->cachedHeaders as $header) { |
166 | 166 | if ($file == $header['filename'] |
167 | - or $file . '/' == $header['filename'] |
|
168 | - or '/' . $file . '/' == $header['filename'] |
|
169 | - or '/' . $file == $header['filename'] |
|
167 | + or $file.'/' == $header['filename'] |
|
168 | + or '/'.$file.'/' == $header['filename'] |
|
169 | + or '/'.$file == $header['filename'] |
|
170 | 170 | ) { |
171 | 171 | return $header; |
172 | 172 | } |
@@ -265,13 +265,13 @@ discard block |
||
265 | 265 | if (!$this->fileExists($path)) { |
266 | 266 | return false; |
267 | 267 | } |
268 | - if ($this->fileExists('/' . $path)) { |
|
269 | - $success = $this->tar->extractList(array('/' . $path), $tmp); |
|
268 | + if ($this->fileExists('/'.$path)) { |
|
269 | + $success = $this->tar->extractList(array('/'.$path), $tmp); |
|
270 | 270 | } else { |
271 | 271 | $success = $this->tar->extractList(array($path), $tmp); |
272 | 272 | } |
273 | 273 | if ($success) { |
274 | - rename($tmp . $path, $dest); |
|
274 | + rename($tmp.$path, $dest); |
|
275 | 275 | } |
276 | 276 | \OCP\Files::rmdirr($tmp); |
277 | 277 | return $success; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function fileExists($path) { |
297 | 297 | $files = $this->getFiles(); |
298 | - if ((array_search($path, $files) !== false) or (array_search($path . '/', $files) !== false)) { |
|
298 | + if ((array_search($path, $files) !== false) or (array_search($path.'/', $files) !== false)) { |
|
299 | 299 | return true; |
300 | 300 | } else { |
301 | 301 | $folderPath = $path; |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | } |
311 | 311 | } |
312 | 312 | if ($path[0] != '/') { //not all programs agree on the use of a leading / |
313 | - return $this->fileExists('/' . $path); |
|
313 | + return $this->fileExists('/'.$path); |
|
314 | 314 | } else { |
315 | 315 | return false; |
316 | 316 | } |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | //no proper way to delete, extract entire archive, delete file and remake archive |
332 | 332 | $tmp = \OCP\Files::tmpFolder(); |
333 | 333 | $this->tar->extract($tmp); |
334 | - \OCP\Files::rmdirr($tmp . $path); |
|
334 | + \OCP\Files::rmdirr($tmp.$path); |
|
335 | 335 | $this->tar = null; |
336 | 336 | unlink($this->path); |
337 | 337 | $this->reopen(); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | return fopen($tmpFile, $mode); |
363 | 363 | } else { |
364 | 364 | $handle = fopen($tmpFile, $mode); |
365 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
365 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
366 | 366 | $this->writeBack($tmpFile, $path); |
367 | 367 | }); |
368 | 368 | } |
@@ -33,21 +33,21 @@ discard block |
||
33 | 33 | |
34 | 34 | use Icewind\Streams\CallbackWrapper; |
35 | 35 | |
36 | -class ZIP extends Archive{ |
|
36 | +class ZIP extends Archive { |
|
37 | 37 | /** |
38 | 38 | * @var \ZipArchive zip |
39 | 39 | */ |
40 | - private $zip=null; |
|
40 | + private $zip = null; |
|
41 | 41 | private $path; |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param string $source |
45 | 45 | */ |
46 | 46 | function __construct($source) { |
47 | - $this->path=$source; |
|
48 | - $this->zip=new \ZipArchive(); |
|
49 | - if($this->zip->open($source, \ZipArchive::CREATE)) { |
|
50 | - }else{ |
|
47 | + $this->path = $source; |
|
48 | + $this->zip = new \ZipArchive(); |
|
49 | + if ($this->zip->open($source, \ZipArchive::CREATE)) { |
|
50 | + } else { |
|
51 | 51 | \OCP\Util::writeLog('files_archive', 'Error while opening archive '.$source, \OCP\Util::WARN); |
52 | 52 | } |
53 | 53 | } |
@@ -65,14 +65,14 @@ discard block |
||
65 | 65 | * @param string $source either a local file or string data |
66 | 66 | * @return bool |
67 | 67 | */ |
68 | - function addFile($path, $source='') { |
|
69 | - if($source and $source[0]=='/' and file_exists($source)) { |
|
70 | - $result=$this->zip->addFile($source, $path); |
|
71 | - }else{ |
|
72 | - $result=$this->zip->addFromString($path, $source); |
|
68 | + function addFile($path, $source = '') { |
|
69 | + if ($source and $source[0] == '/' and file_exists($source)) { |
|
70 | + $result = $this->zip->addFile($source, $path); |
|
71 | + } else { |
|
72 | + $result = $this->zip->addFromString($path, $source); |
|
73 | 73 | } |
74 | - if($result) { |
|
75 | - $this->zip->close();//close and reopen to save the zip |
|
74 | + if ($result) { |
|
75 | + $this->zip->close(); //close and reopen to save the zip |
|
76 | 76 | $this->zip->open($this->path); |
77 | 77 | } |
78 | 78 | return $result; |
@@ -84,8 +84,8 @@ discard block |
||
84 | 84 | * @return boolean|null |
85 | 85 | */ |
86 | 86 | function rename($source, $dest) { |
87 | - $source=$this->stripPath($source); |
|
88 | - $dest=$this->stripPath($dest); |
|
87 | + $source = $this->stripPath($source); |
|
88 | + $dest = $this->stripPath($dest); |
|
89 | 89 | $this->zip->renameName($source, $dest); |
90 | 90 | } |
91 | 91 | /** |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @return int |
95 | 95 | */ |
96 | 96 | function filesize($path) { |
97 | - $stat=$this->zip->statName($path); |
|
97 | + $stat = $this->zip->statName($path); |
|
98 | 98 | return $stat['size']; |
99 | 99 | } |
100 | 100 | /** |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * @return array |
112 | 112 | */ |
113 | 113 | function getFolder($path) { |
114 | - $files=$this->getFiles(); |
|
115 | - $folderContent=array(); |
|
116 | - $pathLength=strlen($path); |
|
117 | - foreach($files as $file) { |
|
118 | - if(substr($file, 0, $pathLength)==$path and $file!=$path) { |
|
119 | - if(strrpos(substr($file, 0, -1), '/')<=$pathLength) { |
|
120 | - $folderContent[]=substr($file, $pathLength); |
|
114 | + $files = $this->getFiles(); |
|
115 | + $folderContent = array(); |
|
116 | + $pathLength = strlen($path); |
|
117 | + foreach ($files as $file) { |
|
118 | + if (substr($file, 0, $pathLength) == $path and $file != $path) { |
|
119 | + if (strrpos(substr($file, 0, -1), '/') <= $pathLength) { |
|
120 | + $folderContent[] = substr($file, $pathLength); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -128,10 +128,10 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | function getFiles() { |
131 | - $fileCount=$this->zip->numFiles; |
|
132 | - $files=array(); |
|
133 | - for($i=0;$i<$fileCount;$i++) { |
|
134 | - $files[]=$this->zip->getNameIndex($i); |
|
131 | + $fileCount = $this->zip->numFiles; |
|
132 | + $files = array(); |
|
133 | + for ($i = 0; $i < $fileCount; $i++) { |
|
134 | + $files[] = $this->zip->getNameIndex($i); |
|
135 | 135 | } |
136 | 136 | return $files; |
137 | 137 | } |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | * @return bool |
168 | 168 | */ |
169 | 169 | function fileExists($path) { |
170 | - return ($this->zip->locateName($path)!==false) or ($this->zip->locateName($path.'/')!==false); |
|
170 | + return ($this->zip->locateName($path) !== false) or ($this->zip->locateName($path.'/') !== false); |
|
171 | 171 | } |
172 | 172 | /** |
173 | 173 | * remove a file or folder from the archive |
@@ -175,9 +175,9 @@ discard block |
||
175 | 175 | * @return bool |
176 | 176 | */ |
177 | 177 | function remove($path) { |
178 | - if($this->fileExists($path.'/')) { |
|
178 | + if ($this->fileExists($path.'/')) { |
|
179 | 179 | return $this->zip->deleteName($path.'/'); |
180 | - }else{ |
|
180 | + } else { |
|
181 | 181 | return $this->zip->deleteName($path); |
182 | 182 | } |
183 | 183 | } |
@@ -188,23 +188,23 @@ discard block |
||
188 | 188 | * @return resource |
189 | 189 | */ |
190 | 190 | function getStream($path, $mode) { |
191 | - if($mode=='r' or $mode=='rb') { |
|
191 | + if ($mode == 'r' or $mode == 'rb') { |
|
192 | 192 | return $this->zip->getStream($path); |
193 | 193 | } else { |
194 | 194 | //since we can't directly get a writable stream, |
195 | 195 | //make a temp copy of the file and put it back |
196 | 196 | //in the archive when the stream is closed |
197 | - if(strrpos($path, '.')!==false) { |
|
198 | - $ext=substr($path, strrpos($path, '.')); |
|
199 | - }else{ |
|
200 | - $ext=''; |
|
197 | + if (strrpos($path, '.') !== false) { |
|
198 | + $ext = substr($path, strrpos($path, '.')); |
|
199 | + } else { |
|
200 | + $ext = ''; |
|
201 | 201 | } |
202 | - $tmpFile=\OCP\Files::tmpFile($ext); |
|
203 | - if($this->fileExists($path)) { |
|
202 | + $tmpFile = \OCP\Files::tmpFile($ext); |
|
203 | + if ($this->fileExists($path)) { |
|
204 | 204 | $this->extractFile($path, $tmpFile); |
205 | 205 | } |
206 | 206 | $handle = fopen($tmpFile, $mode); |
207 | - return CallbackWrapper::wrap($handle, null, null, function () use ($path, $tmpFile) { |
|
207 | + return CallbackWrapper::wrap($handle, null, null, function() use ($path, $tmpFile) { |
|
208 | 208 | $this->writeBack($tmpFile, $path); |
209 | 209 | }); |
210 | 210 | } |
@@ -223,9 +223,9 @@ discard block |
||
223 | 223 | * @return string |
224 | 224 | */ |
225 | 225 | private function stripPath($path) { |
226 | - if(!$path || $path[0]=='/') { |
|
226 | + if (!$path || $path[0] == '/') { |
|
227 | 227 | return substr($path, 1); |
228 | - }else{ |
|
228 | + } else { |
|
229 | 229 | return $path; |
230 | 230 | } |
231 | 231 | } |