Passed
Push — develop ( 02ffeb...d59462 )
by Jens
02:18
created
cloudcontrol/library/search/Indexer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
173 173
 	protected function getSearchDbHandle()
174 174
 	{
175 175
 		if ($this->searchDbHandle === null) {
176
-			$path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR;
177
-			$this->searchDbHandle = new \PDO('sqlite:' . $path . self::SEARCH_TEMP_DB);
176
+			$path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$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
 block discarded – undo
185 185
 	public function replaceOldIndex()
186 186
 	{
187 187
 		$this->searchDbHandle = null;
188
-		$path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR;
189
-		rename($path . self::SEARCH_TEMP_DB, $path . 'search.db');
188
+		$path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$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
Please login to merge, or discard this patch.
cloudcontrol/library/components/cms/SearchRouting.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	}
73 73
 
74 74
 	private function showJson($obj, $httpHeader = 'HTTP/1.0 200 OK') {
75
-		header($_SERVER['SERVER_PROTOCOL'] . $httpHeader, true);
75
+		header($_SERVER['SERVER_PROTOCOL'].$httpHeader, true);
76 76
 		header('Content-type: application/json');
77 77
 		die(json_encode($obj));
78 78
 	}
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	private function stepRouting($step, $cmsComponent, $indexer)
86 86
 	{
87
-		switch($step) {
87
+		switch ($step) {
88 88
 			case 'resetIndex': $indexer->resetIndex(); break;
89 89
 			case 'cleanPublishedDeletedDocuments': $cmsComponent->storage->getDocuments()->cleanPublishedDeletedDocuments(); break;
90 90
 			case 'createDocumentTermCount':
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 			case 'createTermFieldLengthNorm': $indexer->createTermFieldLengthNorm(); break;
96 96
 			case 'createInverseDocumentFrequency': $indexer->createInverseDocumentFrequency(); break;
97 97
 			case 'replaceOldIndex': $indexer->replaceOldIndex(); break;
98
-			default : $this->showJson('Invalid step: ' . $step . '.', 'HTTP/1.0 500 Internal Server Error'); break;
98
+			default : $this->showJson('Invalid step: '.$step.'.', 'HTTP/1.0 500 Internal Server Error'); break;
99 99
 		}
100 100
 		$this->showJson('done');
101 101
 	}
Please login to merge, or discard this patch.
cloudcontrol/templates/cms/documents.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <? include('documents/function.renderAction.php'); ?>
2 2
 <? include('documents/function.renderDocument.php'); ?>
3 3
 <? include('documents/function.renderFolder.php'); ?>
4
-<script>window.onload=function(){History.init();History.replaceState(null, 'Cloud Control CMS', '/<?=$request::$subfolders . $cmsPrefix?>/documents?path=/');};</script>
4
+<script>window.onload=function(){History.init();History.replaceState(null, 'Cloud Control CMS', '/<?=$request::$subfolders.$cmsPrefix?>/documents?path=/');};</script>
5 5
 <section class="documents">
6 6
 	<h2><i class="fa fa-file-text-o"></i> Documents</h2>
7 7
 	<nav class="actions">
@@ -27,9 +27,9 @@  discard block
 block discarded – undo
27 27
 			<? foreach ($documents as $document) : ?>
28 28
 				<li class="grid-container">
29 29
 					<? if ($document->type == 'document') : ?>
30
-						<?renderDocument($document, $cmsPrefix);?>
30
+						<?renderDocument($document, $cmsPrefix); ?>
31 31
 					<? elseif ($document->type == 'folder') : ?>
32
-						<?renderFolder($document, $cmsPrefix, '', true);?>
32
+						<?renderFolder($document, $cmsPrefix, '', true); ?>
33 33
 					<? endif ?>
34 34
 				</li>
35 35
 			<? endforeach ?>
Please login to merge, or discard this patch.
cloudcontrol/templates/cms/documents/function.renderDocument.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,9 +21,9 @@  discard block
 block discarded – undo
21 21
 	<div class="documentActions grid-box-2">
22 22
 		<? if ($document->state == 'unpublished' || $document->unpublishedChanges) : ?>
23 23
             <?renderAction('Publish',
24
-                'publish',
25
-                \library\cc\Request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug,
26
-                'check');?>
24
+				'publish',
25
+				\library\cc\Request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug,
26
+				'check');?>
27 27
 		<? endif ?>
28 28
 		<? if ($document->state == 'published') : ?>
29 29
 			<?renderAction('Unpublish',
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 				'error',
41 41
 				\library\cc\Request::$subfolders . $cmsPrefix . '/documents/delete-document?slug=' . $slugPrefix . $document->slug,
42 42
 				'trash',
43
-                'return confirm(\'Are you sure you want to delete this document?\');');?>
43
+				'return confirm(\'Are you sure you want to delete this document?\');');?>
44 44
 		<? endif ?>
45 45
 	</div>
46 46
 <?}?>
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 function renderDocument($document, $cmsPrefix, $slugPrefix = '') {?>
8 8
 	<div class="grid-box-10">
9 9
 		<h3>
10
-			<a class="btn documentTitle" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix . $document->slug?>" title="Edit">
10
+			<a class="btn documentTitle" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix.$document->slug?>" title="Edit">
11 11
 				<i class="fa fa-file-text-o"></i>
12 12
 				<small class="state <?=strtolower($document->state)?>"><i class="fa <?=$document->state == 'published' ? 'fa-check-circle-o' : 'fa-times-circle-o' ?>"></i></small>
13 13
 				<?=$document->title?>
@@ -28,25 +28,25 @@  discard block
 block discarded – undo
28 28
 		<? if ($document->state == 'unpublished' || $document->unpublishedChanges) : ?>
29 29
             <?renderAction('Publish',
30 30
                 'publish',
31
-                \library\cc\Request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug,
32
-                'check');?>
31
+                \library\cc\Request::$subfolders.$cmsPrefix.'/documents/publish-document?slug='.$slugPrefix.$document->slug,
32
+                'check'); ?>
33 33
 		<? endif ?>
34 34
 		<? if ($document->state == 'published') : ?>
35 35
 			<?renderAction('Unpublish',
36 36
 				'unpublish',
37
-				\library\cc\Request::$subfolders . $cmsPrefix . '/documents/unpublish-document?slug=' . $slugPrefix . $document->slug,
38
-				'times');?>
37
+				\library\cc\Request::$subfolders.$cmsPrefix.'/documents/unpublish-document?slug='.$slugPrefix.$document->slug,
38
+				'times'); ?>
39 39
 		<? endif ?>
40 40
 		<?renderAction('Edit',
41 41
 			'',
42
-			\library\cc\Request::$subfolders . $cmsPrefix . '/documents/edit-document?slug=' . $slugPrefix . $document->slug,
43
-			'pencil');?>
42
+			\library\cc\Request::$subfolders.$cmsPrefix.'/documents/edit-document?slug='.$slugPrefix.$document->slug,
43
+			'pencil'); ?>
44 44
 		<? if ($document->state == 'unpublished') : ?>
45 45
 			<?renderAction('Delete',
46 46
 				'error',
47
-				\library\cc\Request::$subfolders . $cmsPrefix . '/documents/delete-document?slug=' . $slugPrefix . $document->slug,
47
+				\library\cc\Request::$subfolders.$cmsPrefix.'/documents/delete-document?slug='.$slugPrefix.$document->slug,
48 48
 				'trash',
49
-                'return confirm(\'Are you sure you want to delete this document?\');');?>
49
+                'return confirm(\'Are you sure you want to delete this document?\');'); ?>
50 50
 		<? endif ?>
51 51
 	</div>
52 52
 <?}?>
