Passed
Branch develop (96efe9)
by Jens
02:38
created
src/components/cms/FilesRouting.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 	}
69 69
 
70 70
 	/**
71
-	 * @param $request
71
+	 * @param Request $request
72 72
 	 * @param CmsComponent $cmsComponent
73 73
 	 */
74 74
 	private function newRoute($request, $cmsComponent)
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	}
84 84
 
85 85
 	/**
86
-	 * @param $request
86
+	 * @param Request $request
87 87
 	 * @param CmsComponent $cmsComponent
88 88
 	 */
89 89
 	private function deleteRoute($request, $cmsComponent)
Please login to merge, or discard this 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.
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -12,85 +12,85 @@
 block discarded – undo
12 12
 
13 13
 class FilesRouting implements CmsRouting
14 14
 {
15
-	/**
16
-	 * FilesRouting constructor.
17
-	 *
18
-	 * @param Request $request
19
-	 * @param $relativeCmsUri
20
-	 * @param CmsComponent $cmsComponent
21
-	 */
22
-	public function __construct($request, $relativeCmsUri, $cmsComponent)
23
-	{
24
-		if ($relativeCmsUri == '/files') {
25
-			$this->overviewRoute($cmsComponent);
26
-		} elseif ($relativeCmsUri == '/files/new') {
27
-			$this->newRoute($request, $cmsComponent);
28
-		} elseif ($relativeCmsUri == '/files/get' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
29
-			$this->downloadRoute($request::$get[CmsComponent::FILES_PARAMETER_FILE], $cmsComponent);
30
-		} elseif ($relativeCmsUri == '/files/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
31
-			$this->deleteRoute($request, $cmsComponent);
32
-		}
33
-	}
15
+    /**
16
+     * FilesRouting constructor.
17
+     *
18
+     * @param Request $request
19
+     * @param $relativeCmsUri
20
+     * @param CmsComponent $cmsComponent
21
+     */
22
+    public function __construct($request, $relativeCmsUri, $cmsComponent)
23
+    {
24
+        if ($relativeCmsUri == '/files') {
25
+            $this->overviewRoute($cmsComponent);
26
+        } elseif ($relativeCmsUri == '/files/new') {
27
+            $this->newRoute($request, $cmsComponent);
28
+        } elseif ($relativeCmsUri == '/files/get' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
29
+            $this->downloadRoute($request::$get[CmsComponent::FILES_PARAMETER_FILE], $cmsComponent);
30
+        } elseif ($relativeCmsUri == '/files/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) {
31
+            $this->deleteRoute($request, $cmsComponent);
32
+        }
33
+    }
34 34
 
35
-	/**
36
-	 * @param $slug
37
-	 * @param CmsComponent $cmsComponent
38
-	 */
39
-	private function downloadRoute($slug, $cmsComponent)
40
-	{
41
-		$file = $cmsComponent->storage->getFiles()->getFileByName($slug);
42
-		$path = realpath($cmsComponent->storage->getFiles()->getFilesDir());
43
-		$quoted = sprintf('"%s"', addcslashes(basename($path . '/' . $file->file), '"\\'));
44
-		$size = filesize($path . '/' . $file->file);
35
+    /**
36
+     * @param $slug
37
+     * @param CmsComponent $cmsComponent
38
+     */
39
+    private function downloadRoute($slug, $cmsComponent)
40
+    {
41
+        $file = $cmsComponent->storage->getFiles()->getFileByName($slug);
42
+        $path = realpath($cmsComponent->storage->getFiles()->getFilesDir());
43
+        $quoted = sprintf('"%s"', addcslashes(basename($path . '/' . $file->file), '"\\'));
44
+        $size = filesize($path . '/' . $file->file);
45 45
 
46
-		header('Content-Description: File Transfer');
47
-		header('Content-Type: ' . $file->type);
48
-		header('Content-Disposition: attachment; filename=' . $quoted);
49
-		header('Content-Transfer-Encoding: binary');
50
-		header('Connection: Keep-Alive');
51
-		header('Expires: 0');
52
-		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
53
-		header('Pragma: public');
54
-		header('Content-Length: ' . $size);
46
+        header('Content-Description: File Transfer');
47
+        header('Content-Type: ' . $file->type);
48
+        header('Content-Disposition: attachment; filename=' . $quoted);
49
+        header('Content-Transfer-Encoding: binary');
50
+        header('Connection: Keep-Alive');
51
+        header('Expires: 0');
52
+        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
53
+        header('Pragma: public');
54
+        header('Content-Length: ' . $size);
55 55
 
56
-		readfile($path . '/' . $file->file);
57
-		exit;
58
-	}
56
+        readfile($path . '/' . $file->file);
57
+        exit;
58
+    }
59 59
 
60
-	/**
61
-	 * @param CmsComponent $cmsComponent
62
-	 */
63
-	private function overviewRoute($cmsComponent)
64
-	{
65
-		$cmsComponent->subTemplate = 'files';
66
-		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES);
67
-		$cmsComponent->setParameter(CmsComponent::PARAMETER_FILES, $cmsComponent->storage->getFiles()->getFiles());
68
-	}
60
+    /**
61
+     * @param CmsComponent $cmsComponent
62
+     */
63
+    private function overviewRoute($cmsComponent)
64
+    {
65
+        $cmsComponent->subTemplate = 'files';
66
+        $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES);
67
+        $cmsComponent->setParameter(CmsComponent::PARAMETER_FILES, $cmsComponent->storage->getFiles()->getFiles());
68
+    }
69 69
 
70
-	/**
71
-	 * @param $request
72
-	 * @param CmsComponent $cmsComponent
73
-	 */
74
-	private function newRoute($request, $cmsComponent)
75
-	{
76
-		$cmsComponent->subTemplate = 'files/form';
77
-		$cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES);
78
-		if (isset($_FILES[CmsComponent::FILES_PARAMETER_FILE])) {
79
-			$cmsComponent->storage->getFiles()->addFile($_FILES[CmsComponent::FILES_PARAMETER_FILE]);
80
-			header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files');
81
-			exit;
82
-		}
83
-	}
70
+    /**
71
+     * @param $request
72
+     * @param CmsComponent $cmsComponent
73
+     */
74
+    private function newRoute($request, $cmsComponent)
75
+    {
76
+        $cmsComponent->subTemplate = 'files/form';
77
+        $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_FILES);
78
+        if (isset($_FILES[CmsComponent::FILES_PARAMETER_FILE])) {
79
+            $cmsComponent->storage->getFiles()->addFile($_FILES[CmsComponent::FILES_PARAMETER_FILE]);
80
+            header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files');
81
+            exit;
82
+        }
83
+    }
84 84
 
85
-	/**
86
-	 * @param $request
87
-	 * @param CmsComponent $cmsComponent
88
-	 */
89
-	private function deleteRoute($request, $cmsComponent)
90
-	{
91
-		$cmsComponent->storage->getFiles()->deleteFileByName($request::$get[CmsComponent::FILES_PARAMETER_FILE]);
92
-		header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files');
93
-		exit;
94
-	}
85
+    /**
86
+     * @param $request
87
+     * @param CmsComponent $cmsComponent
88
+     */
89
+    private function deleteRoute($request, $cmsComponent)
90
+    {
91
+        $cmsComponent->storage->getFiles()->deleteFileByName($request::$get[CmsComponent::FILES_PARAMETER_FILE]);
92
+        header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/files');
93
+        exit;
94
+    }
95 95
 
96 96
 }
97 97
\ No newline at end of file
Please login to merge, or discard this patch.
src/components/FormComponent.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	}
181 181
 
182 182
 	/**
183
-	 * @param \cc\Request $request
183
+	 * @param \CloudControl\Cms\cc\Request $request
184 184
 	 * @return array
185 185
 	 */
186 186
 	private function getPostValues($request)
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 	}
292 292
 
293 293
 	/**
294
-	 * @return \cc\Request
294
+	 * @return \CloudControl\Cms\cc\Request
295 295
 	 */
296 296
 	private function setPathBackup()
297 297
 	{
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	}
306 306
 
307 307
 	/**
308
-	 * @param \cc\Request $request
308
+	 * @param \CloudControl\Cms\cc\Request $request
309 309
 	 */
310 310
 	private function resetPathBackup($request)
311 311
 	{
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	}
318 318
 
319 319
 	/**
320
-	 * @param $form
320
+	 * @param string|null $form
321 321
 	 */
322 322
 	private function setFormParameter($form)
323 323
 	{
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		if (isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID])) {
163 163
 			$this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
164 164
 		} else {
165
-			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string)microtime(true);
165
+			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string) microtime(true);
166 166
 			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = false;
167 167
 			$this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
168 168
 		}
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 		$postValues = $request::$post;
191 191
 		$postValues[self::PARAMETER_DOCUMENT_TYPE] = $this->documentType;
192 192
 		$postValues[self::GET_PARAMETER_PATH] = $this->responseFolder;
193
-		$postValues['title'] = date('r') . ' - From: ' . $request::$requestUri;
193
+		$postValues['title'] = date('r').' - From: '.$request::$requestUri;
194 194
 
195 195
 		return $postValues;
