@@ -16,7 +16,7 @@ |
||
| 16 | 16 | $app = new App('notes'); |
| 17 | 17 | $container = $app->getContainer(); |
| 18 | 18 | |
| 19 | -$container->query('OCP\INavigationManager')->add(function () use ($container) { |
|
| 19 | +$container->query('OCP\INavigationManager')->add(function() use ($container) { |
|
| 20 | 20 | $urlGenerator = $container->query('OCP\IURLGenerator'); |
| 21 | 21 | $l10n = $container->query('OCP\IL10N'); |
| 22 | 22 | return [ |
@@ -54,7 +54,7 @@ |
||
| 54 | 54 | } |
| 55 | 55 | } |
| 56 | 56 | } else { |
| 57 | - $settings = (object)$this->defaults; |
|
| 57 | + $settings = (object) $this->defaults; |
|
| 58 | 58 | } |
| 59 | 59 | return $settings; |
| 60 | 60 | } |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | public function update($id, $content, $userId, $category = null, $mtime = 0) : Note { |
| 165 | 165 | $notesFolder = $this->getFolderForUser($userId); |
| 166 | 166 | $file = $this->getFileById($notesFolder, $id); |
| 167 | - $title = $this->noteUtil->getSafeTitleFromContent($content===null ? $file->getContent() : $content); |
|
| 167 | + $title = $this->noteUtil->getSafeTitleFromContent($content === null ? $file->getContent() : $content); |
|
| 168 | 168 | |
| 169 | 169 | // rename/move file with respect to title/category |
| 170 | 170 | // this can fail if access rights are not sufficient or category name is illegal |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | private function getFolderForUser($userId) : Folder { |
| 251 | 251 | // TODO use IRootFolder->getUserFolder() ? |
| 252 | - $path = '/' . $userId . '/files/' . $this->settings->get($userId, 'notesPath'); |
|
| 252 | + $path = '/'.$userId.'/files/'.$this->settings->get($userId, 'notesPath'); |
|
| 253 | 253 | try { |
| 254 | 254 | $folder = $this->noteUtil->getOrCreateFolder($path); |
| 255 | 255 | } catch (\Exception $e) { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | if (!array_key_exists($id, $metas)) { |
| 35 | 35 | // INSERT new notes |
| 36 | 36 | $metas[$note->getId()] = $this->create($userId, $note); |
| 37 | - } elseif ($note->getEtag()!==$metas[$id]->getEtag()) { |
|
| 37 | + } elseif ($note->getEtag() !== $metas[$id]->getEtag()) { |
|
| 38 | 38 | // UPDATE changed notes |
| 39 | 39 | $meta = $metas[$id]; |
| 40 | 40 | $this->updateIfNeeded($meta, $note); |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | private function updateIfNeeded(&$meta, $note) { |
| 63 | - if ($note->getEtag()!==$meta->getEtag()) { |
|
| 63 | + if ($note->getEtag() !== $meta->getEtag()) { |
|
| 64 | 64 | $meta->setEtag($note->getEtag()); |
| 65 | 65 | $meta->setLastUpdate(time()); |
| 66 | 66 | $this->metaMapper->update($meta); |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | $response = new TemplateResponse( |
| 35 | 35 | $this->appName, |
| 36 | 36 | $devMode ? 'dev-mode' : 'main', |
| 37 | - [ ] |
|
| 37 | + [] |
|
| 38 | 38 | ); |
| 39 | 39 | |
| 40 | 40 | $csp = new ContentSecurityPolicy(); |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | $metas = $this->metaService->updateAll($this->getUID(), $notes); |
| 87 | 87 | foreach ($notes as $note) { |
| 88 | 88 | $lastUpdate = $metas[$note->getId()]->getLastUpdate(); |
| 89 | - if ($pruneBefore && $lastUpdate<$pruneBefore) { |
|
| 89 | + if ($pruneBefore && $lastUpdate < $pruneBefore) { |
|
| 90 | 90 | $vars = get_object_vars($note); |
| 91 | 91 | unset($vars['id']); |
| 92 | 92 | $this->excludeFields($note, array_keys($vars)); |
@@ -185,10 +185,10 @@ discard block |
||
| 185 | 185 | * @return Note |
| 186 | 186 | */ |
| 187 | 187 | private function updateData($id, $content, $category, $modified, $favorite) { |
| 188 | - if ($favorite!==null) { |
|
| 188 | + if ($favorite !== null) { |
|
| 189 | 189 | $this->service->favorite($id, $favorite, $this->getUID()); |
| 190 | 190 | } |
| 191 | - if ($content===null) { |
|
| 191 | + if ($content === null) { |
|
| 192 | 192 | return $this->service->get($id, $this->getUID()); |
| 193 | 193 | } else { |
| 194 | 194 | return $this->service->update($id, $content, $this->getUID(), $category, $modified); |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | public $content = null; |
| 37 | 37 | public $favorite = false; |
| 38 | 38 | public $error = false; |
| 39 | - public $errorMessage=''; |
|
| 39 | + public $errorMessage = ''; |
|
| 40 | 40 | |
| 41 | 41 | private const TAG_FAVORITE = \OC\Tags::TAG_FAVORITE; // @phan-suppress-current-line PhanUndeclaredClassConstant |
| 42 | 42 | |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | $note = new static(); |
| 54 | 54 | $note->initCommonBaseFields($file, $notesFolder, $tags); |
| 55 | 55 | if (!$onlyMeta) { |
| 56 | - $fileContent=$file->getContent(); |
|
| 56 | + $fileContent = $file->getContent(); |
|
| 57 | 57 | $note->setContent(self::convertEncoding($fileContent)); |
| 58 | 58 | } |
| 59 | 59 | if (!$onlyMeta) { |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->setId($file->getId()); |
| 89 | 89 | $this->setTitle(pathinfo($file->getName(), PATHINFO_FILENAME)); // remove extension |
| 90 | 90 | $this->setModified($file->getMTime()); |
| 91 | - $subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath())+1); |
|
| 91 | + $subdir = substr(dirname($file->getPath()), strlen($notesFolder->getPath()) + 1); |
|
| 92 | 92 | $this->setCategory($subdir ? $subdir : ''); |
| 93 | 93 | if (is_array($tags) && in_array(self::TAG_FAVORITE, $tags)) { |
| 94 | 94 | $this->setFavorite(true); |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | // collect all relevant attributes |
| 101 | 101 | $data = ''; |
| 102 | 102 | foreach (get_object_vars($this) as $key => $val) { |
| 103 | - if ($key!=='etag') { |
|
| 103 | + if ($key !== 'etag') { |
|
| 104 | 104 | $data .= $val; |
| 105 | 105 | } |
| 106 | 106 | } |
@@ -71,10 +71,10 @@ discard block |
||
| 71 | 71 | $id = $file->getId(); |
| 72 | 72 | $currentFilePath = $this->root->getFullPath($file->getPath()); |
| 73 | 73 | $currentBasePath = pathinfo($currentFilePath, PATHINFO_DIRNAME); |
| 74 | - $fileSuffix = '.' . pathinfo($file->getName(), PATHINFO_EXTENSION); |
|
| 74 | + $fileSuffix = '.'.pathinfo($file->getName(), PATHINFO_EXTENSION); |
|
| 75 | 75 | |
| 76 | 76 | // detect (new) folder path based on category name |
| 77 | - if ($category===null) { |
|
| 77 | + if ($category === null) { |
|
| 78 | 78 | $basePath = $currentBasePath; |
| 79 | 79 | } else { |
| 80 | 80 | $basePath = $notesFolder->getPath(); |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | // sanitise path |
| 83 | 83 | $cats = explode('/', $category); |
| 84 | 84 | $cats = array_map([$this, 'sanitisePath'], $cats); |
| 85 | - $cats = array_filter($cats, function ($str) { |
|
| 85 | + $cats = array_filter($cats, function($str) { |
|
| 86 | 86 | return !empty($str); |
| 87 | 87 | }); |
| 88 | 88 | $basePath .= '/'.implode('/', $cats); |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | $folder = $this->getOrCreateFolder($basePath); |
| 92 | 92 | |
| 93 | 93 | // assemble new file path |
| 94 | - $newFilePath = $basePath . '/' . $this->generateFileName($folder, $title, $fileSuffix, $id); |
|
| 94 | + $newFilePath = $basePath.'/'.$this->generateFileName($folder, $title, $fileSuffix, $id); |
|
| 95 | 95 | |
| 96 | 96 | // if the current path is not the new path, the file has to be renamed |
| 97 | 97 | if ($currentFilePath !== $newFilePath) { |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * files with the same title |
| 120 | 120 | */ |
| 121 | 121 | public function generateFileName(Folder $folder, string $title, string $suffix, int $id) : string { |
| 122 | - $path = $title . $suffix; |
|
| 122 | + $path = $title.$suffix; |
|
| 123 | 123 | |
| 124 | 124 | // if file does not exist, that name has not been taken. Similar we don't |
| 125 | 125 | // need to handle file collisions if it is the filename did not change |
@@ -132,11 +132,11 @@ discard block |
||
| 132 | 132 | $newId = ((int) $matches['id']) + 1; |
| 133 | 133 | $newTitle = preg_replace( |
| 134 | 134 | '/(.*)\s\((\d+)\)$/u', |
| 135 | - '$1 (' . $newId . ')', |
|
| 135 | + '$1 ('.$newId.')', |
|
| 136 | 136 | $title |
| 137 | 137 | ); |
| 138 | 138 | } else { |
| 139 | - $newTitle = $title . ' (2)'; |
|
| 139 | + $newTitle = $title.' (2)'; |
|
| 140 | 140 | } |
| 141 | 141 | return $this->generateFileName($folder, $newTitle, $suffix, $id); |
| 142 | 142 | } |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | public function deleteEmptyFolder(Folder $notesFolder, Folder $folder) : void { |
| 215 | 215 | $content = $folder->getDirectoryListing(); |
| 216 | 216 | $isEmpty = !count($content); |
| 217 | - $isNotesFolder = $folder->getPath()===$notesFolder->getPath(); |
|
| 217 | + $isNotesFolder = $folder->getPath() === $notesFolder->getPath(); |
|
| 218 | 218 | if ($isEmpty && !$isNotesFolder) { |
| 219 | 219 | $this->logger->info('Deleting empty category folder '.$folder->getPath(), ['app' => $this->appName]); |
| 220 | 220 | $parent = $folder->getParent(); |