@@ -158,7 +158,9 @@ |
||
| 158 | 158 | |
| 159 | 159 | $result = $this->put($path = trim($path), $stream, $visibility); |
| 160 | 160 | |
| 161 | - if (is_resource($stream)) fclose($stream); |
|
| 161 | + if (is_resource($stream)) { |
|
| 162 | + fclose($stream); |
|
| 163 | + } |
|
| 162 | 164 | |
| 163 | 165 | return $result ? (bool) $path : false; |
| 164 | 166 | } |
@@ -203,8 +203,7 @@ |
||
| 203 | 203 | $file = DbFile::findOne($dirname); |
| 204 | 204 | if ($file === null) { |
| 205 | 205 | $file = new DbFile(['path' => $dirname]); |
| 206 | - } |
|
| 207 | - else if ($file->type == DbFile::TYPE_FILE) { |
|
| 206 | + } else if ($file->type == DbFile::TYPE_FILE) { |
|
| 208 | 207 | throw new FileExistsException('Can not create a directory as a file already exists.'); |
| 209 | 208 | } |
| 210 | 209 | if ($visibility = $config->get('visibility')) { |
@@ -46,8 +46,9 @@ discard block |
||
| 46 | 46 | }, $paths); |
| 47 | 47 | |
| 48 | 48 | if (empty($created)) { |
| 49 | - if ($directory == '') |
|
| 50 | - throw new DirectoryExistsException("The root directory already exists"); |
|
| 49 | + if ($directory == '') { |
|
| 50 | + throw new DirectoryExistsException("The root directory already exists"); |
|
| 51 | + } |
|
| 51 | 52 | throw new DirectoryExistsException("The directory '$directory' already exists"); |
| 52 | 53 | } |
| 53 | 54 | return $created; |
@@ -76,7 +77,9 @@ discard block |
||
| 76 | 77 | $parts = []; |
| 77 | 78 | foreach($bits as $i => $bit) { |
| 78 | 79 | $bitsCurrent[] = $bit; |
| 79 | - if ($i == 0) continue; |
|
| 80 | + if ($i == 0) { |
|
| 81 | + continue; |
|
| 82 | + } |
|
| 80 | 83 | $parts[] = implode('/', $bitsCurrent); |
| 81 | 84 | } |
| 82 | 85 | return $parts; |
@@ -90,11 +93,13 @@ discard block |
||
| 90 | 93 | public function validateAbsoluteDirectoryPath($directory) |
| 91 | 94 | { |
| 92 | 95 | // must be absolute and start with / |
| 93 | - if ($directory[0] !== '/') |
|
| 94 | - throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute path and start with '/'."); |
|
| 96 | + if ($directory[0] !== '/') { |
|
| 97 | + throw new InvalidDirectoryException("Invalid directory parameter '$directory'. The directory must be absolute path and start with '/'."); |
|
| 98 | + } |
|
| 95 | 99 | // prevent folders with no names being created |
| 96 | - if (strpos($directory, '//') !== false) |
|
| 97 | - throw new InvalidDirectoryException("Invalid directory parameter '$directory'. You can not have empty path sections containing '//' each directory needs a name."); |
|
| 100 | + if (strpos($directory, '//') !== false) { |
|
| 101 | + throw new InvalidDirectoryException("Invalid directory parameter '$directory'. You can not have empty path sections containing '//' each directory needs a name."); |
|
| 102 | + } |
|
| 98 | 103 | } |
| 99 | 104 | |
| 100 | 105 | /** |
@@ -170,10 +175,11 @@ discard block |
||
| 170 | 175 | throw new BadRequestHttpException('A name cannot contain a "/" character'); |
| 171 | 176 | } |
| 172 | 177 | |
| 173 | - if ($node->isDir()) |
|
| 174 | - $this->_updateDirectoryName($node, $name); |
|
| 175 | - else |
|
| 176 | - $this->_updateFileName($node, $name); |
|
| 178 | + if ($node->isDir()) { |
|
| 179 | + $this->_updateDirectoryName($node, $name); |
|
| 180 | + } else { |
|
| 181 | + $this->_updateFileName($node, $name); |
|
| 182 | + } |
|
| 177 | 183 | return true; |
| 178 | 184 | } |
| 179 | 185 | |
@@ -249,8 +255,9 @@ discard block |
||
| 249 | 255 | public function getDirectoryMeta($path) |
| 250 | 256 | { |
| 251 | 257 | $dir = Media::findDirectoryByPath($path); |
| 252 | - if ($dir === null) |
|
| 253 | - return null; |
|
| 258 | + if ($dir === null) { |
|
| 259 | + return null; |
|
| 260 | + } |
|
| 254 | 261 | return $dir->toArray(); |
| 255 | 262 | } |
| 256 | 263 | |
@@ -260,8 +267,9 @@ discard block |
||
| 260 | 267 | public function delete($id) |
| 261 | 268 | { |
| 262 | 269 | $item = Media::findOne($id); |
| 263 | - if ($item === null) |
|
| 264 | - throw new NotFoundHttpException("No item with id '$id' could be found'"); |
|
| 270 | + if ($item === null) { |
|
| 271 | + throw new NotFoundHttpException("No item with id '$id' could be found'"); |
|
| 272 | + } |
|
| 265 | 273 | $result = $item->delete(); |
| 266 | 274 | if ($result === false) { |
| 267 | 275 | return $item->getErrors(); |
@@ -275,8 +283,9 @@ discard block |
||
| 275 | 283 | public function destroy($id) |
| 276 | 284 | { |
| 277 | 285 | $item = Media::findWithDeleted()->where(['id' => $id])->one(); |
| 278 | - if ($item === null) |
|
| 279 | - throw new NotFoundHttpException("No item with id '$id' could be found'"); |
|
| 286 | + if ($item === null) { |
|
| 287 | + throw new NotFoundHttpException("No item with id '$id' could be found'"); |
|
| 288 | + } |
|
| 280 | 289 | return $item->destroy(); |
| 281 | 290 | } |
| 282 | 291 | |
@@ -288,11 +297,13 @@ discard block |
||
| 288 | 297 | // get the "into" folder |
| 289 | 298 | $into = Media::findOne($intoId); |
| 290 | 299 | // throw error if it doesn't exist |
| 291 | - if ($into === null) |
|
| 292 | - throw new NotFoundHttpException("No item with id '$intoId' could be found'"); |
|
| 300 | + if ($into === null) { |
|
| 301 | + throw new NotFoundHttpException("No item with id '$intoId' could be found'"); |
|
| 302 | + } |
|
| 293 | 303 | // throw error if its not a directory |
| 294 | - if (!$into->isDir()) |
|
| 295 | - throw new BadRequestHttpException("This is not a directory - you can only move items into directories"); |
|
| 304 | + if (!$into->isDir()) { |
|
| 305 | + throw new BadRequestHttpException("This is not a directory - you can only move items into directories"); |
|
| 306 | + } |
|
| 296 | 307 | |
| 297 | 308 | // find all items to move |
| 298 | 309 | $items = Media::findAll(['id' => $items]); |
@@ -66,7 +66,9 @@ discard block |
||
| 66 | 66 | neon()->firefly->isFileObjectValid($file); |
| 67 | 67 | $stream = fopen($file->getRealPath(), 'r+'); |
| 68 | 68 | $uuid = $this->save($stream, $file->getFilename(), $meta); |
| 69 | - if (is_resource($stream)) fclose($stream); |
|
| 69 | + if (is_resource($stream)) { |
|
| 70 | + fclose($stream); |
|
| 71 | + } |
|
| 70 | 72 | return $uuid; |
| 71 | 73 | } |
| 72 | 74 | |
@@ -336,8 +338,9 @@ discard block |
||
| 336 | 338 | public function findFile($drive, $path) |
| 337 | 339 | { |
| 338 | 340 | $model = Model::find()->where(['drive' => $drive, 'path' => $path])->one(); |
| 339 | - if ($model === null) |
|
| 340 | - return null; |
|
| 341 | + if ($model === null) { |
|
| 342 | + return null; |
|
| 343 | + } |
|
| 341 | 344 | return $model->toArray(); |
| 342 | 345 | } |
| 343 | 346 | |
@@ -82,8 +82,9 @@ |
||
| 82 | 82 | // check this is an image before continuing - type image and not svg |
| 83 | 83 | // Handle SVG images correctly (we do not need to process vector images) |
| 84 | 84 | $meta = $firefly->fileManager->getMeta($id); |
| 85 | - if (strpos($meta['mime_type'], 'image') === false || strpos($meta['mime_type'], 'svg') !== false) |
|
| 86 | - return $this->actionGet(); |
|
| 85 | + if (strpos($meta['mime_type'], 'image') === false || strpos($meta['mime_type'], 'svg') !== false) { |
|
| 86 | + return $this->actionGet(); |
|
| 87 | + } |
|
| 87 | 88 | |
| 88 | 89 | // see if we already have this in cache and the browser already has it too |
| 89 | 90 | // We want to remove the need to process images when ever possible |
@@ -203,16 +203,19 @@ |
||
| 203 | 203 | { |
| 204 | 204 | $items = neon()->request->getBodyParam('items'); |
| 205 | 205 | $into = neon()->request->getBodyParam('into'); |
| 206 | - if ($items === null) |
|
| 207 | - throw new BadRequestHttpException('You must specify an "items" parameter - containing an array of item ids to move'); |
|
| 208 | - if ($into === null) |
|
| 209 | - throw new BadRequestHttpException('You must specify an "into" parameter - specifying the directory to move the items into'); |
|
| 206 | + if ($items === null) { |
|
| 207 | + throw new BadRequestHttpException('You must specify an "items" parameter - containing an array of item ids to move'); |
|
| 208 | + } |
|
| 209 | + if ($into === null) { |
|
| 210 | + throw new BadRequestHttpException('You must specify an "into" parameter - specifying the directory to move the items into'); |
|
| 211 | + } |
|
| 210 | 212 | if (strpos($into, '/') !== false) { |
| 211 | 213 | // into has been specified as a path |
| 212 | 214 | // should this be part of the move interface? |
| 213 | 215 | $dir = neon()->firefly->mediaManager->getDirectoryMeta($into); |
| 214 | - if ($dir === null) |
|
| 215 | - throw new BadRequestHttpException("No directory exists with the specified path of '$into' "); |
|
| 216 | + if ($dir === null) { |
|
| 217 | + throw new BadRequestHttpException("No directory exists with the specified path of '$into' "); |
|
| 218 | + } |
|
| 216 | 219 | $into = $dir['id']; |
| 217 | 220 | } |
| 218 | 221 | |
@@ -33,22 +33,26 @@ discard block |
||
| 33 | 33 | private function convertFireflyGetsToFiles($search, $replace) |
| 34 | 34 | { |
| 35 | 35 | $potentiallyAffected = $this->db->createCommand("SELECT `class_type`, `member_ref` FROM `dds_member` WHERE `data_type_ref`='textlong'")->queryAll(); |
| 36 | - if (count($potentiallyAffected)==0) |
|
| 37 | - return; |
|
| 36 | + if (count($potentiallyAffected)==0) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 38 | 39 | $classes = []; |
| 39 | - foreach ($potentiallyAffected as $pa) |
|
| 40 | - $classes[$pa['class_type']][] = $pa['member_ref']; |
|
| 40 | + foreach ($potentiallyAffected as $pa) { |
|
| 41 | + $classes[$pa['class_type']][] = $pa['member_ref']; |
|
| 42 | + } |
|
| 41 | 43 | $phoebeClasses = array_keys($classes); |
| 42 | 44 | $phoebe = neon('phoebe')->getIPhoebeType('daedalus'); |
| 43 | 45 | |
| 44 | 46 | $phoebeDefinition = []; |
| 45 | - foreach ($phoebeClasses as $pc) |
|
| 46 | - $phoebeDefinition[$pc] = $phoebe->getClass($pc, null, false); |
|
| 47 | + foreach ($phoebeClasses as $pc) { |
|
| 48 | + $phoebeDefinition[$pc] = $phoebe->getClass($pc, null, false); |
|
| 49 | + } |
|
| 47 | 50 | |
| 48 | 51 | $potentiallyAffectedLookup = []; |
| 49 | 52 | foreach ($potentiallyAffected as $pa) { |
| 50 | - if (empty($potentiallyAffectedLookup[$pa['class_type']])) |
|
| 51 | - $potentiallyAffectedLookup[$pa['class_type']] = []; |
|
| 53 | + if (empty($potentiallyAffectedLookup[$pa['class_type']])) { |
|
| 54 | + $potentiallyAffectedLookup[$pa['class_type']] = []; |
|
| 55 | + } |
|
| 52 | 56 | $potentiallyAffectedLookup[$pa['class_type']][] = $pa['member_ref']; |
| 53 | 57 | } |
| 54 | 58 | |
@@ -77,8 +81,9 @@ discard block |
||
| 77 | 81 | foreach ($found as $objectData) { |
| 78 | 82 | $changes = []; |
| 79 | 83 | foreach ($fields as $field) { |
| 80 | - if (!empty($objectData[$field]) && strpos($objectData[$field],$search)!==false) |
|
| 81 | - $changes[$field] = str_replace($search, $replace, $objectData[$field]); |
|
| 84 | + if (!empty($objectData[$field]) && strpos($objectData[$field],$search)!==false) { |
|
| 85 | + $changes[$field] = str_replace($search, $replace, $objectData[$field]); |
|
| 86 | + } |
|
| 82 | 87 | } |
| 83 | 88 | if (count($changes)) { |
| 84 | 89 | $dds->editObject($objectData['_uuid'], $changes); |
@@ -366,8 +366,9 @@ |
||
| 366 | 366 | */ |
| 367 | 367 | public function isFileObjectValid($file, $throwExceptions=true) |
| 368 | 368 | { |
| 369 | - if ($file instanceof IFile) |
|
| 370 | - return true; |
|
| 369 | + if ($file instanceof IFile) { |
|
| 370 | + return true; |
|
| 371 | + } |
|
| 371 | 372 | // not all objects have the privilege of implementing the IFile interface like \SplFileObject |
| 372 | 373 | // Firefly only cares about these two functions 'getRealPath' and 'getFilename' |
| 373 | 374 | $objectIsValid = is_object($file) |
@@ -34,12 +34,14 @@ discard block |
||
| 34 | 34 | // set up the theme directories |
| 35 | 35 | foreach ($themeHierarchy as $theme) { |
| 36 | 36 | if (isset($theme['templates'])) { |
| 37 | - foreach ($theme['templates'] as $tplDir) |
|
| 38 | - $this->addTemplateDir($tplDir); |
|
| 37 | + foreach ($theme['templates'] as $tplDir) { |
|
| 38 | + $this->addTemplateDir($tplDir); |
|
| 39 | + } |
|
| 39 | 40 | } |
| 40 | 41 | if (isset($theme['plugins'])) { |
| 41 | - foreach ($theme['plugins'] as $pluginDir) |
|
| 42 | - $this->addPluginsDir($pluginDir); |
|
| 42 | + foreach ($theme['plugins'] as $pluginDir) { |
|
| 43 | + $this->addPluginsDir($pluginDir); |
|
| 44 | + } |
|
| 43 | 45 | } |
| 44 | 46 | } |
| 45 | 47 | |
@@ -153,8 +155,9 @@ discard block |
||
| 153 | 155 | $this->assign('site', $this->_page->getSiteData()); |
| 154 | 156 | |
| 155 | 157 | // an expensive-ish call so reduce need for it in repeated renders |
| 156 | - if (!isset($templates[$template])) |
|
| 157 | - $templates[$template] = $this->createTemplate($template); |
|
| 158 | + if (!isset($templates[$template])) { |
|
| 159 | + $templates[$template] = $this->createTemplate($template); |
|
| 160 | + } |
|
| 158 | 161 | $tpl = $templates[$template]; |
| 159 | 162 | |
| 160 | 163 | // reset any parameters for the new render |
@@ -233,7 +236,9 @@ discard block |
||
| 233 | 236 | public function page_url($params, $smarty=null) |
| 234 | 237 | { |
| 235 | 238 | $id = Arr::get($params, 'id', Arr::get($params, 'nice', false)); |
| 236 | - if ($id === '#') return '#'; |
|
| 239 | + if ($id === '#') { |
|
| 240 | + return '#'; |
|
| 241 | + } |
|
| 237 | 242 | if ($id) { |
| 238 | 243 | $url = $this->getPage()->getUrlOfPageByNiceId($id); |
| 239 | 244 | } else if (!$id && $this->getPage()->hasPage()) { |
@@ -241,11 +246,13 @@ discard block |
||
| 241 | 246 | } else { |
| 242 | 247 | throw new \InvalidArgumentException('There is no current page - and no id or nice parameter was specified'); |
| 243 | 248 | } |
| 244 | - if (!empty($params['prefix'])) |
|
| 245 | - $url = $params['prefix'].$url; |
|
| 249 | + if (!empty($params['prefix'])) { |
|
| 250 | + $url = $params['prefix'].$url; |
|
| 251 | + } |
|
| 246 | 252 | |
| 247 | - if (isset($params['full'])) |
|
| 248 | - return url_base()."$url"; |
|
| 253 | + if (isset($params['full'])) { |
|
| 254 | + return url_base()."$url"; |
|
| 255 | + } |
|
| 249 | 256 | return $url; |
| 250 | 257 | } |
| 251 | 258 | |
@@ -265,7 +272,9 @@ discard block |
||
| 265 | 272 | { |
| 266 | 273 | $pages = Arr::getRequired($params, 'id'); |
| 267 | 274 | $allPages = is_array($pages) ? $pages : [$pages]; |
| 268 | - $urls = []; foreach ($allPages as $page) $urls[] = $this->page_url(['id' => $page]); |
|
| 275 | + $urls = []; foreach ($allPages as $page) { |
|
| 276 | + $urls[] = $this->page_url(['id' => $page]); |
|
| 277 | + } |
|
| 269 | 278 | return Url::isUrl($urls); |
| 270 | 279 | } |
| 271 | 280 | |