196 196
 	}
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	private function setFormParameter($form)
326 326
 	{
327 327
 		if ($this->isFormSubmitted($this->request) || $this->isSubmitAllowed() === false) {
328
-			$this->parameters[$this->formParameterName] = '<a name="' . $this->formId . '"></a>' . $this->thankYouMessage;
328
+			$this->parameters[$this->formParameterName] = '<a name="'.$this->formId.'"></a>'.$this->thankYouMessage;
329 329
 		} else {
330 330
 			$this->parameters[$this->formParameterName] = $form;
331 331
 		}
Please login to merge, or discard this patch.
Indentation   +320 added lines, -320 removed lines patch added patch discarded remove patch
@@ -7,324 +7,324 @@
 block discarded – undo
7 7
 
8 8
 class FormComponent Extends BaseComponent
9 9
 {
10
-	const GET_PARAMETER_PATH = 'path';
11
-
12
-	const PARAMETER_CMS_PREFIX = 'cmsPrefix';
13
-	const PARAMETER_DOCUMENT_TYPE = 'documentType';
14
-	const PARAMETER_DOCUMENT_TYPES = 'documentTypes';
15
-	const PARAMETER_FORM_ID = 'formId';
16
-	const PARAMETER_FORM_PARAMETER_NAME = 'formParameterName';
17
-	const PARAMETER_HIDE_TITLE_AND_STATE = 'hideTitleAndState';
18
-	const PARAMETER_RESPONSE_FOLDER = 'responseFolder';
19
-	const PARAMETER_SMALLEST_IMAGE = 'smallestImage';
20
-	const PARAMETER_SUBMIT_ONCE_PER_SESSION = 'submitOncePerSession';
21
-	const PARAMETER_SUB_TEMPLATE = 'subTemplate';
22
-	const PARAMETER_THANK_YOU_MESSAGE = 'thankYouMessage';
23
-
24
-	const SESSION_PARAMETER_CLOUDCONTROL = 'cloudcontrol';
25
-	const SESSION_PARAMETER_FORM_COMPONENT = 'FormComponent';
26
-	/**
27
-	 * @var null|string
28
-	 */
29
-	protected $documentType = null;
30
-	/**
31
-	 * @var null|string
32
-	 */
33
-	protected $responseFolder = null;
34
-	/**
35
-	 * @var string
36
-	 */
37
-	protected $subTemplate = 'cms/documents/document-form-form';
38
-	/**
39
-	 * @var string
40
-	 */
41
-	protected $formParameterName = 'form';
42
-	/**
43
-	 * @var string
44
-	 */
45
-	protected $thankYouMessage = 'Thank you for sending us your response.';
46
-
47
-	/**
48
-	 * @var bool
49
-	 */
50
-	protected $submitOncePerSession = false;
51
-
52
-	/**
53
-	 * @var string
54
-	 */
55
-	private $formId;
56
-	/**
57
-	 * @var null|string
58
-	 */
59
-	private $getPathBackup = null;
60
-
61
-	/**
62
-	 * @var null|\stdClass
63
-	 */
64
-	private $userSessionBackup = null;
65
-
66
-	/**
67
-	 * @param Storage $storage
68
-	 *
69
-	 * @return void
70
-	 * @throws \Exception
71
-	 */
72
-	public function run(Storage $storage)
73
-	{
74
-		parent::run($storage);
75
-		$this->checkParameters();
76
-		$this->checkRequiredParameters();
77
-		$this->setFormId();
78
-		$this->initialize($storage);
79
-		$this->checkSubmit($storage);
80
-	}
81
-
82
-	/**
83
-	 * @param null|Application $application
84
-	 *
85
-	 * @throws \Exception
86
-	 */
87
-	public function render($application = null)
88
-	{
89
-		$request = $this->setPathBackup();
90
-		$form = $this->renderTemplate($this->subTemplate);
91
-		$this->resetPathBackup($request);
92
-		$this->setFormParameter($form);
93
-
94
-		parent::render($application);
95
-	}
96
-
97
-	/**
98
-	 * Checks if parameters were given in the CMS configuration and
99
-	 * sets them to their respective fields
100
-	 */
101
-	private function checkParameters()
102
-	{
103
-		$this->checkDocumentTypeParameter();
104
-		$this->checkResponseFolderParameter();
105
-		$this->checkSubTemplateParameter();
106
-		$this->checkFormParameterNameParameter();
107
-		$this->checkThankYouMessageParameter();
108
-		$this->checkSubmitOncePerSessionParameter();
109
-	}
110
-
111
-	/**
112
-	 * Sets variables needed for rendering the form template
113
-	 *
114
-	 * @param Storage $storage
115
-	 */
116
-	private function initialize($storage)
117
-	{
118
-		$this->parameters[self::PARAMETER_SMALLEST_IMAGE] = $storage->getImageSet()->getSmallestImageSet();
119
-		$this->parameters[self::PARAMETER_CMS_PREFIX] = '';
120
-
121
-		$this->parameters[self::PARAMETER_DOCUMENT_TYPE] = $this->storage->getDocumentTypes()->getDocumentTypeBySlug($this->documentType, true);
122
-		$this->parameters[self::PARAMETER_DOCUMENT_TYPES] = $this->storage->getDocumentTypes()->getDocumentTypes();
123
-		$this->parameters[self::PARAMETER_HIDE_TITLE_AND_STATE] = true;
124
-		$this->parameters[self::PARAMETER_FORM_ID] = $this->formId;
125
-	}
126
-
127
-	/**
128
-	 * If the form has been submitted, save the document
129
-	 * Calls $this->postSubmit() afterwards
130
-	 *
131
-	 * @param Storage $storage
132
-	 */
133
-	private function checkSubmit($storage)
134
-	{
135
-		if ($this->isFormSubmitted($this->request) && $this->isSubmitAllowed()) {
136
-			$postValues = $this->getPostValues($this->request);
137
-			$this->setUserSessionBackup();
138
-			$storage->getDocuments()->addDocument($postValues);
139
-			$this->restoreUserSessionBackup();
140
-			$this->setSubmitToSession();
141
-			$this->postSubmit($postValues, $storage);
142
-		}
143
-	}
144
-
145
-	/**
146
-	 * Hook for derived classes to take actions after
147
-	 * submitting the form
148
-	 *
149
-	 * @param $postValues
150
-	 * @param $storage
151
-	 */
152
-	protected function postSubmit($postValues, $storage)
153
-	{}
154
-
155
-	/**
156
-	 * Sets a unique id for this particular form, so it can recognize
157
-	 * it when a submit occurs
158
-	 */
159
-	private function setFormId()
160
-	{
161
-		if (isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID])) {
162
-			$this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
163
-		} else {
164
-			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string)microtime(true);
165
-			$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = false;
166
-			$this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
167
-		}
168
-	}
169
-
170
-	/**
171
-	 * Checks if this form has been submitted
172
-	 *
173
-	 * @param \CloudControl\Cms\cc\Request $request
174
-	 *
175
-	 * @return bool
176
-	 */
177
-	private function isFormSubmitted($request)
178
-	{
179
-		return !empty($request::$post) && isset($request::$post[self::PARAMETER_FORM_ID]) && $request::$post[self::PARAMETER_FORM_ID] === $this->formId && isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID]) && $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] === $this->formId;
180
-	}
181
-
182
-	/**
183
-	 * @param \cc\Request $request
184
-	 * @return array
185
-	 */
186
-	private function getPostValues($request)
187
-	{
188
-		$postValues = $request::$post;
189
-		$postValues[self::PARAMETER_DOCUMENT_TYPE] = $this->documentType;
190
-		$postValues[self::GET_PARAMETER_PATH] = $this->responseFolder;
191
-		$postValues['title'] = date('r') . ' - From: ' . $request::$requestUri;
192
-
193
-		return $postValues;
194
-	}
195
-
196
-	/**
197
-	 * Temporarily stores the current user session in a backup variable
198
-	 * and sets a fake user instead
199
-	 */
200
-	private function setUserSessionBackup()
201
-	{
202
-		$this->userSessionBackup = isset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]) ? $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] : null;
203
-		$fakeUser = new \stdClass();
204
-		$fakeUser->username = self::SESSION_PARAMETER_FORM_COMPONENT;
205
-		$_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $fakeUser;
206
-	}
207
-
208
-	/**
209
-	 * Removes the fake user and restores the existing user
210
-	 * session if it was there
211
-	 */
212
-	private function restoreUserSessionBackup()
213
-	{
214
-		if ($this->userSessionBackup === null) {
215
-			unset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]);
216
-		} else {
217
-			$_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $this->userSessionBackup;
218
-		}
219
-	}
220
-
221
-	private function setSubmitToSession()
222
-	{
223
-		$_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = true;
224
-	}
225
-
226
-	private function isSubmitAllowed()
227
-	{
228
-		if ($this->submitOncePerSession === true && $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] === true) {
229
-			return false;
230
-		} else {
231
-			return true;
232
-		}
233
-	}
234
-
235
-	private function checkDocumentTypeParameter()
236
-	{
237
-		if (isset($this->parameters[self::PARAMETER_DOCUMENT_TYPE])) {
238
-			$this->documentType = $this->parameters[self::PARAMETER_DOCUMENT_TYPE];
239
-			unset($this->parameters[self::PARAMETER_DOCUMENT_TYPE]);
240
-		}
241
-	}
242
-
243
-	private function checkResponseFolderParameter()
244
-	{
245
-		if (isset($this->parameters[self::PARAMETER_RESPONSE_FOLDER])) {
246
-			$this->responseFolder = $this->parameters[self::PARAMETER_RESPONSE_FOLDER];
247
-			unset($this->parameters[self::PARAMETER_RESPONSE_FOLDER]);
248
-		}
249
-	}
250
-
251
-	private function checkSubTemplateParameter()
252
-	{
253
-		if (isset($this->parameters[self::PARAMETER_SUB_TEMPLATE])) {
254
-			$this->subTemplate = $this->parameters[self::PARAMETER_SUB_TEMPLATE];
255
-			unset($this->parameters[self::PARAMETER_SUB_TEMPLATE]);
256
-		}
257
-	}
258
-
259
-	private function checkFormParameterNameParameter()
260
-	{
261
-		if (isset($this->parameters[self::PARAMETER_FORM_PARAMETER_NAME])) {
262
-			$this->formParameterName = $this->parameters[self::PARAMETER_FORM_PARAMETER_NAME];
263
-			unset($this->parameters[self::PARAMETER_FORM_PARAMETER_NAME]);
264
-		}
265
-	}
266
-
267
-	private function checkThankYouMessageParameter()
268
-	{
269
-		if (isset($this->parameters[self::PARAMETER_THANK_YOU_MESSAGE])) {
270
-			$this->thankYouMessage = $this->parameters[self::PARAMETER_THANK_YOU_MESSAGE];
271
-			unset($this->parameters[self::PARAMETER_THANK_YOU_MESSAGE]);
272
-		}
273
-	}
274
-
275
-	private function checkSubmitOncePerSessionParameter()
276
-	{
277
-		if (isset($this->parameters[self::PARAMETER_SUBMIT_ONCE_PER_SESSION])) {
278
-			$this->submitOncePerSession = $this->parameters[self::PARAMETER_SUBMIT_ONCE_PER_SESSION] === 'true';
279
-			unset($this->parameters[self::PARAMETER_SUBMIT_ONCE_PER_SESSION]);
280
-		}
281
-	}
282
-
283
-	/**
284
-	 * @throws \Exception
285
-	 */
286
-	private function checkRequiredParameters()
287
-	{
288
-		if ($this->documentType === null || $this->responseFolder === null) {
289
-			throw new \Exception('Parameters `documentType` and `responseFolder` are required for usage with this form');
290
-		}
291
-	}
292
-
293
-	/**
294
-	 * @return \cc\Request
295
-	 */
296
-	private function setPathBackup()
297
-	{
298
-		$request = $this->request;
299
-		if (isset($request::$get[self::GET_PARAMETER_PATH])) {
300
-			$this->getPathBackup = $request::$get[self::GET_PARAMETER_PATH];
301
-		}
302
-		$request::$get[self::GET_PARAMETER_PATH] = $this->responseFolder;
303
-
304
-		return $request;
305
-	}
306
-
307
-	/**
308
-	 * @param \cc\Request $request
309
-	 */
310
-	private function resetPathBackup($request)
311
-	{
312
-		if ($this->getPathBackup !== null) {
313
-			$request::$get[self::GET_PARAMETER_PATH] = $this->getPathBackup;
314
-		} else {
315
-			unset($request::$get[self::GET_PARAMETER_PATH]);
316
-		}
317
-	}
318
-
319
-	/**
320
-	 * @param $form
321
-	 */
322
-	private function setFormParameter($form)
323
-	{
324
-		if ($this->isFormSubmitted($this->request) || $this->isSubmitAllowed() === false) {
325
-			$this->parameters[$this->formParameterName] = '<a name="' . $this->formId . '"></a>' . $this->thankYouMessage;
326
-		} else {
327
-			$this->parameters[$this->formParameterName] = $form;
328
-		}
329
-	}
10
+    const GET_PARAMETER_PATH = 'path';
11
+
12
+    const PARAMETER_CMS_PREFIX = 'cmsPrefix';
13
+    const PARAMETER_DOCUMENT_TYPE = 'documentType';
14
+    const PARAMETER_DOCUMENT_TYPES = 'documentTypes';
15
+    const PARAMETER_FORM_ID = 'formId';
16
+    const PARAMETER_FORM_PARAMETER_NAME = 'formParameterName';
17
+    const PARAMETER_HIDE_TITLE_AND_STATE = 'hideTitleAndState';
18
+    const PARAMETER_RESPONSE_FOLDER = 'responseFolder';
19
+    const PARAMETER_SMALLEST_IMAGE = 'smallestImage';
20
+    const PARAMETER_SUBMIT_ONCE_PER_SESSION = 'submitOncePerSession';
21
+    const PARAMETER_SUB_TEMPLATE = 'subTemplate';
22
+    const PARAMETER_THANK_YOU_MESSAGE = 'thankYouMessage';
23
+
24
+    const SESSION_PARAMETER_CLOUDCONTROL = 'cloudcontrol';
25
+    const SESSION_PARAMETER_FORM_COMPONENT = 'FormComponent';
26
+    /**
27
+     * @var null|string
28
+     */
29
+    protected $documentType = null;
30
+    /**
31
+     * @var null|string
32
+     */
33
+    protected $responseFolder = null;
34
+    /**
35
+     * @var string
36
+     */
37
+    protected $subTemplate = 'cms/documents/document-form-form';
38
+    /**
39
+     * @var string
40
+     */
41
+    protected $formParameterName = 'form';
42
+    /**
43
+     * @var string
44
+     */
45
+    protected $thankYouMessage = 'Thank you for sending us your response.';
46
+
47
+    /**
48
+     * @var bool
49
+     */
50
+    protected $submitOncePerSession = false;
51
+
52
+    /**
53
+     * @var string
54
+     */
55
+    private $formId;
56
+    /**
57
+     * @var null|string
58
+     */
59
+    private $getPathBackup = null;
60
+
61
+    /**
62
+     * @var null|\stdClass
63
+     */
64
+    private $userSessionBackup = null;
65
+
66
+    /**
67
+     * @param Storage $storage
68
+     *
69
+     * @return void
70
+     * @throws \Exception
71
+     */
72
+    public function run(Storage $storage)
73
+    {
74
+        parent::run($storage);
75
+        $this->checkParameters();
76
+        $this->checkRequiredParameters();
77
+        $this->setFormId();
78
+        $this->initialize($storage);
79
+        $this->checkSubmit($storage);
80
+    }
81
+
82
+    /**
83
+     * @param null|Application $application
84
+     *
85
+     * @throws \Exception
86
+     */
87
+    public function render($application = null)
88
+    {
89
+        $request = $this->setPathBackup();
90
+        $form = $this->renderTemplate($this->subTemplate);
91
+        $this->resetPathBackup($request);
92
+        $this->setFormParameter($form);
93
+
94
+        parent::render($application);
95
+    }
96
+
97
+    /**
98
+     * Checks if parameters were given in the CMS configuration and
99
+     * sets them to their respective fields
100
+     */
101
+    private function checkParameters()
102
+    {
103
+        $this->checkDocumentTypeParameter();
104
+        $this->checkResponseFolderParameter();
105
+        $this->checkSubTemplateParameter();
106
+        $this->checkFormParameterNameParameter();
107
+        $this->checkThankYouMessageParameter();
108
+        $this->checkSubmitOncePerSessionParameter();
109
+    }
110
+
111
+    /**
112
+     * Sets variables needed for rendering the form template
113
+     *
114
+     * @param Storage $storage
115
+     */
116
+    private function initialize($storage)
117
+    {
118
+        $this->parameters[self::PARAMETER_SMALLEST_IMAGE] = $storage->getImageSet()->getSmallestImageSet();
119
+        $this->parameters[self::PARAMETER_CMS_PREFIX] = '';
120
+
121
+        $this->parameters[self::PARAMETER_DOCUMENT_TYPE] = $this->storage->getDocumentTypes()->getDocumentTypeBySlug($this->documentType, true);
122
+        $this->parameters[self::PARAMETER_DOCUMENT_TYPES] = $this->storage->getDocumentTypes()->getDocumentTypes();
123
+        $this->parameters[self::PARAMETER_HIDE_TITLE_AND_STATE] = true;
124
+        $this->parameters[self::PARAMETER_FORM_ID] = $this->formId;
125
+    }
126
+
127
+    /**
128
+     * If the form has been submitted, save the document
129
+     * Calls $this->postSubmit() afterwards
130
+     *
131
+     * @param Storage $storage
132
+     */
133
+    private function checkSubmit($storage)
134
+    {
135
+        if ($this->isFormSubmitted($this->request) && $this->isSubmitAllowed()) {
136
+            $postValues = $this->getPostValues($this->request);
137
+            $this->setUserSessionBackup();
138
+            $storage->getDocuments()->addDocument($postValues);
139
+            $this->restoreUserSessionBackup();
140
+            $this->setSubmitToSession();
141
+            $this->postSubmit($postValues, $storage);
142
+        }
143
+    }
144
+
145
+    /**
146
+     * Hook for derived classes to take actions after
147
+     * submitting the form
148
+     *
149
+     * @param $postValues
150
+     * @param $storage
151
+     */
152
+    protected function postSubmit($postValues, $storage)
153
+    {}
154
+
155
+    /**
156
+     * Sets a unique id for this particular form, so it can recognize
157
+     * it when a submit occurs
158
+     */
159
+    private function setFormId()
160
+    {
161
+        if (isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID])) {
162
+            $this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
163
+        } else {
164
+            $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] = (string)microtime(true);
165
+            $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = false;
166
+            $this->formId = $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID];
167
+        }
168
+    }
169
+
170
+    /**
171
+     * Checks if this form has been submitted
172
+     *
173
+     * @param \CloudControl\Cms\cc\Request $request
174
+     *
175
+     * @return bool
176
+     */
177
+    private function isFormSubmitted($request)
178
+    {
179
+        return !empty($request::$post) && isset($request::$post[self::PARAMETER_FORM_ID]) && $request::$post[self::PARAMETER_FORM_ID] === $this->formId && isset($_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID]) && $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName][self::PARAMETER_FORM_ID] === $this->formId;
180
+    }
181
+
182
+    /**
183
+     * @param \cc\Request $request
184
+     * @return array
185
+     */
186
+    private function getPostValues($request)
187
+    {
188
+        $postValues = $request::$post;
189
+        $postValues[self::PARAMETER_DOCUMENT_TYPE] = $this->documentType;
190
+        $postValues[self::GET_PARAMETER_PATH] = $this->responseFolder;
191
+        $postValues['title'] = date('r') . ' - From: ' . $request::$requestUri;
192
+
193
+        return $postValues;
194
+    }
195
+
196
+    /**
197
+     * Temporarily stores the current user session in a backup variable
198
+     * and sets a fake user instead
199
+     */
200
+    private function setUserSessionBackup()
201
+    {
202
+        $this->userSessionBackup = isset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]) ? $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] : null;
203
+        $fakeUser = new \stdClass();
204
+        $fakeUser->username = self::SESSION_PARAMETER_FORM_COMPONENT;
205
+        $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $fakeUser;
206
+    }
207
+
208
+    /**
209
+     * Removes the fake user and restores the existing user
210
+     * session if it was there
211
+     */
212
+    private function restoreUserSessionBackup()
213
+    {
214
+        if ($this->userSessionBackup === null) {
215
+            unset($_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL]);
216
+        } else {
217
+            $_SESSION[self::SESSION_PARAMETER_CLOUDCONTROL] = $this->userSessionBackup;
218
+        }
219
+    }
220
+
221
+    private function setSubmitToSession()
222
+    {
223
+        $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] = true;
224
+    }
225
+
226
+    private function isSubmitAllowed()
227
+    {
228
+        if ($this->submitOncePerSession === true && $_SESSION[self::SESSION_PARAMETER_FORM_COMPONENT][$this->formParameterName]['submitted'] === true) {
229
+            return false;
230
+        } else {
231
+            return true;
232
+        }
233
+    }
234
+
235
+    private function checkDocumentTypeParameter()
236
+    {
237
+        if (isset($this->parameters[self::PARAMETER_DOCUMENT_TYPE])) {
238
+            $this->documentType = $this->parameters[self::PARAMETER_DOCUMENT_TYPE];
239
+            unset($this->parameters[self::PARAMETER_DOCUMENT_TYPE]);
240
+        }
241
+    }
242
+
243
+    private function checkResponseFolderParameter()
244
+    {
245
+        if (isset($this->parameters[self::PARAMETER_RESPONSE_FOLDER])) {
246
+            $this->responseFolder = $this->parameters[self::PARAMETER_RESPONSE_FOLDER];
247
+            unset($this->parameters[self::PARAMETER_RESPONSE_FOLDER]);
248
+        }
249
+    }
250
+
251
+    private function checkSubTemplateParameter()
252
+    {
253
+        if (isset($this->parameters[self::PARAMETER_SUB_TEMPLATE])) {
254
+            $this->subTemplate = $this->parameters[self::PARAMETER_SUB_TEMPLATE];
255
+            unset($this->parameters[self::PARAMETER_SUB_TEMPLATE]);
256
+        }
257
+    }
258
+
259
+    private function checkFormParameterNameParameter()
260
+    {
261
+        if (isset($this->parameters[self::PARAMETER_FORM_PARAMETER_NAME])) {
262
+            $this->formParameterName = $this->parameters[self::PARAMETER_FORM_PARAMETER_NAME];
263
+            unset($this->parameters[self::PARAMETER_FORM_PARAMETER_NAME]);
264
+        }
265
+    }
266
+
267
+    private function checkThankYouMessageParameter()
268
+    {
269
+        if (isset($this->parameters[self::PARAMETER_THANK_YOU_MESSAGE])) {
270
+            $this->thankYouMessage = $this->parameters[self::PARAMETER_THANK_YOU_MESSAGE];
271
+            unset($this->parameters[self::PARAMETER_THANK_YOU_MESSAGE]);
272
+        }
273
+    }
274
+
275
+    private function checkSubmitOncePerSessionParameter()
276
+    {
277
+        if (isset($this->parameters[self::PARAMETER_SUBMIT_ONCE_PER_SESSION])) {
278
+            $this->submitOncePerSession = $this->parameters[self::PARAMETER_SUBMIT_ONCE_PER_SESSION] === 'true';
279
+            unset($this->parameters[self::PARAMETER_SUBMIT_ONCE_PER_SESSION]);
280
+        }
281
+    }
282
+
283
+    /**
284
+     * @throws \Exception
285
+     */
286
+    private function checkRequiredParameters()
287
+    {
288
+        if ($this->documentType === null || $this->responseFolder === null) {
289
+            throw new \Exception('Parameters `documentType` and `responseFolder` are required for usage with this form');
290
+        }
291
+    }
292
+
293
+    /**
294
+     * @return \cc\Request
295
+     */
296
+    private function setPathBackup()
297
+    {
298
+        $request = $this->request;
299
+        if (isset($request::$get[self::GET_PARAMETER_PATH])) {
300
+            $this->getPathBackup = $request::$get[self::GET_PARAMETER_PATH];
301
+        }
302
+        $request::$get[self::GET_PARAMETER_PATH] = $this->responseFolder;
303
+
304
+        return $request;
305
+    }
306
+
307
+    /**
308
+     * @param \cc\Request $request
309
+     */
310
+    private function resetPathBackup($request)
311
+    {
312
+        if ($this->getPathBackup !== null) {
313
+            $request::$get[self::GET_PARAMETER_PATH] = $this->getPathBackup;
314
+        } else {
315
+            unset($request::$get[self::GET_PARAMETER_PATH]);
316
+        }
317
+    }
318
+
319
+    /**
320
+     * @param $form
321
+     */
322
+    private function setFormParameter($form)
323
+    {
324
+        if ($this->isFormSubmitted($this->request) || $this->isSubmitAllowed() === false) {
325
+            $this->parameters[$this->formParameterName] = '<a name="' . $this->formId . '"></a>' . $this->thankYouMessage;
326
+        } else {
327
+            $this->parameters[$this->formParameterName] = $form;
328
+        }
329
+    }
330 330
 }
