@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function getDocuments($state = 'published') |
22 | 22 | { |
23 | 23 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
24 | - throw new \Exception('Unsupported document state: ' . $state); |
|
24 | + throw new \Exception('Unsupported document state: '.$state); |
|
25 | 25 | } |
26 | 26 | return $this->repository->getDocuments($state); |
27 | 27 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | public function getDocumentBySlug($slug, $state = 'published') |
51 | 51 | { |
52 | 52 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
53 | - throw new \Exception('Unsupported document state: ' . $state); |
|
53 | + throw new \Exception('Unsupported document state: '.$state); |
|
54 | 54 | } |
55 | - $path = '/' . $slug; |
|
55 | + $path = '/'.$slug; |
|
56 | 56 | |
57 | 57 | return $this->repository->getDocumentByPath($path, $state); |
58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | public function saveDocument($postValues, $state = 'unpublished') |
67 | 67 | { |
68 | 68 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
69 | - throw new \Exception('Unsupported document state: ' . $state); |
|
69 | + throw new \Exception('Unsupported document state: '.$state); |
|
70 | 70 | } |
71 | - $oldPath = '/' . $postValues['path']; |
|
71 | + $oldPath = '/'.$postValues['path']; |
|
72 | 72 | |
73 | 73 | $container = $this->getDocumentContainerByPath($oldPath); |
74 | 74 | $documentObject = DocumentFactory::createDocumentFromPostValues($postValues, new DocumentTypesStorage($this->repository)); |
75 | 75 | if ($container->path === '/') { |
76 | - $newPath = $container->path . $documentObject->slug; |
|
76 | + $newPath = $container->path.$documentObject->slug; |
|
77 | 77 | } else { |
78 | - $newPath = $container->path . '/' . $documentObject->slug; |
|
78 | + $newPath = $container->path.'/'.$documentObject->slug; |
|
79 | 79 | } |
80 | 80 | $documentObject->path = $newPath; |
81 | 81 | $this->repository->saveDocument($documentObject, $state); |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | { |
90 | 90 | $documentObject = DocumentFactory::createDocumentFromPostValues($postValues, new DocumentTypesStorage($this->repository)); |
91 | 91 | if ($postValues['path'] === '/') { |
92 | - $documentObject->path = $postValues['path'] . $documentObject->slug; |
|
92 | + $documentObject->path = $postValues['path'].$documentObject->slug; |
|
93 | 93 | } else { |
94 | - $documentObject->path = $postValues['path'] . '/' . $documentObject->slug; |
|
94 | + $documentObject->path = $postValues['path'].'/'.$documentObject->slug; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $this->repository->saveDocument($documentObject, $state); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function deleteDocumentBySlug($slug) |
104 | 104 | { |
105 | - $path = '/' . $slug; |
|
105 | + $path = '/'.$slug; |
|
106 | 106 | $this->repository->deleteDocumentByPath($path); |
107 | 107 | } |
108 | 108 |
@@ -45,10 +45,10 @@ discard block |
||
45 | 45 | $destinationPath = $this->getDestinationPath(); |
46 | 46 | |
47 | 47 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
48 | - $destination = $destinationPath . DIRECTORY_SEPARATOR . $filename; |
|
48 | + $destination = $destinationPath.DIRECTORY_SEPARATOR.$filename; |
|
49 | 49 | |
50 | 50 | if ($postValues['error'] != '0') { |
51 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
51 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | foreach ($images as $key => $image) { |
81 | 81 | if ($image->file == $filename) { |
82 | 82 | foreach ($image->set as $imageSetFilename) { |
83 | - $destination = $destinationPath . '/' . $imageSetFilename; |
|
83 | + $destination = $destinationPath.'/'.$imageSetFilename; |
|
84 | 84 | if (file_exists($destination)) { |
85 | 85 | unlink($destination); |
86 | 86 | } else { |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | */ |
129 | 129 | private function getDestinationPath() |
130 | 130 | { |
131 | - $destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR); |
|
131 | + $destinationPath = realpath($this->imagesDir.DIRECTORY_SEPARATOR); |
|
132 | 132 | return $destinationPath; |
133 | 133 | } |
134 | 134 | } |
135 | 135 | \ No newline at end of file |
@@ -38,19 +38,19 @@ |
||
38 | 38 | array_pop($fileParts); |
39 | 39 | $fileNameWithoutExtension = implode('-', $fileParts); |
40 | 40 | $fileNameWithoutExtension = StringUtil::slugify($fileNameWithoutExtension); |
41 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
41 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
42 | 42 | } else { |
43 | 43 | $filename = StringUtil::slugify($filename); |
44 | 44 | } |
45 | 45 | |
46 | - if (file_exists($path . '/' . $filename)) { |
|
46 | + if (file_exists($path.'/'.$filename)) { |
|
47 | 47 | $fileParts = explode('.', $filename); |
48 | 48 | if (count($fileParts) > 1) { |
49 | 49 | $extension = end($fileParts); |
50 | 50 | array_pop($fileParts); |
51 | 51 | $fileNameWithoutExtension = implode('-', $fileParts); |
52 | 52 | $fileNameWithoutExtension .= '-copy'; |
53 | - $filename = $fileNameWithoutExtension . '.' . $extension; |
|
53 | + $filename = $fileNameWithoutExtension.'.'.$extension; |
|
54 | 54 | } else { |
55 | 55 | $filename .= '-copy'; |
56 | 56 | } |
@@ -37,10 +37,10 @@ discard block |
||
37 | 37 | $destinationPath = $this->getDestinationPath(); |
38 | 38 | |
39 | 39 | $filename = $this->validateFilename($postValues['name'], $destinationPath); |
40 | - $destination = $destinationPath . '/' . $filename; |
|
40 | + $destination = $destinationPath.'/'.$filename; |
|
41 | 41 | |
42 | 42 | if ($postValues['error'] != '0') { |
43 | - throw new \Exception('Error uploading file. Error code: ' . $postValues['error']); |
|
43 | + throw new \Exception('Error uploading file. Error code: '.$postValues['error']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | if (move_uploaded_file($postValues['tmp_name'], $destination)) { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | public function deleteFileByName($filename) |
84 | 84 | { |
85 | 85 | $destinationPath = $this->getDestinationPath(); |
86 | - $destination = $destinationPath . '/' . $filename; |
|
86 | + $destination = $destinationPath.'/'.$filename; |
|
87 | 87 | |
88 | 88 | if (file_exists($destination)) { |
89 | 89 | $files = $this->getFiles(); |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | |
114 | 114 | protected function getDestinationPath() |
115 | 115 | { |
116 | - $destinationPath = realpath($this->filesDir . DIRECTORY_SEPARATOR); |
|
116 | + $destinationPath = realpath($this->filesDir.DIRECTORY_SEPARATOR); |
|
117 | 117 | return $destinationPath; |
118 | 118 | } |
119 | 119 | } |
120 | 120 | \ No newline at end of file |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | $whitelistIps = explode(',', $this->parameters[self::PARAMETER_WHITELIST_IPS]); |
171 | 171 | $whitelistIps = array_map("trim", $whitelistIps); |
172 | 172 | if (!in_array($remoteAddress, $whitelistIps)) { |
173 | - throw new \Exception('Ip address ' . $remoteAddress . ' is not on whitelist'); |
|
173 | + throw new \Exception('Ip address '.$remoteAddress.' is not on whitelist'); |
|
174 | 174 | } |
175 | 175 | } |
176 | 176 | } |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | $blacklistIps = explode(',', $this->parameters[self::PARAMETER_BLACKLIST_IPS]); |
187 | 187 | $blacklistIps = array_map("trim", $blacklistIps); |
188 | 188 | if (in_array($remoteAddress, $blacklistIps)) { |
189 | - throw new \Exception('Ip address ' . $remoteAddress . ' is on blacklist'); |
|
189 | + throw new \Exception('Ip address '.$remoteAddress.' is on blacklist'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | } |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | if ($relativeCmsUri == '/log-off') { |
231 | 231 | $_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL] = null; |
232 | 232 | unset($_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL]); |
233 | - header('Location: ' . $request::$subfolders . $this->parameters[self::PARAMETER_CMS_PREFIX]); |
|
233 | + header('Location: '.$request::$subfolders.$this->parameters[self::PARAMETER_CMS_PREFIX]); |
|
234 | 234 | exit; |
235 | 235 | } |
236 | 236 | } |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | |
372 | 372 | protected function getTemplateDir($template, $application = null) |
373 | 373 | { |
374 | - return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . '.php'; |
|
374 | + return __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$template.'.php'; |
|
375 | 375 | } |
376 | 376 | } |
377 | 377 | } |
378 | 378 | \ No newline at end of file |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | { |
41 | 41 | $file = $cmsComponent->storage->getFiles()->getFileByName($slug); |
42 | 42 | $path = realpath($cmsComponent->storage->getFiles()->getFilesDir()); |
43 | - $quoted = sprintf('"%s"', addcslashes(basename($path . '/' . $file->file), '"\\')); |
|
44 | - $size = filesize($path . '/' . $file->file); |
|
43 | + $quoted = sprintf('"%s"', addcslashes(basename($path.'/'.$file->file), '"\\')); |
|
44 | + $size = filesize($path.'/'.$file->file); |
|
45 | 45 | |
46 | 46 | header('Content-Description: File Transfer'); |
47 | - header('Content-Type: ' . $file->type); |
|
48 | - header('Content-Disposition: attachment; filename=' . $quoted); |
|
47 | + header('Content-Type: '.$file->type); |
|
48 | + header('Content-Disposition: attachment; filename='.$quoted); |
|
49 | 49 | header('Content-Transfer-Encoding: binary'); |
50 | 50 | header('Connection: Keep-Alive'); |
51 | 51 | header('Expires: 0'); |
52 | 52 | header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); |
53 | 53 | header('Pragma: public'); |
54 | - header('Content-Length: ' . $size); |
|
54 | + header('Content-Length: '.$size); |
|
55 | 55 | |
56 | - readfile($path . '/' . $file->file); |
|
56 | + readfile($path.'/'.$file->file); |
|
57 | 57 | exit; |
58 | 58 | } |
59 | 59 | |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES); |
78 | 78 | if (isset($_FILES[CmsComponent::FILES_PARAMETER_FILE])) { |
79 | 79 | $cmsComponent->storage->getFiles()->addFile($_FILES[CmsComponent::FILES_PARAMETER_FILE]); |
80 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files'); |
|
80 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/files'); |
|
81 | 81 | exit; |
82 | 82 | } |
83 | 83 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | private function deleteRoute($request, $cmsComponent) |
90 | 90 | { |
91 | 91 | $cmsComponent->storage->getFiles()->deleteFileByName($request::$get[CmsComponent::FILES_PARAMETER_FILE]); |
92 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files'); |
|
92 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/files'); |
|
93 | 93 | exit; |
94 | 94 | } |
95 | 95 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | private function config() |
68 | 68 | { |
69 | - $configPath = __DIR__ . '/../../config.json'; |
|
69 | + $configPath = __DIR__.'/../../config.json'; |
|
70 | 70 | if (realpath($configPath) !== false) { |
71 | 71 | $json = file_get_contents($configPath); |
72 | 72 | $this->config = json_decode($json); |
@@ -80,13 +80,13 @@ discard block |
||
80 | 80 | */ |
81 | 81 | private function storage() |
82 | 82 | { |
83 | - $this->storage = new Storage($this->config->rootDir . DIRECTORY_SEPARATOR . $this->config->storageDir, $this->config->imagesDir, $this->config->filesDir); |
|
83 | + $this->storage = new Storage($this->config->rootDir.DIRECTORY_SEPARATOR.$this->config->storageDir, $this->config->imagesDir, $this->config->filesDir); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | private function redirectMatching($request) |
87 | 87 | { |
88 | 88 | $redirects = $this->storage->getRedirects()->getRedirects(); |
89 | - $relativeUri = '/' . $request::$relativeUri; |
|
89 | + $relativeUri = '/'.$request::$relativeUri; |
|
90 | 90 | |
91 | 91 | foreach ($redirects as $redirect) { |
92 | 92 | if (preg_match_all($redirect->fromUrl, $relativeUri, $matches)) { |
@@ -96,10 +96,10 @@ discard block |
||
96 | 96 | } |
97 | 97 | if ($redirect->type == '301') { |
98 | 98 | header('HTTP/1.1 301 Moved Permanently'); |
99 | - header('Location: ' . $request::$subfolders . $toUrl); |
|
99 | + header('Location: '.$request::$subfolders.$toUrl); |
|
100 | 100 | exit; |
101 | 101 | } elseif ($redirect->type == '302') { |
102 | - header('Location: ' . $request::$subfolders . $toUrl, true, 302); |
|
102 | + header('Location: '.$request::$subfolders.$toUrl, true, 302); |
|
103 | 103 | exit; |
104 | 104 | } else { |
105 | 105 | throw new \Exception('Invalid redirect type.'); |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | private function sitemapMatching($request) |
118 | 118 | { |
119 | 119 | $sitemap = $this->storage->getSitemap()->getSitemap(); |
120 | - $relativeUri = '/' . $request::$relativeUri; |
|
120 | + $relativeUri = '/'.$request::$relativeUri; |
|
121 | 121 | |
122 | 122 | foreach ($sitemap as $sitemapItem) { |
123 | 123 | if ($sitemapItem->regex) { |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | */ |
183 | 183 | private function getComponentObject($class = '', $template = '', $parameters = array(), $matchedSitemapItem) |
184 | 184 | { |
185 | - $libraryComponentName = '\\CloudControl\Cms\\components\\' . $class; |
|
186 | - $userComponentName = '\\components\\' . $class; |
|
185 | + $libraryComponentName = '\\CloudControl\Cms\\components\\'.$class; |
|
186 | + $userComponentName = '\\components\\'.$class; |
|
187 | 187 | |
188 | 188 | if (!class_exists($libraryComponentName, false)) { |
189 | 189 | $component = new $libraryComponentName($template, $this->request, $parameters, $matchedSitemapItem); |
190 | 190 | } elseif (!class_exists($userComponentName, false)) { |
191 | 191 | $component = new $userComponentName($template, $this->request, $parameters, $matchedSitemapItem); |
192 | 192 | } else { |
193 | - throw new \Exception('Could not load component ' . $class); |
|
193 | + throw new \Exception('Could not load component '.$class); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | if (!$component instanceof Component) { |
@@ -248,8 +248,8 @@ discard block |
||
248 | 248 | */ |
249 | 249 | public function setCachingHeaders() |
250 | 250 | { |
251 | - header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 2))); // 2 days |
|
252 | - header("Cache-Control: max-age=" . (60 * 60 * 24 * 2)); |
|
251 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 2))); // 2 days |
|
252 | + header("Cache-Control: max-age=".(60 * 60 * 24 * 2)); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
@@ -116,13 +116,13 @@ discard block |
||
116 | 116 | if (in_array($name, $this->fileBasedSubsets)) { |
117 | 117 | return $this->$name; |
118 | 118 | } else { |
119 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
119 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
120 | 120 | } |
121 | 121 | } else { |
122 | 122 | if (in_array($name, $this->fileBasedSubsets)) { |
123 | 123 | return $this->loadSubset($name); |
124 | 124 | } else { |
125 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
125 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | } |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | { |
138 | 138 | if (in_array($name, $this->fileBasedSubsets)) { |
139 | 139 | $this->$name = $value; |
140 | - $changes = $name . 'Changes'; |
|
140 | + $changes = $name.'Changes'; |
|
141 | 141 | $this->$changes = true; |
142 | 142 | } else { |
143 | - throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
143 | + throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>'); |
|
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | public function save() |
151 | 151 | { |
152 | 152 | $host = $this; |
153 | - array_map(function ($value) use ($host) { |
|
153 | + array_map(function($value) use ($host) { |
|
154 | 154 | $host->saveSubset($value); |
155 | 155 | }, $this->fileBasedSubsets); |
156 | 156 | } |
@@ -161,14 +161,14 @@ discard block |
||
161 | 161 | */ |
162 | 162 | public function saveSubset($subset) |
163 | 163 | { |
164 | - $changes = $subset . 'Changes'; |
|
164 | + $changes = $subset.'Changes'; |
|
165 | 165 | if ($this->$changes === true) { |
166 | 166 | if (!defined('JSON_PRETTY_PRINT')) { |
167 | 167 | $json = json_encode($this->$subset); |
168 | 168 | } else { |
169 | 169 | $json = json_encode($this->$subset, JSON_PRETTY_PRINT); |
170 | 170 | } |
171 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
171 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
172 | 172 | file_put_contents($subsetStoragePath, $json); |
173 | 173 | |
174 | 174 | $this->$changes = false; |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | */ |
183 | 183 | protected function loadSubset($subset) |
184 | 184 | { |
185 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
185 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
186 | 186 | $json = file_get_contents($subsetStoragePath); |
187 | 187 | $json = json_decode($json); |
188 | 188 | $this->$subset = $json; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | public function getContentDbHandle() |
225 | 225 | { |
226 | 226 | if ($this->contentDbHandle === null) { |
227 | - $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
227 | + $this->contentDbHandle = new \PDO('sqlite:'.$this->storagePath.DIRECTORY_SEPARATOR.'content.db'); |
|
228 | 228 | } |
229 | 229 | return $this->contentDbHandle; |
230 | 230 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | public function getDocuments($state = 'published') |
241 | 241 | { |
242 | 242 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
243 | - throw new \Exception('Unsupported document state: ' . $state); |
|
243 | + throw new \Exception('Unsupported document state: '.$state); |
|
244 | 244 | } |
245 | 245 | return $this->getDocumentsByPath('/', $state); |
246 | 246 | } |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | public function getDocumentsWithState($folderPath = '/') |
249 | 249 | { |
250 | 250 | $db = $this->getContentDbHandle(); |
251 | - $folderPathWithWildcard = $folderPath . '%'; |
|
251 | + $folderPathWithWildcard = $folderPath.'%'; |
|
252 | 252 | |
253 | 253 | $ifRootIndex = 1; |
254 | 254 | if ($folderPath == '/') { |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | FROM documents_unpublished |
264 | 264 | LEFT JOIN documents_published |
265 | 265 | ON documents_published.path = documents_unpublished.path |
266 | - WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
267 | - AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1) . ') NOT LIKE "%/%" |
|
268 | - AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex) . ' |
|
269 | - AND documents_unpublished.path != ' . $db->quote($folderPath) . ' |
|
266 | + WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
267 | + AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1).') NOT LIKE "%/%" |
|
268 | + AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex).' |
|
269 | + AND documents_unpublished.path != ' . $db->quote($folderPath).' |
|
270 | 270 | ORDER BY documents_unpublished.`type` DESC, documents_unpublished.`path` ASC |
271 | 271 | '; |
272 | 272 | $stmt = $this->getDbStatement($sql); |
@@ -293,16 +293,16 @@ discard block |
||
293 | 293 | public function getDocumentsByPath($folderPath, $state = 'published') |
294 | 294 | { |
295 | 295 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
296 | - throw new \Exception('Unsupported document state: ' . $state); |
|
296 | + throw new \Exception('Unsupported document state: '.$state); |
|
297 | 297 | } |
298 | 298 | $db = $this->getContentDbHandle(); |
299 | - $folderPathWithWildcard = $folderPath . '%'; |
|
299 | + $folderPathWithWildcard = $folderPath.'%'; |
|
300 | 300 | |
301 | 301 | $sql = 'SELECT * |
302 | - FROM documents_' . $state . ' |
|
303 | - WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
304 | - AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
|
305 | - AND path != ' . $db->quote($folderPath) . ' |
|
302 | + FROM documents_' . $state.' |
|
303 | + WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
304 | + AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%" |
|
305 | + AND path != ' . $db->quote($folderPath).' |
|
306 | 306 | ORDER BY `type` DESC, `path` ASC'; |
307 | 307 | $stmt = $this->getDbStatement($sql); |
308 | 308 | |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | if ($containerPath === '/') { |
330 | 330 | return $this->getRootFolder(); |
331 | 331 | } |
332 | - if (substr($containerPath, -1) === '/'){ |
|
332 | + if (substr($containerPath, -1) === '/') { |
|
333 | 333 | $containerPath = substr($containerPath, 0, -1); |
334 | 334 | } |
335 | 335 | $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
@@ -346,13 +346,13 @@ discard block |
||
346 | 346 | public function getDocumentByPath($path, $state = 'published') |
347 | 347 | { |
348 | 348 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
349 | - throw new \Exception('Unsupported document state: ' . $state); |
|
349 | + throw new \Exception('Unsupported document state: '.$state); |
|
350 | 350 | } |
351 | 351 | $db = $this->getContentDbHandle(); |
352 | 352 | $document = $this->fetchDocument(' |
353 | 353 | SELECT * |
354 | - FROM documents_' . $state . ' |
|
355 | - WHERE path = ' . $db->quote($path) . ' |
|
354 | + FROM documents_' . $state.' |
|
355 | + WHERE path = ' . $db->quote($path).' |
|
356 | 356 | '); |
357 | 357 | if ($document instanceof Document && $document->type === 'folder') { |
358 | 358 | $document->dbHandle = $db; |
@@ -372,16 +372,16 @@ discard block |
||
372 | 372 | public function getTotalDocumentCount($state = 'published') |
373 | 373 | { |
374 | 374 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
375 | - throw new \Exception('Unsupported document state: ' . $state); |
|
375 | + throw new \Exception('Unsupported document state: '.$state); |
|
376 | 376 | } |
377 | 377 | $db = $this->getContentDbHandle(); |
378 | 378 | $stmt = $db->query(' |
379 | 379 | SELECT count(*) |
380 | - FROM documents_' . $state . ' |
|
380 | + FROM documents_' . $state.' |
|
381 | 381 | WHERE `type` != "folder" |
382 | 382 | '); |
383 | 383 | $result = $stmt->fetch(\PDO::FETCH_ASSOC); |
384 | - if (!is_array($result )) { |
|
384 | + if (!is_array($result)) { |
|
385 | 385 | return 0; |
386 | 386 | } |
387 | 387 | return intval(current($result)); |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | if ($stmt === false || !$stmt->execute()) { |
401 | 401 | $errorInfo = $db->errorInfo(); |
402 | 402 | $errorMsg = $errorInfo[2]; |
403 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
403 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
404 | 404 | } |
405 | 405 | return $result; |
406 | 406 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $sql = ' |
411 | 411 | INSERT OR REPLACE INTO documents_published |
412 | 412 | (`id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`publicationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
413 | - SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time() . ' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
413 | + SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time().' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
414 | 414 | FROM documents_unpublished |
415 | 415 | WHERE `path` = :path |
416 | 416 | '; |
@@ -423,7 +423,7 @@ discard block |
||
423 | 423 | if ($stmt === false) { |
424 | 424 | $errorInfo = $db->errorInfo(); |
425 | 425 | $errorMsg = $errorInfo[2]; |
426 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
426 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
427 | 427 | } |
428 | 428 | $stmt->bindValue(':path', $path); |
429 | 429 | $stmt->execute(); |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | if ($stmt === false) { |
491 | 491 | $errorInfo = $db->errorInfo(); |
492 | 492 | $errorMsg = $errorInfo[2]; |
493 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
493 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
494 | 494 | } |
495 | 495 | return $stmt; |
496 | 496 | } |
@@ -520,25 +520,25 @@ discard block |
||
520 | 520 | public function saveDocument($documentObject, $state = 'published') |
521 | 521 | { |
522 | 522 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
523 | - throw new \Exception('Unsupported document state: ' . $state); |
|
523 | + throw new \Exception('Unsupported document state: '.$state); |
|
524 | 524 | } |
525 | 525 | $db = $this->getContentDbHandle(); |
526 | 526 | $stmt = $this->getDbStatement(' |
527 | - INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
527 | + INSERT OR REPLACE INTO documents_' . $state.' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
528 | 528 | VALUES( |
529 | - ' . $db->quote($documentObject->path) . ', |
|
530 | - ' . $db->quote($documentObject->title) . ', |
|
531 | - ' . $db->quote($documentObject->slug) . ', |
|
532 | - ' . $db->quote($documentObject->type) . ', |
|
533 | - ' . $db->quote($documentObject->documentType) . ', |
|
534 | - ' . $db->quote($documentObject->documentTypeSlug) . ', |
|
535 | - ' . $db->quote($documentObject->state) . ', |
|
536 | - ' . $db->quote($documentObject->lastModificationDate) . ', |
|
537 | - ' . $db->quote($documentObject->creationDate) . ', |
|
538 | - ' . $db->quote($documentObject->lastModifiedBy) . ', |
|
539 | - ' . $db->quote(json_encode($documentObject->fields)) . ', |
|
540 | - ' . $db->quote(json_encode($documentObject->bricks)) . ', |
|
541 | - ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
|
529 | + ' . $db->quote($documentObject->path).', |
|
530 | + ' . $db->quote($documentObject->title).', |
|
531 | + ' . $db->quote($documentObject->slug).', |
|
532 | + ' . $db->quote($documentObject->type).', |
|
533 | + ' . $db->quote($documentObject->documentType).', |
|
534 | + ' . $db->quote($documentObject->documentTypeSlug).', |
|
535 | + ' . $db->quote($documentObject->state).', |
|
536 | + ' . $db->quote($documentObject->lastModificationDate).', |
|
537 | + ' . $db->quote($documentObject->creationDate).', |
|
538 | + ' . $db->quote($documentObject->lastModifiedBy).', |
|
539 | + ' . $db->quote(json_encode($documentObject->fields)).', |
|
540 | + ' . $db->quote(json_encode($documentObject->bricks)).', |
|
541 | + ' . $db->quote(json_encode($documentObject->dynamicBricks)).' |
|
542 | 542 | ) |
543 | 543 | '); |
544 | 544 | $result = $stmt->execute(); |
@@ -562,16 +562,16 @@ discard block |
||
562 | 562 | if ($documentToDelete->type == 'document') { |
563 | 563 | $stmt = $this->getDbStatement(' |
564 | 564 | DELETE FROM documents_unpublished |
565 | - WHERE path = ' . $db->quote($path) . ' |
|
565 | + WHERE path = ' . $db->quote($path).' |
|
566 | 566 | '); |
567 | 567 | $stmt->execute(); |
568 | 568 | } elseif ($documentToDelete->type == 'folder') { |
569 | - $folderPathWithWildcard = $path . '%'; |
|
569 | + $folderPathWithWildcard = $path.'%'; |
|
570 | 570 | $stmt = $this->getDbStatement(' |
571 | 571 | DELETE FROM documents_unpublished |
572 | - WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
573 | - AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
|
574 | - OR path = ' . $db->quote($path) . ' |
|
572 | + WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).' |
|
573 | + AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/") |
|
574 | + OR path = ' . $db->quote($path).' |
|
575 | 575 | '); |
576 | 576 | $stmt->execute(); |
577 | 577 | } |
@@ -599,11 +599,11 @@ discard block |
||
599 | 599 | |
600 | 600 | private function initConfigIfNotExists($json, $subsetName) |
601 | 601 | { |
602 | - $subsetFileName = $this->storagePath . DIRECTORY_SEPARATOR . $subsetName . '.json'; |
|
602 | + $subsetFileName = $this->storagePath.DIRECTORY_SEPARATOR.$subsetName.'.json'; |
|
603 | 603 | if (file_exists($subsetFileName)) { |
604 | 604 | $this->loadSubset($subsetName); |
605 | 605 | } else { |
606 | - $changes = $subsetName . 'Changes'; |
|
606 | + $changes = $subsetName.'Changes'; |
|
607 | 607 | $this->$subsetName = $json->$subsetName; |
608 | 608 | $this->$changes = true; |
609 | 609 | } |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | { |
151 | 151 | $documentFolderObject = DocumentFolderFactory::createDocumentFolderFromPostValues($postValues); |
152 | 152 | if ($postValues['path'] === '/') { |
153 | - $documentFolderObject->path = $postValues['path'] . $documentFolderObject->slug; |
|
153 | + $documentFolderObject->path = $postValues['path'].$documentFolderObject->slug; |
|
154 | 154 | } else { |
155 | - $documentFolderObject->path = $postValues['path'] . '/' . $documentFolderObject->slug; |
|
155 | + $documentFolderObject->path = $postValues['path'].'/'.$documentFolderObject->slug; |
|
156 | 156 | } |
157 | 157 | $this->repository->saveDocument($documentFolderObject, 'published'); |
158 | 158 | $this->repository->saveDocument($documentFolderObject, 'unpublished'); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | public function deleteDocumentFolderBySlug($slug) |
169 | 169 | { |
170 | - $path = '/' . $slug; |
|
170 | + $path = '/'.$slug; |
|
171 | 171 | $this->repository->deleteDocumentByPath($path, 'published'); |
172 | 172 | $this->repository->deleteDocumentByPath($path, 'unpublished'); |
173 | 173 | $this->repository->cleanPublishedDeletedDocuments(); |
@@ -175,13 +175,13 @@ discard block |
||
175 | 175 | |
176 | 176 | public function publishDocumentBySlug($slug) |
177 | 177 | { |
178 | - $path = '/' . $slug; |
|
178 | + $path = '/'.$slug; |
|
179 | 179 | $this->repository->publishDocumentByPath($path); |
180 | 180 | } |
181 | 181 | |
182 | 182 | public function unpublishDocumentBySlug($slug) |
183 | 183 | { |
184 | - $path = '/' . $slug; |
|
184 | + $path = '/'.$slug; |
|
185 | 185 | $this->repository->unpublishDocumentByPath($path); |
186 | 186 | } |
187 | 187 | |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | */ |
196 | 196 | public function getDocumentFolderBySlug($slug) |
197 | 197 | { |
198 | - $path = '/' . $slug; |
|
198 | + $path = '/'.$slug; |
|
199 | 199 | |
200 | 200 | return $this->repository->getDocumentByPath($path); |
201 | 201 | } |