Please login to merge, or discard this patch.
cloudcontrol/library/storage/Repository.php 2 patches
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
             if (in_array($name, $this->fileBasedSubsets)) {
107 107
                 return $this->$name;
108 108
             } else {
109
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
109
+                throw new \Exception('Trying to get undefined property from Repository: '.$name);
110 110
             }
111 111
         } else {
112 112
             if (in_array($name, $this->fileBasedSubsets)) {
113 113
                 return $this->loadSubset($name);
114 114
             } else {
115
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
115
+                throw new \Exception('Trying to get undefined property from Repository: '.$name);
116 116
             }
117 117
         }
118 118
     }
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
     {
128 128
         if (in_array($name, $this->fileBasedSubsets)) {
129 129
             $this->$name = $value;
130
-            $changes = $name . 'Changes';
130
+            $changes = $name.'Changes';
131 131
             $this->$changes = true;
132 132
         } else {
133
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
133
+            throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>');
134 134
         }
135 135
     }
136 136
 
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
      */
140 140
     public function save()
141 141
     {
142
-        array_map(function ($value) {
142
+        array_map(function($value) {
143 143
         	$this->saveSubset($value);
144 144
 		}, $this->fileBasedSubsets);
145 145
     }
@@ -150,10 +150,10 @@  discard block
 block discarded – undo
150 150
      */
151 151
     protected function saveSubset($subset)
152 152
     {
153
-		$changes = $subset . 'Changes';
153
+		$changes = $subset.'Changes';
154 154
 		if ($this->$changes === true) {
155 155
 			$json = json_encode($this->$subset, JSON_PRETTY_PRINT);
156
-			$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
156
+			$subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
157 157
 			file_put_contents($subsetStoragePath, $json);
158 158
 
159 159
 			$this->$changes = false;
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
      */
168 168
     protected function loadSubset($subset)
169 169
     {
170
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
170
+        $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
171 171
         $json = file_get_contents($subsetStoragePath);
172 172
         $json = json_decode($json);
173 173
         $this->$subset = $json;
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     public function getContentDbHandle()
216 216
     {
217 217
         if ($this->contentDbHandle === null) {
218
-            $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db');
218
+            $this->contentDbHandle = new \PDO('sqlite:'.$this->storagePath.DIRECTORY_SEPARATOR.'content.db');
219 219
         }
220 220
         return $this->contentDbHandle;
221 221
     }
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
     public function getDocuments($state = 'published')
232 232
     {
233 233
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
234
-			throw new \Exception('Unsupported document state: ' . $state);
234
+			throw new \Exception('Unsupported document state: '.$state);
235 235
 		}
236 236
         return $this->getDocumentsByPath('/', $state);
237 237
     }
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	public function getDocumentsWithState($folderPath = '/')
240 240
 	{
241 241
 		$db = $this->getContentDbHandle();
242
-		$folderPathWithWildcard = $folderPath . '%';
242
+		$folderPathWithWildcard = $folderPath.'%';
243 243
 
244 244
 		$ifRootIndex = 1;
245 245
 		if ($folderPath == '/') {
@@ -254,10 +254,10 @@  discard block
 block discarded – undo
254 254
               FROM documents_unpublished
255 255
 		 LEFT JOIN documents_published
256 256
          		ON documents_published.path = documents_unpublished.path
257
-             WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard) . '
258
-               AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1) . ') NOT LIKE "%/%"
259
-               AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex) . '
260
-               AND documents_unpublished.path != ' . $db->quote($folderPath) . '
257
+             WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard).'
258
+               AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1).') NOT LIKE "%/%"
259
+               AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex).'
260
+               AND documents_unpublished.path != ' . $db->quote($folderPath).'
261 261
           ORDER BY documents_unpublished.`type` DESC, documents_unpublished.`path` ASC
262 262
         ';
263 263
 		$stmt = $this->getDbStatement($sql);
@@ -284,16 +284,16 @@  discard block
 block discarded – undo
284 284
     public function getDocumentsByPath($folderPath, $state = 'published')
285 285
     {
286 286
     	if (!in_array($state, Document::$DOCUMENT_STATES)) {
287
-    		throw new \Exception('Unsupported document state: ' . $state);
287
+    		throw new \Exception('Unsupported document state: '.$state);
288 288
 		}
289 289
         $db = $this->getContentDbHandle();
290
-        $folderPathWithWildcard = $folderPath . '%';
290
+        $folderPathWithWildcard = $folderPath.'%';
291 291
 
292 292
         $sql = 'SELECT *
293
-              FROM documents_' . $state . '
294
-             WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . '
295
-               AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%"
296
-               AND path != ' . $db->quote($folderPath) . '
293
+              FROM documents_' . $state.'
294
+             WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).'
295
+               AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%"
296
+               AND path != ' . $db->quote($folderPath).'
297 297
           ORDER BY `type` DESC, `path` ASC';
298 298
         $stmt = $this->getDbStatement($sql);
299 299
 
@@ -320,7 +320,7 @@  discard block
 block discarded – undo
320 320
         if ($containerPath === '/') {
321 321
             return $this->getRootFolder();
322 322
         }