331 331
\ No newline at end of file
Please login to merge, or discard this patch.
src/images/Image.php 3 patches
Doc Comments   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 		 * @param string $imagePath
77 77
 		 * @param bool   $getExtension
78 78
 		 *
79
-		 * @return bool|int|string
79
+		 * @return integer
80 80
 		 */
81 81
 		public function getImageMimeType($imagePath, $getExtension = false)
82 82
 		{
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 		}
150 150
 
151 151
 		/**
152
-		 * @param $pathToBitmapFile
152
+		 * @param string $pathToBitmapFile
153 153
 		 *
154 154
 		 * @return string
155 155
 		 */
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 		}
166 166
 
167 167
 		/**
168
-		 * @param $header
168
+		 * @param string $header
169 169
 		 *
170 170
 		 * @return array
171 171
 		 */
@@ -195,14 +195,14 @@  discard block
 block discarded – undo
195 195
 		 * Loop through the data in the body of the bitmap
196 196
 		 * file and calculate each individual pixel based on the
197 197
 		 * bytes
198
-		 * @param $bodySize
199
-		 * @param $x
198
+		 * @param integer $bodySize
199
+		 * @param integer $x
200 200
 		 * @param $width
201
-		 * @param $usePadding
202
-		 * @param $y
201
+		 * @param boolean $usePadding
202
+		 * @param integer $y
203 203
 		 * @param $height
