Passed
Push — develop ( 0cf906...cb779b )
by Jens
06:50
created
src/components/BaseComponent.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
 		 * @param array   $parameters
42 42
 		 * @param         $matchedSitemapItem
43 43
 		 */
44
-		public function __construct($template='', Request $request, $parameters=array(), $matchedSitemapItem)
44
+		public function __construct($template = '', Request $request, $parameters = array(), $matchedSitemapItem)
45 45
 		{
46 46
 			$this->template = $template;
47 47
 			$this->request = $request;
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 		 *
67 67
 		 * @throws \Exception
68 68
 		 */
69
-		public function render($application=null)
69
+		public function render($application = null)
70 70
 		{
71 71
 			$this->renderedContent = $this->renderTemplate($this->template, true, $application);
72 72
 		}
@@ -92,13 +92,13 @@  discard block
 block discarded – undo
92 92
 		 * @return string
93 93
 		 * @throws \Exception
94 94
 		 */
95
-		public function renderTemplate($template='', $obClean = true, $application=null)
95
+		public function renderTemplate($template = '', $obClean = true, $application = null)
96 96
 		{
97 97
 		    $templateDir = $this->getTemplateDir($template, $application);
98 98
 		    if ($application !== null) {
99 99
                 $rootDir = $application->getRootDir();
100 100
                 if (strpos($templateDir, $rootDir) === false) {
101
-                    $templatePath = $rootDir . DIRECTORY_SEPARATOR . $templateDir;
101
+                    $templatePath = $rootDir.DIRECTORY_SEPARATOR.$templateDir;
102 102
                 } else {
103 103
                     $templatePath = $templateDir;
104 104
                 }
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 				return ob_get_contents();
122 122
 			} else {
123 123
 				if ($template !== null) { // If template is null, its a application component, which doesnt have a template
124
-					throw new \Exception('Couldnt find template ' . $templatePath);
124
+					throw new \Exception('Couldnt find template '.$templatePath);
125 125
 				}
126 126
 			}
127 127
 		}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 		 * @return string
137 137
 		 * @throws \Exception
138 138
 		 */
139
-		public function includeTemplate($template='', $parameters = array())
139
+		public function includeTemplate($template = '', $parameters = array())
140 140
 		{
141 141
 			if (is_array($parameters)) {
142 142
 				foreach ($parameters as $name => $value) {
@@ -156,13 +156,13 @@  discard block
 block discarded – undo
156 156
          * @param null | Application $application
157 157
          * @return string
158 158
          */
159
-        protected function getTemplateDir($template, $application=null)
159
+        protected function getTemplateDir($template, $application = null)
160 160
         {
161 161
             $templatePath = '';
162 162
             if ($application !== null) {
163 163
                 $templatePath = $application->getTemplateDir();
164 164
             }
165
-            $templatePath = $templatePath . $template . '.php';
165
+            $templatePath = $templatePath.$template.'.php';
166 166
             return $templatePath;
167 167
         }
168 168
     }
Please login to merge, or discard this patch.
src/components/CmsComponent.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 				$whitelistIps = explode(',', $this->parameters[self::PARAMETER_WHITELIST_IPS]);
171 171
 				$whitelistIps = array_map("trim", $whitelistIps);
172 172
 				if (!in_array($remoteAddress, $whitelistIps)) {
173
-					throw new \Exception('Ip address ' . $remoteAddress . ' is not on whitelist');
173
+					throw new \Exception('Ip address '.$remoteAddress.' is not on whitelist');
174 174
 				}
175 175
 			}
176 176
 		}
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 				$blacklistIps = explode(',', $this->parameters[self::PARAMETER_BLACKLIST_IPS]);
187 187
 				$blacklistIps = array_map("trim", $blacklistIps);
188 188
 				if (in_array($remoteAddress, $blacklistIps)) {
189
-					throw new \Exception('Ip address ' . $remoteAddress . ' is on blacklist');
189
+					throw new \Exception('Ip address '.$remoteAddress.' is on blacklist');
190 190
 				}
191 191
 			}
192 192
 		}
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 			if ($relativeCmsUri == '/log-off') {
231 231
 				$_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL] = null;
232 232
 				unset($_SESSION[self::SESSION_PARAMETER_CLOUD_CONTROL]);
233
-				header('Location: ' . $request::$subfolders . $this->parameters[self::PARAMETER_CMS_PREFIX]);
233
+				header('Location: '.$request::$subfolders.$this->parameters[self::PARAMETER_CMS_PREFIX]);
234 234
 				exit;
235 235
 			}
236 236
 		}
@@ -371,7 +371,7 @@  discard block
 block discarded – undo
371 371
 
372 372
         protected function getTemplateDir($template, $application = null)
373 373
         {
374
-            return __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template . '.php';
374
+            return __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$template.'.php';
375 375
         }
376 376
     }
377 377
 }
378 378
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/cms/FilesRouting.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		$file = $cmsComponent->storage->getFiles()->getFileByName($slug);
42 42
 		$path = realpath($cmsComponent->storage->getFiles()->getFilesDir());
43
-		$quoted = sprintf('"%s"', addcslashes(basename($path . '/' . $file->file), '"\\'));
44
-		$size = filesize($path . '/' . $file->file);
43
+		$quoted = sprintf('"%s"', addcslashes(basename($path.'/'.$file->file), '"\\'));
44
+		$size = filesize($path.'/'.$file->file);
45 45
 
46 46
 		header('Content-Description: File Transfer');
