Passed
Push — develop ( 0cf906...cb779b )
by Jens
06:50
created
src/cc/Application.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
          */
67 67
         private function config()
68 68
         {
69
-            $configPath = __DIR__ . '/../../config.json';
69
+            $configPath = __DIR__.'/../../config.json';
70 70
             if (realpath($configPath) !== false) {
71 71
                 $json = file_get_contents($configPath);
72 72
                 $this->config = json_decode($json);
@@ -80,13 +80,13 @@  discard block
 block discarded – undo
80 80
          */
81 81
         private function storage()
82 82
         {
83
-            $this->storage = new Storage($this->config->rootDir . DIRECTORY_SEPARATOR . $this->config->storageDir, $this->config->imagesDir, $this->config->filesDir);
83
+            $this->storage = new Storage($this->config->rootDir.DIRECTORY_SEPARATOR.$this->config->storageDir, $this->config->imagesDir, $this->config->filesDir);
84 84
         }
85 85
 
86 86
         private function redirectMatching($request)
87 87
         {
88 88
             $redirects = $this->storage->getRedirects()->getRedirects();
89
-            $relativeUri = '/' . $request::$relativeUri;
89
+            $relativeUri = '/'.$request::$relativeUri;
90 90
 
91 91
             foreach ($redirects as $redirect) {
92 92
                 if (preg_match_all($redirect->fromUrl, $relativeUri, $matches)) {
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
                     }
97 97
                     if ($redirect->type == '301') {
98 98
                         header('HTTP/1.1 301 Moved Permanently');
99
-                        header('Location: ' . $request::$subfolders . $toUrl);
99
+                        header('Location: '.$request::$subfolders.$toUrl);
100 100
                         exit;
101 101
                     } elseif ($redirect->type == '302') {
102
-                        header('Location: ' . $request::$subfolders . $toUrl, true, 302);
102
+                        header('Location: '.$request::$subfolders.$toUrl, true, 302);
103 103
                         exit;
104 104
                     } else {
105 105
                         throw new \Exception('Invalid redirect type.');
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
         private function sitemapMatching($request)
118 118
         {
119 119
             $sitemap = $this->storage->getSitemap()->getSitemap();
120
-            $relativeUri = '/' . $request::$relativeUri;
120
+            $relativeUri = '/'.$request::$relativeUri;
121 121
 
122 122
             foreach ($sitemap as $sitemapItem) {
123 123
                 if ($sitemapItem->regex) {
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
          */
183 183
         private function getComponentObject($class = '', $template = '', $parameters = array(), $matchedSitemapItem)
184 184
         {
185
-            $libraryComponentName = '\\CloudControl\Cms\\components\\' . $class;
186
-            $userComponentName = '\\components\\' . $class;
185
+            $libraryComponentName = '\\CloudControl\Cms\\components\\'.$class;
186
+            $userComponentName = '\\components\\'.$class;
187 187
 
188 188
             if (!class_exists($libraryComponentName, false)) {
189 189
                 $component = new $libraryComponentName($template, $this->request, $parameters, $matchedSitemapItem);
190 190
             } elseif (!class_exists($userComponentName, false)) {
191 191
                 $component = new $userComponentName($template, $this->request, $parameters, $matchedSitemapItem);
192 192
             } else {
193
-                throw new \Exception('Could not load component ' . $class);
193
+                throw new \Exception('Could not load component '.$class);
194 194
             }
195 195
 
196 196
             if (!$component instanceof Component) {
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
          */
249 249
         public function setCachingHeaders()
250 250
         {
251
-            header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 2))); // 2 days
252
-            header("Cache-Control: max-age=" . (60 * 60 * 24 * 2));
251
+            header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + (60 * 60 * 24 * 2))); // 2 days
252
+            header("Cache-Control: max-age=".(60 * 60 * 24 * 2));
253 253
         }
254 254
 
255 255
         /**
Please login to merge, or discard this patch.
src/storage/Repository.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
             if (in_array($name, $this->fileBasedSubsets)) {
117 117
                 return $this->$name;
118 118
             } else {
119
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
119
+                throw new \Exception('Trying to get undefined property from Repository: '.$name);
120 120
             }
121 121
         } else {
122 122
             if (in_array($name, $this->fileBasedSubsets)) {
123 123
                 return $this->loadSubset($name);
124 124
             } else {
125
-                throw new \Exception('Trying to get undefined property from Repository: ' . $name);
125
+                throw new \Exception('Trying to get undefined property from Repository: '.$name);
126 126
             }
127 127
         }
128 128
     }
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
     {
138 138
         if (in_array($name, $this->fileBasedSubsets)) {
139 139
             $this->$name = $value;
140
-            $changes = $name . 'Changes';
140
+            $changes = $name.'Changes';
141 141
             $this->$changes = true;
142 142
         } else {
143
-            throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>');
143
+            throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>');
144 144
         }
145 145
     }
146 146
 
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
     public function save()
151 151
     {
152 152
         $host = $this;
153
-        array_map(function ($value) use ($host) {
153
+        array_map(function($value) use ($host) {
154 154
             $host->saveSubset($value);
155 155
 		}, $this->fileBasedSubsets);
156 156
     }
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
      */
162 162
     public function saveSubset($subset)
163 163
     {
164
-		$changes = $subset . 'Changes';
164
+		$changes = $subset.'Changes';
165 165
 		if ($this->$changes === true) {
166 166
             if (!defined('JSON_PRETTY_PRINT')) {
167 167
                 $json = json_encode($this->$subset);
168 168
             } else {
169 169
                 $json = json_encode($this->$subset, JSON_PRETTY_PRINT);
170 170
             }
171
-			$subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
171
+			$subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
172 172
 			file_put_contents($subsetStoragePath, $json);
173 173
 
174 174
 			$this->$changes = false;
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      */
183 183
     protected function loadSubset($subset)
184 184
     {
185
-        $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json';
185
+        $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json';
186 186
         $json = file_get_contents($subsetStoragePath);
187 187
         $json = json_decode($json);
188 188
         $this->$subset = $json;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
     public function getContentDbHandle()
225 225
     {
226 226
         if ($this->contentDbHandle === null) {
227
-            $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db');
227
+            $this->contentDbHandle = new \PDO('sqlite:'.$this->storagePath.DIRECTORY_SEPARATOR.'content.db');
228 228
         }
229 229
         return $this->contentDbHandle;
230 230
     }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
     public function getDocuments($state = 'published')
241 241
     {
242 242
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
243
-			throw new \Exception('Unsupported document state: ' . $state);
243
+			throw new \Exception('Unsupported document state: '.$state);
244 244
 		}
245 245
         return $this->getDocumentsByPath('/', $state);
246 246
     }
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	public function getDocumentsWithState($folderPath = '/')
249 249
 	{
250 250
 		$db = $this->getContentDbHandle();
251
-		$folderPathWithWildcard = $folderPath . '%';
251
+		$folderPathWithWildcard = $folderPath.'%';
252 252
 
253 253
 		$ifRootIndex = 1;
254 254
 		if ($folderPath == '/') {
@@ -263,10 +263,10 @@  discard block
 block discarded – undo
263 263
               FROM documents_unpublished
264 264
 		 LEFT JOIN documents_published
265 265
          		ON documents_published.path = documents_unpublished.path
266
-             WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard) . '
267
-               AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1) . ') NOT LIKE "%/%"
268
-               AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex) . '
269
-               AND documents_unpublished.path != ' . $db->quote($folderPath) . '
266
+             WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard).'
267
+               AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1).') NOT LIKE "%/%"
268
+               AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex).'
269
+               AND documents_unpublished.path != ' . $db->quote($folderPath).'
270 270
           ORDER BY documents_unpublished.`type` DESC, documents_unpublished.`path` ASC
271 271
         ';
272 272
 		$stmt = $this->getDbStatement($sql);
@@ -293,16 +293,16 @@  discard block
 block discarded – undo
293 293
     public function getDocumentsByPath($folderPath, $state = 'published')
294 294
     {
295 295
     	if (!in_array($state, Document::$DOCUMENT_STATES)) {
296
-    		throw new \Exception('Unsupported document state: ' . $state);
296
+    		throw new \Exception('Unsupported document state: '.$state);
297 297
 		}
298 298
         $db = $this->getContentDbHandle();
299
-        $folderPathWithWildcard = $folderPath . '%';
299
+        $folderPathWithWildcard = $folderPath.'%';
300 300
 
301 301
         $sql = 'SELECT *
302
-              FROM documents_' . $state . '
303
-             WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . '
304
-               AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%"
305
-               AND path != ' . $db->quote($folderPath) . '
302
+              FROM documents_' . $state.'
303
+             WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).'
304
+               AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%"
305
+               AND path != ' . $db->quote($folderPath).'
306 306
           ORDER BY `type` DESC, `path` ASC';
307 307
         $stmt = $this->getDbStatement($sql);
308 308
 
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         if ($containerPath === '/') {
330 330
             return $this->getRootFolder();
331 331
         }
332
-        if (substr($containerPath, -1) === '/'){
332
+        if (substr($containerPath, -1) === '/') {
333 333
 			$containerPath = substr($containerPath, 0, -1);
334 334
 		}
335 335
         $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished');
@@ -346,13 +346,13 @@  discard block
 block discarded – undo
346 346
     public function getDocumentByPath($path, $state = 'published')
347 347
     {
348 348
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
349
-			throw new \Exception('Unsupported document state: ' . $state);
349
+			throw new \Exception('Unsupported document state: '.$state);
350 350
 		}
351 351
         $db = $this->getContentDbHandle();
352 352
         $document = $this->fetchDocument('
353 353
             SELECT *
354
-              FROM documents_' .  $state . '
355
-             WHERE path = ' . $db->quote($path) . '
354
+              FROM documents_' .  $state.'
355
+             WHERE path = ' . $db->quote($path).'
356 356
         ');
357 357
         if ($document instanceof Document && $document->type === 'folder') {
358 358
             $document->dbHandle = $db;
@@ -372,16 +372,16 @@  discard block
 block discarded – undo
372 372
 	public function getTotalDocumentCount($state = 'published')
373 373
 	{
374 374
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
375
-			throw new \Exception('Unsupported document state: ' . $state);
375
+			throw new \Exception('Unsupported document state: '.$state);
376 376
 		}
377 377
 		$db = $this->getContentDbHandle();
378 378
 		$stmt = $db->query('
379 379
 			SELECT count(*)
380
-			  FROM documents_' . $state . '
380
+			  FROM documents_' . $state.'
381 381
 			 WHERE `type` != "folder"
382 382
 		');
383 383
 		$result = $stmt->fetch(\PDO::FETCH_ASSOC);
384
-		if (!is_array($result )) {
384
+		if (!is_array($result)) {
385 385
 			return 0;
386 386
 		}
387 387
 		return intval(current($result));
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 		if ($stmt === false || !$stmt->execute()) {
401 401
 			$errorInfo = $db->errorInfo();
402 402
 			$errorMsg = $errorInfo[2];
403
-			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
403
+			throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>');
404 404
 		}
405 405
 		return $result;
406 406
 	}
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 			$sql = '
411 411
 				INSERT OR REPLACE INTO documents_published 
412 412
 					  (`id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`publicationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
413
-				SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time() . ' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`
413
+				SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time().' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`
414 414
 				  FROM documents_unpublished
415 415
 				 WHERE `path` = :path
416 416
 			';
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 		if ($stmt === false) {
424 424
 			$errorInfo = $db->errorInfo();
425 425
 			$errorMsg = $errorInfo[2];
426
-			throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
426
+			throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>');
427 427
 		}
428 428
 		$stmt->bindValue(':path', $path);
429 429
 		$stmt->execute();
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
         if ($stmt === false) {
491 491
             $errorInfo = $db->errorInfo();
492 492
             $errorMsg = $errorInfo[2];
493
-            throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>');
493
+            throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>');
494 494
         }
495 495
         return $stmt;
496 496
     }
@@ -520,25 +520,25 @@  discard block
 block discarded – undo
520 520
     public function saveDocument($documentObject, $state = 'published')
521 521
     {
522 522
 		if (!in_array($state, Document::$DOCUMENT_STATES)) {
523
-			throw new \Exception('Unsupported document state: ' . $state);
523
+			throw new \Exception('Unsupported document state: '.$state);
524 524
 		}
525 525
         $db = $this->getContentDbHandle();
526 526
         $stmt = $this->getDbStatement('
527
-            INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
527
+            INSERT OR REPLACE INTO documents_' . $state.' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`)
528 528
             VALUES(
529
-              ' . $db->quote($documentObject->path) . ',
530
-              ' . $db->quote($documentObject->title) . ',
531
-              ' . $db->quote($documentObject->slug) . ',
532
-              ' . $db->quote($documentObject->type) . ',
533
-              ' . $db->quote($documentObject->documentType) . ',
534
-              ' . $db->quote($documentObject->documentTypeSlug) . ',
535
-              ' . $db->quote($documentObject->state) . ',
536
-              ' . $db->quote($documentObject->lastModificationDate) . ',
537
-              ' . $db->quote($documentObject->creationDate) . ',
538
-              ' . $db->quote($documentObject->lastModifiedBy) . ',
539
-              ' . $db->quote(json_encode($documentObject->fields)) . ',
540
-              ' . $db->quote(json_encode($documentObject->bricks)) . ',
541
-              ' . $db->quote(json_encode($documentObject->dynamicBricks)) . '
529
+              ' . $db->quote($documentObject->path).',
530
+              ' . $db->quote($documentObject->title).',
531
+              ' . $db->quote($documentObject->slug).',
532
+              ' . $db->quote($documentObject->type).',
533
+              ' . $db->quote($documentObject->documentType).',
534
+              ' . $db->quote($documentObject->documentTypeSlug).',
535
+              ' . $db->quote($documentObject->state).',
536
+              ' . $db->quote($documentObject->lastModificationDate).',
537
+              ' . $db->quote($documentObject->creationDate).',
538
+              ' . $db->quote($documentObject->lastModifiedBy).',
539
+              ' . $db->quote(json_encode($documentObject->fields)).',
540
+              ' . $db->quote(json_encode($documentObject->bricks)).',
541
+              ' . $db->quote(json_encode($documentObject->dynamicBricks)).'
542 542
             )
543 543
         ');
544 544
         $result = $stmt->execute();
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
             if ($documentToDelete->type == 'document') {
563 563
                 $stmt = $this->getDbStatement('
564 564
                     DELETE FROM documents_unpublished
565
-                          WHERE path = ' . $db->quote($path) . '
565
+                          WHERE path = ' . $db->quote($path).'
566 566
                 ');
567 567
                 $stmt->execute();
568 568
             } elseif ($documentToDelete->type == 'folder') {
569
-                $folderPathWithWildcard = $path . '%';
569
+                $folderPathWithWildcard = $path.'%';
570 570
                 $stmt = $this->getDbStatement('
571 571
                     DELETE FROM documents_unpublished
572
-                          WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . '
573
-                            AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/")
574
-                            OR path = ' . $db->quote($path) . '
572
+                          WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).'
573
+                            AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/")
574
+                            OR path = ' . $db->quote($path).'
575 575
                 ');
576 576
                 $stmt->execute();
577 577
             }
@@ -599,11 +599,11 @@  discard block
 block discarded – undo
599 599
 
600 600
     private function initConfigIfNotExists($json, $subsetName)
601 601
     {
602
-        $subsetFileName = $this->storagePath . DIRECTORY_SEPARATOR . $subsetName . '.json';
602
+        $subsetFileName = $this->storagePath.DIRECTORY_SEPARATOR.$subsetName.'.json';
603 603
         if (file_exists($subsetFileName)) {
604 604
             $this->loadSubset($subsetName);
605 605
         } else {
606
-            $changes = $subsetName . 'Changes';
606
+            $changes = $subsetName.'Changes';
607 607
             $this->$subsetName = $json->$subsetName;
608 608
             $this->$changes = true;
609 609
         }
Please login to merge, or discard this patch.