204
-		 * @param $body
205
-		 * @param $image
204
+		 * @param string $body
205
+		 * @param resource $image
206 206
 		 */
207 207
 		private function loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image)
208 208
 		{
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 			} elseif (is_string($imageContainer)) {
36 36
 				$this->_imageResource = imagecreatefromstring($imageContainer);
37 37
 			} else {
38
-				throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>' . var_export($imageContainer, true) . '</pre>');
38
+				throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>'.var_export($imageContainer, true).'</pre>');
39 39
 			}
40 40
 		}
41 41
 
@@ -179,9 +179,9 @@  discard block
 block discarded – undo
179 179
 				//    Cut it in parts of 2 bytes
180 180
 				$header_parts = str_split($header, 2);
181 181
 				//    Get the width        4 bytes
182
-				$width = hexdec($header_parts[19] . $header_parts[18]);
182
+				$width = hexdec($header_parts[19].$header_parts[18]);
183 183
 				//    Get the height        4 bytes
184
-				$height = hexdec($header_parts[23] . $header_parts[22]);
184
+				$height = hexdec($header_parts[23].$header_parts[22]);
185 185
 				//    Unset the header params
186 186
 				unset($header_parts);
187 187
 
@@ -226,9 +226,9 @@  discard block
 block discarded – undo
226 226
 				}
227 227
 				//    Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body
228 228
 				$iPos = $i * 2;
229
-				$r = hexdec($body[$iPos + 4] . $body[$iPos + 5]);
230
-				$g = hexdec($body[$iPos + 2] . $body[$iPos + 3]);
231
-				$b = hexdec($body[$iPos] . $body[$iPos + 1]);
229
+				$r = hexdec($body[$iPos + 4].$body[$iPos + 5]);
230
+				$g = hexdec($body[$iPos + 2].$body[$iPos + 3]);
231
+				$b = hexdec($body[$iPos].$body[$iPos + 1]);
232 232
 				//    Calculate and draw the pixel
233 233
 				$color = imagecolorallocate($image, $r, $g, $b);
234 234
 				imagesetpixel($image, $x, $height - $y, $color);
Please login to merge, or discard this patch.
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -9,232 +9,232 @@
 block discarded – undo
9 9
  */
10 10
 