47
-		header('Content-Type: ' . $file->type);
48
-		header('Content-Disposition: attachment; filename=' . $quoted);
47
+		header('Content-Type: '.$file->type);
48
+		header('Content-Disposition: attachment; filename='.$quoted);
49 49
 		header('Content-Transfer-Encoding: binary');
50 50
 		header('Connection: Keep-Alive');
51 51
 		header('Expires: 0');
52 52
 		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
53 53
 		header('Pragma: public');
54
-		header('Content-Length: ' . $size);
54
+		header('Content-Length: '.$size);
55 55
 
56
-		readfile($path . '/' . $file->file);
56
+		readfile($path.'/'.$file->file);
57 57
 		exit;
58 58
 	}
59 59
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES);
78 78
 		if (isset($_FILES[CmsComponent::FILES_PARAMETER_FILE])) {
79 79
 			$cmsComponent->storage->getFiles()->addFile($_FILES[CmsComponent::FILES_PARAMETER_FILE]);
80
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files');
80
+			header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/files');
81 81
 			exit;
82 82
 		}
83 83
 	}
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 	private function deleteRoute($request, $cmsComponent)
90 90
 	{
91 91
 		$cmsComponent->storage->getFiles()->deleteFileByName($request::$get[CmsComponent::FILES_PARAMETER_FILE]);
92
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files');
92
+		header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/files');
93 93
 		exit;
94 94
 	}
95 95
 
Please login to merge, or discard this patch.
src/util/functions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 {
12 12
     $debug_backtrace = current(debug_backtrace());
13 13
     if (PHP_SAPI == 'cli') {
14
-        echo 'Dump: ' . $debug_backtrace['file'] . ':' . $debug_backtrace['line'] . "\n";
14
+        echo 'Dump: '.$debug_backtrace['file'].':'.$debug_backtrace['line']."\n";
15 15
         foreach (func_get_args() as $data) {
16 16
             var_dump($data);
17 17
         }
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 <body>
30 30
 END;
31 31
 
32
-        echo '<div>Dump: ' . $debug_backtrace['file'] . ':<b>' . $debug_backtrace['line'] . "</b></div>";
32
+        echo '<div>Dump: '.$debug_backtrace['file'].':<b>'.$debug_backtrace['line']."</b></div>";
33 33
         echo '<pre>';
34 34
         foreach (func_get_args() as $data) {
35 35
             echo "<code>";
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
 {
56 56
     if (!isset($_GET['unsanitized'])) {
57 57
         $search = array(
58
-            '/\>[^\S ]+/s',     // strip whitespaces after tags, except space
59
-            '/[^\S ]+\</s',     // strip whitespaces before tags, except space
60
-            '/(\s)+/s',         // shorten multiple whitespace sequences
58
+            '/\>[^\S ]+/s', // strip whitespaces after tags, except space
59
+            '/[^\S ]+\</s', // strip whitespaces before tags, except space
60
+            '/(\s)+/s', // shorten multiple whitespace sequences
61 61
             '/<!--(.|\s)*?-->/' // Remove HTML comments
62 62
         );
63 63
 
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
  */
86 86
 function utf8Convert($array)
87 87
 {
88
-    array_walk_recursive($array, function (&$item) {
88
+    array_walk_recursive($array, function(&$item) {
89 89
         if (!mb_detect_encoding($item, 'utf-8', true)) {
90 90
             $item = utf8_encode($item);
91 91
         }
@@ -105,8 +105,8 @@  discard block
 block discarded – undo
105 105
 function getRelativePath($from, $to)
106 106
 {
107 107
     // some compatibility fixes for Windows paths
108
-    $from = is_dir($from) ? rtrim($from, '\/') . DIRECTORY_SEPARATOR : $from;
109
-    $to = is_dir($to) ? rtrim($to, '\/') . DIRECTORY_SEPARATOR : $to;
108
+    $from = is_dir($from) ? rtrim($from, '\/').DIRECTORY_SEPARATOR : $from;
109
+    $to = is_dir($to) ? rtrim($to, '\/').DIRECTORY_SEPARATOR : $to;
110 110
     $from = str_replace('\\', DIRECTORY_SEPARATOR, $from);
111 111
     $to = str_replace('\\', DIRECTORY_SEPARATOR, $to);
112 112
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
                 $relPath = array_pad($relPath, $padLength, '..');
129 129
                 break;
130 130
             } else {
131
-                $relPath[0] = '.' . DIRECTORY_SEPARATOR . $relPath[0];
131
+                $relPath[0] = '.'.DIRECTORY_SEPARATOR.$relPath[0];
132 132
             }
133 133
         }
134 134
     }
135 135
     $relPath = implode(DIRECTORY_SEPARATOR, $relPath);
136
-    while (strpos($relPath, '.' . DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR) !== false) {
137
-        $relPath = str_replace('.' . DIRECTORY_SEPARATOR . '.' . DIRECTORY_SEPARATOR, '.' . DIRECTORY_SEPARATOR, $relPath);
136
+    while (strpos($relPath, '.'.DIRECTORY_SEPARATOR.'.'.DIRECTORY_SEPARATOR) !== false) {
137
+        $relPath = str_replace('.'.DIRECTORY_SEPARATOR.'.'.DIRECTORY_SEPARATOR, '.'.DIRECTORY_SEPARATOR, $relPath);
138 138
     }
139 139
     return $relPath;
140 140
 }
141 141
\ No newline at end of file
Please login to merge, or discard this patch.
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.