@@ -12,34 +12,34 @@ |
||
12 | 12 | |
13 | 13 | class ValuelistFactory |
14 | 14 | { |
15 | - /** |
|
16 | - * Create a sitemap item from post values |
|
17 | - * |
|
18 | - * @param $postValues |
|
19 | - * |
|
20 | - * @return \stdClass |
|
21 | - * @throws \Exception |
|
22 | - */ |
|
23 | - public static function createValuelistFromPostValues($postValues) |
|
24 | - { |
|
25 | - if (isset($postValues['title'])) { |
|
26 | - $valuelistObject = new \stdClass(); |
|
27 | - $valuelistObject->title = $postValues['title']; |
|
28 | - $valuelistObject->slug = StringUtil::slugify($postValues['title']); |
|
29 | - $valuelistObject->pairs = new \stdClass(); |
|
30 | - if (isset($postValues['keys'], $postValues['values'])) { |
|
31 | - foreach ($postValues['keys'] as $key => $value) { |
|
32 | - $valuelistObject->pairs->$value = $postValues['values'][$key]; |
|
33 | - } |
|
34 | - } |
|
35 | - $object_vars = get_object_vars($valuelistObject->pairs); |
|
36 | - ksort($object_vars); |
|
37 | - $valuelistObject->pairs = (object) $object_vars; |
|
15 | + /** |
|
16 | + * Create a sitemap item from post values |
|
17 | + * |
|
18 | + * @param $postValues |
|
19 | + * |
|
20 | + * @return \stdClass |
|
21 | + * @throws \Exception |
|
22 | + */ |
|
23 | + public static function createValuelistFromPostValues($postValues) |
|
24 | + { |
|
25 | + if (isset($postValues['title'])) { |
|
26 | + $valuelistObject = new \stdClass(); |
|
27 | + $valuelistObject->title = $postValues['title']; |
|
28 | + $valuelistObject->slug = StringUtil::slugify($postValues['title']); |
|
29 | + $valuelistObject->pairs = new \stdClass(); |
|
30 | + if (isset($postValues['keys'], $postValues['values'])) { |
|
31 | + foreach ($postValues['keys'] as $key => $value) { |
|
32 | + $valuelistObject->pairs->$value = $postValues['values'][$key]; |
|
33 | + } |
|
34 | + } |
|
35 | + $object_vars = get_object_vars($valuelistObject->pairs); |
|
36 | + ksort($object_vars); |
|
37 | + $valuelistObject->pairs = (object) $object_vars; |
|
38 | 38 | |
39 | - return $valuelistObject; |
|
40 | - } else { |
|
41 | - throw new \Exception('Trying to create valuelist with invalid data.'); |
|
42 | - } |
|
43 | - } |
|
39 | + return $valuelistObject; |
|
40 | + } else { |
|
41 | + throw new \Exception('Trying to create valuelist with invalid data.'); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | \ No newline at end of file |
@@ -12,33 +12,33 @@ discard block |
||
12 | 12 | |
13 | 13 | class DocumentRouting implements CmsRouting |
14 | 14 | { |
15 | - /** |
|
16 | - * DocumentRouting constructor. |
|
17 | - * @param $request |
|
18 | - * @param $relativeCmsUri |
|
19 | - * @param CmsComponent $cmsComponent |
|
20 | - */ |
|
21 | - public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
22 | - { |
|
23 | - if ($relativeCmsUri == '/documents') { |
|
24 | - $cmsComponent->subTemplate = 'cms/documents'; |
|
25 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments()->getDocumentsWithState()); |
|
26 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
|
27 | - } |
|
28 | - $this->documentRouting($request, $relativeCmsUri, $cmsComponent); |
|
29 | - $this->folderRouting($request, $relativeCmsUri, $cmsComponent); |
|
15 | + /** |
|
16 | + * DocumentRouting constructor. |
|
17 | + * @param $request |
|
18 | + * @param $relativeCmsUri |
|
19 | + * @param CmsComponent $cmsComponent |
|
20 | + */ |
|
21 | + public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
22 | + { |
|
23 | + if ($relativeCmsUri == '/documents') { |
|
24 | + $cmsComponent->subTemplate = 'cms/documents'; |
|
25 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments()->getDocumentsWithState()); |
|
26 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
|
27 | + } |
|
28 | + $this->documentRouting($request, $relativeCmsUri, $cmsComponent); |
|
29 | + $this->folderRouting($request, $relativeCmsUri, $cmsComponent); |
|
30 | 30 | $this->valuelistsRouting($request, $relativeCmsUri, $cmsComponent); |
31 | - } |
|
31 | + } |
|
32 | 32 | |
33 | 33 | |
34 | - /** |
|
35 | - * @param $request |
|
36 | - * @param $relativeCmsUri |
|
37 | - * @param CmsComponent $cmsComponent |
|
38 | - * @throws \Exception |
|
39 | - */ |
|
40 | - private function documentRouting($request, $relativeCmsUri, $cmsComponent) |
|
41 | - { |
|
34 | + /** |
|
35 | + * @param $request |
|
36 | + * @param $relativeCmsUri |
|
37 | + * @param CmsComponent $cmsComponent |
|
38 | + * @throws \Exception |
|
39 | + */ |
|
40 | + private function documentRouting($request, $relativeCmsUri, $cmsComponent) |
|
41 | + { |
|
42 | 42 | if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
43 | 43 | $this->documentNewRoute($request, $cmsComponent); |
44 | 44 | } elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])){ |
@@ -50,23 +50,23 @@ discard block |
||
50 | 50 | case '/documents/unpublish-document': $this->unpublishDocumentRoute($request, $cmsComponent); break; |
51 | 51 | } |
52 | 52 | } |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * @param $request |
|
57 | - * @param $relativeCmsUri |
|
58 | - * @param CmsComponent $cmsComponent |
|
59 | - */ |
|
60 | - private function folderRouting($request, $relativeCmsUri, $cmsComponent) |
|
61 | - { |
|
62 | - if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
55 | + /** |
|
56 | + * @param $request |
|
57 | + * @param $relativeCmsUri |
|
58 | + * @param CmsComponent $cmsComponent |
|
59 | + */ |
|
60 | + private function folderRouting($request, $relativeCmsUri, $cmsComponent) |
|
61 | + { |
|
62 | + if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
63 | 63 | $this->newFolderRoute($request, $cmsComponent); |
64 | - } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
64 | + } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
65 | 65 | $this->editFolderRoute($request, $cmsComponent); |
66 | - } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
66 | + } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
67 | 67 | $this->deleteFolderRoute($request, $cmsComponent); |
68 | - } |
|
69 | - } |
|
68 | + } |
|
69 | + } |
|
70 | 70 | |
71 | 71 | private function valuelistsRouting($request, $relativeCmsUri, $cmsComponent) |
72 | 72 | { |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | { |
42 | 42 | if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
43 | 43 | $this->documentNewRoute($request, $cmsComponent); |
44 | - } elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])){ |
|
44 | + } elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
45 | 45 | switch ($relativeCmsUri) { |
46 | 46 | case '/documents/edit-document': $this->editDocumentRoute($request, $cmsComponent); break; |
47 | 47 | case '/documents/get-brick': $this->getBrickRoute($request, $cmsComponent); break; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | if (isset($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE])) { |
96 | 96 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], $request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
97 | 97 | $cmsComponent->storage->getDocuments()->addDocument($request::$post); |
98 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
98 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
99 | 99 | exit; |
100 | 100 | } |
101 | 101 | $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPE, $cmsComponent->storage->getDocumentTypes()->getDocumentTypeBySlug($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], true)); |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | } else { |
104 | 104 | $documentTypes = $cmsComponent->storage->getDocumentTypes()->getDocumentTypes(); |
105 | 105 | if (count($documentTypes) < 1) { |
106 | - throw new \Exception('No Document Types defined yet. <a href="' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/configuration/document-types/new">Please do so first.</a>'); |
|
106 | + throw new \Exception('No Document Types defined yet. <a href="'.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/configuration/document-types/new">Please do so first.</a>'); |
|
107 | 107 | } |
108 | 108 | $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPES, $documentTypes); |
109 | 109 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | $cmsComponent->setParameter(CmsComponent::PARAMETER_SMALLEST_IMAGE, $cmsComponent->storage->getImageSet()->getSmallestImageSet()->slug); |
121 | 121 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
122 | 122 | $cmsComponent->storage->getDocuments()->saveDocument($request::$post); |
123 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
123 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
124 | 124 | exit; |
125 | 125 | } |
126 | 126 | $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT, $cmsComponent->storage->getDocuments()->getDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG], 'unpublished')); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | private function deleteDocumentRoute($request, $cmsComponent) |
158 | 158 | { |
159 | 159 | $cmsComponent->storage->getDocuments()->deleteDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
160 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
160 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
161 | 161 | exit; |
162 | 162 | } |
163 | 163 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
172 | 172 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::GET_PARAMETER_PATH])) { |
173 | 173 | $cmsComponent->storage->addDocumentFolder($request::$post); |
174 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
174 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
175 | 175 | exit; |
176 | 176 | } |
177 | 177 | } |
@@ -190,11 +190,11 @@ discard block |
||
190 | 190 | array_pop($path); |
191 | 191 | $path = implode('/', $path); |
192 | 192 | |
193 | - $request::$get[CmsComponent::GET_PARAMETER_PATH] = '/' . $path; |
|
193 | + $request::$get[CmsComponent::GET_PARAMETER_PATH] = '/'.$path; |
|
194 | 194 | |
195 | 195 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post['content'])) { |
196 | 196 | $cmsComponent->storage->saveDocumentFolder($request::$post); |
197 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
197 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
198 | 198 | exit; |
199 | 199 | } |
200 | 200 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | private function deleteFolderRoute($request, $cmsComponent) |
210 | 210 | { |
211 | 211 | $cmsComponent->storage->deleteDocumentFolderBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
212 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
212 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
213 | 213 | exit; |
214 | 214 | } |
215 | 215 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | private function publishDocumentRoute($request, $cmsComponent) |
221 | 221 | { |
222 | 222 | $cmsComponent->storage->publishDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
223 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
223 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
224 | 224 | exit; |
225 | 225 | } |
226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | private function unpublishDocumentRoute($request, $cmsComponent) |
232 | 232 | { |
233 | 233 | $cmsComponent->storage->unpublishDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
234 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
234 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
235 | 235 | exit; |
236 | 236 | } |
237 | 237 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
249 | 249 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE])) { |
250 | 250 | $cmsComponent->storage->getValuelists()->addValuelist($request::$post); |
251 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents/valuelists'); |
|
251 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents/valuelists'); |
|
252 | 252 | exit; |
253 | 253 | } |
254 | 254 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | |
261 | 261 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
262 | 262 | $cmsComponent->storage->getValuelists()->saveValuelist($request::$get[CmsComponent::GET_PARAMETER_SLUG], $request::$post); |
263 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents/valuelists'); |
|
263 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents/valuelists'); |
|
264 | 264 | exit; |
265 | 265 | } |
266 | 266 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | private function deleteValuelistRoute($request, $cmsComponent) |
272 | 272 | { |
273 | 273 | $cmsComponent->storage->getValuelists()->deleteValuelistBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
274 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents/valuelists'); |
|
274 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents/valuelists'); |
|
275 | 275 | exit; |
276 | 276 | } |
277 | 277 | } |
278 | 278 | \ No newline at end of file |