11 11
 namespace CloudControl\Cms\images {
12
-	class Image
13
-	{
14
-		private $_imageResource;
15
-
16
-		/**
17
-		 * Load the a image resource into $this->_imageResource
18
-		 * automagically :-)
19
-		 *
20
-		 * @param    resource | string | path
21
-		 *
22
-		 * @throws    \Exception
23
-		 */
24
-		public function loadImage($imageContainer)
25
-		{
26
-			if (is_resource($imageContainer) && get_resource_type($imageContainer) === 'gd') {
27
-				$this->_imageResource = $imageContainer;
28
-			} elseif (is_string($imageContainer) && file_exists($imageContainer)) {
29
-				if ($this->getImageMimeType($imageContainer) == IMAGETYPE_BMP) {
30
-					$this->_imageResource = $this->createImageFromBmp($imageContainer);
31
-				} else {
32
-					$imageContent = file_get_contents($imageContainer);
33
-					$this->_imageResource = imagecreatefromstring($imageContent);
34
-				}
35
-			} elseif (is_string($imageContainer)) {
36
-				$this->_imageResource = imagecreatefromstring($imageContainer);
37
-			} else {
38
-				throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>' . var_export($imageContainer, true) . '</pre>');
39
-			}
40
-		}
41
-
42
-		/**
43
-		 * Saves the image to a file
44
-		 *
45
-		 * @param string $path
46
-		 * @param int    $mimeTypeConstantValue
47
-		 * @param int    $quality
48
-		 * @param null   $imageResource If no resource is given, uses $this->_imageResource
49
-		 *
50
-		 * @return bool
51
-		 * @throws \Exception
52
-		 */
53
-		public function saveImage($path, $mimeTypeConstantValue, $quality = 100, $imageResource = null)
54
-		{
55
-			if ($imageResource == null) {
56
-				$imageResource = $this->getImageResource();
57
-			}
58
-
59
-			if ($mimeTypeConstantValue == IMAGETYPE_GIF) {
60
-				return imagegif($imageResource, $path);
61
-			} elseif ($mimeTypeConstantValue == IMAGETYPE_JPEG) {
62
-				return imagejpeg($imageResource, $path, $quality);
63
-			} elseif ($mimeTypeConstantValue == IMAGETYPE_PNG) {
64
-				return imagepng($imageResource, $path, (intval($quality / 10) - 1));
65
-			} else {
66
-				throw new \Exception('Not a valid mimetypeconstant given see function documentation');
67
-			}
68
-		}
69
-
70
-		/**
71
-		 * Returns either the Mime-Type Constant value
72
-		 * or the default extension for the detected mime-type;
73
-		 *
74
-		 * @see http://www.php.net/manual/en/function.image-type-to-mime-type.php
75
-		 *
76
-		 * @param string $imagePath
77
-		 * @param bool   $getExtension
78
-		 *
79
-		 * @return bool|int|string
80
-		 */
81
-		public function getImageMimeType($imagePath, $getExtension = false)
82
-		{
83
-			if (function_exists('exif_imagetype')) {
84
-				$exif = exif_imagetype($imagePath);
85
-			} else {
86
-				if ((list($width, $height, $type, $attr) = getimagesize($imagePath)) !== false) {
87
-					$exif = $type;
88
-				} else {
89
-					$exif = false;
90
-				}
91
-			}
92
-
93
-			return $getExtension ? image_type_to_extension($exif) : $exif;
94
-		}
95
-
96
-		/**
97
-		 * Create Image resource from Bitmap
98
-		 *
99
-		 * @see       http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
100
-		 * @author    alexander at alexauto dot nl
101
-		 *
102
-		 * @param    string $pathToBitmapFile
103
-		 *
104
-		 * @return  resource
105
-		 */
106
-		public function createImageFromBmp($pathToBitmapFile)
107
-		{
108
-			$bitmapFileData = $this->getBitmapFileData($pathToBitmapFile);
109
-
110
-			$temp = unpack("H*", $bitmapFileData);
111
-			$hex = $temp[1];
112
-			$header = substr($hex, 0, 108);
113
-			list($width, $height) = $this->calculateWidthAndHeight($header);
114
-
115
-			//    Define starting X and Y 
116
-			$x = 0;
117
-			$y = 1;
118
-
119
-			$image = imagecreatetruecolor($width, $height);
120
-
121
-			//    Grab the body from the image 
122
-			$body = substr($hex, 108);
123
-
124
-			//    Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars
125
-			$bodySize = (strlen($body) / 2);
126
-			$headerSize = ($width * $height);
127
-
128
-			//    Use end-line padding? Only when needed 
129
-			$usePadding = ($bodySize > ($headerSize * 3) + 4);
130
-			$this->loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image);
131
-
132
-			unset($body);
133
-
134
-			return $image;
135
-		}
136
-
137
-		/**
138
-		 * Returns the image resource
139
-		 * @return resource
140
-		 * @throws \Exception
141
-		 */
142
-		final public function getImageResource()
143
-		{
144
-			if (is_resource($this->_imageResource) && get_resource_type($this->_imageResource) === 'gd') {
145
-				return $this->_imageResource;
146
-			} else {
147
-				throw new \Exception('Image resource is not set. Use $this->LoadImage to load an image into the resource');
148
-			}
149
-		}
150
-
151
-		/**
152
-		 * @param $pathToBitmapFile
153
-		 *
154
-		 * @return string
155
-		 */
156
-		private function getBitmapFileData($pathToBitmapFile)
157
-		{
158
-			$fileHandle = fopen($pathToBitmapFile, "rb");
159
-			$bitmapFileData = fread($fileHandle, 10);
160
-			while (!feof($fileHandle) && ($bitmapFileData <> "")) {
161
-				$bitmapFileData .= fread($fileHandle, 1024);
162
-			}
163
-
164
-			return $bitmapFileData;
165
-		}
166
-
167
-		/**
168
-		 * @param $header
169
-		 *
170
-		 * @return array
171
-		 */
172
-		private function calculateWidthAndHeight($header)
173
-		{
174
-			$width = null;
175
-			$height = null;
176
-
177
-			//    Structure: http://www.fastgraph.com/help/bmp_header_format.html
178
-			if (substr($header, 0, 4) == "424d") {
179
-				//    Cut it in parts of 2 bytes
180
-				$header_parts = str_split($header, 2);
181
-				//    Get the width        4 bytes
182
-				$width = hexdec($header_parts[19] . $header_parts[18]);
183
-				//    Get the height        4 bytes
184
-				$height = hexdec($header_parts[23] . $header_parts[22]);
185
-				//    Unset the header params
186
-				unset($header_parts);
187
-
188
-				return array($width, $height);
189
-			}
190
-
191
-			return array($width, $height);
192
-		}
193
-
194
-		/**
195
-		 * Loop through the data in the body of the bitmap
196
-		 * file and calculate each individual pixel based on the
197
-		 * bytes
198
-		 * @param $bodySize
199
-		 * @param $x
200
-		 * @param $width
201
-		 * @param $usePadding
202
-		 * @param $y
203
-		 * @param $height
204
-		 * @param $body
205
-		 * @param $image
206
-		 */
207
-		private function loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image)
208
-		{
12
+    class Image
13
+    {
14
+        private $_imageResource;
15
+
16
+        /**
17
+         * Load the a image resource into $this->_imageResource
18
+         * automagically :-)
19
+         *
20
+         * @param    resource | string | path
21
+         *
22
+         * @throws    \Exception
23
+         */
24
+        public function loadImage($imageContainer)
25
+        {
26
+            if (is_resource($imageContainer) && get_resource_type($imageContainer) === 'gd') {
27
+                $this->_imageResource = $imageContainer;
28
+            } elseif (is_string($imageContainer) && file_exists($imageContainer)) {
29
+                if ($this->getImageMimeType($imageContainer) == IMAGETYPE_BMP) {
30
+                    $this->_imageResource = $this->createImageFromBmp($imageContainer);
31
+                } else {
32
+                    $imageContent = file_get_contents($imageContainer);
33
+                    $this->_imageResource = imagecreatefromstring($imageContent);
34
+                }
35
+            } elseif (is_string($imageContainer)) {
36
+                $this->_imageResource = imagecreatefromstring($imageContainer);
37
+            } else {
38
+                throw new \Exception('Could not create image resource, accepted inputs are: "resource of type (gd)", path_to_image and "string". <br /><pre>' . var_export($imageContainer, true) . '</pre>');
39
+            }
40
+        }
41
+
42
+        /**
43
+         * Saves the image to a file
44
+         *
45
+         * @param string $path
46
+         * @param int    $mimeTypeConstantValue
47
+         * @param int    $quality
48
+         * @param null   $imageResource If no resource is given, uses $this->_imageResource
49
+         *
50
+         * @return bool
51
+         * @throws \Exception
52
+         */
53
+        public function saveImage($path, $mimeTypeConstantValue, $quality = 100, $imageResource = null)
54
+        {
55
+            if ($imageResource == null) {
56
+                $imageResource = $this->getImageResource();
57
+            }
58
+
59
+            if ($mimeTypeConstantValue == IMAGETYPE_GIF) {
60
+                return imagegif($imageResource, $path);
61
+            } elseif ($mimeTypeConstantValue == IMAGETYPE_JPEG) {
62
+                return imagejpeg($imageResource, $path, $quality);
63
+            } elseif ($mimeTypeConstantValue == IMAGETYPE_PNG) {
64
+                return imagepng($imageResource, $path, (intval($quality / 10) - 1));
65
+            } else {
66
+                throw new \Exception('Not a valid mimetypeconstant given see function documentation');
67
+            }
68
+        }
69
+
70
+        /**
71
+         * Returns either the Mime-Type Constant value
72
+         * or the default extension for the detected mime-type;
73
+         *
74
+         * @see http://www.php.net/manual/en/function.image-type-to-mime-type.php
75
+         *
76
+         * @param string $imagePath
77
+         * @param bool   $getExtension
78
+         *
79
+         * @return bool|int|string
80
+         */
81
+        public function getImageMimeType($imagePath, $getExtension = false)
82
+        {
83
+            if (function_exists('exif_imagetype')) {
84
+                $exif = exif_imagetype($imagePath);
85
+            } else {
86
+                if ((list($width, $height, $type, $attr) = getimagesize($imagePath)) !== false) {
87
+                    $exif = $type;
88
+                } else {
89
+                    $exif = false;
90
+                }
91
+            }
92
+
93
+            return $getExtension ? image_type_to_extension($exif) : $exif;
94
+        }
95
+
96
+        /**
97
+         * Create Image resource from Bitmap
98
+         *
99
+         * @see       http://www.php.net/manual/en/function.imagecreatefromwbmp.php#86214
100
+         * @author    alexander at alexauto dot nl
101
+         *
102
+         * @param    string $pathToBitmapFile
103
+         *
104
+         * @return  resource
105
+         */
106
+        public function createImageFromBmp($pathToBitmapFile)
107
+        {
108
+            $bitmapFileData = $this->getBitmapFileData($pathToBitmapFile);
109
+
110
+            $temp = unpack("H*", $bitmapFileData);
111
+            $hex = $temp[1];
112
+            $header = substr($hex, 0, 108);
113
+            list($width, $height) = $this->calculateWidthAndHeight($header);
114
+
115
+            //    Define starting X and Y 
116
+            $x = 0;
117
+            $y = 1;
118
+
119
+            $image = imagecreatetruecolor($width, $height);
120
+
121
+            //    Grab the body from the image 
122
+            $body = substr($hex, 108);
123
+
124
+            //    Calculate if padding at the end-line is needed. Divided by two to keep overview. 1 byte = 2 HEX-chars
125
+            $bodySize = (strlen($body) / 2);
126
+            $headerSize = ($width * $height);
127
+
128
+            //    Use end-line padding? Only when needed 
129
+            $usePadding = ($bodySize > ($headerSize * 3) + 4);
130
+            $this->loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image);
131
+
132
+            unset($body);
133
+
134
+            return $image;
135
+        }
136
+
137
+        /**
138
+         * Returns the image resource
139
+         * @return resource
140
+         * @throws \Exception
141
+         */
142
+        final public function getImageResource()
143
+        {
144
+            if (is_resource($this->_imageResource) && get_resource_type($this->_imageResource) === 'gd') {
145
+                return $this->_imageResource;
146
+            } else {
147
+                throw new \Exception('Image resource is not set. Use $this->LoadImage to load an image into the resource');
148
+            }
149
+        }
150
+
151
+        /**
152
+         * @param $pathToBitmapFile
153
+         *
154
+         * @return string
155
+         */
156
+        private function getBitmapFileData($pathToBitmapFile)
157
+        {
158
+            $fileHandle = fopen($pathToBitmapFile, "rb");
159
+            $bitmapFileData = fread($fileHandle, 10);
160
+            while (!feof($fileHandle) && ($bitmapFileData <> "")) {
161
+                $bitmapFileData .= fread($fileHandle, 1024);
162
+            }
163
+
164
+            return $bitmapFileData;
165
+        }
166
+
167
+        /**
168
+         * @param $header
169
+         *
170
+         * @return array
171
+         */
172
+        private function calculateWidthAndHeight($header)
173
+        {
174
+            $width = null;
175
+            $height = null;
176
+
177
+            //    Structure: http://www.fastgraph.com/help/bmp_header_format.html
178
+            if (substr($header, 0, 4) == "424d") {
179
+                //    Cut it in parts of 2 bytes
180
+                $header_parts = str_split($header, 2);
181
+                //    Get the width        4 bytes
182
+                $width = hexdec($header_parts[19] . $header_parts[18]);
183
+                //    Get the height        4 bytes
184
+                $height = hexdec($header_parts[23] . $header_parts[22]);
185
+                //    Unset the header params
186
+                unset($header_parts);
187
+
188
+                return array($width, $height);
189
+            }
190
+
191
+            return array($width, $height);
192
+        }
193
+
194
+        /**
195
+         * Loop through the data in the body of the bitmap
196
+         * file and calculate each individual pixel based on the
197
+         * bytes
198
+         * @param $bodySize
199
+         * @param $x
200
+         * @param $width
201
+         * @param $usePadding
202
+         * @param $y
203
+         * @param $height
204
+         * @param $body
205
+         * @param $image
206
+         */
207
+        private function loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image)
208
+        {
209 209
 //    Using a for-loop with index-calculation instead of str_split to avoid large memory consumption
210
-			//    Calculate the next DWORD-position in the body
211
-			for ($i = 0; $i < $bodySize; $i += 3) {
212
-				//    Calculate line-ending and padding
213
-				if ($x >= $width) {
214
-					//    If padding needed, ignore image-padding. Shift i to the ending of the current 32-bit-block
215
-					if ($usePadding) {
216
-						$i += $width % 4;
217
-					}
218
-					//    Reset horizontal position
219
-					$x = 0;
220
-					//    Raise the height-position (bottom-up)
221
-					$y++;
222
-					//    Reached the image-height? Break the for-loop
223
-					if ($y > $height) {
224
-						break;
225
-					}
226
-				}
227
-				//    Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body
228
-				$iPos = $i * 2;
229
-				$r = hexdec($body[$iPos + 4] . $body[$iPos + 5]);
230
-				$g = hexdec($body[$iPos + 2] . $body[$iPos + 3]);
231
-				$b = hexdec($body[$iPos] . $body[$iPos + 1]);
232
-				//    Calculate and draw the pixel
233
-				$color = imagecolorallocate($image, $r, $g, $b);
234
-				imagesetpixel($image, $x, $height - $y, $color);
235
-				//    Raise the horizontal position
236
-				$x++;
237
-			}
238
-		}
239
-	}
210
+            //    Calculate the next DWORD-position in the body
211
+            for ($i = 0; $i < $bodySize; $i += 3) {
212
+                //    Calculate line-ending and padding
213
+                if ($x >= $width) {
214
+                    //    If padding needed, ignore image-padding. Shift i to the ending of the current 32-bit-block
215
+                    if ($usePadding) {
216
+                        $i += $width % 4;
217
+                    }
218
+                    //    Reset horizontal position
219
+                    $x = 0;
220
+                    //    Raise the height-position (bottom-up)
221
+                    $y++;
222
+                    //    Reached the image-height? Break the for-loop
223
+                    if ($y > $height) {
224
+                        break;
225
+                    }
226
+                }
227
+                //    Calculation of the RGB-pixel (defined as BGR in image-data). Define $iPos as absolute position in the body
228
+                $iPos = $i * 2;
229
+                $r = hexdec($body[$iPos + 4] . $body[$iPos + 5]);
230
+                $g = hexdec($body[$iPos + 2] . $body[$iPos + 3]);
231
+                $b = hexdec($body[$iPos] . $body[$iPos + 1]);
232
+                //    Calculate and draw the pixel
233
+                $color = imagecolorallocate($image, $r, $g, $b);
234
+                imagesetpixel($image, $x, $height - $y, $color);
235
+                //    Raise the horizontal position
236
+                $x++;
237
+            }
238
+        }
239
+    }
240 240
 }
241 241
\ No newline at end of file
Please login to merge, or discard this patch.
src/storage/storage/ImagesStorage.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -13,6 +13,10 @@
 block discarded – undo