323
-        if (substr($containerPath, -1) === '/'){
323
+        if (substr($containerPath, -1) === '/') {
324 324
 			$containerPath = substr($containerPath, 0, -1);
325 325
 		}
326 326
         $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished');
@@ -337,13 +337,13 @@  discard block
 block discarded – undo
337 337
     public function getDocumentByPath($path, $state = 'published')
338 338
     {
339 339
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
340
-			throw new \Exception('Unsupported document state: ' . $state);
340
+			throw new \Exception('Unsupported document state: '.$state);
341 341
 		}
342 342
         $db = $this->getContentDbHandle();
343 343
         $document = $this->fetchDocument('
344 344
             SELECT *
345
-              FROM documents_' .  $state . '
346
-             WHERE path = ' . $db->quote($path) . '
345
+              FROM documents_' .  $state.'
346
+             WHERE path = ' . $db->quote($path).'
347 347
         ');
348 348
         if ($document instanceof Document && $document->type === 'folder') {
349 349
             $document->dbHandle = $db;
@@ -363,16 +363,16 @@  discard block
 block discarded – undo
363 363
 	public function getTotalDocumentCount($state = 'published')
364 364
 	{
365 365
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
366
-			throw new \Exception('Unsupported document state: ' . $state);
366
+			throw new \Exception('Unsupported document state: '.$state);
367 367
 		}
368 368
 		$db = $this->getContentDbHandle();
369 369
 		$stmt = $db->query('
370 370
 			SELECT count(*)
371
-			  FROM documents_' . $state . '
371
+			  FROM documents_' . $state.'
372 372
 			 WHERE `type` != "folder"
373 373
 		');
374 374
 		$result = $stmt->fetch(\PDO::FETCH_ASSOC);
375
-		if (!is_array($result )) {
375
+		if (!is_array($result)) {
376 376
 			return 0;
377 377
 		}
378 378
 		return intval(current($result));
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 		if ($stmt === false || !$stmt->execute()) {
392 392
 			$errorInfo = $db->errorInfo();
393 393
 			$errorMsg = $errorInfo[2];
394
-			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
394
+			throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>');
395 395
 		}
396 396
 		return $result;
397 397
 	}
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
 			$sql = '
402 402
 				INSERT OR REPLACE INTO documents_published 
403 403
 					  (`id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`publicationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
404
-				SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time() . ' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`
404
+				SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time().' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`
405 405
 				  FROM documents_unpublished
406 406
 				 WHERE `path` = :path
407 407
 			';
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 		if ($stmt === false) {
415 415
 			$errorInfo = $db->errorInfo();
416 416
 			$errorMsg = $errorInfo[2];
417
-			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
417
+			throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>');
418 418
 		}
419 419
 		$stmt->bindValue(':path', $path);
420 420
 		$stmt->execute();
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
         if ($stmt === false) {
482 482
             $errorInfo = $db->errorInfo();
483 483
             $errorMsg = $errorInfo[2];
484
-            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
484
+            throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>');
485 485
         }
486 486
         return $stmt;
487 487
     }
@@ -511,25 +511,25 @@  discard block
 block discarded – undo
511 511
     public function saveDocument($documentObject, $state = 'published')
512 512
     {
513 513
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
514
-			throw new \Exception('Unsupported document state: ' . $state);
514
+			throw new \Exception('Unsupported document state: '.$state);
515 515
 		}
516 516
         $db = $this->getContentDbHandle();
517 517
         $stmt = $this->getDbStatement('
518
-            INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
518
+            INSERT OR REPLACE INTO documents_' . $state.' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
519 519
             VALUES(
520
-              ' . $db->quote($documentObject->path) . ',
521
-              ' . $db->quote($documentObject->title) . ',
522
-              ' . $db->quote($documentObject->slug) . ',
523
-              ' . $db->quote($documentObject->type) . ',
524
-              ' . $db->quote($documentObject->documentType) . ',
525
-              ' . $db->quote($documentObject->documentTypeSlug) . ',
526
-              ' . $db->quote($documentObject->state) . ',
527
-              ' . $db->quote($documentObject->lastModificationDate) . ',
528
-              ' . $db->quote($documentObject->creationDate) . ',
529
-              ' . $db->quote($documentObject->lastModifiedBy) . ',
530
-              ' . $db->quote(json_encode($documentObject->fields)) . ',
531
-              ' . $db->quote(json_encode($documentObject->bricks)) . ',
532
-              ' . $db->quote(json_encode($documentObject->dynamicBricks)) . '
520
+              ' . $db->quote($documentObject->path).',
521
+              ' . $db->quote($documentObject->title).',
522
+              ' . $db->quote($documentObject->slug).',
523
+              ' . $db->quote($documentObject->type).',
524
+              ' . $db->quote($documentObject->documentType).',
525
+              ' . $db->quote($documentObject->documentTypeSlug).',
526
+              ' . $db->quote($documentObject->state).',
527
+              ' . $db->quote($documentObject->lastModificationDate).',
528
+              ' . $db->quote($documentObject->creationDate).',
529
+              ' . $db->quote($documentObject->lastModifiedBy).',
530
+              ' . $db->quote(json_encode($documentObject->fields)).',
531
+              ' . $db->quote(json_encode($documentObject->bricks)).',
532
+              ' . $db->quote(json_encode($documentObject->dynamicBricks)).'
533 533
             )
534 534
         ');
535 535
         $result = $stmt->execute();
@@ -553,16 +553,16 @@  discard block
 block discarded – undo
553 553
             if ($documentToDelete->type == 'document') {
554 554
                 $stmt = $this->getDbStatement('
555 555
                     DELETE FROM documents_unpublished
556
-                          WHERE path = ' . $db->quote($path) . '
556
+                          WHERE path = ' . $db->quote($path).'
557 557
                 ');
558 558
                 $stmt->execute();
559 559
             } elseif ($documentToDelete->type == 'folder') {
560
-                $folderPathWithWildcard = $path . '%';
560
+                $folderPathWithWildcard = $path.'%';
561 561
                 $stmt = $this->getDbStatement('
562 562
                     DELETE FROM documents_unpublished
563
-                          WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . '
564
-                            AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/")
565
-                            OR path = ' . $db->quote($path) . '
563
+                          WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).'
564
+                            AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/")
565
+                            OR path = ' . $db->quote($path).'
566 566
                 ');
567 567
                 $stmt->execute();
568 568
             }
Please login to merge, or discard this patch.
Indentation   +319 added lines, -319 removed lines patch added patch discarded remove patch
@@ -24,141 +24,141 @@  discard block
 block discarded – undo
24 24
  */
25 25
 class Repository
26 26
 {
27
-    protected $storagePath;
28
-
29
-    protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users', 'valuelists', 'redirects');
30
-
31
-    protected $sitemap;
32
-    protected $sitemapChanges = false;
33
-
34
-    protected $applicationComponents;
35
-    protected $applicationComponentsChanges = false;
36
-
37
-    protected $documentTypes;
38
-    protected $documentTypesChanges = false;
39
-
40
-    protected $bricks;
41
-    protected $bricksChanges = false;
42
-
43
-    protected $imageSet;
44
-    protected $imageSetChanges = false;
45
-
46
-    protected $images;
47
-    protected $imagesChanges = false;
48
-
49
-    protected $files;
50
-    protected $filesChanges = false;
51
-
52
-    protected $users;
53
-    protected $usersChanges = false;
54
-
55
-    protected $valuelists;
56
-    protected $valuelistsChanges = false;
57
-
58
-    protected $redirects;
59
-    protected $redirectsChanges = false;
60
-
61
-    protected $contentDbHandle;
62
-
63
-
64
-    /**
65
-     * Repository constructor.
66
-     * @param $storagePath
67
-     * @throws \Exception
68
-     */
69
-    public function __construct($storagePath)
70
-    {
71
-        $storagePath = realpath($storagePath);
72
-        if (is_dir($storagePath) && $storagePath !== false) {
73
-            $this->storagePath = $storagePath;
74
-        } else {
75
-            throw new \Exception('Repository not yet initialized.');
76
-        }
77
-    }
78
-
79
-    /**
80
-     * Creates the folder in which to create all storage related files
81
-     *
82
-     * @param $storagePath
83
-     * @return bool
84
-     */
85
-    public static function create($storagePath)
86
-    {
87
-        return mkdir($storagePath);
88
-    }
89
-
90
-    /**
91
-     * Initiates default storage
92
-     * @throws \Exception
93
-     */
94
-    public function init()
95
-    {
96
-        $storageDefaultPath = realpath('../library/cc/install/_storage.json');
97
-        $contentSqlPath = realpath('../library/cc/install/content.sql');
98
-
99
-        $this->initConfigStorage($storageDefaultPath);
100
-        $this->initContentDb($contentSqlPath);
101
-
102
-        $this->save();
103
-    }
104
-
105
-    /**
106
-     * Load filebased subset and return it's contents
107
-     *
108
-     * @param $name
109
-     * @return mixed|string
110
-     * @throws \Exception
111
-     */
112
-    public function __get($name)
113
-    {
114
-        if (isset($this->$name)) {
115
-            if (in_array($name, $this->fileBasedSubsets)) {
116
-                return $this->$name;
117
-            } else {
118
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
119
-            }
120
-        } else {
121
-            if (in_array($name, $this->fileBasedSubsets)) {
122
-                return $this->loadSubset($name);
123
-            } else {
124
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
125
-            }
126
-        }
127
-    }
128
-
129
-    /**
130
-     * Set filebased subset contents
131
-     * @param $name
132
-     * @param $value
133
-     * @throws \Exception
134
-     */
135
-    public function __set($name, $value)
136
-    {
137
-        if (in_array($name, $this->fileBasedSubsets)) {
138
-            $this->$name = $value;
139
-            $changes = $name . 'Changes';
140
-            $this->$changes = true;
141
-        } else {
142
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
143
-        }
144
-    }
145
-
146
-    /**
147
-     * Persist all subsets
148
-     */
149
-    public function save()
150
-    {
151
-        array_map(function ($value) {
152
-        	$this->saveSubset($value);
27
+	protected $storagePath;
28
+
29
+	protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users', 'valuelists', 'redirects');
30
+
31
+	protected $sitemap;
32
+	protected $sitemapChanges = false;
33
+
34
+	protected $applicationComponents;
35
+	protected $applicationComponentsChanges = false;
36
+
37
+	protected $documentTypes;
38
+	protected $documentTypesChanges = false;
39
+
40
+	protected $bricks;
41
+	protected $bricksChanges = false;
42
+
43
+	protected $imageSet;
44
+	protected $imageSetChanges = false;
45
+
46
+	protected $images;
47
+	protected $imagesChanges = false;
48
+
49
+	protected $files;
50
+	protected $filesChanges = false;
51
+
52
+	protected $users;
53
+	protected $usersChanges = false;
54
+
55
+	protected $valuelists;
56
+	protected $valuelistsChanges = false;
57
+
58
+	protected $redirects;
59
+	protected $redirectsChanges = false;
60
+
61
+	protected $contentDbHandle;
62
+
63
+
64
+	/**
65
+	 * Repository constructor.
66
+	 * @param $storagePath
67
+	 * @throws \Exception
68
+	 */
69
+	public function __construct($storagePath)
70
+	{
71
+		$storagePath = realpath($storagePath);
72
+		if (is_dir($storagePath) && $storagePath !== false) {
73
+			$this->storagePath = $storagePath;
74
+		} else {
75
+			throw new \Exception('Repository not yet initialized.');
76
+		}
77
+	}
78
+
79
+	/**
80
+	 * Creates the folder in which to create all storage related files
81
+	 *
82
+	 * @param $storagePath
83
+	 * @return bool
84
+	 */
85
+	public static function create($storagePath)
86
+	{
87
+		return mkdir($storagePath);
88
+	}
89
+
90
+	/**
91
+	 * Initiates default storage
92
+	 * @throws \Exception
93
+	 */
94
+	public function init()
95
+	{
96
+		$storageDefaultPath = realpath('../library/cc/install/_storage.json');
97
+		$contentSqlPath = realpath('../library/cc/install/content.sql');
98
+
99
+		$this->initConfigStorage($storageDefaultPath);
100
+		$this->initContentDb($contentSqlPath);
101
+
102
+		$this->save();
103
+	}
104
+
105
+	/**
106
+	 * Load filebased subset and return it's contents
107
+	 *
108
+	 * @param $name
109
+	 * @return mixed|string
110
+	 * @throws \Exception
111
+	 */
112
+	public function __get($name)
113
+	{
114
+		if (isset($this->$name)) {
115
+			if (in_array($name, $this->fileBasedSubsets)) {
116
+				return $this->$name;
117
+			} else {
118
+				throw new \Exception('Trying to get undefined property from Repository: ' . $name);
119
+			}
120
+		} else {
121
+			if (in_array($name, $this->fileBasedSubsets)) {
122
+				return $this->loadSubset($name);
123
+			} else {
124
+				throw new \Exception('Trying to get undefined property from Repository: ' . $name);
125
+			}
126
+		}
127
+	}
128
+
129
+	/**
130
+	 * Set filebased subset contents
131
+	 * @param $name
132
+	 * @param $value
133
+	 * @throws \Exception
134
+	 */
135
+	public function __set($name, $value)
136
+	{
137
+		if (in_array($name, $this->fileBasedSubsets)) {
138
+			$this->$name = $value;
139
+			$changes = $name . 'Changes';
140
+			$this->$changes = true;
141
+		} else {
142
+			throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
143
+		}
144
+	}
145
+
146
+	/**
147
+	 * Persist all subsets
148
+	 */
149
+	public function save()
150
+	{
151
+		array_map(function ($value) {
152
+			$this->saveSubset($value);
153 153
 		}, $this->fileBasedSubsets);
154
-    }
155
-
156
-    /**
157
-     * Persist subset to disk
158
-     * @param $subset
159
-     */
160
-    protected function saveSubset($subset)
161
-    {
154
+	}
155
+
156
+	/**
157
+	 * Persist subset to disk
158
+	 * @param $subset
159
+	 */
160
+	protected function saveSubset($subset)
161
+	{
162 162
 		$changes = $subset . 'Changes';
163 163
 		if ($this->$changes === true) {
164 164
 			$json = json_encode($this->$subset, JSON_PRETTY_PRINT);
@@ -167,69 +167,69 @@  discard block
 block discarded – undo
167 167
 
168 168
 			$this->$changes = false;
169 169
 		}
170
-    }
171
-
172
-    /**
173
-     * Load subset from disk
174
-     * @param $subset
175
-     * @return mixed|string
176
-     */
177
-    protected function loadSubset($subset)
178
-    {
179
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
180
-        $json = file_get_contents($subsetStoragePath);
181
-        $json = json_decode($json);
182
-        $this->$subset = $json;
183
-        return $json;
184
-    }
185
-
186
-    /**
187
-     * @param $contentSqlPath
188
-     */
189
-    protected function initContentDb($contentSqlPath)
190
-    {
191
-        $db = $this->getContentDbHandle();
192
-        $sql = file_get_contents($contentSqlPath);
193
-        $db->exec($sql);
194
-    }
195
-
196
-    /**
197
-     * @param $storageDefaultPath
198
-     */
199
-    protected function initConfigStorage($storageDefaultPath)
200
-    {
201
-        $json = file_get_contents($storageDefaultPath);
202
-        $json = json_decode($json);
203
-        $this->sitemap = $json->sitemap;
204
-        $this->sitemapChanges = true;
205
-        $this->applicationComponents = $json->applicationComponents;
206
-        $this->applicationComponentsChanges = true;
207
-        $this->documentTypes = $json->documentTypes;
208
-        $this->documentTypesChanges = true;
209
-        $this->bricks = $json->bricks;
210
-        $this->bricksChanges = true;
211
-        $this->imageSet = $json->imageSet;
212
-        $this->imageSetChanges = true;
213
-        $this->images = $json->images;
214
-        $this->imagesChanges = true;
215
-        $this->files = $json->files;
216
-        $this->filesChanges = true;
217
-        $this->users = $json->users;
218
-        $this->usersChanges = true;
219
-        $this->valuelists = $json->valuelists;
220
-        $this->valuelistsChanges = true;
221
-    }
222
-
223
-    /**
224
-     * @return \PDO
225
-     */
226
-    public function getContentDbHandle()
227
-    {
228
-        if ($this->contentDbHandle === null) {
229
-            $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db');
230
-        }
231
-        return $this->contentDbHandle;
232
-    }
170
+	}
171
+
172
+	/**
173
+	 * Load subset from disk
174
+	 * @param $subset
175
+	 * @return mixed|string
176
+	 */
177
+	protected function loadSubset($subset)
178
+	{
179
+		$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
180
+		$json = file_get_contents($subsetStoragePath);
181
+		$json = json_decode($json);
182
+		$this->$subset = $json;
183
+		return $json;
184
+	}
185
+
186
+	/**
187
+	 * @param $contentSqlPath
188
+	 */
189
+	protected function initContentDb($contentSqlPath)
190
+	{
191
+		$db = $this->getContentDbHandle();
192
+		$sql = file_get_contents($contentSqlPath);
193
+		$db->exec($sql);
194
+	}
195
+
196
+	/**
197
+	 * @param $storageDefaultPath
198
+	 */
199
+	protected function initConfigStorage($storageDefaultPath)
200
+	{
201
+		$json = file_get_contents($storageDefaultPath);
202
+		$json = json_decode($json);
203
+		$this->sitemap = $json->sitemap;
204
+		$this->sitemapChanges = true;
205
+		$this->applicationComponents = $json->applicationComponents;
206
+		$this->applicationComponentsChanges = true;
207
+		$this->documentTypes = $json->documentTypes;
208
+		$this->documentTypesChanges = true;
209
+		$this->bricks = $json->bricks;
210
+		$this->bricksChanges = true;
211
+		$this->imageSet = $json->imageSet;
212
+		$this->imageSetChanges = true;
213
+		$this->images = $json->images;
214
+		$this->imagesChanges = true;
215
+		$this->files = $json->files;
216
+		$this->filesChanges = true;
217
+		$this->users = $json->users;
218
+		$this->usersChanges = true;
219
+		$this->valuelists = $json->valuelists;
220
+		$this->valuelistsChanges = true;
221
+	}
222
+
223
+	/**
224
+	 * @return \PDO
225
+	 */
226
+	public function getContentDbHandle()
227
+	{
228
+		if ($this->contentDbHandle === null) {
229
+			$this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db');
230
+		}
231
+		return $this->contentDbHandle;
232
+	}
233 233
 
234 234
 	/**
235 235
 	 * Get all documents
@@ -239,13 +239,13 @@  discard block
 block discarded – undo
239 239
 	 * @return array
240 240
 	 * @throws \Exception
241 241
 	 */
242
-    public function getDocuments($state = 'published')
243
-    {
242
+	public function getDocuments($state = 'published')
243
+	{
244 244
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
245 245
 			throw new \Exception('Unsupported document state: ' . $state);
246 246
 		}
247
-        return $this->getDocumentsByPath('/', $state);
248
-    }
247
+		return $this->getDocumentsByPath('/', $state);
248
+	}
249 249
 
250 250
 	public function getDocumentsWithState($folderPath = '/')
251 251
 	{
@@ -292,51 +292,51 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 * @throws \Exception
294 294
 	 */
295
-    public function getDocumentsByPath($folderPath, $state = 'published')
296
-    {
297
-    	if (!in_array($state, Document::$DOCUMENT_STATES)) {
298
-    		throw new \Exception('Unsupported document state: ' . $state);
295
+	public function getDocumentsByPath($folderPath, $state = 'published')
296
+	{
297
+		if (!in_array($state, Document::$DOCUMENT_STATES)) {
298
+			throw new \Exception('Unsupported document state: ' . $state);
299 299
 		}
300
-        $db = $this->getContentDbHandle();
301
-        $folderPathWithWildcard = $folderPath . '%';
300
+		$db = $this->getContentDbHandle();
301
+		$folderPathWithWildcard = $folderPath . '%';
302 302
 
303
-        $sql = 'SELECT *
303
+		$sql = 'SELECT *
304 304
               FROM documents_' . $state . '
305 305
              WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . '
306 306
                AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%"
307 307
                AND path != ' . $db->quote($folderPath) . '
308 308
           ORDER BY `type` DESC, `path` ASC';
309
-        $stmt = $this->getDbStatement($sql);
309
+		$stmt = $this->getDbStatement($sql);
310 310
 
311
-        $documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
312
-        foreach ($documents as $key => $document) {
311
+		$documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
312
+		foreach ($documents as $key => $document) {
313 313
 			$documents = $this->setAssetsToDocumentFolders($document, $db, $documents, $key);
314
-        }
315
-        return $documents;
316
-    }
317
-
318
-
319
-    /**
320
-     * @param $path
321
-     * @return bool|Document
322
-     */
323
-    public function getDocumentContainerByPath($path)
324
-    {
325
-        $document = $this->getDocumentByPath($path, 'unpublished');
326
-        if ($document === false) {
327
-            return false;
328
-        }
329
-        $slugLength = strlen($document->slug);
330
-        $containerPath = substr($path, 0, -$slugLength);
331
-        if ($containerPath === '/') {
332
-            return $this->getRootFolder();
333
-        }
334
-        if (substr($containerPath, -1) === '/'){
314
+		}
315
+		return $documents;
316
+	}
317
+
318
+
319
+	/**
320
+	 * @param $path
321
+	 * @return bool|Document
322
+	 */
323
+	public function getDocumentContainerByPath($path)
324
+	{
325
+		$document = $this->getDocumentByPath($path, 'unpublished');
326
+		if ($document === false) {
327
+			return false;
328
+		}
329
+		$slugLength = strlen($document->slug);
330
+		$containerPath = substr($path, 0, -$slugLength);
331
+		if ($containerPath === '/') {
332
+			return $this->getRootFolder();
333
+		}
334
+		if (substr($containerPath, -1) === '/'){
335 335
 			$containerPath = substr($containerPath, 0, -1);
336 336
 		}
337
-        $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished');
338
-        return $containerFolder;
339
-    }
337
+		$containerFolder = $this->getDocumentByPath($containerPath, 'unpublished');
338
+		return $containerFolder;
339
+	}
340 340
 
341 341
 	/**
342 342
 	 * @param        $path
@@ -345,23 +345,23 @@  discard block
 block discarded – undo
345 345
 	 * @return bool|\library\storage\Document
346 346
 	 * @throws \Exception
347 347
 	 */
348
-    public function getDocumentByPath($path, $state = 'published')
349
-    {
348
+	public function getDocumentByPath($path, $state = 'published')
349
+	{
350 350
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
351 351
 			throw new \Exception('Unsupported document state: ' . $state);
352 352
 		}
353
-        $db = $this->getContentDbHandle();
354
-        $document = $this->fetchDocument('
353
+		$db = $this->getContentDbHandle();
354
+		$document = $this->fetchDocument('
355 355
             SELECT *
356 356
               FROM documents_' .  $state . '
357 357
              WHERE path = ' . $db->quote($path) . '
358 358
         ');
359
-        if ($document instanceof Document && $document->type === 'folder') {
360
-            $document->dbHandle = $db;
361
-            $document->documentStorage = new DocumentStorage($this);
362
-        }
363
-        return $document;
364
-    }
359
+		if ($document instanceof Document && $document->type === 'folder') {
360
+			$document->dbHandle = $db;
361
+			$document->documentStorage = new DocumentStorage($this);
362
+		}
363
+		return $document;
364
+	}
365 365
 
366 366
 	/**
367 367
 	 * Returns the count of all documents stored in the db
@@ -456,58 +456,58 @@  discard block
 block discarded – undo
456 456
 	}
457 457
 
458 458
 	/**
459
-     * Return the results of the query as array of Documents
460
-     * @param $sql
461
-     * @return array
462
-     * @throws \Exception
463
-     */
464
-    protected function fetchAllDocuments($sql)
465
-    {
466
-        $stmt = $this->getDbStatement($sql);
467
-        return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
468
-    }
469
-
470
-    /**
471
-     * Return the result of the query as Document
472
-     * @param $sql
473
-     * @return mixed
474
-     * @throws \Exception
475
-     */
476
-    protected function fetchDocument($sql)
477
-    {
478
-        $stmt = $this->getDbStatement($sql);
479
-        return $stmt->fetchObject('\library\storage\Document');
480
-    }
481
-
482
-    /**
483
-     * Prepare the sql statement
484
-     * @param $sql
485
-     * @return \PDOStatement
486
-     * @throws \Exception
487
-     */
488
-    protected function getDbStatement($sql)
489
-    {
490
-        $db = $this->getContentDbHandle();
491
-        $stmt = $db->query($sql);
492
-        if ($stmt === false) {
493
-            $errorInfo = $db->errorInfo();
494
-            $errorMsg = $errorInfo[2];
495
-            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
496
-        }
497
-        return $stmt;
498
-    }
499
-
500
-    /**
501
-     * Create a (non-existent) root folder Document and return it
502
-     * @return Document
503
-     */
504
-    protected function getRootFolder()
505
-    {
506
-        $rootFolder = new Document();
507
-        $rootFolder->path = '/';
508
-        $rootFolder->type = 'folder';
509
-        return $rootFolder;
510
-    }
459
+	 * Return the results of the query as array of Documents
460
+	 * @param $sql
461
+	 * @return array
462
+	 * @throws \Exception
463
+	 */
464
+	protected function fetchAllDocuments($sql)
465
+	{
466
+		$stmt = $this->getDbStatement($sql);
467
+		return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document');
468
+	}
469
+
470
+	/**
471
+	 * Return the result of the query as Document
472
+	 * @param $sql
473
+	 * @return mixed
474
+	 * @throws \Exception
475
+	 */
476
+	protected function fetchDocument($sql)
477
+	{
478
+		$stmt = $this->getDbStatement($sql);
479
+		return $stmt->fetchObject('\library\storage\Document');
480
+	}
481
+
482
+	/**
483
+	 * Prepare the sql statement
484
+	 * @param $sql
485
+	 * @return \PDOStatement
486
+	 * @throws \Exception
487
+	 */
488
+	protected function getDbStatement($sql)
489
+	{
490
+		$db = $this->getContentDbHandle();
491
+		$stmt = $db->query($sql);
492
+		if ($stmt === false) {
493
+			$errorInfo = $db->errorInfo();
494
+			$errorMsg = $errorInfo[2];
495
+			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
496
+		}
497
+		return $stmt;
498
+	}
499
+
500
+	/**
501
+	 * Create a (non-existent) root folder Document and return it
502
+	 * @return Document
503
+	 */
504
+	protected function getRootFolder()
505
+	{
506
+		$rootFolder = new Document();
507
+		$rootFolder->path = '/';
508
+		$rootFolder->type = 'folder';
509
+		return $rootFolder;
510
+	}
511 511
 
512 512
 	/**
513 513
 	 * Save the document to the database
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 	 * @throws \Exception
520 520
 	 * @internal param $path
521 521
 	 */
522
-    public function saveDocument($documentObject, $state = 'published')
523
-    {
522
+	public function saveDocument($documentObject, $state = 'published')
523
+	{
524 524
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
525 525
 			throw new \Exception('Unsupported document state: ' . $state);
526 526
 		}
527
-        $db = $this->getContentDbHandle();
528
-        $stmt = $this->getDbStatement('
527
+		$db = $this->getContentDbHandle();
528
+		$stmt = $this->getDbStatement('
529 529
             INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
530 530
             VALUES(
531 531
               ' . $db->quote($documentObject->path) . ',
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
               ' . $db->quote(json_encode($documentObject->dynamicBricks)) . '
544 544
             )
545 545
         ');
546
-        $result = $stmt->execute();
547
-        return $result;
548
-    }
546
+		$result = $stmt->execute();
547
+		return $result;
548
+	}
549 549
 
550 550
 	/**
551 551
 	 * Delete the document from the database
@@ -556,29 +556,29 @@  discard block
 block discarded – undo
556 556
 	 * @internal param string $state
557 557
 	 *
558 558
 	 */
559
-    public function deleteDocumentByPath($path)
560
-    {
561
-        $db = $this->getContentDbHandle();
562
-        $documentToDelete = $this->getDocumentByPath($path, 'unpublished');
563
-        if ($documentToDelete instanceof Document) {
564
-            if ($documentToDelete->type == 'document') {
565
-                $stmt = $this->getDbStatement('
559
+	public function deleteDocumentByPath($path)
560
+	{
561
+		$db = $this->getContentDbHandle();
562
+		$documentToDelete = $this->getDocumentByPath($path, 'unpublished');
563
+		if ($documentToDelete instanceof Document) {
564
+			if ($documentToDelete->type == 'document') {
565
+				$stmt = $this->getDbStatement('
566 566
                     DELETE FROM documents_unpublished
567 567
                           WHERE path = ' . $db->quote($path) . '
568 568
                 ');
569
-                $stmt->execute();
570
-            } elseif ($documentToDelete->type == 'folder') {
571
-                $folderPathWithWildcard = $path . '%';
572
-                $stmt = $this->getDbStatement('
569
+				$stmt->execute();
570
+			} elseif ($documentToDelete->type == 'folder') {
571
+				$folderPathWithWildcard = $path . '%';
572
+				$stmt = $this->getDbStatement('
573 573
                     DELETE FROM documents_unpublished
574 574
                           WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . '
575 575
                             AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/")
576 576
                             OR path = ' . $db->quote($path) . '
577 577
                 ');
578
-                $stmt->execute();
579
-            }
580
-        }
581
-    }
578
+				$stmt->execute();
579
+			}
580
+		}
581
+	}
582 582
 
583 583
 	/**
584 584
 	 * @param $document
Please login to merge, or discard this patch.
cloudcontrol/templates/cms/documents/function.renderFolder.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,10 +5,10 @@  discard block
 block discarded – undo
5 5
  * @param string                    $slugPrefix
6 6
  * @param bool                      $root
7 7
  */
8
-function renderFolder($document, $cmsPrefix, $slugPrefix ='', $root = false) {?>
8
+function renderFolder($document, $cmsPrefix, $slugPrefix = '', $root = false) {?>
9 9
 	<div class="grid-box-8">
10 10
 		<h3>
11
-			<a class="btn documentTitle openFolder" data-slug="<?=$slugPrefix . $document->slug?>" title="Open">
11
+			<a class="btn documentTitle openFolder" data-slug="<?=$slugPrefix.$document->slug?>" title="Open">
12 12
 				<i class="fa fa-folder-o "></i> <?=$document->title?>
13 13
 			</a>
14 14
 		</h3>
@@ -16,21 +16,21 @@  discard block
 block discarded – undo
16 16
 	<div class="documentActions grid-box-4">
17 17
 		<?renderAction('Edit',
18 18
 			'',
19
-			\library\cc\Request::$subfolders . $cmsPrefix . '/documents/edit-folder?slug=' . $slugPrefix . $document->slug,
20
-			'pencil');?>
19
+			\library\cc\Request::$subfolders.$cmsPrefix.'/documents/edit-folder?slug='.$slugPrefix.$document->slug,
20
+			'pencil'); ?>
21 21
 		<?renderAction('Delete',
22 22
 			'error',
23
-			\library\cc\Request::$subfolders . $cmsPrefix . '/documents/delete-folder?slug=' . $slugPrefix . $document->slug,
23
+			\library\cc\Request::$subfolders.$cmsPrefix.'/documents/delete-folder?slug='.$slugPrefix.$document->slug,
24 24
 			'trash',
25
-			'return confirm(\'Are you sure you want to delete this document?\');');?>
25
+			'return confirm(\'Are you sure you want to delete this document?\');'); ?>
26 26
 	</div>
27 27
 	<ul class="documents grid-wrapper nested<?=$root ? ' root' : '' ?>">
28 28
 		<? foreach ($document->content as $subDocument) : ?>
29 29
 			<li class="grid-container">
30 30
 				<? if ($subDocument->type == 'document') : ?>
31
-					<?renderDocument($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/');?>
31
+					<?renderDocument($subDocument, $cmsPrefix, $slugPrefix.$document->slug.'/'); ?>
32 32
 				<? elseif ($subDocument->type == 'folder') : ?>
33
-					<?renderFolder($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/');?>
33
+					<?renderFolder($subDocument, $cmsPrefix, $slugPrefix.$document->slug.'/'); ?>
34 34
 				<? endif ?>
35 35
 			</li>
36 36
 		<? endforeach ?>
Please login to merge, or discard this patch.
cloudcontrol/library/storage/storage/ValuelistsStorage.php 1 patch
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -12,83 +12,83 @@
 block discarded – undo
12 12
 
13 13
 class ValuelistsStorage extends AbstractStorage
14 14
 {
15
-    /**
16
-     * Get all valuelists
17
-     *
18
-     * @return mixed
19
-     */
20
-    public function getValuelists()
21
-    {
22
-        return $this->repository->valuelists;
23
-    }
15
+	/**
16
+	 * Get all valuelists
17
+	 *
18
+	 * @return mixed
19
+	 */
20
+	public function getValuelists()
21
+	{
22
+		return $this->repository->valuelists;
23
+	}
24 24
 
25
-    public function addValuelist($postValues)
26
-    {
27
-        $valueListObject = ValuelistFactory::createValuelistFromPostValues($postValues);
28
-        $valuelists = $this->repository->valuelists;
29
-        $valuelists[] = $valueListObject;
30
-        $this->repository->valuelists = $valuelists;
31
-        $this->save();
32
-    }
25
+	public function addValuelist($postValues)
26
+	{
27
+		$valueListObject = ValuelistFactory::createValuelistFromPostValues($postValues);
28
+		$valuelists = $this->repository->valuelists;
29
+		$valuelists[] = $valueListObject;
30
+		$this->repository->valuelists = $valuelists;
31
+		$this->save();
32
+	}
33 33
 
34
-    /**
35
-     * Save changes to a valuelist
36
-     *
37
-     * @param $slug
38
-     * @param $postValues
39
-     *
40
-     * @throws \Exception
41
-     */
42
-    public function saveValuelist($slug, $postValues)
43
-    {
44
-        $valuelistObject = ValuelistFactory::createValuelistFromPostValues($postValues);
34
+	/**
35
+	 * Save changes to a valuelist
36
+	 *
37
+	 * @param $slug
38
+	 * @param $postValues
39
+	 *
40
+	 * @throws \Exception
41
+	 */
42
+	public function saveValuelist($slug, $postValues)
43
+	{
44
+		$valuelistObject = ValuelistFactory::createValuelistFromPostValues($postValues);
45 45
 
46
-        $valuelists = $this->repository->valuelists;
47
-        foreach ($valuelists as $key => $valuelist) {
48
-            if ($valuelist->slug == $slug) {
49
-                $valuelists[$key] = $valuelistObject;
50
-            }
51
-        }
52
-        $this->repository->valuelists = $valuelists;
53
-        $this->save();
54
-    }
46
+		$valuelists = $this->repository->valuelists;
47
+		foreach ($valuelists as $key => $valuelist) {
48
+			if ($valuelist->slug == $slug) {
49
+				$valuelists[$key] = $valuelistObject;
50
+			}
51
+		}
52
+		$this->repository->valuelists = $valuelists;
53
+		$this->save();
54
+	}
55 55
 
56
-    /**
57
-     * Get a valuelist by its slug
58
-     *
59
-     * @param $slug
60
-     *
61
-     * @return mixed
62
-     */
63
-    public function getValuelistBySlug($slug)
64
-    {
65
-        $valuelists = $this->repository->valuelists;
66
-        foreach ($valuelists as $valuelist) {
67
-            if ($valuelist->slug == $slug) {
68
-                return $valuelist;
69
-            }
70
-        }
56
+	/**
57
+	 * Get a valuelist by its slug
58
+	 *
59
+	 * @param $slug
60
+	 *
61
+	 * @return mixed
62
+	 */
63
+	public function getValuelistBySlug($slug)
64
+	{
65
+		$valuelists = $this->repository->valuelists;
66
+		foreach ($valuelists as $valuelist) {
67
+			if ($valuelist->slug == $slug) {
68
+				return $valuelist;
69
+			}
70
+		}
71 71
 
72
-        return null;
73
-    }
72
+		return null;
73
+	}
74 74
 
75
-    /**
76
-     * Delete a sitemap item by its slug
77
-     *
78
-     * @param $slug
79
-     *
80
-     * @throws \Exception
81
-     */
82
-    public function deleteValuelistBySlug($slug)
83
-    {
84
-        $valuelists = $this->repository->valuelists;
85
-        foreach ($valuelists as $key => $valuelist) {
86
-            if ($valuelist->slug == $slug) {
87
-                unset($valuelists[$key]);
88
-            }
89
-        }
90
-        $valuelists = array_values($valuelists);
91
-        $this->repository->valuelists = $valuelists;
92
-        $this->save();
93
-    }
75
+	/**
76
+	 * Delete a sitemap item by its slug
77
+	 *
78
+	 * @param $slug
79
+	 *
80
+	 * @throws \Exception
81
+	 */
82
+	public function deleteValuelistBySlug($slug)
83
+	{
84
+		$valuelists = $this->repository->valuelists;
85
+		foreach ($valuelists as $key => $valuelist) {
86
+			if ($valuelist->slug == $slug) {
87
+				unset($valuelists[$key]);
88
+			}
89
+		}
90
+		$valuelists = array_values($valuelists);
91
+		$this->repository->valuelists = $valuelists;
92
+		$this->save();
93
+	}
94 94
 }
95 95
\ No newline at end of file
Please login to merge, or discard this patch.
cloudcontrol/library/storage/factories/ValuelistFactory.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -12,34 +12,34 @@
 block discarded – undo
12 12
 
13 13
 class ValuelistFactory
14 14
 {
15
-    /**
16
-     * Create a sitemap item from post values
17
-     *
18
-     * @param $postValues
19
-     *
20
-     * @return \stdClass
21
-     * @throws \Exception
22
-     */
23
-    public static function createValuelistFromPostValues($postValues)
24
-    {
25
-        if (isset($postValues['title'])) {
26
-            $valuelistObject = new \stdClass();
27
-            $valuelistObject->title = $postValues['title'];
28
-            $valuelistObject->slug = StringUtil::slugify($postValues['title']);
29
-            $valuelistObject->pairs = new \stdClass();
30
-            if (isset($postValues['keys'], $postValues['values'])) {
31
-                foreach ($postValues['keys'] as $key => $value) {
32
-                    $valuelistObject->pairs->$value = $postValues['values'][$key];
33
-                }
34
-            }
35
-            $object_vars = get_object_vars($valuelistObject->pairs);
36
-            ksort($object_vars);
37
-            $valuelistObject->pairs = (object) $object_vars;
15
+	/**
16
+	 * Create a sitemap item from post values
17
+	 *
18
+	 * @param $postValues
19
+	 *
20
+	 * @return \stdClass
21
+	 * @throws \Exception
22
+	 */
23
+	public static function createValuelistFromPostValues($postValues)
24
+	{
25
+		if (isset($postValues['title'])) {
26
+			$valuelistObject = new \stdClass();
27
+			$valuelistObject->title = $postValues['title'];
28
+			$valuelistObject->slug = StringUtil::slugify($postValues['title']);
29
+			$valuelistObject->pairs = new \stdClass();
30
+			if (isset($postValues['keys'], $postValues['values'])) {
31
+				foreach ($postValues['keys'] as $key => $value) {
32
+					$valuelistObject->pairs->$value = $postValues['values'][$key];
33
+				}
34
+			}
35
+			$object_vars = get_object_vars($valuelistObject->pairs);
36
+			ksort($object_vars);
37
+			$valuelistObject->pairs = (object) $object_vars;
38 38
 
39
-            return $valuelistObject;
40
-        } else {
41
-            throw new \Exception('Trying to create valuelist with invalid data.');
42
-        }
43
-    }
39
+			return $valuelistObject;
40
+		} else {
41
+			throw new \Exception('Trying to create valuelist with invalid data.');
42
+		}
43
+	}
44 44
 
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
cloudcontrol/library/components/cms/DocumentRouting.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -12,33 +12,33 @@  discard block
 block discarded – undo
12 12
 
13 13
 class DocumentRouting implements CmsRouting
14 14
 {
15
-    /**
16
-     * DocumentRouting constructor.
17
-     * @param $request
18
-     * @param $relativeCmsUri
19
-     * @param CmsComponent $cmsComponent
20
-     */
21
-    public function __construct($request, $relativeCmsUri, $cmsComponent)
22
-    {
23
-        if ($relativeCmsUri == '/documents') {
24
-            $cmsComponent->subTemplate = 'cms/documents';
25
-            $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments()->getDocumentsWithState());
26
-            $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
27
-        }
28
-        $this->documentRouting($request, $relativeCmsUri, $cmsComponent);
29
-        $this->folderRouting($request, $relativeCmsUri, $cmsComponent);
15
+	/**
16
+	 * DocumentRouting constructor.
17
+	 * @param $request
18
+	 * @param $relativeCmsUri
19
+	 * @param CmsComponent $cmsComponent
20
+	 */
21
+	public function __construct($request, $relativeCmsUri, $cmsComponent)
22
+	{
23
+		if ($relativeCmsUri == '/documents') {
24
+			$cmsComponent->subTemplate = 'cms/documents';
25
+			$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments()->getDocumentsWithState());
26
+			$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
27
+		}
28
+		$this->documentRouting($request, $relativeCmsUri, $cmsComponent);
29
+		$this->folderRouting($request, $relativeCmsUri, $cmsComponent);
30 30
 		$this->valuelistsRouting($request, $relativeCmsUri, $cmsComponent);
31
-    }
31
+	}
32 32
 
33 33
 
34
-    /**
35
-     * @param $request
36
-     * @param $relativeCmsUri
37
-     * @param CmsComponent $cmsComponent
38
-     * @throws \Exception
39
-     */
40
-    private function documentRouting($request, $relativeCmsUri, $cmsComponent)
41
-    {
34
+	/**
35
+	 * @param $request
36
+	 * @param $relativeCmsUri
37
+	 * @param CmsComponent $cmsComponent
38
+	 * @throws \Exception
39
+	 */
40
+	private function documentRouting($request, $relativeCmsUri, $cmsComponent)
41
+	{
42 42
 		if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
43 43
 			$this->documentNewRoute($request, $cmsComponent);
44 44
 		} elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])){
@@ -50,23 +50,23 @@  discard block
 block discarded – undo
50 50
 				case '/documents/unpublish-document': $this->unpublishDocumentRoute($request, $cmsComponent); break;
51 51
 			}
52 52
 		}
53
-    }
53
+	}
54 54
 
55
-    /**
56
-     * @param $request
57
-     * @param $relativeCmsUri
58
-     * @param CmsComponent $cmsComponent
59
-     */
60
-    private function folderRouting($request, $relativeCmsUri, $cmsComponent)
61
-    {
62
-        if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
55
+	/**
56
+	 * @param $request
57
+	 * @param $relativeCmsUri
58
+	 * @param CmsComponent $cmsComponent
59
+	 */
60
+	private function folderRouting($request, $relativeCmsUri, $cmsComponent)
61
+	{
62
+		if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
63 63
 			$this->newFolderRoute($request, $cmsComponent);
64
-        } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
64
+		} else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
65 65
 			$this->editFolderRoute($request, $cmsComponent);
66
-        } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
66
+		} else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
67 67
 			$this->deleteFolderRoute($request, $cmsComponent);
68
-        }
69
-    }
68
+		}
69
+	}
70 70
 
71 71
 	private function valuelistsRouting($request, $relativeCmsUri, $cmsComponent)
72 72
 	{
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
     {
42 42
 		if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) {
43 43
 			$this->documentNewRoute($request, $cmsComponent);
44
-		} elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])){
44
+		} elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
45 45
 			switch ($relativeCmsUri) {
46 46
 				case '/documents/edit-document': $this->editDocumentRoute($request, $cmsComponent); break;
47 47
 				case '/documents/get-brick': $this->getBrickRoute($request, $cmsComponent); break;
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 		if (isset($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE])) {
96 96
 			if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], $request::$get[CmsComponent::GET_PARAMETER_PATH])) {
97 97
 				$cmsComponent->storage->getDocuments()->addDocument($request::$post);
98
-				header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
98
+				header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
99 99
 				exit;
100 100
 			}
101 101
 			$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPE, $cmsComponent->storage->getDocumentTypes()->getDocumentTypeBySlug($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], true));
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 		} else {
104 104
 			$documentTypes = $cmsComponent->storage->getDocumentTypes()->getDocumentTypes();
105 105
 			if (count($documentTypes) < 1) {
106
-				throw new \Exception('No Document Types defined yet. <a href="' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/configuration/document-types/new">Please do so first.</a>');
106
+				throw new \Exception('No Document Types defined yet. <a href="'.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/configuration/document-types/new">Please do so first.</a>');
107 107
 			}
108 108
 			$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPES, $documentTypes);
109 109
 		}
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_SMALLEST_IMAGE, $cmsComponent->storage->getImageSet()->getSmallestImageSet()->slug);
121 121
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
122 122
 			$cmsComponent->storage->getDocuments()->saveDocument($request::$post);
123
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
123
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
124 124
 			exit;
125 125
 		}
