@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | |
90 | 90 | private function tokenizeBrick($brick, $brickSlug) |
91 | 91 | { |
92 | - $fields = $brick->fields; |
|
92 | + $fields = $brick->fields; |
|
93 | 93 | $brickDefinition = $this->storage->getBricks()->getBrickBySlug($brick->type); |
94 | 94 | foreach ($fields as $fieldName => $field) { |
95 | 95 | $fieldType = $this->getFieldType($fieldName, $brickDefinition); |
96 | - $this->tokenizeField($field, $brickSlug . '__' . $fieldName, $fieldType); |
|
96 | + $this->tokenizeField($field, $brickSlug.'__'.$fieldName, $fieldType); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | $dynamicBricks = $this->document->dynamicBricks; |
103 | 103 | foreach ($dynamicBricks as $key => $brick) { |
104 | - $this->tokenizeBrick($brick, 'dynamicBricks__' . $brick->type . $key); |
|
104 | + $this->tokenizeBrick($brick, 'dynamicBricks__'.$brick->type.$key); |
|
105 | 105 | } |
106 | 106 | } |
107 | 107 | |
@@ -154,6 +154,6 @@ discard block |
||
154 | 154 | } |
155 | 155 | } |
156 | 156 | |
157 | - throw new \Exception('Unknown field type for field' . $fieldName . ' in document ' . $this->document->path); |
|
157 | + throw new \Exception('Unknown field type for field'.$fieldName.' in document '.$this->document->path); |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | \ No newline at end of file |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | protected function configureDatabase() |
54 | 54 | { |
55 | 55 | $db = $this->getSearchDbHandle(); |
56 | - $sqlPath = __DIR__ . DIRECTORY_SEPARATOR . '../cc/install/search.sql'; |
|
56 | + $sqlPath = __DIR__.DIRECTORY_SEPARATOR.'../cc/install/search.sql'; |
|
57 | 57 | $searchSql = file_get_contents($sqlPath); |
58 | 58 | $db->exec($searchSql); |
59 | 59 | } |
@@ -69,8 +69,8 @@ discard block |
||
69 | 69 | protected function getSearchDbHandle() |
70 | 70 | { |
71 | 71 | if ($this->searchDbHandle === null) { |
72 | - $path = $this->storageDir . DIRECTORY_SEPARATOR; |
|
73 | - $this->searchDbHandle = new \PDO('sqlite:' . $path . 'search.db'); |
|
72 | + $path = $this->storageDir.DIRECTORY_SEPARATOR; |
|
73 | + $this->searchDbHandle = new \PDO('sqlite:'.$path.'search.db'); |
|
74 | 74 | } |
75 | 75 | return $this->searchDbHandle; |
76 | 76 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $string = strip_tags($string); |
49 | 49 | $string = trim($string); |
50 | 50 | $string = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string); // Remove special alphanumeric characters |
51 | - $string = str_replace(array('+', '=', '!', ',', '.',';', ':', '?'), ' ', $string); // Replace sentence breaking charaters with spaces |
|
51 | + $string = str_replace(array('+', '=', '!', ',', '.', ';', ':', '?'), ' ', $string); // Replace sentence breaking charaters with spaces |
|
52 | 52 | $string = preg_replace("/[\r\n]+/", " ", $string); // Replace multiple newlines with a single space. |
53 | 53 | $string = preg_replace("/[\t]+/", " ", $string); // Replace multiple tabs with a single space. |
54 | 54 | $string = preg_replace("/[^a-zA-Z0-9 ]/", '', $string); // Filter out everything that is not alphanumeric or a space |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | { |
67 | 67 | $encoding = mb_detect_encoding($string, mb_detect_order(), false); |
68 | 68 | |
69 | - if($encoding == "UTF-8") { |
|
69 | + if ($encoding == "UTF-8") { |
|
70 | 70 | $string = mb_convert_encoding($string, 'UTF-8', 'UTF-8'); |
71 | 71 | } |
72 | 72 |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $this->storage->getDocuments()->cleanPublishedDeletedDocuments(); |
61 | 61 | $this->addLog('Retrieving documents to be indexed.'); |
62 | 62 | $documents = $this->storage->getDocuments()->getPublishedDocumentsNoFolders(); |
63 | - $this->addLog('Start Document Term Count for ' . count($documents) . ' documents'); |
|
63 | + $this->addLog('Start Document Term Count for '.count($documents).' documents'); |
|
64 | 64 | $this->createDocumentTermCount($documents); |
65 | 65 | $this->addLog('Start Document Term Frequency.'); |
66 | 66 | $this->createDocumentTermFrequency(); |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | private function addLog($string) |
162 | 162 | { |
163 | 163 | $currentTime = round(microtime(true) * 1000); |
164 | - $this->log .= date('d-m-Y H:i:s - ') . str_pad($string, 50, " ", STR_PAD_RIGHT) . "\t" . ($currentTime - $this->lastLog) . 'ms since last log. ' . "\t" . ($currentTime - $this->loggingStart) . 'ms since start.' . PHP_EOL; |
|
164 | + $this->log .= date('d-m-Y H:i:s - ').str_pad($string, 50, " ", STR_PAD_RIGHT)."\t".($currentTime - $this->lastLog).'ms since last log. '."\t".($currentTime - $this->loggingStart).'ms since start.'.PHP_EOL; |
|
165 | 165 | $this->lastLog = round(microtime(true) * 1000); |
166 | 166 | } |
167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
173 | 173 | protected function getSearchDbHandle() |
174 | 174 | { |
175 | 175 | if ($this->searchDbHandle === null) { |
176 | - $path = $this->storageDir . DIRECTORY_SEPARATOR; |
|
177 | - $this->searchDbHandle = new \PDO('sqlite:' . $path . self::SEARCH_TEMP_DB); |
|
176 | + $path = $this->storageDir.DIRECTORY_SEPARATOR; |
|
177 | + $this->searchDbHandle = new \PDO('sqlite:'.$path.self::SEARCH_TEMP_DB); |
|
178 | 178 | } |
179 | 179 | return $this->searchDbHandle; |
180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | public function replaceOldIndex() |
186 | 186 | { |
187 | 187 | $this->searchDbHandle = null; |
188 | - $path = $this->storageDir . DIRECTORY_SEPARATOR; |
|
189 | - rename($path . self::SEARCH_TEMP_DB, $path . 'search.db'); |
|
188 | + $path = $this->storageDir.DIRECTORY_SEPARATOR; |
|
189 | + rename($path.self::SEARCH_TEMP_DB, $path.'search.db'); |
|
190 | 190 | } |
191 | 191 | } |
192 | 192 | \ No newline at end of file |
@@ -49,7 +49,7 @@ |
||
49 | 49 | $output = ''; |
50 | 50 | for ($i = 0; $i < $count; $i += 16) { |
51 | 51 | $random_state = |
52 | - md5(microtime() . $random_state); |
|
52 | + md5(microtime().$random_state); |
|
53 | 53 | $output .= |
54 | 54 | pack('H*', md5($random_state)); |
55 | 55 | } |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $repository->init(); |
114 | 114 | $this->repository = $repository; |
115 | 115 | } else { |
116 | - throw new \Exception('Could not create repository directory: ' . $storagePath); |
|
116 | + throw new \Exception('Could not create repository directory: '.$storagePath); |
|
117 | 117 | } |
118 | 118 | } else { |
119 | 119 | $this->repository = new Repository($storagePath); |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | { |
157 | 157 | $documentFolderObject = DocumentFolderFactory::createDocumentFolderFromPostValues($postValues); |
158 | 158 | if ($postValues['path'] === '/') { |
159 | - $documentFolderObject->path = $postValues['path'] . $documentFolderObject->slug; |
|
159 | + $documentFolderObject->path = $postValues['path'].$documentFolderObject->slug; |
|
160 | 160 | } else { |
161 | - $documentFolderObject->path = $postValues['path'] . '/' . $documentFolderObject->slug; |
|
161 | + $documentFolderObject->path = $postValues['path'].'/'.$documentFolderObject->slug; |
|
162 | 162 | } |
163 | 163 | $this->repository->saveDocument($documentFolderObject, 'published'); |
164 | 164 | $this->repository->saveDocument($documentFolderObject, 'unpublished'); |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | public function deleteDocumentFolderBySlug($slug) |
175 | 175 | { |
176 | - $path = '/' . $slug; |
|
176 | + $path = '/'.$slug; |
|
177 | 177 | $this->repository->deleteDocumentByPath($path, 'published'); |
178 | 178 | $this->repository->deleteDocumentByPath($path, 'unpublished'); |
179 | 179 | $this->repository->cleanPublishedDeletedDocuments(); |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | |
182 | 182 | public function publishDocumentBySlug($slug) |
183 | 183 | { |
184 | - $path = '/' . $slug; |
|
184 | + $path = '/'.$slug; |
|
185 | 185 | $this->repository->publishDocumentByPath($path); |
186 | 186 | } |
187 | 187 | |
188 | 188 | public function unpublishDocumentBySlug($slug) |
189 | 189 | { |
190 | - $path = '/' . $slug; |
|
190 | + $path = '/'.$slug; |
|
191 | 191 | $this->repository->unpublishDocumentByPath($path); |
192 | 192 | } |
193 | 193 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | public function getDocumentFolderBySlug($slug) |
203 | 203 | { |
204 | - $path = '/' . $slug; |
|
204 | + $path = '/'.$slug; |
|
205 | 205 | |
206 | 206 | return $this->repository->getDocumentByPath($path); |
207 | 207 | } |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | } elseif ($name === 'content') { |
54 | 54 | if ($this->dbHandle === null) { |
55 | - throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
55 | + throw new \Exception('Document doesnt have a dbHandle handle. (path: '.$this->path.')'); |
|
56 | 56 | } else { |
57 | 57 | if ($this->content === null) { |
58 | 58 | return $this->getContent(); |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function __toString() |
99 | 99 | { |
100 | - return 'Document:' . $this->title; |
|
100 | + return 'Document:'.$this->title; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 |
@@ -115,13 +115,13 @@ discard block |
||
115 | 115 | if (in_array($name, $this->fileBasedSubsets)) { |
116 | 116 | return $this->$name; |
117 | 117 | } else { |
118 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
118 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
119 | 119 | } |
120 | 120 | } else { |
121 | 121 | if (in_array($name, $this->fileBasedSubsets)) { |
122 | 122 | return $this->loadSubset($name); |
123 | 123 | } else { |
124 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
124 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
125 | 125 | } |
126 | 126 | } |
127 | 127 | } |
@@ -136,10 +136,10 @@ discard block |
||
136 | 136 | { |
137 | 137 | if (in_array($name, $this->fileBasedSubsets)) { |
138 | 138 | $this->$name = $value; |
139 | - $changes = $name . 'Changes'; |
|
139 | + $changes = $name.'Changes'; |
|
140 | 140 | $this->$changes = true; |
141 | 141 | } else { |
142 | - throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
142 | + throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>'); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | public function save() |
150 | 150 | { |
151 | 151 | $host = $this; |
152 | - array_map(function ($value) use ($host) { |
|
152 | + array_map(function($value) use ($host) { |
|
153 | 153 | $host->saveSubset($value); |
154 | 154 | }, $this->fileBasedSubsets); |
155 | 155 | } |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | */ |
161 | 161 | public function saveSubset($subset) |
162 | 162 | { |
163 | - $changes = $subset . 'Changes'; |
|
163 | + $changes = $subset.'Changes'; |
|
164 | 164 | if ($this->$changes === true) { |
165 | 165 | if (!defined('JSON_PRETTY_PRINT')) { |
166 | 166 | $json = json_encode($this->$subset); |
167 | 167 | } else { |
168 | 168 | $json = json_encode($this->$subset, JSON_PRETTY_PRINT); |
169 | 169 | } |
170 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
170 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
171 | 171 | file_put_contents($subsetStoragePath, $json); |
172 | 172 | |
173 | 173 | $this->$changes = false; |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | */ |
182 | 182 | protected function loadSubset($subset) |
183 | 183 | { |
184 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
184 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
185 | 185 | $json = file_get_contents($subsetStoragePath); |
186 | 186 | $json = json_decode($json); |
187 | 187 | $this->$subset = $json; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | public function getContentDbHandle() |
232 | 232 | { |
233 | 233 | if ($this->contentDbHandle === null) { |
234 | - $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
234 | + $this->contentDbHandle = new \PDO('sqlite:'.$this->storagePath.DIRECTORY_SEPARATOR.'content.db'); |
|
235 | 235 | } |
236 | 236 | return $this->contentDbHandle; |
237 | 237 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | public function getDocuments($state = 'published') |
248 | 248 | { |
249 | 249 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
250 | - throw new \Exception('Unsupported document state: ' . $state); |
|
250 | + throw new \Exception('Unsupported document state: '.$state); |
|
251 | 251 | } |
252 | 252 | return $this->getDocumentsByPath('/', $state); |
253 | 253 | } |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | public function getDocumentsWithState($folderPath = '/') |
256 | 256 | { |
257 | 257 | $db = $this->getContentDbHandle(); |
258 | - $folderPathWithWildcard = $folderPath . '%'; |
|
258 | + $folderPathWithWildcard = $folderPath.'%'; |
|
259 | 259 | |
260 | 260 | $ifRootIndex = 1; |
261 | 261 | if ($folderPath == '/') { |
@@ -270,10 +270,10 @@ discard block |
||
270 | 270 | FROM documents_unpublished |
271 | 271 | LEFT JOIN documents_published |
272 | 272 | ON documents_published.path = documents_unpublished.path |
273 | - WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
274 | - AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1) . ') NOT LIKE "%/%" |
|
275 | - AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex) . ' |
|
276 | - AND documents_unpublished.path != ' . $db->quote($folderPath) . ' |
|
273 | + WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
274 | + AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1).') NOT LIKE "%/%" |
|
275 | + AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex).' |
|
276 | + AND documents_unpublished.path != ' . $db->quote($folderPath).' |
|
277 | 277 | ORDER BY documents_unpublished.`type` DESC, documents_unpublished.`path` ASC |
278 | 278 | '; |
279 | 279 | $stmt = $this->getDbStatement($sql); |
@@ -300,16 +300,16 @@ discard block |
||
300 | 300 | public function getDocumentsByPath($folderPath, $state = 'published') |
301 | 301 | { |
302 | 302 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
303 | - throw new \Exception('Unsupported document state: ' . $state); |
|
303 | + throw new \Exception('Unsupported document state: '.$state); |
|
304 | 304 | } |
305 | 305 | $db = $this->getContentDbHandle(); |
306 | - $folderPathWithWildcard = $folderPath . '%'; |
|
306 | + $folderPathWithWildcard = $folderPath.'%'; |
|
307 | 307 | |
308 | 308 | $sql = 'SELECT * |
309 | - FROM documents_' . $state . ' |
|
310 | - WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
311 | - AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
|
312 | - AND path != ' . $db->quote($folderPath) . ' |
|
309 | + FROM documents_' . $state.' |
|
310 | + WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
311 | + AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%" |
|
312 | + AND path != ' . $db->quote($folderPath).' |
|
313 | 313 | ORDER BY `type` DESC, `path` ASC'; |
314 | 314 | $stmt = $this->getDbStatement($sql); |
315 | 315 | |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | if ($containerPath === '/') { |
337 | 337 | return $this->getRootFolder(); |
338 | 338 | } |
339 | - if (substr($containerPath, -1) === '/'){ |
|
339 | + if (substr($containerPath, -1) === '/') { |
|
340 | 340 | $containerPath = substr($containerPath, 0, -1); |
341 | 341 | } |
342 | 342 | $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
@@ -353,13 +353,13 @@ discard block |
||
353 | 353 | public function getDocumentByPath($path, $state = 'published') |
354 | 354 | { |
355 | 355 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
356 | - throw new \Exception('Unsupported document state: ' . $state); |
|
356 | + throw new \Exception('Unsupported document state: '.$state); |
|
357 | 357 | } |
358 | 358 | $db = $this->getContentDbHandle(); |
359 | 359 | $document = $this->fetchDocument(' |
360 | 360 | SELECT * |
361 | - FROM documents_' . $state . ' |
|
362 | - WHERE path = ' . $db->quote($path) . ' |
|
361 | + FROM documents_' . $state.' |
|
362 | + WHERE path = ' . $db->quote($path).' |
|
363 | 363 | '); |
364 | 364 | if ($document instanceof Document && $document->type === 'folder') { |
365 | 365 | $document->dbHandle = $db; |
@@ -379,16 +379,16 @@ discard block |
||
379 | 379 | public function getTotalDocumentCount($state = 'published') |
380 | 380 | { |
381 | 381 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
382 | - throw new \Exception('Unsupported document state: ' . $state); |
|
382 | + throw new \Exception('Unsupported document state: '.$state); |
|
383 | 383 | } |
384 | 384 | $db = $this->getContentDbHandle(); |
385 | 385 | $stmt = $db->query(' |
386 | 386 | SELECT count(*) |
387 | - FROM documents_' . $state . ' |
|
387 | + FROM documents_' . $state.' |
|
388 | 388 | WHERE `type` != "folder" |
389 | 389 | '); |
390 | 390 | $result = $stmt->fetch(\PDO::FETCH_ASSOC); |
391 | - if (!is_array($result )) { |
|
391 | + if (!is_array($result)) { |
|
392 | 392 | return 0; |
393 | 393 | } |
394 | 394 | return intval(current($result)); |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | if ($stmt === false || !$stmt->execute()) { |
408 | 408 | $errorInfo = $db->errorInfo(); |
409 | 409 | $errorMsg = $errorInfo[2]; |
410 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
410 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
411 | 411 | } |
412 | 412 | return $result; |
413 | 413 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | $sql = ' |
418 | 418 | INSERT OR REPLACE INTO documents_published |
419 | 419 | (`id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`publicationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
420 | - SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time() . ' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
420 | + SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time().' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
421 | 421 | FROM documents_unpublished |
422 | 422 | WHERE `path` = :path |
423 | 423 | '; |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | if ($stmt === false) { |
431 | 431 | $errorInfo = $db->errorInfo(); |
432 | 432 | $errorMsg = $errorInfo[2]; |
433 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
433 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
434 | 434 | } |
435 | 435 | $stmt->bindValue(':path', $path); |
436 | 436 | $stmt->execute(); |
@@ -497,7 +497,7 @@ discard block |
||
497 | 497 | if ($stmt === false) { |
498 | 498 | $errorInfo = $db->errorInfo(); |
499 | 499 | $errorMsg = $errorInfo[2]; |
500 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
500 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
501 | 501 | } |
502 | 502 | return $stmt; |
503 | 503 | } |
@@ -527,25 +527,25 @@ discard block |
||
527 | 527 | public function saveDocument($documentObject, $state = 'published') |
528 | 528 | { |
529 | 529 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
530 | - throw new \Exception('Unsupported document state: ' . $state); |
|
530 | + throw new \Exception('Unsupported document state: '.$state); |
|
531 | 531 | } |
532 | 532 | $db = $this->getContentDbHandle(); |
533 | 533 | $stmt = $this->getDbStatement(' |
534 | - INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
534 | + INSERT OR REPLACE INTO documents_' . $state.' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
535 | 535 | VALUES( |
536 | - ' . $db->quote($documentObject->path) . ', |
|
537 | - ' . $db->quote($documentObject->title) . ', |
|
538 | - ' . $db->quote($documentObject->slug) . ', |
|
539 | - ' . $db->quote($documentObject->type) . ', |
|
540 | - ' . $db->quote($documentObject->documentType) . ', |
|
541 | - ' . $db->quote($documentObject->documentTypeSlug) . ', |
|
542 | - ' . $db->quote($documentObject->state) . ', |
|
543 | - ' . $db->quote($documentObject->lastModificationDate) . ', |
|
544 | - ' . $db->quote($documentObject->creationDate) . ', |
|
545 | - ' . $db->quote($documentObject->lastModifiedBy) . ', |
|
546 | - ' . $db->quote(json_encode($documentObject->fields)) . ', |
|
547 | - ' . $db->quote(json_encode($documentObject->bricks)) . ', |
|
548 | - ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
|
536 | + ' . $db->quote($documentObject->path).', |
|
537 | + ' . $db->quote($documentObject->title).', |
|
538 | + ' . $db->quote($documentObject->slug).', |
|
539 | + ' . $db->quote($documentObject->type).', |
|
540 | + ' . $db->quote($documentObject->documentType).', |
|
541 | + ' . $db->quote($documentObject->documentTypeSlug).', |
|
542 | + ' . $db->quote($documentObject->state).', |
|
543 | + ' . $db->quote($documentObject->lastModificationDate).', |
|
544 | + ' . $db->quote($documentObject->creationDate).', |
|
545 | + ' . $db->quote($documentObject->lastModifiedBy).', |
|
546 | + ' . $db->quote(json_encode($documentObject->fields)).', |
|
547 | + ' . $db->quote(json_encode($documentObject->bricks)).', |
|
548 | + ' . $db->quote(json_encode($documentObject->dynamicBricks)).' |
|
549 | 549 | ) |
550 | 550 | '); |
551 | 551 | $result = $stmt->execute(); |
@@ -569,16 +569,16 @@ discard block |
||
569 | 569 | if ($documentToDelete->type == 'document') { |
570 | 570 | $stmt = $this->getDbStatement(' |
571 | 571 | DELETE FROM documents_unpublished |
572 | - WHERE path = ' . $db->quote($path) . ' |
|
572 | + WHERE path = ' . $db->quote($path).' |
|
573 | 573 | '); |
574 | 574 | $stmt->execute(); |
575 | 575 | } elseif ($documentToDelete->type == 'folder') { |
576 | - $folderPathWithWildcard = $path . '%'; |
|
576 | + $folderPathWithWildcard = $path.'%'; |
|
577 | 577 | $stmt = $this->getDbStatement(' |
578 | 578 | DELETE FROM documents_unpublished |
579 | - WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
580 | - AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
|
581 | - OR path = ' . $db->quote($path) . ' |
|
579 | + WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).' |
|
580 | + AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/") |
|
581 | + OR path = ' . $db->quote($path).' |
|
582 | 582 | '); |
583 | 583 | $stmt->execute(); |
584 | 584 | } |
@@ -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 |