13 13
 {
14 14
     protected $imagesDir;
15 15
 
16
+    /**
17
+     * @param \CloudControl\Cms\storage\Repository $repository
18
+     * @param string $imagesDir
19
+     */
16 20
     public function __construct($repository, $imagesDir)
17 21
     {
18 22
         parent::__construct($repository);
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
         $destinationPath = $this->getDestinationPath();
46 46
 
47 47
         $filename = $this->validateFilename($postValues['name'], $destinationPath);
48
-        $destination = $destinationPath . DIRECTORY_SEPARATOR . $filename;
48
+        $destination = $destinationPath.DIRECTORY_SEPARATOR.$filename;
49 49
 
50 50
         if ($postValues['error'] != '0') {
51
-            throw new \Exception('Error uploading file. Error code: ' . $postValues['error']);
51
+            throw new \Exception('Error uploading file. Error code: '.$postValues['error']);
52 52
         }
53 53
 
54 54
         if (move_uploaded_file($postValues['tmp_name'], $destination)) {
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
         foreach ($images as $key => $image) {
81 81
             if ($image->file == $filename) {
82 82
                 foreach ($image->set as $imageSetFilename) {
83
-                    $destination = $destinationPath . '/' . $imageSetFilename;
83
+                    $destination = $destinationPath.'/'.$imageSetFilename;
84 84
                     if (file_exists($destination)) {
85 85
                         unlink($destination);
86 86
                     } else {
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
      */
129 129
     private function getDestinationPath()
130 130
     {
131
-        $destinationPath = realpath($this->imagesDir . DIRECTORY_SEPARATOR);
131
+        $destinationPath = realpath($this->imagesDir.DIRECTORY_SEPARATOR);
132 132
         return $destinationPath;
133 133
     }
134 134
 }
135 135
\ No newline at end of file
Please login to merge, or discard this patch.
src/images/methods/Resize.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 			
64 64
 			// Define the ratio and adjust the width and height
65 65
 			if ($this->_preserveAspectRatio) {
66
-				$ratio = min($this->_width/$originalWidth, $this->_height/$originalHeight);
66
+				$ratio = min($this->_width / $originalWidth, $this->_height / $originalHeight);
67 67
 				$this->_width = $originalWidth * $ratio;
68 68
 				$this->_height = $originalHeight * $ratio;
69 69
 			}
Please login to merge, or discard this patch.
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -14,73 +14,73 @@
 block discarded – undo
14 14
     use CloudControl\Cms\images\IMethod;
15 15
 
16 16
     class Resize extends IMethod
17
-	{
18
-		protected $_width;
19
-		protected $_height;
20
-		protected $_preserveAspectRatio = true;
17
+    {
18
+        protected $_width;
19
+        protected $_height;
20
+        protected $_preserveAspectRatio = true;
21 21
 		
22
-		/**
23
-		 * Set the width
24
-		 *
25
-		 * @param  int $width
26
-		 * @return self
27
-		 */
28
-		public function SetWidth($width)
29
-		{
30
-			$this->_width = intval($width);
31
-			return $this;
32
-		}
22
+        /**
23
+         * Set the width
24
+         *
25
+         * @param  int $width
26
+         * @return self
27
+         */
28
+        public function SetWidth($width)
29
+        {
30
+            $this->_width = intval($width);
31
+            return $this;
32
+        }
33 33
 		
34
-		/**
35
-		 * Set the height
36
-		 *
37
-		 * @param  int $height
38
-		 * @return self
39
-		 */
40
-		public function SetHeight($height)
41
-		{
42
-			$this->_height = intval($height);
43
-			return $this;
44
-		}
34
+        /**
35
+         * Set the height
36
+         *
37
+         * @param  int $height
38
+         * @return self
39
+         */
40
+        public function SetHeight($height)
41
+        {
42
+            $this->_height = intval($height);
43
+            return $this;
44
+        }
45 45
 		
46
-		/**
47
-		 * Sets wheter or not the aspect ratio of the original
48
-		 * image needs to preserved
49
-		 *
50
-		 * @param  bool $bool
51
-		 * @return self
52
-		 */
53
-		public function SetPreserveAspectRatio($bool)
54
-		{
55
-			$this->_preserveAspectRatio = (bool) $bool;
56
-			return $this;
57
-		}
46
+        /**
47
+         * Sets wheter or not the aspect ratio of the original
48
+         * image needs to preserved
49
+         *
50
+         * @param  bool $bool
51
+         * @return self
52
+         */
53
+        public function SetPreserveAspectRatio($bool)
54
+        {
55
+            $this->_preserveAspectRatio = (bool) $bool;
56
+            return $this;
57
+        }
58 58
 		
59
-		public function Execute($imageResource)
60
-		{
61
-			// Define the origial width and height
62
-			$originalWidth = imagesx($imageResource);
63
-			$originalHeight = imagesy($imageResource);
59
+        public function Execute($imageResource)
60
+        {
61
+            // Define the origial width and height
62
+            $originalWidth = imagesx($imageResource);
63
+            $originalHeight = imagesy($imageResource);
64 64
 			
65
-			// Define the ratio and adjust the width and height
66
-			if ($this->_preserveAspectRatio) {
67
-				$ratio = min($this->_width/$originalWidth, $this->_height/$originalHeight);
68
-				$this->_width = $originalWidth * $ratio;
69
-				$this->_height = $originalHeight * $ratio;
70
-			}
65
+            // Define the ratio and adjust the width and height
66
+            if ($this->_preserveAspectRatio) {
67
+                $ratio = min($this->_width/$originalWidth, $this->_height/$originalHeight);
68
+                $this->_width = $originalWidth * $ratio;
69
+                $this->_height = $originalHeight * $ratio;
70
+            }
71 71
 			
72
-			// Create the new image
73
-			$new = imagecreatetruecolor($this->_width, $this->_height);
72
+            // Create the new image
73
+            $new = imagecreatetruecolor($this->_width, $this->_height);
74 74
 			
75
-			// Preserve transparency
76
-			imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
77
-			imagealphablending($new, false);
78
-			imagesavealpha($new, true);
75
+            // Preserve transparency
76
+            imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127));
77
+            imagealphablending($new, false);
78
+            imagesavealpha($new, true);
79 79
 			
80
-			// Do the actual resizing
81
-			imagecopyresampled($new, $imageResource, 0, 0, 0, 0, $this->_width, $this->_height, $originalWidth, $originalHeight);
80
+            // Do the actual resizing
81
+            imagecopyresampled($new, $imageResource, 0, 0, 0, 0, $this->_width, $this->_height, $originalWidth, $originalHeight);
82 82
 			
83
-			return $new;
84
-		}
85
-	}
83
+            return $new;
84
+        }
85
+    }
86 86
 }
87 87
\ No newline at end of file
Please login to merge, or discard this patch.
src/images/methods/BoxCrop.php 3 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -26,14 +26,14 @@
 block discarded – undo
26 26
 			
27 27
 			// Define which ratio will be used, depending on which is the smallest side
28 28
 			$ratio = min($hRatio, $wRatio);
29
-			if($ratio > 1) $ratio = 1;
29
+			if ($ratio > 1) $ratio = 1;
30 30
 			
31 31
 			// Define sizes
32 32
 			$this->_destWidth = floor($originalWidth * $ratio);
33 33
 			$this->_destHeight = floor($originalHeight * $ratio);
34 34
 			
35 35
 			// Define margins
36
-			$this->_destX = floor(($this->_width  - $this->_destWidth) / 2);
36
+			$this->_destX = floor(($this->_width - $this->_destWidth) / 2);
37 37
 			$this->_destY = floor(($this->_height - $this->_destHeight) / 2);
38 38
 			
39 39
 			// Execute the Crop method with the given parameters
Please login to merge, or discard this patch.
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,36 +10,36 @@
 block discarded – undo
10 10
  
11 11
 namespace CloudControl\Cms\images\methods
12 12
 {
13
-	class BoxCrop extends Crop
14
-	{
15
-		/**
16
-		 * @param resource $imageResource
17
-		 * @return resource
13
+    class BoxCrop extends Crop
14
+    {
15
+        /**
16
+         * @param resource $imageResource
17
+         * @return resource
18 18
          */
19
-		public function Execute($imageResource)
20
-		{
21
-			// Define the origial width and height
22
-			$originalWidth = imagesx($imageResource);
23
-			$originalHeight = imagesy($imageResource);
19
+        public function Execute($imageResource)
20
+        {
21
+            // Define the origial width and height
22
+            $originalWidth = imagesx($imageResource);
23
+            $originalHeight = imagesy($imageResource);
24 24
 			
25
-			// Define the ratios
26
-			$wRatio = $this->_width / $originalWidth;
27
-			$hRatio = $this->_height / $originalHeight;
25
+            // Define the ratios
26
+            $wRatio = $this->_width / $originalWidth;
27
+            $hRatio = $this->_height / $originalHeight;
28 28
 			
29
-			// Define which ratio will be used, depending on which is the smallest side
30
-			$ratio = min($hRatio, $wRatio);
31
-			if($ratio > 1) $ratio = 1;
29
+            // Define which ratio will be used, depending on which is the smallest side
30
+            $ratio = min($hRatio, $wRatio);
31
+            if($ratio > 1) $ratio = 1;
32 32
 			
33
-			// Define sizes
34
-			$this->_destWidth = floor($originalWidth * $ratio);
35
-			$this->_destHeight = floor($originalHeight * $ratio);
33
+            // Define sizes
34
+            $this->_destWidth = floor($originalWidth * $ratio);
35
+            $this->_destHeight = floor($originalHeight * $ratio);
36 36
 			
37
-			// Define margins
38
-			$this->_destX = floor(($this->_width  - $this->_destWidth) / 2);
39
-			$this->_destY = floor(($this->_height - $this->_destHeight) / 2);
37
+            // Define margins
38
+            $this->_destX = floor(($this->_width  - $this->_destWidth) / 2);
39
+            $this->_destY = floor(($this->_height - $this->_destHeight) / 2);
40 40
 			
41
-			// Execute the Crop method with the given parameters
42
-			return parent::Execute($imageResource);
43
-		}
44
-	}
41
+            // Execute the Crop method with the given parameters
42
+            return parent::Execute($imageResource);
43
+        }
44
+    }
45 45
 }
46 46
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -28,7 +28,9 @@
 block discarded – undo
28 28
 			
29 29
 			// Define which ratio will be used, depending on which is the smallest side
30 30
 			$ratio = min($hRatio, $wRatio);
31
-			if($ratio > 1) $ratio = 1;
31
+			if($ratio > 1) {
32
+			    $ratio = 1;
33
+			}
32 34
 			
33 35
 			// Define sizes
34 36
 			$this->_destWidth = floor($originalWidth * $ratio);
Please login to merge, or discard this patch.
src/images/ImageResizer.php 2 patches
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 				}
46 46
 				return $returnFileNames;
47 47
 			} else {
48
-				throw new \Exception('Image doesnt exist: ' . $imagePath);
48
+				throw new \Exception('Image doesnt exist: '.$imagePath);
49 49
 			}
50 50
 		}
51 51
 
@@ -56,10 +56,10 @@  discard block
 block discarded – undo
56 56
 		 * @return string
57 57
 		 * @throws \Exception
58 58
 		 */
59
-		public function resize($imagePath='', $width='',$height='')
59
+		public function resize($imagePath = '', $width = '', $height = '')
60 60
 		{
61
-			$modifier = '-r' . $width . 'x' . $height;
62
-			return $this->applyMethod('Resize', $imagePath, $width,$height, $modifier);
61
+			$modifier = '-r'.$width.'x'.$height;
62
+			return $this->applyMethod('Resize', $imagePath, $width, $height, $modifier);
63 63
 		}
64 64
 
65 65
 		/**
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 		 * @return string
70 70
 		 * @throws \Exception
71 71
 		 */
72
-		public function smartcrop($imagePath='', $width='',$height='')
72
+		public function smartcrop($imagePath = '', $width = '', $height = '')
73 73
 		{
74
-			$modifier = '-s' . $width . 'x' . $height;
75
-			return $this->applyMethod('SmartCrop', $imagePath, $width,$height, $modifier);
74
+			$modifier = '-s'.$width.'x'.$height;
75
+			return $this->applyMethod('SmartCrop', $imagePath, $width, $height, $modifier);
76 76
 		}
77 77
 
78 78
 		/**
@@ -82,10 +82,10 @@  discard block
 block discarded – undo
82 82
 		 * @return string
83 83
 		 * @throws \Exception
84 84
 		 */
85
-		public function boxcrop($imagePath='', $width='',$height='')
85
+		public function boxcrop($imagePath = '', $width = '', $height = '')
86 86
 		{
87
-			$modifier = '-b' . $width . 'x' . $height;
88
-			return $this->applyMethod('BoxCrop', $imagePath, $width,$height, $modifier);
87
+			$modifier = '-b'.$width.'x'.$height;
88
+			return $this->applyMethod('BoxCrop', $imagePath, $width, $height, $modifier);
89 89
 		}
90 90
 
91 91
 		/**
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		 *
95 95
 		 * @return string
96 96
 		 */
97
-		private function modifyName($imagePath, $modifier='')
97
+		private function modifyName($imagePath, $modifier = '')
98 98
 		{
99 99
 			$filename = basename($imagePath);
100 100
 			$path = dirname($imagePath);
@@ -104,30 +104,30 @@  discard block
 block discarded – undo
104 104
 				array_pop($fileParts);
105 105
 				$fileNameWithoutExtension = implode('-', $fileParts);
106 106
 				$fileNameWithoutExtension = StringUtil::slugify($fileNameWithoutExtension);
107
-				$filename = $fileNameWithoutExtension . $modifier  . '.' . $extension;
107
+				$filename = $fileNameWithoutExtension.$modifier.'.'.$extension;
108 108
 			} else {
109 109
 				$filename = StringUtil::slugify($filename);
110 110
 			}
111 111
 
