@@ -1,4 +1,4 @@ discard block |
||
1 | -<script>window.onload=function(){History.init();History.replaceState(null, 'Cloud Control CMS', '/<?=$request::$subfolders . $cmsPrefix?>/documents?path=/');};</script> |
|
1 | +<script>window.onload=function(){History.init();History.replaceState(null, 'Cloud Control CMS', '/<?=$request::$subfolders.$cmsPrefix?>/documents?path=/');};</script> |
|
2 | 2 | <section class="documents"> |
3 | 3 | <h2><i class="fa fa-file-text-o"></i> Documents</h2> |
4 | 4 | <nav class="actions"> |
@@ -24,9 +24,9 @@ discard block |
||
24 | 24 | <? foreach ($documents as $document) : ?> |
25 | 25 | <li class="grid-container"> |
26 | 26 | <? if ($document->type == 'document') : ?> |
27 | - <?renderDocument($document, $cmsPrefix);?> |
|
27 | + <?renderDocument($document, $cmsPrefix); ?> |
|
28 | 28 | <? elseif ($document->type == 'folder') : ?> |
29 | - <?renderFolder($document, $cmsPrefix, '', true);?> |
|
29 | + <?renderFolder($document, $cmsPrefix, '', true); ?> |
|
30 | 30 | <? endif ?> |
31 | 31 | </li> |
32 | 32 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | <? function renderDocument($document, $cmsPrefix, $slugPrefix = '') {?> |
38 | 38 | <div class="grid-box-10"> |
39 | 39 | <h3> |
40 | - <a class="btn documentTitle" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix . $document->slug?>" title="Edit"> |
|
40 | + <a class="btn documentTitle" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix.$document->slug?>" title="Edit"> |
|
41 | 41 | <i class="fa fa-file-text-o"></i> |
42 | 42 | <small class="state <?=strtolower($document->state)?>"><i class="fa <?=$document->state == 'published' ? 'fa-check-circle-o' : 'fa-times-circle-o' ?>"></i></small> |
43 | 43 | <?=$document->title?> |
@@ -56,36 +56,36 @@ discard block |
||
56 | 56 | </div> |
57 | 57 | <div class="documentActions grid-box-2"> |
58 | 58 | <? if (strtolower($document->state) == 'unpublished' || $document->unpublishedChanges) : ?> |
59 | - <a class="btn publish" title="Publish" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/publish-document?slug=<?=$slugPrefix . $document->slug?>"><i class="fa fa-check"></i></a> |
|
59 | + <a class="btn publish" title="Publish" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/publish-document?slug=<?=$slugPrefix.$document->slug?>"><i class="fa fa-check"></i></a> |
|
60 | 60 | <? endif ?> |
61 | 61 | <? if (strtolower($document->state) == 'published') : ?> |
62 | - <a class="btn unpublish" title="Unpublish" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/unpublish-document?slug=<?=$slugPrefix . $document->slug?>"><i class="fa fa-times"></i></a> |
|
62 | + <a class="btn unpublish" title="Unpublish" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/unpublish-document?slug=<?=$slugPrefix.$document->slug?>"><i class="fa fa-times"></i></a> |
|
63 | 63 | <? endif ?> |
64 | - <a class="btn" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix . $document->slug?>" title="Edit"><i class="fa fa-pencil"></i></a> |
|
64 | + <a class="btn" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix.$document->slug?>" title="Edit"><i class="fa fa-pencil"></i></a> |
|
65 | 65 | <? if (strtolower($document->state) == 'unpublished') : ?> |
66 | - <a onclick="return confirm('Are you sure you want to delete this item?');" class="btn error" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/delete-document?slug=<?=$slugPrefix . $document->slug?>" title="Delete"><i class="fa fa-trash"></i></a> |
|
66 | + <a onclick="return confirm('Are you sure you want to delete this item?');" class="btn error" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/delete-document?slug=<?=$slugPrefix.$document->slug?>" title="Delete"><i class="fa fa-trash"></i></a> |
|
67 | 67 | <? endif ?> |
68 | 68 | </div> |
69 | 69 | <?}?> |
70 | -<? function renderFolder($document, $cmsPrefix, $slugPrefix ='', $root = false) {?> |
|
70 | +<? function renderFolder($document, $cmsPrefix, $slugPrefix = '', $root = false) {?> |
|
71 | 71 | <div class="grid-box-8"> |
72 | 72 | <h3> |
73 | - <a class="btn documentTitle openFolder" data-slug="<?=$slugPrefix . $document->slug?>" title="Open"> |
|
73 | + <a class="btn documentTitle openFolder" data-slug="<?=$slugPrefix.$document->slug?>" title="Open"> |
|
74 | 74 | <i class="fa fa-folder-o "></i> <?=$document->title?> |
75 | 75 | </a> |
76 | 76 | </h3> |
77 | 77 | </div> |
78 | 78 | <div class="documentActions grid-box-4"> |
79 | - <a class="btn" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-folder?slug=<?=$slugPrefix . $document->slug?>" title="Edit"><i class="fa fa-pencil"></i></a> |
|
80 | - <a onclick="return confirm('Are you sure you want to delete this item?');" class="btn error" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/delete-folder?slug=<?=$slugPrefix . $document->slug?>" title="Delete"><i class="fa fa-trash"></i></a> |
|
79 | + <a class="btn" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-folder?slug=<?=$slugPrefix.$document->slug?>" title="Edit"><i class="fa fa-pencil"></i></a> |
|
80 | + <a onclick="return confirm('Are you sure you want to delete this item?');" class="btn error" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/delete-folder?slug=<?=$slugPrefix.$document->slug?>" title="Delete"><i class="fa fa-trash"></i></a> |
|
81 | 81 | </div> |
82 | 82 | <ul class="documents grid-wrapper nested<?=$root ? ' root' : '' ?>"> |
83 | 83 | <? foreach ($document->content as $subDocument) : ?> |
84 | 84 | <li class="grid-container"> |
85 | 85 | <? if ($subDocument->type == 'document') : ?> |
86 | - <?renderDocument($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/');?> |
|
86 | + <?renderDocument($subDocument, $cmsPrefix, $slugPrefix.$document->slug.'/'); ?> |
|
87 | 87 | <? elseif ($subDocument->type == 'folder') : ?> |
88 | - <?renderFolder($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/');?> |
|
88 | + <?renderFolder($subDocument, $cmsPrefix, $slugPrefix.$document->slug.'/'); ?> |
|
89 | 89 | <? endif ?> |
90 | 90 | </li> |
91 | 91 | <? endforeach ?> |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
4 | 4 | </div> |
5 | 5 | <?if ($static == true) { |
6 | - $fieldPrefix = 'bricks[' . $myBrickSlug . '][' . str_replace('.', '', str_replace(' ', '', microtime())) . '][fields]'; |
|
6 | + $fieldPrefix = 'bricks['.$myBrickSlug.']['.str_replace('.', '', str_replace(' ', '', microtime())).'][fields]'; |
|
7 | 7 | } else { |
8 | - $fieldPrefix = 'dynamicBricks[' . $brick->slug . '][' . str_replace('.', '', str_replace(' ', '', microtime())) . ']'; |
|
8 | + $fieldPrefix = 'dynamicBricks['.$brick->slug.']['.str_replace('.', '', str_replace(' ', '', microtime())).']'; |
|
9 | 9 | }?> |
10 | 10 | <? foreach ($brick->fields as $field) : ?> |
11 | 11 | <div class="form-element"> |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
31 | 31 | <div class="form-element"> |
32 | 32 | <? endif ?> |
33 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
33 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
34 | 34 | <? if ($field->multiple == true && $field->type != 'Rich Text') : ?> |
35 | 35 | |
36 | 36 | </div> |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | <li class="grid-container"> |
53 | 53 | <div class="grid-box-10"> |
54 | 54 | <div class="grid-inner form-element"> |
55 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
55 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
56 | 56 | </div> |
57 | 57 | </div> |
58 | 58 | <div class="grid-box-2"> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | </div> |
63 | 63 | </div> |
64 | 64 | </li> |
65 | - <?$value='';?> |
|
65 | + <?$value = ''; ?> |
|
66 | 66 | <? endforeach ?> |
67 | 67 | <? endif ?> |
68 | 68 | </ul> |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | <a class="btn error js-deletemultiple"><i class="fa fa-trash"></i></a> |
80 | 80 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
81 | 81 | <div class="form-element"> |
82 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
82 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
83 | 83 | </div> |
84 | 84 | </li> |
85 | - <?$value='';?> |
|
85 | + <?$value = ''; ?> |
|
86 | 86 | <? endforeach ?> |
87 | 87 | <? endif ?> |
88 | 88 | </div> |
@@ -91,5 +91,5 @@ discard block |
||
91 | 91 | <a class="btn js-addrtemultiple">+</a> |
92 | 92 | <? endif ?> |
93 | 93 | </div> |
94 | - <?$value='';?> |
|
94 | + <?$value = ''; ?> |
|
95 | 95 | <? endforeach ?> |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<form method="<?= isset($documentType) ? 'post' : 'get' ?>" onsubmit="return processRtes();" action="<?=isset($formId) ? '#' . $formId : '' ?>"> |
|
1 | +<form method="<?= isset($documentType) ? 'post' : 'get' ?>" onsubmit="return processRtes();" action="<?=isset($formId) ? '#'.$formId : '' ?>"> |
|
2 | 2 | <? if (!isset($hideTitleAndState)) : ?> |
3 | 3 | <input type="hidden" name="path" value="<?=$request::$get['path']?>" /> |
4 | 4 | <? else : ?> |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | <input required="required" value="<?=isset($document) ? $document->title : '' ?>" type="text" id="title" name="title" placeholder="Title" /> |
18 | 18 | </div> |
19 | 19 | <? endif ?> |
20 | - <?$fieldPrefix='fields';?> |
|
20 | + <?$fieldPrefix = 'fields'; ?> |
|
21 | 21 | <? foreach ($documentType->fields as $field) : ?> |
22 | 22 | <div class="form-element"> |
23 | 23 | <label for="<?=$field->slug?>"><?=$field->title?></label> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
42 | 42 | <div class="form-element"> |
43 | 43 | <? endif ?> |
44 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
44 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
45 | 45 | <? if ($field->multiple == true && $field->type != 'Rich Text') : ?> |
46 | 46 | |
47 | 47 | </div> |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | <li class="grid-container"> |
64 | 64 | <div class="grid-box-10"> |
65 | 65 | <div class="grid-inner form-element"> |
66 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
66 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
67 | 67 | </div> |
68 | 68 | </div> |
69 | 69 | <div class="grid-box-2"> |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | </div> |
74 | 74 | </div> |
75 | 75 | </li> |
76 | - <?$value='';?> |
|
76 | + <?$value = ''; ?> |
|
77 | 77 | <? endforeach ?> |
78 | 78 | <? endif ?> |
79 | 79 | </ul> |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | <a class="btn error js-deletemultiple"><i class="fa fa-trash"></i></a> |
91 | 91 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
92 | 92 | <div class="form-element"> |
93 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
93 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
94 | 94 | </div> |
95 | 95 | </li> |
96 | - <?$value='';?> |
|
96 | + <?$value = ''; ?> |
|
97 | 97 | <? endforeach ?> |
98 | 98 | <? endif ?> |
99 | 99 | </div> |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | <a class="btn js-addrtemultiple">+</a> |
103 | 103 | <? endif ?> |
104 | 104 | </div> |
105 | - <?$value='';?> |
|
105 | + <?$value = ''; ?> |
|
106 | 106 | <? endforeach ?> |
107 | 107 | <hr /> |
108 | - <? $static_brick_nr = 0;?> |
|
108 | + <? $static_brick_nr = 0; ?> |
|
109 | 109 | <? foreach ($documentType->bricks as $brick) : ?> |
110 | 110 | <div class="brick"> |
111 | 111 | <label><?=$brick->title?></label> |
112 | 112 | <? if ($brick->multiple == 'true') : ?> |
113 | 113 | <input type="hidden" value="<?=$brick->brickSlug?>"/> |
114 | 114 | <input type="hidden" value="<?=$brick->slug?>"/> |
115 | - <?$myBrickSlug=$brick->slug;?> |
|
115 | + <?$myBrickSlug = $brick->slug; ?> |
|
116 | 116 | <ul id="newBrickDropzone_<?=$static_brick_nr?>" class="dynamicBricks sortable"> |
117 | 117 | <? if (isset($document)) : ?> |
118 | 118 | <? foreach ($document->bricks as $currentBrickSlug => $brickArray) : ?> |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | <li class="brick form-element"> |
127 | 127 | <label><?=$brick->title?></label> |
128 | 128 | <?$static = true; ?> |
129 | - <?include(__DIR__ . '/brick.php')?> |
|
129 | + <?include(__DIR__.'/brick.php')?> |
|
130 | 130 | </li> |
131 | 131 | <? endif ?> |
132 | 132 | <? endforeach ?> |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | <a class="btn" onclick="addDynamicBrick(this, 'true', 'newBrickDropzone_<?=$static_brick_nr?>');">+</a> |
137 | 137 | <?$static_brick_nr += 1?> |
138 | 138 | <? else : ?> |
139 | - <?$fieldPrefix='bricks[' . $brick->slug . '][fields]';?> |
|
139 | + <?$fieldPrefix = 'bricks['.$brick->slug.'][fields]'; ?> |
|
140 | 140 | <input type="hidden" name="bricks[<?=$brick->slug?>][type]" value="<?=$brick->brickSlug?>" /> |
141 | 141 | <? foreach ($brick->structure->fields as $field) : ?> |
142 | 142 | <div class="form-element"> |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
163 | 163 | <div class="form-element"> |
164 | 164 | <? endif ?> |
165 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
165 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
166 | 166 | <? if ($field->multiple == true && $field->type != 'Rich Text') : ?> |
167 | 167 | |
168 | 168 | </div> |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | <li class="grid-container"> |
186 | 186 | <div class="grid-box-10"> |
187 | 187 | <div class="grid-inner form-element"> |
188 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
188 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
189 | 189 | </div> |
190 | 190 | </div> |
191 | 191 | <div class="grid-box-2"> |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | </div> |
196 | 196 | </div> |
197 | 197 | </li> |
198 | - <?$value='';?> |
|
198 | + <?$value = ''; ?> |
|
199 | 199 | <? endforeach ?> |
200 | 200 | <? endif ?> |
201 | 201 | </ul> |
@@ -213,10 +213,10 @@ discard block |
||
213 | 213 | <a class="btn error js-deletemultiple"><i class="fa fa-trash"></i></a> |
214 | 214 | <a class="btn move ui-sortable-handle"><i class="fa fa-arrows-v"></i></a> |
215 | 215 | <div class="form-element"> |
216 | - <? include(__DIR__ . '/fieldTypes/' . str_replace(' ', '-', $field->type) . '.php') ?> |
|
216 | + <? include(__DIR__.'/fieldTypes/'.str_replace(' ', '-', $field->type).'.php') ?> |
|
217 | 217 | </div> |
218 | 218 | </li> |
219 | - <?$value='';?> |
|
219 | + <?$value = ''; ?> |
|
220 | 220 | <? endforeach ?> |
221 | 221 | <? endif ?> |
222 | 222 | </div> |
@@ -225,12 +225,12 @@ discard block |
||
225 | 225 | <a class="btn js-addrtemultiple">+</a> |
226 | 226 | <? endif ?> |
227 | 227 | </div> |
228 | - <?$value='';?> |
|
228 | + <?$value = ''; ?> |
|
229 | 229 | <? endforeach ?> |
230 | 230 | <? endif ?> |
231 | 231 | </div> |
232 | 232 | <hr /> |
233 | - <? endforeach;?> |
|
233 | + <? endforeach; ?> |
|
234 | 234 | |
235 | 235 | |
236 | 236 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | <li class="brick form-element"> |
254 | 254 | <label><?=$brick->title?></label> |
255 | 255 | <?$static = false; ?> |
256 | - <?include(__DIR__ . '/brick.php')?> |
|
256 | + <?include(__DIR__.'/brick.php')?> |
|
257 | 257 | </li> |
258 | 258 | <? endforeach ?> |
259 | 259 | <? endif ?> |
@@ -1,7 +1,8 @@ discard block |
||
1 | 1 | <form method="<?= isset($documentType) ? 'post' : 'get' ?>" onsubmit="return processRtes();" action="<?=isset($formId) ? '#' . $formId : '' ?>"> |
2 | 2 | <? if (!isset($hideTitleAndState)) : ?> |
3 | 3 | <input type="hidden" name="path" value="<?=$request::$get['path']?>" /> |
4 | - <? else : ?> |
|
4 | + <? else { |
|
5 | + : ?> |
|
5 | 6 | <input type="hidden" name="formId" value="<?=$formId?>" /> |
6 | 7 | <a name="<?=$formId?>"></a> |
7 | 8 | <? endif ?> |
@@ -17,15 +18,19 @@ discard block |
||
17 | 18 | <input required="required" value="<?=isset($document) ? $document->title : '' ?>" type="text" id="title" name="title" placeholder="Title" /> |
18 | 19 | </div> |
19 | 20 | <? endif ?> |
20 | - <?$fieldPrefix='fields';?> |
|
21 | + <?$fieldPrefix='fields'; |
|
22 | +} |
|
23 | +?> |
|
21 | 24 | <? foreach ($documentType->fields as $field) : ?> |
22 | 25 | <div class="form-element"> |
23 | 26 | <label for="<?=$field->slug?>"><?=$field->title?></label> |
24 | 27 | <? if (isset($document)) : |
25 | 28 | $fieldSlug = $field->slug; |
26 | 29 | $value = isset($document->fields->$fieldSlug) ? current($document->fields->$fieldSlug) : ''; |
27 | - else : |
|
30 | + else { |
|
31 | + : |
|
28 | 32 | $value = ''; |
33 | + } |
|
29 | 34 | endif ?> |
30 | 35 | <? if ($field->multiple == true && $field->type != 'Rich Text') : ?> |
31 | 36 | <ul class="grid-wrapper sortable"> |
@@ -135,8 +140,11 @@ discard block |
||
135 | 140 | </ul> |
136 | 141 | <a class="btn" onclick="addDynamicBrick(this, 'true', 'newBrickDropzone_<?=$static_brick_nr?>');">+</a> |
137 | 142 | <?$static_brick_nr += 1?> |
138 | - <? else : ?> |
|
139 | - <?$fieldPrefix='bricks[' . $brick->slug . '][fields]';?> |
|
143 | + <? else { |
|
144 | + : ?> |
|
145 | + <?$fieldPrefix='bricks[' . $brick->slug . '][fields]'; |
|
146 | +} |
|
147 | +?> |
|
140 | 148 | <input type="hidden" name="bricks[<?=$brick->slug?>][type]" value="<?=$brick->brickSlug?>" /> |
141 | 149 | <? foreach ($brick->structure->fields as $field) : ?> |
142 | 150 | <div class="form-element"> |
@@ -145,8 +153,10 @@ discard block |
||
145 | 153 | $brickSlug = $brick->slug; |
146 | 154 | $fieldSlug = $field->slug; |
147 | 155 | $value = isset($document->bricks->$brickSlug->fields->$fieldSlug) ? current($document->bricks->$brickSlug->fields->$fieldSlug) : ''; |
148 | - else : |
|
156 | + else { |
|
157 | + : |
|
149 | 158 | $value = ''; |
159 | + } |
|
150 | 160 | endif ?> |
151 | 161 | <? if ($field->multiple == true && $field->type != 'Rich Text') : ?> |
152 | 162 | <ul class="grid-wrapper sortable"> |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function getDocuments($state = 'published') |
22 | 22 | { |
23 | 23 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
24 | - throw new \Exception('Unsupported document state: ' . $state); |
|
24 | + throw new \Exception('Unsupported document state: '.$state); |
|
25 | 25 | } |
26 | 26 | return $this->repository->getDocuments($state); |
27 | 27 | } |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | public function getDocumentBySlug($slug, $state = 'published') |
51 | 51 | { |
52 | 52 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
53 | - throw new \Exception('Unsupported document state: ' . $state); |
|
53 | + throw new \Exception('Unsupported document state: '.$state); |
|
54 | 54 | } |
55 | - $path = '/' . $slug; |
|
55 | + $path = '/'.$slug; |
|
56 | 56 | |
57 | 57 | return $this->repository->getDocumentByPath($path, $state); |
58 | 58 | } |
@@ -66,16 +66,16 @@ discard block |
||
66 | 66 | public function saveDocument($postValues, $state = 'unpublished') |
67 | 67 | { |
68 | 68 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
69 | - throw new \Exception('Unsupported document state: ' . $state); |
|
69 | + throw new \Exception('Unsupported document state: '.$state); |
|
70 | 70 | } |
71 | - $oldPath = '/' . $postValues['path']; |
|
71 | + $oldPath = '/'.$postValues['path']; |
|
72 | 72 | |
73 | 73 | $container = $this->getDocumentContainerByPath($oldPath); |
74 | 74 | $documentObject = DocumentFactory::createDocumentFromPostValues($postValues, new DocumentTypesStorage($this->repository)); |
75 | 75 | if ($container->path === '/') { |
76 | - $newPath = $container->path . $documentObject->slug; |
|
76 | + $newPath = $container->path.$documentObject->slug; |
|
77 | 77 | } else { |
78 | - $newPath = $container->path . '/' . $documentObject->slug; |
|
78 | + $newPath = $container->path.'/'.$documentObject->slug; |
|
79 | 79 | } |
80 | 80 | $documentObject->path = $newPath; |
81 | 81 | $this->repository->saveDocument($documentObject, $state); |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | { |
90 | 90 | $documentObject = DocumentFactory::createDocumentFromPostValues($postValues, new DocumentTypesStorage($this->repository)); |
91 | 91 | if ($postValues['path'] === '/') { |
92 | - $documentObject->path = $postValues['path'] . $documentObject->slug; |
|
92 | + $documentObject->path = $postValues['path'].$documentObject->slug; |
|
93 | 93 | } else { |
94 | - $documentObject->path = $postValues['path'] . '/' . $documentObject->slug; |
|
94 | + $documentObject->path = $postValues['path'].'/'.$documentObject->slug; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $this->repository->saveDocument($documentObject, $state); |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function deleteDocumentBySlug($slug) |
104 | 104 | { |
105 | - $path = '/' . $slug; |
|
105 | + $path = '/'.$slug; |
|
106 | 106 | $this->repository->deleteDocumentByPath($path); |
107 | 107 | } |
108 | 108 |
@@ -20,60 +20,60 @@ discard block |
||
20 | 20 | */ |
21 | 21 | class Document |
22 | 22 | { |
23 | - public $id; |
|
24 | - public $path; |
|
25 | - public $title; |
|
26 | - public $slug; |
|
27 | - public $type; |
|
28 | - public $documentType; |
|
29 | - public $documentTypeSlug; |
|
30 | - public $state; |
|
31 | - public $lastModificationDate; |
|
32 | - public $creationDate; |
|
33 | - public $lastModifiedBy; |
|
34 | - protected $fields; |
|
35 | - protected $bricks; |
|
36 | - protected $dynamicBricks; |
|
37 | - protected $content; |
|
23 | + public $id; |
|
24 | + public $path; |
|
25 | + public $title; |
|
26 | + public $slug; |
|
27 | + public $type; |
|
28 | + public $documentType; |
|
29 | + public $documentTypeSlug; |
|
30 | + public $state; |
|
31 | + public $lastModificationDate; |
|
32 | + public $creationDate; |
|
33 | + public $lastModifiedBy; |
|
34 | + protected $fields; |
|
35 | + protected $bricks; |
|
36 | + protected $dynamicBricks; |
|
37 | + protected $content; |
|
38 | 38 | |
39 | - protected $dbHandle; |
|
39 | + protected $dbHandle; |
|
40 | 40 | |
41 | - protected $jsonEncodedFields = array('fields', 'bricks', 'dynamicBricks'); |
|
42 | - protected $orderableFields = array('title', 'slug', 'type', 'documentType', 'documentTypeSlug', 'state', 'lastModificationDate', 'creationDate', 'lastModifiedBy'); |
|
41 | + protected $jsonEncodedFields = array('fields', 'bricks', 'dynamicBricks'); |
|
42 | + protected $orderableFields = array('title', 'slug', 'type', 'documentType', 'documentTypeSlug', 'state', 'lastModificationDate', 'creationDate', 'lastModifiedBy'); |
|
43 | 43 | |
44 | - public static $DOCUMENT_STATES = array('published', 'unpublished'); |
|
44 | + public static $DOCUMENT_STATES = array('published', 'unpublished'); |
|
45 | 45 | |
46 | - public function __get($name) { |
|
47 | - if (in_array($name, $this->jsonEncodedFields)) { |
|
48 | - if (is_string($this->$name)) { |
|
49 | - return json_decode($this->$name); |
|
50 | - } else { |
|
51 | - return $this->$name; |
|
52 | - } |
|
53 | - } elseif ($name === 'content') { |
|
54 | - if ($this->dbHandle === null) { |
|
55 | - throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
56 | - } else { |
|
57 | - if ($this->content === null) { |
|
58 | - return $this->getContent(); |
|
59 | - } |
|
60 | - } |
|
61 | - } elseif ($name === 'dbHandle') { |
|
62 | - throw new \Exception('Trying to get protected property repository.'); |
|
63 | - } |
|
64 | - return $this->$name; |
|
65 | - } |
|
46 | + public function __get($name) { |
|
47 | + if (in_array($name, $this->jsonEncodedFields)) { |
|
48 | + if (is_string($this->$name)) { |
|
49 | + return json_decode($this->$name); |
|
50 | + } else { |
|
51 | + return $this->$name; |
|
52 | + } |
|
53 | + } elseif ($name === 'content') { |
|
54 | + if ($this->dbHandle === null) { |
|
55 | + throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
56 | + } else { |
|
57 | + if ($this->content === null) { |
|
58 | + return $this->getContent(); |
|
59 | + } |
|
60 | + } |
|
61 | + } elseif ($name === 'dbHandle') { |
|
62 | + throw new \Exception('Trying to get protected property repository.'); |
|
63 | + } |
|
64 | + return $this->$name; |
|
65 | + } |
|
66 | 66 | |
67 | - public function __set($name, $value) { |
|
68 | - if (in_array($name, $this->jsonEncodedFields)) { |
|
69 | - $this->$name = json_encode($value); |
|
70 | - } elseif ($name === 'content') { |
|
71 | - // Dont do anything for now.. |
|
72 | - return; |
|
73 | - } |
|
67 | + public function __set($name, $value) { |
|
68 | + if (in_array($name, $this->jsonEncodedFields)) { |
|
69 | + $this->$name = json_encode($value); |
|
70 | + } elseif ($name === 'content') { |
|
71 | + // Dont do anything for now.. |
|
72 | + return; |
|
73 | + } |
|
74 | 74 | |
75 | - $this->$name = $value; |
|
76 | - } |
|
75 | + $this->$name = $value; |
|
76 | + } |
|
77 | 77 | |
78 | 78 | /** |
79 | 79 | * @param string $orderBy |
@@ -82,13 +82,13 @@ discard block |
||
82 | 82 | * @return array |
83 | 83 | * @throws \Exception |
84 | 84 | */ |
85 | - public function getContent($orderBy = 'title', $order = 'ASC') |
|
86 | - { |
|
87 | - $docs = $this->documentStorage->getDocumentsWithState($this->path); |
|
88 | - return $docs; |
|
89 | - //dump($this->path, $docs); |
|
90 | - $folderPathWithWildcard = $this->path . '%'; |
|
91 | - $sql = ' SELECT * |
|
85 | + public function getContent($orderBy = 'title', $order = 'ASC') |
|
86 | + { |
|
87 | + $docs = $this->documentStorage->getDocumentsWithState($this->path); |
|
88 | + return $docs; |
|
89 | + //dump($this->path, $docs); |
|
90 | + $folderPathWithWildcard = $this->path . '%'; |
|
91 | + $sql = ' SELECT * |
|
92 | 92 | FROM documents_published |
93 | 93 | WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard) . ' |
94 | 94 | AND substr(`path`, ' . (strlen($this->path) + 2) . ') NOT LIKE "%/%" |
@@ -96,24 +96,24 @@ discard block |
||
96 | 96 | AND path != ' . $this->dbHandle->quote($this->path) . ' |
97 | 97 | ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title') . ' ' . ($order === 'ASC' ? 'ASC' : 'DESC') . ' |
98 | 98 | '; |
99 | - $stmt = $this->dbHandle->prepare($sql); |
|
99 | + $stmt = $this->dbHandle->prepare($sql); |
|
100 | 100 | if ($stmt === false) { |
101 | 101 | $errorInfo = $this->dbHandle->errorInfo(); |
102 | 102 | $errorMsg = $errorInfo[2]; |
103 | 103 | throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
104 | 104 | } |
105 | - $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT); |
|
105 | + $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT); |
|
106 | 106 | $stmt->execute(); |
107 | - $contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
108 | - foreach ($contents as $key => $document) { |
|
109 | - if ($document->type === 'folder') { |
|
110 | - $document->dbHandle = $this->dbHandle; |
|
111 | - $contents[$key] = $document; |
|
112 | - } |
|
113 | - } |
|
114 | - $this->content = $contents; |
|
115 | - return $this->content; |
|
116 | - } |
|
107 | + $contents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
108 | + foreach ($contents as $key => $document) { |
|
109 | + if ($document->type === 'folder') { |
|
110 | + $document->dbHandle = $this->dbHandle; |
|
111 | + $contents[$key] = $document; |
|
112 | + } |
|
113 | + } |
|
114 | + $this->content = $contents; |
|
115 | + return $this->content; |
|
116 | + } |
|
117 | 117 | |
118 | 118 | /** |
119 | 119 | * @return string |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | } |
53 | 53 | } elseif ($name === 'content') { |
54 | 54 | if ($this->dbHandle === null) { |
55 | - throw new \Exception('Document doesnt have a dbHandle handle. (path: ' . $this->path . ')'); |
|
55 | + throw new \Exception('Document doesnt have a dbHandle handle. (path: '.$this->path.')'); |
|
56 | 56 | } else { |
57 | 57 | if ($this->content === null) { |
58 | 58 | return $this->getContent(); |
@@ -87,20 +87,20 @@ discard block |
||
87 | 87 | $docs = $this->documentStorage->getDocumentsWithState($this->path); |
88 | 88 | return $docs; |
89 | 89 | //dump($this->path, $docs); |
90 | - $folderPathWithWildcard = $this->path . '%'; |
|
90 | + $folderPathWithWildcard = $this->path.'%'; |
|
91 | 91 | $sql = ' SELECT * |
92 | 92 | FROM documents_published |
93 | - WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard) . ' |
|
94 | - AND substr(`path`, ' . (strlen($this->path) + 2) . ') NOT LIKE "%/%" |
|
95 | - AND substr(`path`, ' . (strlen($this->path) + 1) . ', 1) = "/" |
|
96 | - AND path != ' . $this->dbHandle->quote($this->path) . ' |
|
97 | - ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title') . ' ' . ($order === 'ASC' ? 'ASC' : 'DESC') . ' |
|
93 | + WHERE `path` LIKE ' . $this->dbHandle->quote($folderPathWithWildcard).' |
|
94 | + AND substr(`path`, ' . (strlen($this->path) + 2).') NOT LIKE "%/%" |
|
95 | + AND substr(`path`, ' . (strlen($this->path) + 1).', 1) = "/" |
|
96 | + AND path != ' . $this->dbHandle->quote($this->path).' |
|
97 | + ORDER BY ' . (in_array($orderBy, $this->orderableFields) ? $orderBy : 'title').' '.($order === 'ASC' ? 'ASC' : 'DESC').' |
|
98 | 98 | '; |
99 | 99 | $stmt = $this->dbHandle->prepare($sql); |
100 | 100 | if ($stmt === false) { |
101 | 101 | $errorInfo = $this->dbHandle->errorInfo(); |
102 | 102 | $errorMsg = $errorInfo[2]; |
103 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
103 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
104 | 104 | } |
105 | 105 | $stmt->bindColumn(':orderBy', $orderBy, \PDO::PARAM_STMT); |
106 | 106 | $stmt->execute(); |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function __toString() |
122 | 122 | { |
123 | - return 'Document:' . $this->title; |
|
123 | + return 'Document:'.$this->title; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 |
@@ -22,134 +22,134 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class Repository |
24 | 24 | { |
25 | - protected $storagePath; |
|
26 | - |
|
27 | - protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users'); |
|
28 | - |
|
29 | - protected $sitemap; |
|
30 | - protected $sitemapChanges = false; |
|
31 | - |
|
32 | - protected $applicationComponents; |
|
33 | - protected $applicationComponentsChanges = false; |
|
34 | - |
|
35 | - protected $documentTypes; |
|
36 | - protected $documentTypesChanges = false; |
|
37 | - |
|
38 | - protected $bricks; |
|
39 | - protected $bricksChanges = false; |
|
40 | - |
|
41 | - protected $imageSet; |
|
42 | - protected $imageSetChanges = false; |
|
43 | - |
|
44 | - protected $images; |
|
45 | - protected $imagesChanges = false; |
|
46 | - |
|
47 | - protected $files; |
|
48 | - protected $filesChanges = false; |
|
49 | - |
|
50 | - protected $users; |
|
51 | - protected $usersChanges = false; |
|
52 | - |
|
53 | - protected $contentDbHandle; |
|
54 | - |
|
55 | - /** |
|
56 | - * Repository constructor. |
|
57 | - * @param $storagePath |
|
58 | - * @throws \Exception |
|
59 | - */ |
|
60 | - public function __construct($storagePath) |
|
61 | - { |
|
62 | - $storagePath = realpath($storagePath); |
|
63 | - if (is_dir($storagePath) && $storagePath !== false) { |
|
64 | - $this->storagePath = $storagePath; |
|
65 | - } else { |
|
66 | - throw new \Exception('Repository not yet initialized.'); |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - /** |
|
71 | - * Creates the folder in which to create all storage related files |
|
72 | - * |
|
73 | - * @param $storagePath |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public static function create($storagePath) |
|
77 | - { |
|
78 | - return mkdir($storagePath); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Initiates default storage |
|
83 | - * @throws \Exception |
|
84 | - */ |
|
85 | - public function init() |
|
86 | - { |
|
87 | - $storageDefaultPath = realpath('../library/cc/install/_storage.json'); |
|
88 | - $contentSqlPath = realpath('../library/cc/install/content.sql'); |
|
89 | - |
|
90 | - $this->initConfigStorage($storageDefaultPath); |
|
91 | - $this->initContentDb($contentSqlPath); |
|
92 | - |
|
93 | - $this->save(); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Load filebased subset and return it's contents |
|
98 | - * |
|
99 | - * @param $name |
|
100 | - * @return mixed|string |
|
101 | - * @throws \Exception |
|
102 | - */ |
|
103 | - public function __get($name) |
|
104 | - { |
|
105 | - if (isset($this->$name)) { |
|
106 | - if (in_array($name, $this->fileBasedSubsets)) { |
|
107 | - return $this->$name; |
|
108 | - } else { |
|
109 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
110 | - } |
|
111 | - } else { |
|
112 | - if (in_array($name, $this->fileBasedSubsets)) { |
|
113 | - return $this->loadSubset($name); |
|
114 | - } else { |
|
115 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
116 | - } |
|
117 | - } |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Set filebased subset contents |
|
122 | - * @param $name |
|
123 | - * @param $value |
|
124 | - * @throws \Exception |
|
125 | - */ |
|
126 | - public function __set($name, $value) |
|
127 | - { |
|
128 | - if (in_array($name, $this->fileBasedSubsets)) { |
|
129 | - $this->$name = $value; |
|
130 | - $changes = $name . 'Changes'; |
|
131 | - $this->$changes = true; |
|
132 | - } else { |
|
133 | - throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
134 | - } |
|
135 | - } |
|
136 | - |
|
137 | - /** |
|
138 | - * Persist all subsets |
|
139 | - */ |
|
140 | - public function save() |
|
141 | - { |
|
142 | - array_map(function ($value) { |
|
143 | - $this->saveSubset($value); |
|
25 | + protected $storagePath; |
|
26 | + |
|
27 | + protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users'); |
|
28 | + |
|
29 | + protected $sitemap; |
|
30 | + protected $sitemapChanges = false; |
|
31 | + |
|
32 | + protected $applicationComponents; |
|
33 | + protected $applicationComponentsChanges = false; |
|
34 | + |
|
35 | + protected $documentTypes; |
|
36 | + protected $documentTypesChanges = false; |
|
37 | + |
|
38 | + protected $bricks; |
|
39 | + protected $bricksChanges = false; |
|
40 | + |
|
41 | + protected $imageSet; |
|
42 | + protected $imageSetChanges = false; |
|
43 | + |
|
44 | + protected $images; |
|
45 | + protected $imagesChanges = false; |
|
46 | + |
|
47 | + protected $files; |
|
48 | + protected $filesChanges = false; |
|
49 | + |
|
50 | + protected $users; |
|
51 | + protected $usersChanges = false; |
|
52 | + |
|
53 | + protected $contentDbHandle; |
|
54 | + |
|
55 | + /** |
|
56 | + * Repository constructor. |
|
57 | + * @param $storagePath |
|
58 | + * @throws \Exception |
|
59 | + */ |
|
60 | + public function __construct($storagePath) |
|
61 | + { |
|
62 | + $storagePath = realpath($storagePath); |
|
63 | + if (is_dir($storagePath) && $storagePath !== false) { |
|
64 | + $this->storagePath = $storagePath; |
|
65 | + } else { |
|
66 | + throw new \Exception('Repository not yet initialized.'); |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + /** |
|
71 | + * Creates the folder in which to create all storage related files |
|
72 | + * |
|
73 | + * @param $storagePath |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public static function create($storagePath) |
|
77 | + { |
|
78 | + return mkdir($storagePath); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Initiates default storage |
|
83 | + * @throws \Exception |
|
84 | + */ |
|
85 | + public function init() |
|
86 | + { |
|
87 | + $storageDefaultPath = realpath('../library/cc/install/_storage.json'); |
|
88 | + $contentSqlPath = realpath('../library/cc/install/content.sql'); |
|
89 | + |
|
90 | + $this->initConfigStorage($storageDefaultPath); |
|
91 | + $this->initContentDb($contentSqlPath); |
|
92 | + |
|
93 | + $this->save(); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Load filebased subset and return it's contents |
|
98 | + * |
|
99 | + * @param $name |
|
100 | + * @return mixed|string |
|
101 | + * @throws \Exception |
|
102 | + */ |
|
103 | + public function __get($name) |
|
104 | + { |
|
105 | + if (isset($this->$name)) { |
|
106 | + if (in_array($name, $this->fileBasedSubsets)) { |
|
107 | + return $this->$name; |
|
108 | + } else { |
|
109 | + throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
110 | + } |
|
111 | + } else { |
|
112 | + if (in_array($name, $this->fileBasedSubsets)) { |
|
113 | + return $this->loadSubset($name); |
|
114 | + } else { |
|
115 | + throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
116 | + } |
|
117 | + } |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Set filebased subset contents |
|
122 | + * @param $name |
|
123 | + * @param $value |
|
124 | + * @throws \Exception |
|
125 | + */ |
|
126 | + public function __set($name, $value) |
|
127 | + { |
|
128 | + if (in_array($name, $this->fileBasedSubsets)) { |
|
129 | + $this->$name = $value; |
|
130 | + $changes = $name . 'Changes'; |
|
131 | + $this->$changes = true; |
|
132 | + } else { |
|
133 | + throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
134 | + } |
|
135 | + } |
|
136 | + |
|
137 | + /** |
|
138 | + * Persist all subsets |
|
139 | + */ |
|
140 | + public function save() |
|
141 | + { |
|
142 | + array_map(function ($value) { |
|
143 | + $this->saveSubset($value); |
|
144 | 144 | }, $this->fileBasedSubsets); |
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Persist subset to disk |
|
149 | - * @param $subset |
|
150 | - */ |
|
151 | - protected function saveSubset($subset) |
|
152 | - { |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Persist subset to disk |
|
149 | + * @param $subset |
|
150 | + */ |
|
151 | + protected function saveSubset($subset) |
|
152 | + { |
|
153 | 153 | $changes = $subset . 'Changes'; |
154 | 154 | if ($this->$changes === true) { |
155 | 155 | $json = json_encode($this->$subset, JSON_PRETTY_PRINT); |
@@ -158,67 +158,67 @@ discard block |
||
158 | 158 | |
159 | 159 | $this->$changes = false; |
160 | 160 | } |
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Load subset from disk |
|
165 | - * @param $subset |
|
166 | - * @return mixed|string |
|
167 | - */ |
|
168 | - protected function loadSubset($subset) |
|
169 | - { |
|
170 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
171 | - $json = file_get_contents($subsetStoragePath); |
|
172 | - $json = json_decode($json); |
|
173 | - $this->$subset = $json; |
|
174 | - return $json; |
|
175 | - } |
|
176 | - |
|
177 | - /** |
|
178 | - * @param $contentSqlPath |
|
179 | - */ |
|
180 | - protected function initContentDb($contentSqlPath) |
|
181 | - { |
|
182 | - $db = $this->getContentDbHandle(); |
|
183 | - $sql = file_get_contents($contentSqlPath); |
|
184 | - $db->exec($sql); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * @param $storageDefaultPath |
|
189 | - */ |
|
190 | - protected function initConfigStorage($storageDefaultPath) |
|
191 | - { |
|
192 | - $json = file_get_contents($storageDefaultPath); |
|
193 | - $json = json_decode($json); |
|
194 | - $this->sitemap = $json->sitemap; |
|
195 | - $this->sitemapChanges = true; |
|
196 | - $this->applicationComponents = $json->applicationComponents; |
|
197 | - $this->applicationComponentsChanges = true; |
|
198 | - $this->documentTypes = $json->documentTypes; |
|
199 | - $this->documentTypesChanges = true; |
|
200 | - $this->bricks = $json->bricks; |
|
201 | - $this->bricksChanges = true; |
|
202 | - $this->imageSet = $json->imageSet; |
|
203 | - $this->imageSetChanges = true; |
|
204 | - $this->images = $json->images; |
|
205 | - $this->imagesChanges = true; |
|
206 | - $this->files = $json->files; |
|
207 | - $this->filesChanges = true; |
|
208 | - $this->users = $json->users; |
|
209 | - $this->usersChanges = true; |
|
210 | - } |
|
211 | - |
|
212 | - /** |
|
213 | - * @return \PDO |
|
214 | - */ |
|
215 | - public function getContentDbHandle() |
|
216 | - { |
|
217 | - if ($this->contentDbHandle === null) { |
|
218 | - $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
219 | - } |
|
220 | - return $this->contentDbHandle; |
|
221 | - } |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Load subset from disk |
|
165 | + * @param $subset |
|
166 | + * @return mixed|string |
|
167 | + */ |
|
168 | + protected function loadSubset($subset) |
|
169 | + { |
|
170 | + $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
171 | + $json = file_get_contents($subsetStoragePath); |
|
172 | + $json = json_decode($json); |
|
173 | + $this->$subset = $json; |
|
174 | + return $json; |
|
175 | + } |
|
176 | + |
|
177 | + /** |
|
178 | + * @param $contentSqlPath |
|
179 | + */ |
|
180 | + protected function initContentDb($contentSqlPath) |
|
181 | + { |
|
182 | + $db = $this->getContentDbHandle(); |
|
183 | + $sql = file_get_contents($contentSqlPath); |
|
184 | + $db->exec($sql); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * @param $storageDefaultPath |
|
189 | + */ |
|
190 | + protected function initConfigStorage($storageDefaultPath) |
|
191 | + { |
|
192 | + $json = file_get_contents($storageDefaultPath); |
|
193 | + $json = json_decode($json); |
|
194 | + $this->sitemap = $json->sitemap; |
|
195 | + $this->sitemapChanges = true; |
|
196 | + $this->applicationComponents = $json->applicationComponents; |
|
197 | + $this->applicationComponentsChanges = true; |
|
198 | + $this->documentTypes = $json->documentTypes; |
|
199 | + $this->documentTypesChanges = true; |
|
200 | + $this->bricks = $json->bricks; |
|
201 | + $this->bricksChanges = true; |
|
202 | + $this->imageSet = $json->imageSet; |
|
203 | + $this->imageSetChanges = true; |
|
204 | + $this->images = $json->images; |
|
205 | + $this->imagesChanges = true; |
|
206 | + $this->files = $json->files; |
|
207 | + $this->filesChanges = true; |
|
208 | + $this->users = $json->users; |
|
209 | + $this->usersChanges = true; |
|
210 | + } |
|
211 | + |
|
212 | + /** |
|
213 | + * @return \PDO |
|
214 | + */ |
|
215 | + public function getContentDbHandle() |
|
216 | + { |
|
217 | + if ($this->contentDbHandle === null) { |
|
218 | + $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
219 | + } |
|
220 | + return $this->contentDbHandle; |
|
221 | + } |
|
222 | 222 | |
223 | 223 | /** |
224 | 224 | * Get all documents |
@@ -228,13 +228,13 @@ discard block |
||
228 | 228 | * @return array |
229 | 229 | * @throws \Exception |
230 | 230 | */ |
231 | - public function getDocuments($state = 'published') |
|
232 | - { |
|
231 | + public function getDocuments($state = 'published') |
|
232 | + { |
|
233 | 233 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
234 | 234 | throw new \Exception('Unsupported document state: ' . $state); |
235 | 235 | } |
236 | - return $this->getDocumentsByPath('/', $state); |
|
237 | - } |
|
236 | + return $this->getDocumentsByPath('/', $state); |
|
237 | + } |
|
238 | 238 | |
239 | 239 | public function getDocumentsWithState($folderPath = '/') |
240 | 240 | { |
@@ -285,55 +285,55 @@ discard block |
||
285 | 285 | * @return array |
286 | 286 | * @throws \Exception |
287 | 287 | */ |
288 | - public function getDocumentsByPath($folderPath, $state = 'published') |
|
289 | - { |
|
290 | - if (!in_array($state, Document::$DOCUMENT_STATES)) { |
|
291 | - throw new \Exception('Unsupported document state: ' . $state); |
|
288 | + public function getDocumentsByPath($folderPath, $state = 'published') |
|
289 | + { |
|
290 | + if (!in_array($state, Document::$DOCUMENT_STATES)) { |
|
291 | + throw new \Exception('Unsupported document state: ' . $state); |
|
292 | 292 | } |
293 | - $db = $this->getContentDbHandle(); |
|
294 | - $folderPathWithWildcard = $folderPath . '%'; |
|
293 | + $db = $this->getContentDbHandle(); |
|
294 | + $folderPathWithWildcard = $folderPath . '%'; |
|
295 | 295 | |
296 | - $sql = 'SELECT * |
|
296 | + $sql = 'SELECT * |
|
297 | 297 | FROM documents_' . $state . ' |
298 | 298 | WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
299 | 299 | AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
300 | 300 | AND path != ' . $db->quote($folderPath) . ' |
301 | 301 | ORDER BY `type` DESC, `path` ASC'; |
302 | - $stmt = $this->getDbStatement($sql); |
|
303 | - |
|
304 | - $documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
305 | - foreach ($documents as $key => $document) { |
|
306 | - if ($document->type === 'folder') { |
|
307 | - $document->dbHandle = $db; |
|
308 | - $document->documentStorage = new DocumentStorage($this); |
|
309 | - $documents[$key] = $document; |
|
310 | - } |
|
311 | - } |
|
312 | - return $documents; |
|
313 | - } |
|
314 | - |
|
315 | - |
|
316 | - /** |
|
317 | - * @param $path |
|
318 | - * @return bool|Document |
|
319 | - */ |
|
320 | - public function getDocumentContainerByPath($path) |
|
321 | - { |
|
322 | - $document = $this->getDocumentByPath($path, 'unpublished'); |
|
323 | - if ($document === false) { |
|
324 | - return false; |
|
325 | - } |
|
326 | - $slugLength = strlen($document->slug); |
|
327 | - $containerPath = substr($path, 0, -$slugLength); |
|
328 | - if ($containerPath === '/') { |
|
329 | - return $this->getRootFolder(); |
|
330 | - } |
|
331 | - if (substr($containerPath, -1) === '/'){ |
|
302 | + $stmt = $this->getDbStatement($sql); |
|
303 | + |
|
304 | + $documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
305 | + foreach ($documents as $key => $document) { |
|
306 | + if ($document->type === 'folder') { |
|
307 | + $document->dbHandle = $db; |
|
308 | + $document->documentStorage = new DocumentStorage($this); |
|
309 | + $documents[$key] = $document; |
|
310 | + } |
|
311 | + } |
|
312 | + return $documents; |
|
313 | + } |
|
314 | + |
|
315 | + |
|
316 | + /** |
|
317 | + * @param $path |
|
318 | + * @return bool|Document |
|
319 | + */ |
|
320 | + public function getDocumentContainerByPath($path) |
|
321 | + { |
|
322 | + $document = $this->getDocumentByPath($path, 'unpublished'); |
|
323 | + if ($document === false) { |
|
324 | + return false; |
|
325 | + } |
|
326 | + $slugLength = strlen($document->slug); |
|
327 | + $containerPath = substr($path, 0, -$slugLength); |
|
328 | + if ($containerPath === '/') { |
|
329 | + return $this->getRootFolder(); |
|
330 | + } |
|
331 | + if (substr($containerPath, -1) === '/'){ |
|
332 | 332 | $containerPath = substr($containerPath, 0, -1); |
333 | 333 | } |
334 | - $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
|
335 | - return $containerFolder; |
|
336 | - } |
|
334 | + $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
|
335 | + return $containerFolder; |
|
336 | + } |
|
337 | 337 | |
338 | 338 | /** |
339 | 339 | * @param $path |
@@ -342,23 +342,23 @@ discard block |
||
342 | 342 | * @return bool|\library\storage\Document |
343 | 343 | * @throws \Exception |
344 | 344 | */ |
345 | - public function getDocumentByPath($path, $state = 'published') |
|
346 | - { |
|
345 | + public function getDocumentByPath($path, $state = 'published') |
|
346 | + { |
|
347 | 347 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
348 | 348 | throw new \Exception('Unsupported document state: ' . $state); |
349 | 349 | } |
350 | - $db = $this->getContentDbHandle(); |
|
351 | - $document = $this->fetchDocument(' |
|
350 | + $db = $this->getContentDbHandle(); |
|
351 | + $document = $this->fetchDocument(' |
|
352 | 352 | SELECT * |
353 | 353 | FROM documents_' . $state . ' |
354 | 354 | WHERE path = ' . $db->quote($path) . ' |
355 | 355 | '); |
356 | - if ($document instanceof Document && $document->type === 'folder') { |
|
357 | - $document->dbHandle = $db; |
|
358 | - $document->documentStorage = new DocumentStorage($this); |
|
359 | - } |
|
360 | - return $document; |
|
361 | - } |
|
356 | + if ($document instanceof Document && $document->type === 'folder') { |
|
357 | + $document->dbHandle = $db; |
|
358 | + $document->documentStorage = new DocumentStorage($this); |
|
359 | + } |
|
360 | + return $document; |
|
361 | + } |
|
362 | 362 | |
363 | 363 | /** |
364 | 364 | * Returns the count of all documents stored in the db |
@@ -440,58 +440,58 @@ discard block |
||
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
443 | - * Return the results of the query as array of Documents |
|
444 | - * @param $sql |
|
445 | - * @return array |
|
446 | - * @throws \Exception |
|
447 | - */ |
|
448 | - protected function fetchAllDocuments($sql) |
|
449 | - { |
|
450 | - $stmt = $this->getDbStatement($sql); |
|
451 | - return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
452 | - } |
|
453 | - |
|
454 | - /** |
|
455 | - * Return the result of the query as Document |
|
456 | - * @param $sql |
|
457 | - * @return mixed |
|
458 | - * @throws \Exception |
|
459 | - */ |
|
460 | - protected function fetchDocument($sql) |
|
461 | - { |
|
462 | - $stmt = $this->getDbStatement($sql); |
|
463 | - return $stmt->fetchObject('\library\storage\Document'); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Prepare the sql statement |
|
468 | - * @param $sql |
|
469 | - * @return \PDOStatement |
|
470 | - * @throws \Exception |
|
471 | - */ |
|
472 | - protected function getDbStatement($sql) |
|
473 | - { |
|
474 | - $db = $this->getContentDbHandle(); |
|
475 | - $stmt = $db->query($sql); |
|
476 | - if ($stmt === false) { |
|
477 | - $errorInfo = $db->errorInfo(); |
|
478 | - $errorMsg = $errorInfo[2]; |
|
479 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
480 | - } |
|
481 | - return $stmt; |
|
482 | - } |
|
483 | - |
|
484 | - /** |
|
485 | - * Create a (non-existent) root folder Document and return it |
|
486 | - * @return Document |
|
487 | - */ |
|
488 | - protected function getRootFolder() |
|
489 | - { |
|
490 | - $rootFolder = new Document(); |
|
491 | - $rootFolder->path = '/'; |
|
492 | - $rootFolder->type = 'folder'; |
|
493 | - return $rootFolder; |
|
494 | - } |
|
443 | + * Return the results of the query as array of Documents |
|
444 | + * @param $sql |
|
445 | + * @return array |
|
446 | + * @throws \Exception |
|
447 | + */ |
|
448 | + protected function fetchAllDocuments($sql) |
|
449 | + { |
|
450 | + $stmt = $this->getDbStatement($sql); |
|
451 | + return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
452 | + } |
|
453 | + |
|
454 | + /** |
|
455 | + * Return the result of the query as Document |
|
456 | + * @param $sql |
|
457 | + * @return mixed |
|
458 | + * @throws \Exception |
|
459 | + */ |
|
460 | + protected function fetchDocument($sql) |
|
461 | + { |
|
462 | + $stmt = $this->getDbStatement($sql); |
|
463 | + return $stmt->fetchObject('\library\storage\Document'); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Prepare the sql statement |
|
468 | + * @param $sql |
|
469 | + * @return \PDOStatement |
|
470 | + * @throws \Exception |
|
471 | + */ |
|
472 | + protected function getDbStatement($sql) |
|
473 | + { |
|
474 | + $db = $this->getContentDbHandle(); |
|
475 | + $stmt = $db->query($sql); |
|
476 | + if ($stmt === false) { |
|
477 | + $errorInfo = $db->errorInfo(); |
|
478 | + $errorMsg = $errorInfo[2]; |
|
479 | + throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
480 | + } |
|
481 | + return $stmt; |
|
482 | + } |
|
483 | + |
|
484 | + /** |
|
485 | + * Create a (non-existent) root folder Document and return it |
|
486 | + * @return Document |
|
487 | + */ |
|
488 | + protected function getRootFolder() |
|
489 | + { |
|
490 | + $rootFolder = new Document(); |
|
491 | + $rootFolder->path = '/'; |
|
492 | + $rootFolder->type = 'folder'; |
|
493 | + return $rootFolder; |
|
494 | + } |
|
495 | 495 | |
496 | 496 | /** |
497 | 497 | * Save the document to the database |
@@ -503,13 +503,13 @@ discard block |
||
503 | 503 | * @throws \Exception |
504 | 504 | * @internal param $path |
505 | 505 | */ |
506 | - public function saveDocument($documentObject, $state = 'published') |
|
507 | - { |
|
506 | + public function saveDocument($documentObject, $state = 'published') |
|
507 | + { |
|
508 | 508 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
509 | 509 | throw new \Exception('Unsupported document state: ' . $state); |
510 | 510 | } |
511 | - $db = $this->getContentDbHandle(); |
|
512 | - $stmt = $this->getDbStatement(' |
|
511 | + $db = $this->getContentDbHandle(); |
|
512 | + $stmt = $this->getDbStatement(' |
|
513 | 513 | INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
514 | 514 | VALUES( |
515 | 515 | ' . $db->quote($documentObject->path) . ', |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
528 | 528 | ) |
529 | 529 | '); |
530 | - $result = $stmt->execute(); |
|
531 | - return $result; |
|
532 | - } |
|
530 | + $result = $stmt->execute(); |
|
531 | + return $result; |
|
532 | + } |
|
533 | 533 | |
534 | 534 | /** |
535 | 535 | * Delete the document from the database |
@@ -540,27 +540,27 @@ discard block |
||
540 | 540 | * @internal param string $state |
541 | 541 | * |
542 | 542 | */ |
543 | - public function deleteDocumentByPath($path) |
|
544 | - { |
|
545 | - $db = $this->getContentDbHandle(); |
|
546 | - $documentToDelete = $this->getDocumentByPath($path, 'unpublished'); |
|
547 | - if ($documentToDelete instanceof Document) { |
|
548 | - if ($documentToDelete->type == 'document') { |
|
549 | - $stmt = $this->getDbStatement(' |
|
543 | + public function deleteDocumentByPath($path) |
|
544 | + { |
|
545 | + $db = $this->getContentDbHandle(); |
|
546 | + $documentToDelete = $this->getDocumentByPath($path, 'unpublished'); |
|
547 | + if ($documentToDelete instanceof Document) { |
|
548 | + if ($documentToDelete->type == 'document') { |
|
549 | + $stmt = $this->getDbStatement(' |
|
550 | 550 | DELETE FROM documents_unpublished |
551 | 551 | WHERE path = ' . $db->quote($path) . ' |
552 | 552 | '); |
553 | - $stmt->execute(); |
|
554 | - } elseif ($documentToDelete->type == 'folder') { |
|
555 | - $folderPathWithWildcard = $path . '%'; |
|
556 | - $stmt = $this->getDbStatement(' |
|
553 | + $stmt->execute(); |
|
554 | + } elseif ($documentToDelete->type == 'folder') { |
|
555 | + $folderPathWithWildcard = $path . '%'; |
|
556 | + $stmt = $this->getDbStatement(' |
|
557 | 557 | DELETE FROM documents_unpublished |
558 | 558 | WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
559 | 559 | AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
560 | 560 | OR path = ' . $db->quote($path) . ' |
561 | 561 | '); |
562 | - $stmt->execute(); |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
562 | + $stmt->execute(); |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | 566 | } |
567 | 567 | \ No newline at end of file |
@@ -106,13 +106,13 @@ discard block |
||
106 | 106 | if (in_array($name, $this->fileBasedSubsets)) { |
107 | 107 | return $this->$name; |
108 | 108 | } else { |
109 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
109 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
110 | 110 | } |
111 | 111 | } else { |
112 | 112 | if (in_array($name, $this->fileBasedSubsets)) { |
113 | 113 | return $this->loadSubset($name); |
114 | 114 | } else { |
115 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
115 | + throw new \Exception('Trying to get undefined property from Repository: '.$name); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | } |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | { |
128 | 128 | if (in_array($name, $this->fileBasedSubsets)) { |
129 | 129 | $this->$name = $value; |
130 | - $changes = $name . 'Changes'; |
|
130 | + $changes = $name.'Changes'; |
|
131 | 131 | $this->$changes = true; |
132 | 132 | } else { |
133 | - throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
133 | + throw new \Exception('Trying to persist unknown subset in repository: '.$name.' <br /><pre>'.print_r($value, true).'</pre>'); |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | */ |
140 | 140 | public function save() |
141 | 141 | { |
142 | - array_map(function ($value) { |
|
142 | + array_map(function($value) { |
|
143 | 143 | $this->saveSubset($value); |
144 | 144 | }, $this->fileBasedSubsets); |
145 | 145 | } |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | */ |
151 | 151 | protected function saveSubset($subset) |
152 | 152 | { |
153 | - $changes = $subset . 'Changes'; |
|
153 | + $changes = $subset.'Changes'; |
|
154 | 154 | if ($this->$changes === true) { |
155 | 155 | $json = json_encode($this->$subset, JSON_PRETTY_PRINT); |
156 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
156 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
157 | 157 | file_put_contents($subsetStoragePath, $json); |
158 | 158 | |
159 | 159 | $this->$changes = false; |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function loadSubset($subset) |
169 | 169 | { |
170 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
170 | + $subsetStoragePath = $this->storagePath.DIRECTORY_SEPARATOR.$subset.'.json'; |
|
171 | 171 | $json = file_get_contents($subsetStoragePath); |
172 | 172 | $json = json_decode($json); |
173 | 173 | $this->$subset = $json; |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | public function getContentDbHandle() |
216 | 216 | { |
217 | 217 | if ($this->contentDbHandle === null) { |
218 | - $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
218 | + $this->contentDbHandle = new \PDO('sqlite:'.$this->storagePath.DIRECTORY_SEPARATOR.'content.db'); |
|
219 | 219 | } |
220 | 220 | return $this->contentDbHandle; |
221 | 221 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | public function getDocuments($state = 'published') |
232 | 232 | { |
233 | 233 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
234 | - throw new \Exception('Unsupported document state: ' . $state); |
|
234 | + throw new \Exception('Unsupported document state: '.$state); |
|
235 | 235 | } |
236 | 236 | return $this->getDocumentsByPath('/', $state); |
237 | 237 | } |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | public function getDocumentsWithState($folderPath = '/') |
240 | 240 | { |
241 | 241 | $db = $this->getContentDbHandle(); |
242 | - $folderPathWithWildcard = $folderPath . '%'; |
|
242 | + $folderPathWithWildcard = $folderPath.'%'; |
|
243 | 243 | |
244 | 244 | $ifRootIndex = 1; |
245 | 245 | if ($folderPath == '/') { |
@@ -254,10 +254,10 @@ discard block |
||
254 | 254 | FROM documents_unpublished |
255 | 255 | LEFT JOIN documents_published |
256 | 256 | ON documents_published.path = documents_unpublished.path |
257 | - WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
258 | - AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1) . ') NOT LIKE "%/%" |
|
259 | - AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex) . ' |
|
260 | - AND documents_unpublished.path != ' . $db->quote($folderPath) . ' |
|
257 | + WHERE documents_unpublished.`path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
258 | + AND substr(documents_unpublished.`path`, ' . (strlen($folderPath) + $ifRootIndex + 1).') NOT LIKE "%/%" |
|
259 | + AND length(documents_unpublished.`path`) > ' . (strlen($folderPath) + $ifRootIndex).' |
|
260 | + AND documents_unpublished.path != ' . $db->quote($folderPath).' |
|
261 | 261 | ORDER BY documents_unpublished.`type` DESC, documents_unpublished.`path` ASC |
262 | 262 | '; |
263 | 263 | $stmt = $this->getDbStatement($sql); |
@@ -288,16 +288,16 @@ discard block |
||
288 | 288 | public function getDocumentsByPath($folderPath, $state = 'published') |
289 | 289 | { |
290 | 290 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
291 | - throw new \Exception('Unsupported document state: ' . $state); |
|
291 | + throw new \Exception('Unsupported document state: '.$state); |
|
292 | 292 | } |
293 | 293 | $db = $this->getContentDbHandle(); |
294 | - $folderPathWithWildcard = $folderPath . '%'; |
|
294 | + $folderPathWithWildcard = $folderPath.'%'; |
|
295 | 295 | |
296 | 296 | $sql = 'SELECT * |
297 | - FROM documents_' . $state . ' |
|
298 | - WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
299 | - AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
|
300 | - AND path != ' . $db->quote($folderPath) . ' |
|
297 | + FROM documents_' . $state.' |
|
298 | + WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
299 | + AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%" |
|
300 | + AND path != ' . $db->quote($folderPath).' |
|
301 | 301 | ORDER BY `type` DESC, `path` ASC'; |
302 | 302 | $stmt = $this->getDbStatement($sql); |
303 | 303 | |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | if ($containerPath === '/') { |
329 | 329 | return $this->getRootFolder(); |
330 | 330 | } |
331 | - if (substr($containerPath, -1) === '/'){ |
|
331 | + if (substr($containerPath, -1) === '/') { |
|
332 | 332 | $containerPath = substr($containerPath, 0, -1); |
333 | 333 | } |
334 | 334 | $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
@@ -345,13 +345,13 @@ discard block |
||
345 | 345 | public function getDocumentByPath($path, $state = 'published') |
346 | 346 | { |
347 | 347 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
348 | - throw new \Exception('Unsupported document state: ' . $state); |
|
348 | + throw new \Exception('Unsupported document state: '.$state); |
|
349 | 349 | } |
350 | 350 | $db = $this->getContentDbHandle(); |
351 | 351 | $document = $this->fetchDocument(' |
352 | 352 | SELECT * |
353 | - FROM documents_' . $state . ' |
|
354 | - WHERE path = ' . $db->quote($path) . ' |
|
353 | + FROM documents_' . $state.' |
|
354 | + WHERE path = ' . $db->quote($path).' |
|
355 | 355 | '); |
356 | 356 | if ($document instanceof Document && $document->type === 'folder') { |
357 | 357 | $document->dbHandle = $db; |
@@ -371,16 +371,16 @@ discard block |
||
371 | 371 | public function getTotalDocumentCount($state = 'published') |
372 | 372 | { |
373 | 373 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
374 | - throw new \Exception('Unsupported document state: ' . $state); |
|
374 | + throw new \Exception('Unsupported document state: '.$state); |
|
375 | 375 | } |
376 | 376 | $db = $this->getContentDbHandle(); |
377 | 377 | $stmt = $db->query(' |
378 | 378 | SELECT count(*) |
379 | - FROM documents_' . $state . ' |
|
379 | + FROM documents_' . $state.' |
|
380 | 380 | WHERE `type` != "folder" |
381 | 381 | '); |
382 | 382 | $result = $stmt->fetch(\PDO::FETCH_ASSOC); |
383 | - if (!is_array($result )) { |
|
383 | + if (!is_array($result)) { |
|
384 | 384 | return 0; |
385 | 385 | } |
386 | 386 | return intval(current($result)); |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | if ($stmt === false || !$stmt->execute()) { |
400 | 400 | $errorInfo = $db->errorInfo(); |
401 | 401 | $errorMsg = $errorInfo[2]; |
402 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
402 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
403 | 403 | } |
404 | 404 | return $result; |
405 | 405 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $sql = ' |
411 | 411 | INSERT OR REPLACE INTO documents_published |
412 | 412 | (`id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`publicationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
413 | - SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time() . ' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
413 | + SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time().' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
414 | 414 | FROM documents_unpublished |
415 | 415 | WHERE `path` = :path |
416 | 416 | '; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | if ($stmt === false) { |
419 | 419 | $errorInfo = $db->errorInfo(); |
420 | 420 | $errorMsg = $errorInfo[2]; |
421 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
421 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
422 | 422 | } |
423 | 423 | $stmt->bindValue(':path', $path); |
424 | 424 | $stmt->execute(); |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | if ($stmt === false) { |
434 | 434 | $errorInfo = $db->errorInfo(); |
435 | 435 | $errorMsg = $errorInfo[2]; |
436 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
436 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
437 | 437 | } |
438 | 438 | $stmt->bindValue(':path', $path); |
439 | 439 | $stmt->execute(); |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | if ($stmt === false) { |
477 | 477 | $errorInfo = $db->errorInfo(); |
478 | 478 | $errorMsg = $errorInfo[2]; |
479 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
479 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
480 | 480 | } |
481 | 481 | return $stmt; |
482 | 482 | } |
@@ -506,25 +506,25 @@ discard block |
||
506 | 506 | public function saveDocument($documentObject, $state = 'published') |
507 | 507 | { |
508 | 508 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
509 | - throw new \Exception('Unsupported document state: ' . $state); |
|
509 | + throw new \Exception('Unsupported document state: '.$state); |
|
510 | 510 | } |
511 | 511 | $db = $this->getContentDbHandle(); |
512 | 512 | $stmt = $this->getDbStatement(' |
513 | - INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
513 | + INSERT OR REPLACE INTO documents_' . $state.' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
514 | 514 | VALUES( |
515 | - ' . $db->quote($documentObject->path) . ', |
|
516 | - ' . $db->quote($documentObject->title) . ', |
|
517 | - ' . $db->quote($documentObject->slug) . ', |
|
518 | - ' . $db->quote($documentObject->type) . ', |
|
519 | - ' . $db->quote($documentObject->documentType) . ', |
|
520 | - ' . $db->quote($documentObject->documentTypeSlug) . ', |
|
521 | - ' . $db->quote($documentObject->state) . ', |
|
522 | - ' . $db->quote($documentObject->lastModificationDate) . ', |
|
523 | - ' . $db->quote($documentObject->creationDate) . ', |
|
524 | - ' . $db->quote($documentObject->lastModifiedBy) . ', |
|
525 | - ' . $db->quote(json_encode($documentObject->fields)) . ', |
|
526 | - ' . $db->quote(json_encode($documentObject->bricks)) . ', |
|
527 | - ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
|
515 | + ' . $db->quote($documentObject->path).', |
|
516 | + ' . $db->quote($documentObject->title).', |
|
517 | + ' . $db->quote($documentObject->slug).', |
|
518 | + ' . $db->quote($documentObject->type).', |
|
519 | + ' . $db->quote($documentObject->documentType).', |
|
520 | + ' . $db->quote($documentObject->documentTypeSlug).', |
|
521 | + ' . $db->quote($documentObject->state).', |
|
522 | + ' . $db->quote($documentObject->lastModificationDate).', |
|
523 | + ' . $db->quote($documentObject->creationDate).', |
|
524 | + ' . $db->quote($documentObject->lastModifiedBy).', |
|
525 | + ' . $db->quote(json_encode($documentObject->fields)).', |
|
526 | + ' . $db->quote(json_encode($documentObject->bricks)).', |
|
527 | + ' . $db->quote(json_encode($documentObject->dynamicBricks)).' |
|
528 | 528 | ) |
529 | 529 | '); |
530 | 530 | $result = $stmt->execute(); |
@@ -548,16 +548,16 @@ discard block |
||
548 | 548 | if ($documentToDelete->type == 'document') { |
549 | 549 | $stmt = $this->getDbStatement(' |
550 | 550 | DELETE FROM documents_unpublished |
551 | - WHERE path = ' . $db->quote($path) . ' |
|
551 | + WHERE path = ' . $db->quote($path).' |
|
552 | 552 | '); |
553 | 553 | $stmt->execute(); |
554 | 554 | } elseif ($documentToDelete->type == 'folder') { |
555 | - $folderPathWithWildcard = $path . '%'; |
|
555 | + $folderPathWithWildcard = $path.'%'; |
|
556 | 556 | $stmt = $this->getDbStatement(' |
557 | 557 | DELETE FROM documents_unpublished |
558 | - WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
559 | - AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
|
560 | - OR path = ' . $db->quote($path) . ' |
|
558 | + WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).' |
|
559 | + AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/") |
|
560 | + OR path = ' . $db->quote($path).' |
|
561 | 561 | '); |
562 | 562 | $stmt->execute(); |
563 | 563 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function config() |
84 | 84 | { |
85 | - $storagePath = __DIR__ . '/../../' . $this->storageDir; |
|
85 | + $storagePath = __DIR__.'/../../'.$this->storageDir; |
|
86 | 86 | if (realpath($storagePath) === false) { |
87 | 87 | initFramework(); |
88 | 88 | if (Repository::create($storagePath)) { |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | $repository->init(); |
91 | 91 | $this->repository = $repository; |
92 | 92 | } else { |
93 | - throw new \Exception('Could not create repository directory: ' . $storagePath); |
|
93 | + throw new \Exception('Could not create repository directory: '.$storagePath); |
|
94 | 94 | } |
95 | 95 | } else { |
96 | 96 | $this->repository = new Repository($storagePath); |
@@ -133,9 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $documentFolderObject = DocumentFolderFactory::createDocumentFolderFromPostValues($postValues); |
135 | 135 | if ($postValues['path'] === '/') { |
136 | - $documentFolderObject->path = $postValues['path'] . $documentFolderObject->slug; |
|
136 | + $documentFolderObject->path = $postValues['path'].$documentFolderObject->slug; |
|
137 | 137 | } else { |
138 | - $documentFolderObject->path = $postValues['path'] . '/' . $documentFolderObject->slug; |
|
138 | + $documentFolderObject->path = $postValues['path'].'/'.$documentFolderObject->slug; |
|
139 | 139 | } |
140 | 140 | $this->repository->saveDocument($documentFolderObject, 'published'); |
141 | 141 | $this->repository->saveDocument($documentFolderObject, 'unpublished'); |
@@ -150,20 +150,20 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function deleteDocumentFolderBySlug($slug) |
152 | 152 | { |
153 | - $path = '/' . $slug; |
|
153 | + $path = '/'.$slug; |
|
154 | 154 | $this->repository->deleteDocumentByPath($path, 'published'); |
155 | 155 | $this->repository->deleteDocumentByPath($path, 'unpublished'); |
156 | 156 | } |
157 | 157 | |
158 | 158 | public function publishDocumentBySlug($slug) |
159 | 159 | { |
160 | - $path = '/' . $slug; |
|
160 | + $path = '/'.$slug; |
|
161 | 161 | $this->repository->publishDocumentByPath($path); |
162 | 162 | } |
163 | 163 | |
164 | 164 | public function unpublishDocumentBySlug($slug) |
165 | 165 | { |
166 | - $path = '/' . $slug; |
|
166 | + $path = '/'.$slug; |
|
167 | 167 | $this->repository->unpublishDocumentByPath($path); |
168 | 168 | } |
169 | 169 | |
@@ -177,7 +177,7 @@ discard block |
||
177 | 177 | */ |
178 | 178 | public function getDocumentFolderBySlug($slug) |
179 | 179 | { |
180 | - $path = '/' . $slug; |
|
180 | + $path = '/'.$slug; |
|
181 | 181 | |
182 | 182 | return $this->repository->getDocumentByPath($path); |
183 | 183 | } |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->resetIndex(); |
59 | 59 | $this->addLog('Retrieving documents to be indexed.'); |
60 | 60 | $documents = $this->storage->getDocuments()->getPublishedDocumentsNoFolders(); |
61 | - $this->addLog('Start Document Term Count for ' . count($documents) . ' documents'); |
|
61 | + $this->addLog('Start Document Term Count for '.count($documents).' documents'); |
|
62 | 62 | $this->createDocumentTermCount($documents); |
63 | 63 | $this->addLog('Start Document Term Frequency.'); |
64 | 64 | $this->createDocumentTermFrequency(); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | private function addLog($string) |
160 | 160 | { |
161 | 161 | $currentTime = round(microtime(true) * 1000); |
162 | - $this->log .= date('d-m-Y H:i:s - ') . str_pad($string, 50, " ", STR_PAD_RIGHT) . "\t" . ($currentTime - $this->lastLog) . 'ms since last log. ' . "\t" . ($currentTime - $this->loggingStart) . 'ms since start.' . PHP_EOL; |
|
162 | + $this->log .= date('d-m-Y H:i:s - ').str_pad($string, 50, " ", STR_PAD_RIGHT)."\t".($currentTime - $this->lastLog).'ms since last log. '."\t".($currentTime - $this->loggingStart).'ms since start.'.PHP_EOL; |
|
163 | 163 | $this->lastLog = round(microtime(true) * 1000); |
164 | 164 | } |
165 | 165 | |
@@ -171,8 +171,8 @@ discard block |
||
171 | 171 | protected function getSearchDbHandle() |
172 | 172 | { |
173 | 173 | if ($this->searchDbHandle === null) { |
174 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
175 | - $this->searchDbHandle = new \PDO('sqlite:' . $path . self::SEARCH_TEMP_DB); |
|
174 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
175 | + $this->searchDbHandle = new \PDO('sqlite:'.$path.self::SEARCH_TEMP_DB); |
|
176 | 176 | } |
177 | 177 | return $this->searchDbHandle; |
178 | 178 | } |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | public function replaceOldIndex() |
184 | 184 | { |
185 | 185 | $this->searchDbHandle = null; |
186 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
187 | - rename($path . self::SEARCH_TEMP_DB, $path . 'search.db'); |
|
186 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
187 | + rename($path.self::SEARCH_TEMP_DB, $path.'search.db'); |
|
188 | 188 | } |
189 | 189 | } |
190 | 190 | \ No newline at end of file |
@@ -12,62 +12,62 @@ |
||
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); |
|
30 | - } |
|
31 | - |
|
32 | - |
|
33 | - /** |
|
34 | - * @param $request |
|
35 | - * @param $relativeCmsUri |
|
36 | - * @param CmsComponent $cmsComponent |
|
37 | - * @throws \Exception |
|
38 | - */ |
|
39 | - private function documentRouting($request, $relativeCmsUri, $cmsComponent) |
|
40 | - { |
|
41 | - if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
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 | + } |
|
31 | + |
|
32 | + |
|
33 | + /** |
|
34 | + * @param $request |
|
35 | + * @param $relativeCmsUri |
|
36 | + * @param CmsComponent $cmsComponent |
|
37 | + * @throws \Exception |
|
38 | + */ |
|
39 | + private function documentRouting($request, $relativeCmsUri, $cmsComponent) |
|
40 | + { |
|
41 | + if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
42 | 42 | $this->documentNewRoute($request, $cmsComponent); |
43 | - } elseif ($relativeCmsUri == '/documents/edit-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
43 | + } elseif ($relativeCmsUri == '/documents/edit-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
44 | 44 | $this->editDocumentRoute($request, $cmsComponent); |
45 | - } elseif ($relativeCmsUri == '/documents/get-brick' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
45 | + } elseif ($relativeCmsUri == '/documents/get-brick' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
46 | 46 | $this->getBrickRoute($request, $cmsComponent); |
47 | - } else if ($relativeCmsUri == '/documents/delete-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
47 | + } else if ($relativeCmsUri == '/documents/delete-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
48 | 48 | $this->deleteDocumentRoute($request, $cmsComponent); |
49 | - } else if ($relativeCmsUri == '/documents/publish-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
49 | + } else if ($relativeCmsUri == '/documents/publish-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
50 | 50 | $this->publishDocumentRoute($request, $cmsComponent); |
51 | 51 | } else if ($relativeCmsUri == '/documents/unpublish-document' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
52 | 52 | $this->unpublishDocumentRoute($request, $cmsComponent); |
53 | 53 | } |
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * @param $request |
|
58 | - * @param $relativeCmsUri |
|
59 | - * @param CmsComponent $cmsComponent |
|
60 | - */ |
|
61 | - private function folderRouting($request, $relativeCmsUri, $cmsComponent) |
|
62 | - { |
|
63 | - if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * @param $request |
|
58 | + * @param $relativeCmsUri |
|
59 | + * @param CmsComponent $cmsComponent |
|
60 | + */ |
|
61 | + private function folderRouting($request, $relativeCmsUri, $cmsComponent) |
|
62 | + { |
|
63 | + if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
64 | 64 | $this->newFolderRoute($request, $cmsComponent); |
65 | - } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
65 | + } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
66 | 66 | $this->editFolderRoute($request, $cmsComponent); |
67 | - } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
67 | + } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
68 | 68 | $this->deleteFolderRoute($request, $cmsComponent); |
69 | - } |
|
70 | - } |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * @param $request |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | if (isset($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE])) { |
84 | 84 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], $request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
85 | 85 | $cmsComponent->storage->getDocuments()->addDocument($request::$post); |
86 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
86 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
87 | 87 | exit; |
88 | 88 | } |
89 | 89 | $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPE, $cmsComponent->storage->getDocumentTypes()->getDocumentTypeBySlug($request::$get[CmsComponent::PARAMETER_DOCUMENT_TYPE], true)); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } else { |
92 | 92 | $documentTypes = $cmsComponent->storage->getDocumentTypes()->getDocumentTypes(); |
93 | 93 | if (count($documentTypes) < 1) { |
94 | - 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>'); |
|
94 | + 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>'); |
|
95 | 95 | } |
96 | 96 | $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT_TYPES, $documentTypes); |
97 | 97 | } |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | $cmsComponent->setParameter(CmsComponent::PARAMETER_SMALLEST_IMAGE, $cmsComponent->storage->getImageSet()->getSmallestImageSet()->slug); |
109 | 109 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
110 | 110 | $cmsComponent->storage->getDocuments()->saveDocument($request::$post); |
111 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
111 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
112 | 112 | exit; |
113 | 113 | } |
114 | 114 | $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENT, $cmsComponent->storage->getDocuments()->getDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG], 'unpublished')); |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | private function deleteDocumentRoute($request, $cmsComponent) |
146 | 146 | { |
147 | 147 | $cmsComponent->storage->getDocuments()->deleteDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
148 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
148 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
149 | 149 | exit; |
150 | 150 | } |
151 | 151 | |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
160 | 160 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::GET_PARAMETER_PATH])) { |
161 | 161 | $cmsComponent->storage->addDocumentFolder($request::$post); |
162 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
162 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
163 | 163 | exit; |
164 | 164 | } |
165 | 165 | } |
@@ -178,11 +178,11 @@ discard block |
||
178 | 178 | array_pop($path); |
179 | 179 | $path = implode('/', $path); |
180 | 180 | |
181 | - $request::$get[CmsComponent::GET_PARAMETER_PATH] = '/' . $path; |
|
181 | + $request::$get[CmsComponent::GET_PARAMETER_PATH] = '/'.$path; |
|
182 | 182 | |
183 | 183 | if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post['content'])) { |
184 | 184 | $cmsComponent->storage->saveDocumentFolder($request::$post); |
185 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
185 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
186 | 186 | exit; |
187 | 187 | } |
188 | 188 | |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | private function deleteFolderRoute($request, $cmsComponent) |
198 | 198 | { |
199 | 199 | $cmsComponent->storage->deleteDocumentFolderBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
200 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
200 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
201 | 201 | exit; |
202 | 202 | } |
203 | 203 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | private function publishDocumentRoute($request, $cmsComponent) |
209 | 209 | { |
210 | 210 | $cmsComponent->storage->publishDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
211 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
211 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
212 | 212 | exit; |
213 | 213 | } |
214 | 214 | |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | private function unpublishDocumentRoute($request, $cmsComponent) |
220 | 220 | { |
221 | 221 | $cmsComponent->storage->unpublishDocumentBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
222 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/documents'); |
|
222 | + header('Location: '.$request::$subfolders.$cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX).'/documents'); |
|
223 | 223 | exit; |
224 | 224 | } |
225 | 225 | } |
226 | 226 | \ No newline at end of file |