126 126
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT, $cmsComponent->storage->getDocuments()->getDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG], 'unpublished'));
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 	private function deleteDocumentRoute($request, $cmsComponent)
158 158
 	{
159 159
 		$cmsComponent->storage->getDocuments()->deleteDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
160
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
160
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
161 161
 		exit;
162 162
 	}
163 163
 
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
172 172
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::GET_PARAMETER_PATH])) {
173 173
 			$cmsComponent->storage->addDocumentFolder($request::$post);
174
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
174
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
175 175
 			exit;
176 176
 		}
177 177
 	}
@@ -190,11 +190,11 @@  discard block
 block discarded – undo
190 190
 		array_pop($path);
191 191
 		$path = implode('/', $path);
192 192
 
193
-		$request::$get[CmsComponent::GET_PARAMETER_PATH] = '/' . $path;
193
+		$request::$get[CmsComponent::GET_PARAMETER_PATH] = '/'.$path;
194 194
 
195 195
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post['content'])) {
196 196
 			$cmsComponent->storage->saveDocumentFolder($request::$post);
197
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
197
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
198 198
 			exit;
199 199
 		}
200 200
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	private function deleteFolderRoute($request, $cmsComponent)
210 210
 	{
211 211
 		$cmsComponent->storage->deleteDocumentFolderBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
212
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
212
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
213 213
 		exit;
214 214
 	}