112
-			if (file_exists($path . '/' . $filename)) {
112
+			if (file_exists($path.'/'.$filename)) {
113 113
 				$fileParts = explode('.', $filename);
114 114
 				if (count($fileParts) > 1) {
115 115
 					$extension = end($fileParts);
116 116
 					array_pop($fileParts);
117 117
 					$fileNameWithoutExtension = implode('-', $fileParts);
118 118
 					$fileNameWithoutExtension .= '-copy';
119
-					$filename = $fileNameWithoutExtension . '.' . $extension;
119
+					$filename = $fileNameWithoutExtension.'.'.$extension;
120 120
 				} else {
121 121
 					$filename .= '-copy';
122 122
 				}
123
-				return $this->modifyName($path . '/' . $filename);
123
+				return $this->modifyName($path.'/'.$filename);
124 124
 			}
125
-			return $path . '/' . $filename;
125
+			return $path.'/'.$filename;
126 126
 		}
127 127
 
128 128
 		private function applyMethod($method, $imagePath, $width, $height, $modifier)
129 129
 		{
130
-			$method = 'CloudControl\Cms\\images\\methods\\' . $method;
130
+			$method = 'CloudControl\Cms\\images\\methods\\'.$method;
131 131
 			$destination = $this->modifyName($imagePath, $modifier);
132 132
 			if (file_exists($imagePath)) {
133 133
 				$image = new Image();
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 				$resizedImage->saveImage($destination, $resizedImage->getImageMimeType($imagePath), 80);
142 142
 				return basename($destination);
143 143
 			} else {
144
-				throw new \Exception('Image doesnt exist: ' . $imagePath);
144
+				throw new \Exception('Image doesnt exist: '.$imagePath);
145 145
 			}
146 146
 		}
147 147
 	}
Please login to merge, or discard this patch.
Indentation   +132 added lines, -132 removed lines patch added patch discarded remove patch
@@ -5,144 +5,144 @@
 block discarded – undo
5 5
     use CloudControl\Cms\cc\StringUtil;
6 6
 
7 7
     /**
8
-	 * Class ImageResizer
9
-	 * @package CloudControl\Cms\images
10
-	 */
11
-	class ImageResizer
12
-	{
13
-		protected $imageSet;
8
+     * Class ImageResizer
9
+     * @package CloudControl\Cms\images
10
+     */
11
+    class ImageResizer
12
+    {
13
+        protected $imageSet;
14 14
 
15
-		/**
16
-		 * ImageResizer constructor.
17
-		 *
18
-		 * @param $imageSet
19
-		 */
20
-		public function __construct($imageSet)
21
-		{
22
-			$this->imageSet = $imageSet;
23
-		}
15
+        /**
16
+         * ImageResizer constructor.
17
+         *
18
+         * @param $imageSet
19
+         */
20
+        public function __construct($imageSet)
21
+        {
22
+            $this->imageSet = $imageSet;
23
+        }
24 24
 
25
-		/**
26
-		 * @param $imagePath
27
-		 *
28
-		 * @return array
29
-		 * @throws \Exception
30
-		 */
31
-		public function applyImageSetToImage($imagePath)
32
-		{
33
-			$returnFileNames = array();
34
-			$filename = '';
35
-			if (file_exists($imagePath)) {
36
-				foreach ($this->imageSet as $set) {
37
-					if ($set->method == 'resize') {
38
-						$filename = $this->resize($imagePath, $set->width, $set->height);
39
-					} elseif ($set->method == 'smartcrop') {
40
-						$filename = $this->smartcrop($imagePath, $set->width, $set->height);
41
-					} elseif ($set->method == 'boxcrop') {
42
-						$filename = $this->boxcrop($imagePath, $set->width, $set->height);
43
-					}
44
-					$returnFileNames[$set->slug] = $filename;
45
-				}
46
-				return $returnFileNames;
47
-			} else {
48
-				throw new \Exception('Image doesnt exist: ' . $imagePath);
49
-			}
50
-		}
25
+        /**
26
+         * @param $imagePath
27
+         *
28
+         * @return array
29
+         * @throws \Exception
30
+         */
31
+        public function applyImageSetToImage($imagePath)
32
+        {
33
+            $returnFileNames = array();
34
+            $filename = '';
35
+            if (file_exists($imagePath)) {
36
+                foreach ($this->imageSet as $set) {
37
+                    if ($set->method == 'resize') {
38
+                        $filename = $this->resize($imagePath, $set->width, $set->height);
39
+                    } elseif ($set->method == 'smartcrop') {
40
+                        $filename = $this->smartcrop($imagePath, $set->width, $set->height);
41
+                    } elseif ($set->method == 'boxcrop') {
42
+                        $filename = $this->boxcrop($imagePath, $set->width, $set->height);
43
+                    }
44
+                    $returnFileNames[$set->slug] = $filename;
45
+                }
46
+                return $returnFileNames;
47
+            } else {
48
+                throw new \Exception('Image doesnt exist: ' . $imagePath);
49
+            }
50
+        }
51 51
 
52
-		/**
53
-		 * @param string $imagePath
54
-		 * @param string $width
55
-		 * @param string $height
56
-		 * @return string
57
-		 * @throws \Exception
58
-		 */
59
-		public function resize($imagePath='', $width='',$height='')
60
-		{
61
-			$modifier = '-r' . $width . 'x' . $height;
62
-			return $this->applyMethod('Resize', $imagePath, $width,$height, $modifier);
63
-		}
52
+        /**
53
+         * @param string $imagePath
54
+         * @param string $width
55
+         * @param string $height
56
+         * @return string
57
+         * @throws \Exception
58
+         */
59
+        public function resize($imagePath='', $width='',$height='')
60
+        {
61
+            $modifier = '-r' . $width . 'x' . $height;
62
+            return $this->applyMethod('Resize', $imagePath, $width,$height, $modifier);
63
+        }
64 64
 
65
-		/**
66
-		 * @param string $imagePath
67
-		 * @param string $width
68
-		 * @param string $height
69
-		 * @return string
70
-		 * @throws \Exception
71
-		 */
72
-		public function smartcrop($imagePath='', $width='',$height='')
73
-		{
74
-			$modifier = '-s' . $width . 'x' . $height;
75
-			return $this->applyMethod('SmartCrop', $imagePath, $width,$height, $modifier);
76
-		}
65
+        /**
66
+         * @param string $imagePath
67
+         * @param string $width
68
+         * @param string $height
69
+         * @return string
70
+         * @throws \Exception
71
+         */
72
+        public function smartcrop($imagePath='', $width='',$height='')
73
+        {
74
+            $modifier = '-s' . $width . 'x' . $height;
75
+            return $this->applyMethod('SmartCrop', $imagePath, $width,$height, $modifier);
76
+        }
77 77
 
78
-		/**
79
-		 * @param string $imagePath
80
-		 * @param string $width
81
-		 * @param string $height
82
-		 * @return string
83
-		 * @throws \Exception
84
-		 */
85
-		public function boxcrop($imagePath='', $width='',$height='')
86
-		{
87
-			$modifier = '-b' . $width . 'x' . $height;
88
-			return $this->applyMethod('BoxCrop', $imagePath, $width,$height, $modifier);
89
-		}
78
+        /**
79
+         * @param string $imagePath
80
+         * @param string $width
81
+         * @param string $height
82
+         * @return string
83
+         * @throws \Exception
84
+         */
85
+        public function boxcrop($imagePath='', $width='',$height='')
86
+        {
87
+            $modifier = '-b' . $width . 'x' . $height;
88
+            return $this->applyMethod('BoxCrop', $imagePath, $width,$height, $modifier);
89
+        }
90 90
 
91
-		/**
92
-		 * @param        $imagePath
93
-		 * @param string $modifier
94
-		 *
95
-		 * @return string
96
-		 */
97
-		private function modifyName($imagePath, $modifier='')
98
-		{
99
-			$filename = basename($imagePath);
100
-			$path = dirname($imagePath);
101
-			$fileParts = explode('.', $filename);
102
-			if (count($fileParts) > 1) {
103
-				$extension = end($fileParts);
104
-				array_pop($fileParts);
105
-				$fileNameWithoutExtension = implode('-', $fileParts);
106
-				$fileNameWithoutExtension = StringUtil::slugify($fileNameWithoutExtension);
107
-				$filename = $fileNameWithoutExtension . $modifier  . '.' . $extension;
108
-			} else {
109
-				$filename = StringUtil::slugify($filename);
110
-			}
91
+        /**
92
+         * @param        $imagePath
93
+         * @param string $modifier
94
+         *
95
+         * @return string
96
+         */
97
+        private function modifyName($imagePath, $modifier='')
98
+        {
99
+            $filename = basename($imagePath);
100
+            $path = dirname($imagePath);
101
+            $fileParts = explode('.', $filename);
102
+            if (count($fileParts) > 1) {
103
+                $extension = end($fileParts);
104
+                array_pop($fileParts);
105
+                $fileNameWithoutExtension = implode('-', $fileParts);
106
+                $fileNameWithoutExtension = StringUtil::slugify($fileNameWithoutExtension);
107
+                $filename = $fileNameWithoutExtension . $modifier  . '.' . $extension;
108
+            } else {
109
+                $filename = StringUtil::slugify($filename);
110
+            }
111 111
 
112
-			if (file_exists($path . '/' . $filename)) {
113
-				$fileParts = explode('.', $filename);
114
-				if (count($fileParts) > 1) {
115
-					$extension = end($fileParts);
116
-					array_pop($fileParts);
117
-					$fileNameWithoutExtension = implode('-', $fileParts);
118
-					$fileNameWithoutExtension .= '-copy';
119
-					$filename = $fileNameWithoutExtension . '.' . $extension;
120
-				} else {
121
-					$filename .= '-copy';
122
-				}
123
-				return $this->modifyName($path . '/' . $filename);
124
-			}
125
-			return $path . '/' . $filename;
126
-		}
112
+            if (file_exists($path . '/' . $filename)) {
113
+                $fileParts = explode('.', $filename);
114
+                if (count($fileParts) > 1) {
115
+                    $extension = end($fileParts);
116
+                    array_pop($fileParts);
117
+                    $fileNameWithoutExtension = implode('-', $fileParts);
118
+                    $fileNameWithoutExtension .= '-copy';
119
+                    $filename = $fileNameWithoutExtension . '.' . $extension;
120
+                } else {
121
+                    $filename .= '-copy';
122
+                }
123
+                return $this->modifyName($path . '/' . $filename);
124
+            }
125
+            return $path . '/' . $filename;
126
+        }
127 127
 
128
-		private function applyMethod($method, $imagePath, $width, $height, $modifier)
129
-		{
130
-			$method = 'CloudControl\Cms\\images\\methods\\' . $method;
131
-			$destination = $this->modifyName($imagePath, $modifier);
132
-			if (file_exists($imagePath)) {
133
-				$image = new Image();
134
-				$image->loadImage($imagePath);
135
-				$resize = new $method();
136
-				$resize->SetWidth($width);
137
-				$resize->SetHeight($height);
138
-				$resizedImageResource = $resize->Execute($image->getImageResource());
139
-				$resizedImage = new Image();
140
-				$resizedImage->loadImage($resizedImageResource);
141
-				$resizedImage->saveImage($destination, $resizedImage->getImageMimeType($imagePath), 80);
142
-				return basename($destination);
143
-			} else {
144
-				throw new \Exception('Image doesnt exist: ' . $imagePath);
145
-			}
146
-		}
147
-	}
128
+        private function applyMethod($method, $imagePath, $width, $height, $modifier)
129
+        {
130
+            $method = 'CloudControl\Cms\\images\\methods\\' . $method;
131
+            $destination = $this->modifyName($imagePath, $modifier);
132
+            if (file_exists($imagePath)) {
133
+                $image = new Image();
134
+                $image->loadImage($imagePath);
135
+                $resize = new $method();
136
+                $resize->SetWidth($width);
137
+                $resize->SetHeight($height);
138
+                $resizedImageResource = $resize->Execute($image->getImageResource());
139
+                $resizedImage = new Image();
140
+                $resizedImage->loadImage($resizedImageResource);
141
+                $resizedImage->saveImage($destination, $resizedImage->getImageMimeType($imagePath), 80);
142
+                return basename($destination);
143
+            } else {
144
+                throw new \Exception('Image doesnt exist: ' . $imagePath);
145
+            }
146
+        }
147
+    }
148 148
 }
149 149
\ No newline at end of file
Please login to merge, or discard this patch.
src/cc/Request.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -45,23 +45,23 @@
 block discarded – undo
45 45
 		 */
46 46
 		public function __construct() 
47 47
 		{
48
-            $rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)) . '/../../') . '/');
48
+            $rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)).'/../../').'/');
49 49
 			
50
-			self::$subfolders = '/' . str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath));
50
+			self::$subfolders = '/'.str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath));
51 51
 			self::$subfolders = str_replace('//', '/', self::$subfolders);
52 52
 			if (PHP_SAPI === 'cli') {
53 53
 				global $argv;
54 54
 				array_shift($argv);
55 55
 				self::$queryString = '';
56
-				self::$requestUri = self::$subfolders . implode('/', $argv);
56
+				self::$requestUri = self::$subfolders.implode('/', $argv);
57 57
 			} else {
58 58
 				self::$requestUri = $_SERVER['REQUEST_URI'];
59 59
 				self::$queryString = $_SERVER['QUERY_STRING'];
60 60
 			}
61 61
 			if (self::$subfolders === '/') {
62
-				self::$relativeUri = str_replace('?' . self::$queryString, '', substr(self::$requestUri,1));
62
+				self::$relativeUri = str_replace('?'.self::$queryString, '', substr(self::$requestUri, 1));
63 63
 			} else {
64
-				self::$relativeUri = str_replace('?' . self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri));
64
+				self::$relativeUri = str_replace('?'.self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri));
65 65
 			}
66 66
 
67 67
 			self::$requestParameters = explode('/', self::$relativeUri);
Please login to merge, or discard this patch.
Indentation   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -5,79 +5,79 @@
 block discarded – undo
5 5
      * Class Request
6 6
      * @package CloudControl\Cms\cc
7 7
      */
8
-	class Request {
8
+    class Request {
9 9
 
10
-		/**
11
-		 * @var string
12
-		 */
13
-		public static $subfolders;
14
-		/**
15
-		 * @var string
16
-		 */
17
-		public static $requestUri;
18
-		/**
19
-		 * @var string
20
-		 */
21
-		public static $relativeUri;
22
-		/**
23
-		 * @var string
24
-		 */
25
-		public static $queryString;
26
-		/**
27
-		 * @var array
28
-		 */
29
-		public static $requestParameters;
30
-		/**
31
-		 * @var array
32
-		 */
33
-		public static $post = array();
34
-		/**
35
-		 * @var array
36
-		 */
37
-		public static $get = array();
38
-		/**
39
-		 * @var array
40
-		 */
41
-		private $statics = array();
10
+        /**
11
+         * @var string
12
+         */
13
+        public static $subfolders;
14
+        /**
15
+         * @var string
16
+         */
17
+        public static $requestUri;
18
+        /**
19
+         * @var string
20
+         */
21
+        public static $relativeUri;
22
+        /**
23
+         * @var string
24
+         */
25
+        public static $queryString;
26
+        /**
27
+         * @var array
28
+         */
29
+        public static $requestParameters;
30
+        /**
31
+         * @var array
32
+         */
33
+        public static $post = array();
34
+        /**
35
+         * @var array
36
+         */
37
+        public static $get = array();
38
+        /**
39
+         * @var array
40
+         */
41
+        private $statics = array();
42 42
 
43
-		/**
44
-		 * Request constructor.
45
-		 */
46
-		public function __construct() 
47
-		{
43
+        /**
44
+         * Request constructor.
45
+         */
46
+        public function __construct() 
47
+        {
48 48
             $rootPath = str_replace('\\', '/', realpath(str_replace('\\', '/', dirname(__FILE__)) . '/../../') . '/');
49 49
 			
50
-			self::$subfolders = '/' . str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath));
51
-			self::$subfolders = str_replace('//', '/', self::$subfolders);
52
-			if (PHP_SAPI === 'cli') {
53
-				global $argv;
54
-				array_shift($argv);
55
-				self::$queryString = '';
56
-				self::$requestUri = self::$subfolders . implode('/', $argv);
57
-			} else {
58
-				self::$requestUri = $_SERVER['REQUEST_URI'];
59
-				self::$queryString = $_SERVER['QUERY_STRING'];
60
-			}
61
-			if (self::$subfolders === '/') {
62
-				self::$relativeUri = str_replace('?' . self::$queryString, '', substr(self::$requestUri,1));
63
-			} else {
64
-				self::$relativeUri = str_replace('?' . self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri));
65
-			}
50
+            self::$subfolders = '/' . str_replace('//', '/', str_replace(str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']), "", $rootPath));
51
+            self::$subfolders = str_replace('//', '/', self::$subfolders);
52
+            if (PHP_SAPI === 'cli') {
53
+                global $argv;
54
+                array_shift($argv);
55
+                self::$queryString = '';
56
+                self::$requestUri = self::$subfolders . implode('/', $argv);
57
+            } else {
58
+                self::$requestUri = $_SERVER['REQUEST_URI'];
59
+                self::$queryString = $_SERVER['QUERY_STRING'];
60
+            }
61
+            if (self::$subfolders === '/') {
62
+                self::$relativeUri = str_replace('?' . self::$queryString, '', substr(self::$requestUri,1));
63
+            } else {
64
+                self::$relativeUri = str_replace('?' . self::$queryString, '', str_replace(self::$subfolders, '', self::$requestUri));
65
+            }
66 66
 
67
-			self::$requestParameters = explode('/', self::$relativeUri);
67
+            self::$requestParameters = explode('/', self::$relativeUri);
68 68
 			
69
-			self::$get = $_GET;
70
-			self::$post = $_POST;
69
+            self::$get = $_GET;
70
+            self::$post = $_POST;
71 71
 			
72
-			$this->statics = array(
73
-				'subfolders' => self::$subfolders,
74
-				'requestUri' => self::$requestUri,
75
-				'relativeUri' => self::$relativeUri,
76
-				'queryString' => self::$queryString,
77
-				'requestParameters' => self::$requestParameters,
78
-				'post' => self::$post,
79
-				'get' => self::$get
80
-			);
81
-		}
82
-	}
72
+            $this->statics = array(
73
+                'subfolders' => self::$subfolders,
74
+                'requestUri' => self::$requestUri,
75
+                'relativeUri' => self::$relativeUri,
76
+                'queryString' => self::$queryString,
77
+                'requestParameters' => self::$requestParameters,
78
+                'post' => self::$post,
79
+                'get' => self::$get
80
+            );
81
+        }
82
+    }
83 83
 }
84 84
\ No newline at end of file
Please login to merge, or discard this patch.
src/cc/errortemplates/errorviewcli.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,21 +2,21 @@  discard block
 block discarded – undo
2 2
 | THE FOLLOWING ERROR OCCURED                                                                                                                  |
3 3
 ------------------------------------------------------------------------------------------------------------------------------------------------
4 4
 
5
- <?php echo $message . PHP_EOL; ?>
5
+ <?php echo $message.PHP_EOL; ?>
6 6
 
7 7
 ------------------------------------------------------------------------------------------------------------------------------------------------
8 8
 | IN FILE                                                                                                                                      |
9 9
 ------------------------------------------------------------------------------------------------------------------------------------------------
10 10
 
11
- <?php echo $file . ':' . $line . PHP_EOL; ?>
11
+ <?php echo $file.':'.$line.PHP_EOL; ?>
12 12
 
13 13
 ------------------------------------------------------------------------------------------------------------------------------------------------
14 14
 | CONTENTS OF THE FILE                                                                                                                         |
15 15
 ------------------------------------------------------------------------------------------------------------------------------------------------
16 16
 
17 17
 <?php
18
-foreach($lines as $nr => $currentLine) {
19
-	echo ($nr == $line ? '* ' : '  ' ) . str_pad($nr, 3, "0", STR_PAD_LEFT) . ' ' . $currentLine;
18
+foreach ($lines as $nr => $currentLine) {
19
+	echo ($nr == $line ? '* ' : '  ').str_pad($nr, 3, "0", STR_PAD_LEFT).' '.$currentLine;
20 20
 }
21 21
 ?>
22 22
 
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
 ------------------------------------------------------------------------------------------------------------------------------------------------
26 26
 
27 27
 <?php
28
-foreach($trace as $row) {
29
-	echo (isset($row['file']) ? basename($row['file']) : '') . ':'
30
-		. (isset($row['line']) ? $row['line'] : '') . "\t\t\t"
31
-		. (isset($row['class']) ? $row['class'] : ' ') . "\t\t\t"
32
-		. (isset($row['type']) ? $row['type'] : ' ') . "\t\t\t"
33
-		. (isset($row['function']) ? $row['function'] : ' ') . PHP_EOL;
28
+foreach ($trace as $row) {
29
+	echo (isset($row['file']) ? basename($row['file']) : '').':'
30
+		. (isset($row['line']) ? $row['line'] : '')."\t\t\t"
31
+		. (isset($row['class']) ? $row['class'] : ' ')."\t\t\t"
32
+		. (isset($row['type']) ? $row['type'] : ' ')."\t\t\t"
33
+		. (isset($row['function']) ? $row['function'] : ' ').PHP_EOL;
34 34
 }
35 35
 ?>
36 36
\ No newline at end of file
Please login to merge, or discard this patch.
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
 <?php
18 18
 foreach($lines as $nr => $currentLine) {
19
-	echo ($nr == $line ? '* ' : '  ' ) . str_pad($nr, 3, "0", STR_PAD_LEFT) . ' ' . $currentLine;
19
+    echo ($nr == $line ? '* ' : '  ' ) . str_pad($nr, 3, "0", STR_PAD_LEFT) . ' ' . $currentLine;
20 20
 }
21 21
 ?>
22 22
 
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 
27 27
 <?php
28 28
 foreach($trace as $row) {
29
-	echo (isset($row['file']) ? basename($row['file']) : '') . ':'
30
-		. (isset($row['line']) ? $row['line'] : '') . "\t\t\t"
31
-		. (isset($row['class']) ? $row['class'] : ' ') . "\t\t\t"
32
-		. (isset($row['type']) ? $row['type'] : ' ') . "\t\t\t"
33
-		. (isset($row['function']) ? $row['function'] : ' ') . PHP_EOL;
29
+    echo (isset($row['file']) ? basename($row['file']) : '') . ':'
30
+        . (isset($row['line']) ? $row['line'] : '') . "\t\t\t"
31
+        . (isset($row['class']) ? $row['class'] : ' ') . "\t\t\t"
32
+        . (isset($row['type']) ? $row['type'] : ' ') . "\t\t\t"
33
+        . (isset($row['function']) ? $row['function'] : ' ') . PHP_EOL;
34 34
 }
35 35
 ?>
36 36
\ No newline at end of file
Please login to merge, or discard this patch.