215 215
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	private function publishDocumentRoute($request, $cmsComponent)
221 221
 	{
222 222
 		$cmsComponent->storage->publishDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
223
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
223
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
224 224
 		exit;
225 225
 	}
226 226
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 	private function unpublishDocumentRoute($request, $cmsComponent)
232 232
 	{
233 233
 		$cmsComponent->storage->unpublishDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
234
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents');
234
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents');
235 235
 		exit;
236 236
 	}
237 237
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS);
249 249
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE])) {
250 250
 			$cmsComponent->storage->getValuelists()->addValuelist($request::$post);
251
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents/valuelists');
251
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents/valuelists');
252 252
 			exit;
253 253
 		}
254 254
 	}
@@ -260,7 +260,7 @@  discard block
 block discarded – undo
260 260
 
261 261
 		if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::GET_PARAMETER_SLUG])) {
262 262
 			$cmsComponent->storage->getValuelists()->saveValuelist($request::$get[CmsComponent::GET_PARAMETER_SLUG], $request::$post);
263
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents/valuelists');
263
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents/valuelists');
264 264
 			exit;
265 265
 		}
266 266
 
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	private function deleteValuelistRoute($request, $cmsComponent)
272 272
 	{
273 273
 		$cmsComponent->storage->getValuelists()->deleteValuelistBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]);
274
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents/valuelists');
274
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents/valuelists');
275 275
 		exit;
276 276
 	}
277 277
 }
278 278
\ No newline at end of file
Please login to merge, or discard this patch.