@@ -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,7 +150,7 @@ 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 | $this->repository->cleanPublishedDeletedDocuments(); |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | |
| 159 | 159 | public function publishDocumentBySlug($slug) |
| 160 | 160 | { |
| 161 | - $path = '/' . $slug; |
|
| 161 | + $path = '/'.$slug; |
|
| 162 | 162 | $this->repository->publishDocumentByPath($path); |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | public function unpublishDocumentBySlug($slug) |
| 166 | 166 | { |
| 167 | - $path = '/' . $slug; |
|
| 167 | + $path = '/'.$slug; |
|
| 168 | 168 | $this->repository->unpublishDocumentByPath($path); |
| 169 | 169 | } |
| 170 | 170 | |
@@ -178,7 +178,7 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | public function getDocumentFolderBySlug($slug) |
| 180 | 180 | { |
| 181 | - $path = '/' . $slug; |
|
| 181 | + $path = '/'.$slug; |
|
| 182 | 182 | |
| 183 | 183 | return $this->repository->getDocumentByPath($path); |
| 184 | 184 | } |
@@ -1,22 +1,22 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace library\storage { |
| 3 | 3 | |
| 4 | - use library\storage\factories\DocumentFolderFactory; |
|
| 5 | - use library\storage\storage\ApplicationComponentsStorage; |
|
| 6 | - use library\storage\storage\BricksStorage; |
|
| 7 | - use library\storage\storage\DocumentStorage; |
|
| 8 | - use library\storage\storage\DocumentTypesStorage; |
|
| 9 | - use library\storage\storage\FilesStorage; |
|
| 10 | - use library\storage\storage\ImageSetStorage; |
|
| 11 | - use library\storage\storage\ImagesStorage; |
|
| 12 | - use library\storage\storage\RedirectsStorage; |
|
| 13 | - use library\storage\storage\SitemapStorage; |
|
| 14 | - use library\storage\storage\UsersStorage; |
|
| 15 | - use library\storage\storage\ValuelistsStorage; |
|
| 4 | + use library\storage\factories\DocumentFolderFactory; |
|
| 5 | + use library\storage\storage\ApplicationComponentsStorage; |
|
| 6 | + use library\storage\storage\BricksStorage; |
|
| 7 | + use library\storage\storage\DocumentStorage; |
|
| 8 | + use library\storage\storage\DocumentTypesStorage; |
|
| 9 | + use library\storage\storage\FilesStorage; |
|
| 10 | + use library\storage\storage\ImageSetStorage; |
|
| 11 | + use library\storage\storage\ImagesStorage; |
|
| 12 | + use library\storage\storage\RedirectsStorage; |
|
| 13 | + use library\storage\storage\SitemapStorage; |
|
| 14 | + use library\storage\storage\UsersStorage; |
|
| 15 | + use library\storage\storage\ValuelistsStorage; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Class JsonStorage |
| 19 | - * @package library\storage |
|
| 19 | + * @package library\storage |
|
| 20 | 20 | */ |
| 21 | 21 | class Storage |
| 22 | 22 | { |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | * @var DocumentStorage |
| 62 | 62 | */ |
| 63 | 63 | protected $documents; |
| 64 | - /** |
|
| 65 | - * @var RedirectsStorage |
|
| 66 | - */ |
|
| 67 | - protected $redirects; |
|
| 64 | + /** |
|
| 65 | + * @var RedirectsStorage |
|
| 66 | + */ |
|
| 67 | + protected $redirects; |
|
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * @var String |
@@ -325,16 +325,16 @@ discard block |
||
| 325 | 325 | return $this->valuelists; |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | - /** |
|
| 329 | - * @return RedirectsStorage |
|
| 330 | - */ |
|
| 331 | - public function getRedirects() |
|
| 332 | - { |
|
| 333 | - if (!$this->redirects instanceof RedirectsStorage) { |
|
| 334 | - $this->redirects = new RedirectsStorage($this->repository); |
|
| 335 | - } |
|
| 336 | - return $this->redirects; |
|
| 337 | - } |
|
| 328 | + /** |
|
| 329 | + * @return RedirectsStorage |
|
| 330 | + */ |
|
| 331 | + public function getRedirects() |
|
| 332 | + { |
|
| 333 | + if (!$this->redirects instanceof RedirectsStorage) { |
|
| 334 | + $this->redirects = new RedirectsStorage($this->repository); |
|
| 335 | + } |
|
| 336 | + return $this->redirects; |
|
| 337 | + } |
|
| 338 | 338 | |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | \ No newline at end of file |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $this->storage->getDocuments()->cleanPublishedDeletedDocuments(); |
| 61 | 61 | $this->addLog('Retrieving documents to be indexed.'); |
| 62 | 62 | $documents = $this->storage->getDocuments()->getPublishedDocumentsNoFolders(); |
| 63 | - $this->addLog('Start Document Term Count for ' . count($documents) . ' documents'); |
|
| 63 | + $this->addLog('Start Document Term Count for '.count($documents).' documents'); |
|
| 64 | 64 | $this->createDocumentTermCount($documents); |
| 65 | 65 | $this->addLog('Start Document Term Frequency.'); |
| 66 | 66 | $this->createDocumentTermFrequency(); |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | private function addLog($string) |
| 162 | 162 | { |
| 163 | 163 | $currentTime = round(microtime(true) * 1000); |
| 164 | - $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; |
|
| 164 | + $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; |
|
| 165 | 165 | $this->lastLog = round(microtime(true) * 1000); |
| 166 | 166 | } |
| 167 | 167 | |
@@ -173,8 +173,8 @@ discard block |
||
| 173 | 173 | protected function getSearchDbHandle() |
| 174 | 174 | { |
| 175 | 175 | if ($this->searchDbHandle === null) { |
| 176 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
| 177 | - $this->searchDbHandle = new \PDO('sqlite:' . $path . self::SEARCH_TEMP_DB); |
|
| 176 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
| 177 | + $this->searchDbHandle = new \PDO('sqlite:'.$path.self::SEARCH_TEMP_DB); |
|
| 178 | 178 | } |
| 179 | 179 | return $this->searchDbHandle; |
| 180 | 180 | } |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | public function replaceOldIndex() |
| 186 | 186 | { |
| 187 | 187 | $this->searchDbHandle = null; |
| 188 | - $path = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . $this->storageDir . DIRECTORY_SEPARATOR; |
|
| 189 | - rename($path . self::SEARCH_TEMP_DB, $path . 'search.db'); |
|
| 188 | + $path = __DIR__.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.$this->storageDir.DIRECTORY_SEPARATOR; |
|
| 189 | + rename($path.self::SEARCH_TEMP_DB, $path.'search.db'); |
|
| 190 | 190 | } |
| 191 | 191 | } |
| 192 | 192 | \ No newline at end of file |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | private function showJson($obj, $httpHeader = 'HTTP/1.0 200 OK') { |
| 75 | - header($_SERVER['SERVER_PROTOCOL'] . $httpHeader, true); |
|
| 75 | + header($_SERVER['SERVER_PROTOCOL'].$httpHeader, true); |
|
| 76 | 76 | header('Content-type: application/json'); |
| 77 | 77 | die(json_encode($obj)); |
| 78 | 78 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | */ |
| 85 | 85 | private function stepRouting($step, $cmsComponent, $indexer) |
| 86 | 86 | { |
| 87 | - switch($step) { |
|
| 87 | + switch ($step) { |
|
| 88 | 88 | case 'resetIndex': $indexer->resetIndex(); break; |
| 89 | 89 | case 'cleanPublishedDeletedDocuments': $cmsComponent->storage->getDocuments()->cleanPublishedDeletedDocuments(); break; |
| 90 | 90 | case 'createDocumentTermCount': |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | case 'createTermFieldLengthNorm': $indexer->createTermFieldLengthNorm(); break; |
| 96 | 96 | case 'createInverseDocumentFrequency': $indexer->createInverseDocumentFrequency(); break; |
| 97 | 97 | case 'replaceOldIndex': $indexer->replaceOldIndex(); break; |
| 98 | - default : $this->showJson('Invalid step: ' . $step . '.', 'HTTP/1.0 500 Internal Server Error'); break; |
|
| 98 | + default : $this->showJson('Invalid step: '.$step.'.', 'HTTP/1.0 500 Internal Server Error'); break; |
|
| 99 | 99 | } |
| 100 | 100 | $this->showJson('done'); |
| 101 | 101 | } |
@@ -1,7 +1,7 @@ discard block |
||
| 1 | 1 | <? include('documents/function.renderAction.php'); ?> |
| 2 | 2 | <? include('documents/function.renderDocument.php'); ?> |
| 3 | 3 | <? include('documents/function.renderFolder.php'); ?> |
| 4 | -<script>window.onload=function(){History.init();History.replaceState(null, 'Cloud Control CMS', '/<?=$request::$subfolders . $cmsPrefix?>/documents?path=/');};</script> |
|
| 4 | +<script>window.onload=function(){History.init();History.replaceState(null, 'Cloud Control CMS', '/<?=$request::$subfolders.$cmsPrefix?>/documents?path=/');};</script> |
|
| 5 | 5 | <section class="documents"> |
| 6 | 6 | <h2><i class="fa fa-file-text-o"></i> Documents</h2> |
| 7 | 7 | <nav class="actions"> |
@@ -27,9 +27,9 @@ discard block |
||
| 27 | 27 | <? foreach ($documents as $document) : ?> |
| 28 | 28 | <li class="grid-container"> |
| 29 | 29 | <? if ($document->type == 'document') : ?> |
| 30 | - <?renderDocument($document, $cmsPrefix);?> |
|
| 30 | + <?renderDocument($document, $cmsPrefix); ?> |
|
| 31 | 31 | <? elseif ($document->type == 'folder') : ?> |
| 32 | - <?renderFolder($document, $cmsPrefix, '', true);?> |
|
| 32 | + <?renderFolder($document, $cmsPrefix, '', true); ?> |
|
| 33 | 33 | <? endif ?> |
| 34 | 34 | </li> |
| 35 | 35 | <? endforeach ?> |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | <div class="documentActions grid-box-2"> |
| 22 | 22 | <? if ($document->state == 'unpublished' || $document->unpublishedChanges) : ?> |
| 23 | 23 | <?renderAction('Publish', |
| 24 | - 'publish', |
|
| 25 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug, |
|
| 26 | - 'check');?> |
|
| 24 | + 'publish', |
|
| 25 | + \library\cc\Request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug, |
|
| 26 | + 'check');?> |
|
| 27 | 27 | <? endif ?> |
| 28 | 28 | <? if ($document->state == 'published') : ?> |
| 29 | 29 | <?renderAction('Unpublish', |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | 'error', |
| 41 | 41 | \library\cc\Request::$subfolders . $cmsPrefix . '/documents/delete-document?slug=' . $slugPrefix . $document->slug, |
| 42 | 42 | 'trash', |
| 43 | - 'return confirm(\'Are you sure you want to delete this document?\');');?> |
|
| 43 | + 'return confirm(\'Are you sure you want to delete this document?\');');?> |
|
| 44 | 44 | <? endif ?> |
| 45 | 45 | </div> |
| 46 | 46 | <?}?> |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | function renderDocument($document, $cmsPrefix, $slugPrefix = '') {?> |
| 8 | 8 | <div class="grid-box-10"> |
| 9 | 9 | <h3> |
| 10 | - <a class="btn documentTitle" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix . $document->slug?>" title="Edit"> |
|
| 10 | + <a class="btn documentTitle" href="<?=\library\cc\Request::$subfolders?><?=$cmsPrefix?>/documents/edit-document?slug=<?=$slugPrefix.$document->slug?>" title="Edit"> |
|
| 11 | 11 | <i class="fa fa-file-text-o"></i> |
| 12 | 12 | <small class="state <?=strtolower($document->state)?>"><i class="fa <?=$document->state == 'published' ? 'fa-check-circle-o' : 'fa-times-circle-o' ?>"></i></small> |
| 13 | 13 | <?=$document->title?> |
@@ -28,25 +28,25 @@ discard block |
||
| 28 | 28 | <? if ($document->state == 'unpublished' || $document->unpublishedChanges) : ?> |
| 29 | 29 | <?renderAction('Publish', |
| 30 | 30 | 'publish', |
| 31 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/publish-document?slug=' . $slugPrefix . $document->slug, |
|
| 32 | - 'check');?> |
|
| 31 | + \library\cc\Request::$subfolders.$cmsPrefix.'/documents/publish-document?slug='.$slugPrefix.$document->slug, |
|
| 32 | + 'check'); ?> |
|
| 33 | 33 | <? endif ?> |
| 34 | 34 | <? if ($document->state == 'published') : ?> |
| 35 | 35 | <?renderAction('Unpublish', |
| 36 | 36 | 'unpublish', |
| 37 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/unpublish-document?slug=' . $slugPrefix . $document->slug, |
|
| 38 | - 'times');?> |
|
| 37 | + \library\cc\Request::$subfolders.$cmsPrefix.'/documents/unpublish-document?slug='.$slugPrefix.$document->slug, |
|
| 38 | + 'times'); ?> |
|
| 39 | 39 | <? endif ?> |
| 40 | 40 | <?renderAction('Edit', |
| 41 | 41 | '', |
| 42 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/edit-document?slug=' . $slugPrefix . $document->slug, |
|
| 43 | - 'pencil');?> |
|
| 42 | + \library\cc\Request::$subfolders.$cmsPrefix.'/documents/edit-document?slug='.$slugPrefix.$document->slug, |
|
| 43 | + 'pencil'); ?> |
|
| 44 | 44 | <? if ($document->state == 'unpublished') : ?> |
| 45 | 45 | <?renderAction('Delete', |
| 46 | 46 | 'error', |
| 47 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/delete-document?slug=' . $slugPrefix . $document->slug, |
|
| 47 | + \library\cc\Request::$subfolders.$cmsPrefix.'/documents/delete-document?slug='.$slugPrefix.$document->slug, |
|
| 48 | 48 | 'trash', |
| 49 | - 'return confirm(\'Are you sure you want to delete this document?\');');?> |
|
| 49 | + 'return confirm(\'Are you sure you want to delete this document?\');'); ?> |
|
| 50 | 50 | <? endif ?> |
| 51 | 51 | </div> |
| 52 | 52 | <?}?> |
@@ -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); |
@@ -284,16 +284,16 @@ discard block |
||
| 284 | 284 | public function getDocumentsByPath($folderPath, $state = 'published') |
| 285 | 285 | { |
| 286 | 286 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 287 | - throw new \Exception('Unsupported document state: ' . $state); |
|
| 287 | + throw new \Exception('Unsupported document state: '.$state); |
|
| 288 | 288 | } |
| 289 | 289 | $db = $this->getContentDbHandle(); |
| 290 | - $folderPathWithWildcard = $folderPath . '%'; |
|
| 290 | + $folderPathWithWildcard = $folderPath.'%'; |
|
| 291 | 291 | |
| 292 | 292 | $sql = 'SELECT * |
| 293 | - FROM documents_' . $state . ' |
|
| 294 | - WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
| 295 | - AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
|
| 296 | - AND path != ' . $db->quote($folderPath) . ' |
|
| 293 | + FROM documents_' . $state.' |
|
| 294 | + WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard).' |
|
| 295 | + AND substr(`path`, ' . (strlen($folderPath) + 1).') NOT LIKE "%/%" |
|
| 296 | + AND path != ' . $db->quote($folderPath).' |
|
| 297 | 297 | ORDER BY `type` DESC, `path` ASC'; |
| 298 | 298 | $stmt = $this->getDbStatement($sql); |
| 299 | 299 | |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | if ($containerPath === '/') { |
| 321 | 321 | return $this->getRootFolder(); |
| 322 | 322 | } |
| 323 | - if (substr($containerPath, -1) === '/'){ |
|
| 323 | + if (substr($containerPath, -1) === '/') { |
|
| 324 | 324 | $containerPath = substr($containerPath, 0, -1); |
| 325 | 325 | } |
| 326 | 326 | $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | public function getDocumentByPath($path, $state = 'published') |
| 338 | 338 | { |
| 339 | 339 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 340 | - throw new \Exception('Unsupported document state: ' . $state); |
|
| 340 | + throw new \Exception('Unsupported document state: '.$state); |
|
| 341 | 341 | } |
| 342 | 342 | $db = $this->getContentDbHandle(); |
| 343 | 343 | $document = $this->fetchDocument(' |
| 344 | 344 | SELECT * |
| 345 | - FROM documents_' . $state . ' |
|
| 346 | - WHERE path = ' . $db->quote($path) . ' |
|
| 345 | + FROM documents_' . $state.' |
|
| 346 | + WHERE path = ' . $db->quote($path).' |
|
| 347 | 347 | '); |
| 348 | 348 | if ($document instanceof Document && $document->type === 'folder') { |
| 349 | 349 | $document->dbHandle = $db; |
@@ -363,16 +363,16 @@ discard block |
||
| 363 | 363 | public function getTotalDocumentCount($state = 'published') |
| 364 | 364 | { |
| 365 | 365 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 366 | - throw new \Exception('Unsupported document state: ' . $state); |
|
| 366 | + throw new \Exception('Unsupported document state: '.$state); |
|
| 367 | 367 | } |
| 368 | 368 | $db = $this->getContentDbHandle(); |
| 369 | 369 | $stmt = $db->query(' |
| 370 | 370 | SELECT count(*) |
| 371 | - FROM documents_' . $state . ' |
|
| 371 | + FROM documents_' . $state.' |
|
| 372 | 372 | WHERE `type` != "folder" |
| 373 | 373 | '); |
| 374 | 374 | $result = $stmt->fetch(\PDO::FETCH_ASSOC); |
| 375 | - if (!is_array($result )) { |
|
| 375 | + if (!is_array($result)) { |
|
| 376 | 376 | return 0; |
| 377 | 377 | } |
| 378 | 378 | return intval(current($result)); |
@@ -391,7 +391,7 @@ discard block |
||
| 391 | 391 | if ($stmt === false || !$stmt->execute()) { |
| 392 | 392 | $errorInfo = $db->errorInfo(); |
| 393 | 393 | $errorMsg = $errorInfo[2]; |
| 394 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 394 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 395 | 395 | } |
| 396 | 396 | return $result; |
| 397 | 397 | } |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | $sql = ' |
| 402 | 402 | INSERT OR REPLACE INTO documents_published |
| 403 | 403 | (`id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`publicationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
| 404 | - SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time() . ' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
| 404 | + SELECT `id`,`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,"published" as state,`lastModificationDate`,`creationDate`,' . time().' as publicationDate, `lastModifiedBy`,`fields`,`bricks`,`dynamicBricks` |
|
| 405 | 405 | FROM documents_unpublished |
| 406 | 406 | WHERE `path` = :path |
| 407 | 407 | '; |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | if ($stmt === false) { |
| 415 | 415 | $errorInfo = $db->errorInfo(); |
| 416 | 416 | $errorMsg = $errorInfo[2]; |
| 417 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 417 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 418 | 418 | } |
| 419 | 419 | $stmt->bindValue(':path', $path); |
| 420 | 420 | $stmt->execute(); |
@@ -481,7 +481,7 @@ discard block |
||
| 481 | 481 | if ($stmt === false) { |
| 482 | 482 | $errorInfo = $db->errorInfo(); |
| 483 | 483 | $errorMsg = $errorInfo[2]; |
| 484 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 484 | + throw new \Exception('SQLite Exception: '.$errorMsg.' in SQL: <br /><pre>'.$sql.'</pre>'); |
|
| 485 | 485 | } |
| 486 | 486 | return $stmt; |
| 487 | 487 | } |
@@ -511,25 +511,25 @@ discard block |
||
| 511 | 511 | public function saveDocument($documentObject, $state = 'published') |
| 512 | 512 | { |
| 513 | 513 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 514 | - throw new \Exception('Unsupported document state: ' . $state); |
|
| 514 | + throw new \Exception('Unsupported document state: '.$state); |
|
| 515 | 515 | } |
| 516 | 516 | $db = $this->getContentDbHandle(); |
| 517 | 517 | $stmt = $this->getDbStatement(' |
| 518 | - INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
| 518 | + INSERT OR REPLACE INTO documents_' . $state.' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
|
| 519 | 519 | VALUES( |
| 520 | - ' . $db->quote($documentObject->path) . ', |
|
| 521 | - ' . $db->quote($documentObject->title) . ', |
|
| 522 | - ' . $db->quote($documentObject->slug) . ', |
|
| 523 | - ' . $db->quote($documentObject->type) . ', |
|
| 524 | - ' . $db->quote($documentObject->documentType) . ', |
|
| 525 | - ' . $db->quote($documentObject->documentTypeSlug) . ', |
|
| 526 | - ' . $db->quote($documentObject->state) . ', |
|
| 527 | - ' . $db->quote($documentObject->lastModificationDate) . ', |
|
| 528 | - ' . $db->quote($documentObject->creationDate) . ', |
|
| 529 | - ' . $db->quote($documentObject->lastModifiedBy) . ', |
|
| 530 | - ' . $db->quote(json_encode($documentObject->fields)) . ', |
|
| 531 | - ' . $db->quote(json_encode($documentObject->bricks)) . ', |
|
| 532 | - ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
|
| 520 | + ' . $db->quote($documentObject->path).', |
|
| 521 | + ' . $db->quote($documentObject->title).', |
|
| 522 | + ' . $db->quote($documentObject->slug).', |
|
| 523 | + ' . $db->quote($documentObject->type).', |
|
| 524 | + ' . $db->quote($documentObject->documentType).', |
|
| 525 | + ' . $db->quote($documentObject->documentTypeSlug).', |
|
| 526 | + ' . $db->quote($documentObject->state).', |
|
| 527 | + ' . $db->quote($documentObject->lastModificationDate).', |
|
| 528 | + ' . $db->quote($documentObject->creationDate).', |
|
| 529 | + ' . $db->quote($documentObject->lastModifiedBy).', |
|
| 530 | + ' . $db->quote(json_encode($documentObject->fields)).', |
|
| 531 | + ' . $db->quote(json_encode($documentObject->bricks)).', |
|
| 532 | + ' . $db->quote(json_encode($documentObject->dynamicBricks)).' |
|
| 533 | 533 | ) |
| 534 | 534 | '); |
| 535 | 535 | $result = $stmt->execute(); |
@@ -553,16 +553,16 @@ discard block |
||
| 553 | 553 | if ($documentToDelete->type == 'document') { |
| 554 | 554 | $stmt = $this->getDbStatement(' |
| 555 | 555 | DELETE FROM documents_unpublished |
| 556 | - WHERE path = ' . $db->quote($path) . ' |
|
| 556 | + WHERE path = ' . $db->quote($path).' |
|
| 557 | 557 | '); |
| 558 | 558 | $stmt->execute(); |
| 559 | 559 | } elseif ($documentToDelete->type == 'folder') { |
| 560 | - $folderPathWithWildcard = $path . '%'; |
|
| 560 | + $folderPathWithWildcard = $path.'%'; |
|
| 561 | 561 | $stmt = $this->getDbStatement(' |
| 562 | 562 | DELETE FROM documents_unpublished |
| 563 | - WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
|
| 564 | - AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
|
| 565 | - OR path = ' . $db->quote($path) . ' |
|
| 563 | + WHERE (path LIKE ' . $db->quote($folderPathWithWildcard).' |
|
| 564 | + AND substr(`path`, ' . (strlen($path) + 1).', 1) = "/") |
|
| 565 | + OR path = ' . $db->quote($path).' |
|
| 566 | 566 | '); |
| 567 | 567 | $stmt->execute(); |
| 568 | 568 | } |
@@ -24,141 +24,141 @@ discard block |
||
| 24 | 24 | */ |
| 25 | 25 | class Repository |
| 26 | 26 | { |
| 27 | - protected $storagePath; |
|
| 28 | - |
|
| 29 | - protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users', 'valuelists', 'redirects'); |
|
| 30 | - |
|
| 31 | - protected $sitemap; |
|
| 32 | - protected $sitemapChanges = false; |
|
| 33 | - |
|
| 34 | - protected $applicationComponents; |
|
| 35 | - protected $applicationComponentsChanges = false; |
|
| 36 | - |
|
| 37 | - protected $documentTypes; |
|
| 38 | - protected $documentTypesChanges = false; |
|
| 39 | - |
|
| 40 | - protected $bricks; |
|
| 41 | - protected $bricksChanges = false; |
|
| 42 | - |
|
| 43 | - protected $imageSet; |
|
| 44 | - protected $imageSetChanges = false; |
|
| 45 | - |
|
| 46 | - protected $images; |
|
| 47 | - protected $imagesChanges = false; |
|
| 48 | - |
|
| 49 | - protected $files; |
|
| 50 | - protected $filesChanges = false; |
|
| 51 | - |
|
| 52 | - protected $users; |
|
| 53 | - protected $usersChanges = false; |
|
| 54 | - |
|
| 55 | - protected $valuelists; |
|
| 56 | - protected $valuelistsChanges = false; |
|
| 57 | - |
|
| 58 | - protected $redirects; |
|
| 59 | - protected $redirectsChanges = false; |
|
| 60 | - |
|
| 61 | - protected $contentDbHandle; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * Repository constructor. |
|
| 66 | - * @param $storagePath |
|
| 67 | - * @throws \Exception |
|
| 68 | - */ |
|
| 69 | - public function __construct($storagePath) |
|
| 70 | - { |
|
| 71 | - $storagePath = realpath($storagePath); |
|
| 72 | - if (is_dir($storagePath) && $storagePath !== false) { |
|
| 73 | - $this->storagePath = $storagePath; |
|
| 74 | - } else { |
|
| 75 | - throw new \Exception('Repository not yet initialized.'); |
|
| 76 | - } |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Creates the folder in which to create all storage related files |
|
| 81 | - * |
|
| 82 | - * @param $storagePath |
|
| 83 | - * @return bool |
|
| 84 | - */ |
|
| 85 | - public static function create($storagePath) |
|
| 86 | - { |
|
| 87 | - return mkdir($storagePath); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - /** |
|
| 91 | - * Initiates default storage |
|
| 92 | - * @throws \Exception |
|
| 93 | - */ |
|
| 94 | - public function init() |
|
| 95 | - { |
|
| 96 | - $storageDefaultPath = realpath('../library/cc/install/_storage.json'); |
|
| 97 | - $contentSqlPath = realpath('../library/cc/install/content.sql'); |
|
| 98 | - |
|
| 99 | - $this->initConfigStorage($storageDefaultPath); |
|
| 100 | - $this->initContentDb($contentSqlPath); |
|
| 101 | - |
|
| 102 | - $this->save(); |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Load filebased subset and return it's contents |
|
| 107 | - * |
|
| 108 | - * @param $name |
|
| 109 | - * @return mixed|string |
|
| 110 | - * @throws \Exception |
|
| 111 | - */ |
|
| 112 | - public function __get($name) |
|
| 113 | - { |
|
| 114 | - if (isset($this->$name)) { |
|
| 115 | - if (in_array($name, $this->fileBasedSubsets)) { |
|
| 116 | - return $this->$name; |
|
| 117 | - } else { |
|
| 118 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
| 119 | - } |
|
| 120 | - } else { |
|
| 121 | - if (in_array($name, $this->fileBasedSubsets)) { |
|
| 122 | - return $this->loadSubset($name); |
|
| 123 | - } else { |
|
| 124 | - throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
| 125 | - } |
|
| 126 | - } |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * Set filebased subset contents |
|
| 131 | - * @param $name |
|
| 132 | - * @param $value |
|
| 133 | - * @throws \Exception |
|
| 134 | - */ |
|
| 135 | - public function __set($name, $value) |
|
| 136 | - { |
|
| 137 | - if (in_array($name, $this->fileBasedSubsets)) { |
|
| 138 | - $this->$name = $value; |
|
| 139 | - $changes = $name . 'Changes'; |
|
| 140 | - $this->$changes = true; |
|
| 141 | - } else { |
|
| 142 | - throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
| 143 | - } |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * Persist all subsets |
|
| 148 | - */ |
|
| 149 | - public function save() |
|
| 150 | - { |
|
| 151 | - array_map(function ($value) { |
|
| 152 | - $this->saveSubset($value); |
|
| 27 | + protected $storagePath; |
|
| 28 | + |
|
| 29 | + protected $fileBasedSubsets = array('sitemap', 'applicationComponents', 'documentTypes', 'bricks', 'imageSet', 'images', 'files', 'users', 'valuelists', 'redirects'); |
|
| 30 | + |
|
| 31 | + protected $sitemap; |
|
| 32 | + protected $sitemapChanges = false; |
|
| 33 | + |
|
| 34 | + protected $applicationComponents; |
|
| 35 | + protected $applicationComponentsChanges = false; |
|
| 36 | + |
|
| 37 | + protected $documentTypes; |
|
| 38 | + protected $documentTypesChanges = false; |
|
| 39 | + |
|
| 40 | + protected $bricks; |
|
| 41 | + protected $bricksChanges = false; |
|
| 42 | + |
|
| 43 | + protected $imageSet; |
|
| 44 | + protected $imageSetChanges = false; |
|
| 45 | + |
|
| 46 | + protected $images; |
|
| 47 | + protected $imagesChanges = false; |
|
| 48 | + |
|
| 49 | + protected $files; |
|
| 50 | + protected $filesChanges = false; |
|
| 51 | + |
|
| 52 | + protected $users; |
|
| 53 | + protected $usersChanges = false; |
|
| 54 | + |
|
| 55 | + protected $valuelists; |
|
| 56 | + protected $valuelistsChanges = false; |
|
| 57 | + |
|
| 58 | + protected $redirects; |
|
| 59 | + protected $redirectsChanges = false; |
|
| 60 | + |
|
| 61 | + protected $contentDbHandle; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * Repository constructor. |
|
| 66 | + * @param $storagePath |
|
| 67 | + * @throws \Exception |
|
| 68 | + */ |
|
| 69 | + public function __construct($storagePath) |
|
| 70 | + { |
|
| 71 | + $storagePath = realpath($storagePath); |
|
| 72 | + if (is_dir($storagePath) && $storagePath !== false) { |
|
| 73 | + $this->storagePath = $storagePath; |
|
| 74 | + } else { |
|
| 75 | + throw new \Exception('Repository not yet initialized.'); |
|
| 76 | + } |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Creates the folder in which to create all storage related files |
|
| 81 | + * |
|
| 82 | + * @param $storagePath |
|
| 83 | + * @return bool |
|
| 84 | + */ |
|
| 85 | + public static function create($storagePath) |
|
| 86 | + { |
|
| 87 | + return mkdir($storagePath); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + /** |
|
| 91 | + * Initiates default storage |
|
| 92 | + * @throws \Exception |
|
| 93 | + */ |
|
| 94 | + public function init() |
|
| 95 | + { |
|
| 96 | + $storageDefaultPath = realpath('../library/cc/install/_storage.json'); |
|
| 97 | + $contentSqlPath = realpath('../library/cc/install/content.sql'); |
|
| 98 | + |
|
| 99 | + $this->initConfigStorage($storageDefaultPath); |
|
| 100 | + $this->initContentDb($contentSqlPath); |
|
| 101 | + |
|
| 102 | + $this->save(); |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Load filebased subset and return it's contents |
|
| 107 | + * |
|
| 108 | + * @param $name |
|
| 109 | + * @return mixed|string |
|
| 110 | + * @throws \Exception |
|
| 111 | + */ |
|
| 112 | + public function __get($name) |
|
| 113 | + { |
|
| 114 | + if (isset($this->$name)) { |
|
| 115 | + if (in_array($name, $this->fileBasedSubsets)) { |
|
| 116 | + return $this->$name; |
|
| 117 | + } else { |
|
| 118 | + throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + if (in_array($name, $this->fileBasedSubsets)) { |
|
| 122 | + return $this->loadSubset($name); |
|
| 123 | + } else { |
|
| 124 | + throw new \Exception('Trying to get undefined property from Repository: ' . $name); |
|
| 125 | + } |
|
| 126 | + } |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * Set filebased subset contents |
|
| 131 | + * @param $name |
|
| 132 | + * @param $value |
|
| 133 | + * @throws \Exception |
|
| 134 | + */ |
|
| 135 | + public function __set($name, $value) |
|
| 136 | + { |
|
| 137 | + if (in_array($name, $this->fileBasedSubsets)) { |
|
| 138 | + $this->$name = $value; |
|
| 139 | + $changes = $name . 'Changes'; |
|
| 140 | + $this->$changes = true; |
|
| 141 | + } else { |
|
| 142 | + throw new \Exception('Trying to persist unknown subset in repository: ' . $name . ' <br /><pre>' . print_r($value, true) . '</pre>'); |
|
| 143 | + } |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * Persist all subsets |
|
| 148 | + */ |
|
| 149 | + public function save() |
|
| 150 | + { |
|
| 151 | + array_map(function ($value) { |
|
| 152 | + $this->saveSubset($value); |
|
| 153 | 153 | }, $this->fileBasedSubsets); |
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Persist subset to disk |
|
| 158 | - * @param $subset |
|
| 159 | - */ |
|
| 160 | - protected function saveSubset($subset) |
|
| 161 | - { |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Persist subset to disk |
|
| 158 | + * @param $subset |
|
| 159 | + */ |
|
| 160 | + protected function saveSubset($subset) |
|
| 161 | + { |
|
| 162 | 162 | $changes = $subset . 'Changes'; |
| 163 | 163 | if ($this->$changes === true) { |
| 164 | 164 | $json = json_encode($this->$subset, JSON_PRETTY_PRINT); |
@@ -167,69 +167,69 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | $this->$changes = false; |
| 169 | 169 | } |
| 170 | - } |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * Load subset from disk |
|
| 174 | - * @param $subset |
|
| 175 | - * @return mixed|string |
|
| 176 | - */ |
|
| 177 | - protected function loadSubset($subset) |
|
| 178 | - { |
|
| 179 | - $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
| 180 | - $json = file_get_contents($subsetStoragePath); |
|
| 181 | - $json = json_decode($json); |
|
| 182 | - $this->$subset = $json; |
|
| 183 | - return $json; |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @param $contentSqlPath |
|
| 188 | - */ |
|
| 189 | - protected function initContentDb($contentSqlPath) |
|
| 190 | - { |
|
| 191 | - $db = $this->getContentDbHandle(); |
|
| 192 | - $sql = file_get_contents($contentSqlPath); |
|
| 193 | - $db->exec($sql); |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - /** |
|
| 197 | - * @param $storageDefaultPath |
|
| 198 | - */ |
|
| 199 | - protected function initConfigStorage($storageDefaultPath) |
|
| 200 | - { |
|
| 201 | - $json = file_get_contents($storageDefaultPath); |
|
| 202 | - $json = json_decode($json); |
|
| 203 | - $this->sitemap = $json->sitemap; |
|
| 204 | - $this->sitemapChanges = true; |
|
| 205 | - $this->applicationComponents = $json->applicationComponents; |
|
| 206 | - $this->applicationComponentsChanges = true; |
|
| 207 | - $this->documentTypes = $json->documentTypes; |
|
| 208 | - $this->documentTypesChanges = true; |
|
| 209 | - $this->bricks = $json->bricks; |
|
| 210 | - $this->bricksChanges = true; |
|
| 211 | - $this->imageSet = $json->imageSet; |
|
| 212 | - $this->imageSetChanges = true; |
|
| 213 | - $this->images = $json->images; |
|
| 214 | - $this->imagesChanges = true; |
|
| 215 | - $this->files = $json->files; |
|
| 216 | - $this->filesChanges = true; |
|
| 217 | - $this->users = $json->users; |
|
| 218 | - $this->usersChanges = true; |
|
| 219 | - $this->valuelists = $json->valuelists; |
|
| 220 | - $this->valuelistsChanges = true; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - /** |
|
| 224 | - * @return \PDO |
|
| 225 | - */ |
|
| 226 | - public function getContentDbHandle() |
|
| 227 | - { |
|
| 228 | - if ($this->contentDbHandle === null) { |
|
| 229 | - $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
| 230 | - } |
|
| 231 | - return $this->contentDbHandle; |
|
| 232 | - } |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * Load subset from disk |
|
| 174 | + * @param $subset |
|
| 175 | + * @return mixed|string |
|
| 176 | + */ |
|
| 177 | + protected function loadSubset($subset) |
|
| 178 | + { |
|
| 179 | + $subsetStoragePath = $this->storagePath . DIRECTORY_SEPARATOR . $subset . '.json'; |
|
| 180 | + $json = file_get_contents($subsetStoragePath); |
|
| 181 | + $json = json_decode($json); |
|
| 182 | + $this->$subset = $json; |
|
| 183 | + return $json; |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @param $contentSqlPath |
|
| 188 | + */ |
|
| 189 | + protected function initContentDb($contentSqlPath) |
|
| 190 | + { |
|
| 191 | + $db = $this->getContentDbHandle(); |
|
| 192 | + $sql = file_get_contents($contentSqlPath); |
|
| 193 | + $db->exec($sql); |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + /** |
|
| 197 | + * @param $storageDefaultPath |
|
| 198 | + */ |
|
| 199 | + protected function initConfigStorage($storageDefaultPath) |
|
| 200 | + { |
|
| 201 | + $json = file_get_contents($storageDefaultPath); |
|
| 202 | + $json = json_decode($json); |
|
| 203 | + $this->sitemap = $json->sitemap; |
|
| 204 | + $this->sitemapChanges = true; |
|
| 205 | + $this->applicationComponents = $json->applicationComponents; |
|
| 206 | + $this->applicationComponentsChanges = true; |
|
| 207 | + $this->documentTypes = $json->documentTypes; |
|
| 208 | + $this->documentTypesChanges = true; |
|
| 209 | + $this->bricks = $json->bricks; |
|
| 210 | + $this->bricksChanges = true; |
|
| 211 | + $this->imageSet = $json->imageSet; |
|
| 212 | + $this->imageSetChanges = true; |
|
| 213 | + $this->images = $json->images; |
|
| 214 | + $this->imagesChanges = true; |
|
| 215 | + $this->files = $json->files; |
|
| 216 | + $this->filesChanges = true; |
|
| 217 | + $this->users = $json->users; |
|
| 218 | + $this->usersChanges = true; |
|
| 219 | + $this->valuelists = $json->valuelists; |
|
| 220 | + $this->valuelistsChanges = true; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + /** |
|
| 224 | + * @return \PDO |
|
| 225 | + */ |
|
| 226 | + public function getContentDbHandle() |
|
| 227 | + { |
|
| 228 | + if ($this->contentDbHandle === null) { |
|
| 229 | + $this->contentDbHandle = new \PDO('sqlite:' . $this->storagePath . DIRECTORY_SEPARATOR . 'content.db'); |
|
| 230 | + } |
|
| 231 | + return $this->contentDbHandle; |
|
| 232 | + } |
|
| 233 | 233 | |
| 234 | 234 | /** |
| 235 | 235 | * Get all documents |
@@ -239,13 +239,13 @@ discard block |
||
| 239 | 239 | * @return array |
| 240 | 240 | * @throws \Exception |
| 241 | 241 | */ |
| 242 | - public function getDocuments($state = 'published') |
|
| 243 | - { |
|
| 242 | + public function getDocuments($state = 'published') |
|
| 243 | + { |
|
| 244 | 244 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 245 | 245 | throw new \Exception('Unsupported document state: ' . $state); |
| 246 | 246 | } |
| 247 | - return $this->getDocumentsByPath('/', $state); |
|
| 248 | - } |
|
| 247 | + return $this->getDocumentsByPath('/', $state); |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | 250 | public function getDocumentsWithState($folderPath = '/') |
| 251 | 251 | { |
@@ -292,51 +292,51 @@ discard block |
||
| 292 | 292 | * @return array |
| 293 | 293 | * @throws \Exception |
| 294 | 294 | */ |
| 295 | - public function getDocumentsByPath($folderPath, $state = 'published') |
|
| 296 | - { |
|
| 297 | - if (!in_array($state, Document::$DOCUMENT_STATES)) { |
|
| 298 | - throw new \Exception('Unsupported document state: ' . $state); |
|
| 295 | + public function getDocumentsByPath($folderPath, $state = 'published') |
|
| 296 | + { |
|
| 297 | + if (!in_array($state, Document::$DOCUMENT_STATES)) { |
|
| 298 | + throw new \Exception('Unsupported document state: ' . $state); |
|
| 299 | 299 | } |
| 300 | - $db = $this->getContentDbHandle(); |
|
| 301 | - $folderPathWithWildcard = $folderPath . '%'; |
|
| 300 | + $db = $this->getContentDbHandle(); |
|
| 301 | + $folderPathWithWildcard = $folderPath . '%'; |
|
| 302 | 302 | |
| 303 | - $sql = 'SELECT * |
|
| 303 | + $sql = 'SELECT * |
|
| 304 | 304 | FROM documents_' . $state . ' |
| 305 | 305 | WHERE `path` LIKE ' . $db->quote($folderPathWithWildcard) . ' |
| 306 | 306 | AND substr(`path`, ' . (strlen($folderPath) + 1) . ') NOT LIKE "%/%" |
| 307 | 307 | AND path != ' . $db->quote($folderPath) . ' |
| 308 | 308 | ORDER BY `type` DESC, `path` ASC'; |
| 309 | - $stmt = $this->getDbStatement($sql); |
|
| 309 | + $stmt = $this->getDbStatement($sql); |
|
| 310 | 310 | |
| 311 | - $documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
| 312 | - foreach ($documents as $key => $document) { |
|
| 311 | + $documents = $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
| 312 | + foreach ($documents as $key => $document) { |
|
| 313 | 313 | $documents = $this->setAssetsToDocumentFolders($document, $db, $documents, $key); |
| 314 | - } |
|
| 315 | - return $documents; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - |
|
| 319 | - /** |
|
| 320 | - * @param $path |
|
| 321 | - * @return bool|Document |
|
| 322 | - */ |
|
| 323 | - public function getDocumentContainerByPath($path) |
|
| 324 | - { |
|
| 325 | - $document = $this->getDocumentByPath($path, 'unpublished'); |
|
| 326 | - if ($document === false) { |
|
| 327 | - return false; |
|
| 328 | - } |
|
| 329 | - $slugLength = strlen($document->slug); |
|
| 330 | - $containerPath = substr($path, 0, -$slugLength); |
|
| 331 | - if ($containerPath === '/') { |
|
| 332 | - return $this->getRootFolder(); |
|
| 333 | - } |
|
| 334 | - if (substr($containerPath, -1) === '/'){ |
|
| 314 | + } |
|
| 315 | + return $documents; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + |
|
| 319 | + /** |
|
| 320 | + * @param $path |
|
| 321 | + * @return bool|Document |
|
| 322 | + */ |
|
| 323 | + public function getDocumentContainerByPath($path) |
|
| 324 | + { |
|
| 325 | + $document = $this->getDocumentByPath($path, 'unpublished'); |
|
| 326 | + if ($document === false) { |
|
| 327 | + return false; |
|
| 328 | + } |
|
| 329 | + $slugLength = strlen($document->slug); |
|
| 330 | + $containerPath = substr($path, 0, -$slugLength); |
|
| 331 | + if ($containerPath === '/') { |
|
| 332 | + return $this->getRootFolder(); |
|
| 333 | + } |
|
| 334 | + if (substr($containerPath, -1) === '/'){ |
|
| 335 | 335 | $containerPath = substr($containerPath, 0, -1); |
| 336 | 336 | } |
| 337 | - $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
|
| 338 | - return $containerFolder; |
|
| 339 | - } |
|
| 337 | + $containerFolder = $this->getDocumentByPath($containerPath, 'unpublished'); |
|
| 338 | + return $containerFolder; |
|
| 339 | + } |
|
| 340 | 340 | |
| 341 | 341 | /** |
| 342 | 342 | * @param $path |
@@ -345,23 +345,23 @@ discard block |
||
| 345 | 345 | * @return bool|\library\storage\Document |
| 346 | 346 | * @throws \Exception |
| 347 | 347 | */ |
| 348 | - public function getDocumentByPath($path, $state = 'published') |
|
| 349 | - { |
|
| 348 | + public function getDocumentByPath($path, $state = 'published') |
|
| 349 | + { |
|
| 350 | 350 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 351 | 351 | throw new \Exception('Unsupported document state: ' . $state); |
| 352 | 352 | } |
| 353 | - $db = $this->getContentDbHandle(); |
|
| 354 | - $document = $this->fetchDocument(' |
|
| 353 | + $db = $this->getContentDbHandle(); |
|
| 354 | + $document = $this->fetchDocument(' |
|
| 355 | 355 | SELECT * |
| 356 | 356 | FROM documents_' . $state . ' |
| 357 | 357 | WHERE path = ' . $db->quote($path) . ' |
| 358 | 358 | '); |
| 359 | - if ($document instanceof Document && $document->type === 'folder') { |
|
| 360 | - $document->dbHandle = $db; |
|
| 361 | - $document->documentStorage = new DocumentStorage($this); |
|
| 362 | - } |
|
| 363 | - return $document; |
|
| 364 | - } |
|
| 359 | + if ($document instanceof Document && $document->type === 'folder') { |
|
| 360 | + $document->dbHandle = $db; |
|
| 361 | + $document->documentStorage = new DocumentStorage($this); |
|
| 362 | + } |
|
| 363 | + return $document; |
|
| 364 | + } |
|
| 365 | 365 | |
| 366 | 366 | /** |
| 367 | 367 | * Returns the count of all documents stored in the db |
@@ -456,58 +456,58 @@ discard block |
||
| 456 | 456 | } |
| 457 | 457 | |
| 458 | 458 | /** |
| 459 | - * Return the results of the query as array of Documents |
|
| 460 | - * @param $sql |
|
| 461 | - * @return array |
|
| 462 | - * @throws \Exception |
|
| 463 | - */ |
|
| 464 | - protected function fetchAllDocuments($sql) |
|
| 465 | - { |
|
| 466 | - $stmt = $this->getDbStatement($sql); |
|
| 467 | - return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - /** |
|
| 471 | - * Return the result of the query as Document |
|
| 472 | - * @param $sql |
|
| 473 | - * @return mixed |
|
| 474 | - * @throws \Exception |
|
| 475 | - */ |
|
| 476 | - protected function fetchDocument($sql) |
|
| 477 | - { |
|
| 478 | - $stmt = $this->getDbStatement($sql); |
|
| 479 | - return $stmt->fetchObject('\library\storage\Document'); |
|
| 480 | - } |
|
| 481 | - |
|
| 482 | - /** |
|
| 483 | - * Prepare the sql statement |
|
| 484 | - * @param $sql |
|
| 485 | - * @return \PDOStatement |
|
| 486 | - * @throws \Exception |
|
| 487 | - */ |
|
| 488 | - protected function getDbStatement($sql) |
|
| 489 | - { |
|
| 490 | - $db = $this->getContentDbHandle(); |
|
| 491 | - $stmt = $db->query($sql); |
|
| 492 | - if ($stmt === false) { |
|
| 493 | - $errorInfo = $db->errorInfo(); |
|
| 494 | - $errorMsg = $errorInfo[2]; |
|
| 495 | - throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 496 | - } |
|
| 497 | - return $stmt; |
|
| 498 | - } |
|
| 499 | - |
|
| 500 | - /** |
|
| 501 | - * Create a (non-existent) root folder Document and return it |
|
| 502 | - * @return Document |
|
| 503 | - */ |
|
| 504 | - protected function getRootFolder() |
|
| 505 | - { |
|
| 506 | - $rootFolder = new Document(); |
|
| 507 | - $rootFolder->path = '/'; |
|
| 508 | - $rootFolder->type = 'folder'; |
|
| 509 | - return $rootFolder; |
|
| 510 | - } |
|
| 459 | + * Return the results of the query as array of Documents |
|
| 460 | + * @param $sql |
|
| 461 | + * @return array |
|
| 462 | + * @throws \Exception |
|
| 463 | + */ |
|
| 464 | + protected function fetchAllDocuments($sql) |
|
| 465 | + { |
|
| 466 | + $stmt = $this->getDbStatement($sql); |
|
| 467 | + return $stmt->fetchAll(\PDO::FETCH_CLASS, '\library\storage\Document'); |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + /** |
|
| 471 | + * Return the result of the query as Document |
|
| 472 | + * @param $sql |
|
| 473 | + * @return mixed |
|
| 474 | + * @throws \Exception |
|
| 475 | + */ |
|
| 476 | + protected function fetchDocument($sql) |
|
| 477 | + { |
|
| 478 | + $stmt = $this->getDbStatement($sql); |
|
| 479 | + return $stmt->fetchObject('\library\storage\Document'); |
|
| 480 | + } |
|
| 481 | + |
|
| 482 | + /** |
|
| 483 | + * Prepare the sql statement |
|
| 484 | + * @param $sql |
|
| 485 | + * @return \PDOStatement |
|
| 486 | + * @throws \Exception |
|
| 487 | + */ |
|
| 488 | + protected function getDbStatement($sql) |
|
| 489 | + { |
|
| 490 | + $db = $this->getContentDbHandle(); |
|
| 491 | + $stmt = $db->query($sql); |
|
| 492 | + if ($stmt === false) { |
|
| 493 | + $errorInfo = $db->errorInfo(); |
|
| 494 | + $errorMsg = $errorInfo[2]; |
|
| 495 | + throw new \Exception('SQLite Exception: ' . $errorMsg . ' in SQL: <br /><pre>' . $sql . '</pre>'); |
|
| 496 | + } |
|
| 497 | + return $stmt; |
|
| 498 | + } |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * Create a (non-existent) root folder Document and return it |
|
| 502 | + * @return Document |
|
| 503 | + */ |
|
| 504 | + protected function getRootFolder() |
|
| 505 | + { |
|
| 506 | + $rootFolder = new Document(); |
|
| 507 | + $rootFolder->path = '/'; |
|
| 508 | + $rootFolder->type = 'folder'; |
|
| 509 | + return $rootFolder; |
|
| 510 | + } |
|
| 511 | 511 | |
| 512 | 512 | /** |
| 513 | 513 | * Save the document to the database |
@@ -519,13 +519,13 @@ discard block |
||
| 519 | 519 | * @throws \Exception |
| 520 | 520 | * @internal param $path |
| 521 | 521 | */ |
| 522 | - public function saveDocument($documentObject, $state = 'published') |
|
| 523 | - { |
|
| 522 | + public function saveDocument($documentObject, $state = 'published') |
|
| 523 | + { |
|
| 524 | 524 | if (!in_array($state, Document::$DOCUMENT_STATES)) { |
| 525 | 525 | throw new \Exception('Unsupported document state: ' . $state); |
| 526 | 526 | } |
| 527 | - $db = $this->getContentDbHandle(); |
|
| 528 | - $stmt = $this->getDbStatement(' |
|
| 527 | + $db = $this->getContentDbHandle(); |
|
| 528 | + $stmt = $this->getDbStatement(' |
|
| 529 | 529 | INSERT OR REPLACE INTO documents_' . $state . ' (`path`,`title`,`slug`,`type`,`documentType`,`documentTypeSlug`,`state`,`lastModificationDate`,`creationDate`,`lastModifiedBy`,`fields`,`bricks`,`dynamicBricks`) |
| 530 | 530 | VALUES( |
| 531 | 531 | ' . $db->quote($documentObject->path) . ', |
@@ -543,9 +543,9 @@ discard block |
||
| 543 | 543 | ' . $db->quote(json_encode($documentObject->dynamicBricks)) . ' |
| 544 | 544 | ) |
| 545 | 545 | '); |
| 546 | - $result = $stmt->execute(); |
|
| 547 | - return $result; |
|
| 548 | - } |
|
| 546 | + $result = $stmt->execute(); |
|
| 547 | + return $result; |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | 550 | /** |
| 551 | 551 | * Delete the document from the database |
@@ -556,29 +556,29 @@ discard block |
||
| 556 | 556 | * @internal param string $state |
| 557 | 557 | * |
| 558 | 558 | */ |
| 559 | - public function deleteDocumentByPath($path) |
|
| 560 | - { |
|
| 561 | - $db = $this->getContentDbHandle(); |
|
| 562 | - $documentToDelete = $this->getDocumentByPath($path, 'unpublished'); |
|
| 563 | - if ($documentToDelete instanceof Document) { |
|
| 564 | - if ($documentToDelete->type == 'document') { |
|
| 565 | - $stmt = $this->getDbStatement(' |
|
| 559 | + public function deleteDocumentByPath($path) |
|
| 560 | + { |
|
| 561 | + $db = $this->getContentDbHandle(); |
|
| 562 | + $documentToDelete = $this->getDocumentByPath($path, 'unpublished'); |
|
| 563 | + if ($documentToDelete instanceof Document) { |
|
| 564 | + if ($documentToDelete->type == 'document') { |
|
| 565 | + $stmt = $this->getDbStatement(' |
|
| 566 | 566 | DELETE FROM documents_unpublished |
| 567 | 567 | WHERE path = ' . $db->quote($path) . ' |
| 568 | 568 | '); |
| 569 | - $stmt->execute(); |
|
| 570 | - } elseif ($documentToDelete->type == 'folder') { |
|
| 571 | - $folderPathWithWildcard = $path . '%'; |
|
| 572 | - $stmt = $this->getDbStatement(' |
|
| 569 | + $stmt->execute(); |
|
| 570 | + } elseif ($documentToDelete->type == 'folder') { |
|
| 571 | + $folderPathWithWildcard = $path . '%'; |
|
| 572 | + $stmt = $this->getDbStatement(' |
|
| 573 | 573 | DELETE FROM documents_unpublished |
| 574 | 574 | WHERE (path LIKE ' . $db->quote($folderPathWithWildcard) . ' |
| 575 | 575 | AND substr(`path`, ' . (strlen($path) + 1) . ', 1) = "/") |
| 576 | 576 | OR path = ' . $db->quote($path) . ' |
| 577 | 577 | '); |
| 578 | - $stmt->execute(); |
|
| 579 | - } |
|
| 580 | - } |
|
| 581 | - } |
|
| 578 | + $stmt->execute(); |
|
| 579 | + } |
|
| 580 | + } |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | 583 | /** |
| 584 | 584 | * @param $document |
@@ -5,10 +5,10 @@ discard block |
||
| 5 | 5 | * @param string $slugPrefix |
| 6 | 6 | * @param bool $root |
| 7 | 7 | */ |
| 8 | -function renderFolder($document, $cmsPrefix, $slugPrefix ='', $root = false) {?> |
|
| 8 | +function renderFolder($document, $cmsPrefix, $slugPrefix = '', $root = false) {?> |
|
| 9 | 9 | <div class="grid-box-8"> |
| 10 | 10 | <h3> |
| 11 | - <a class="btn documentTitle openFolder" data-slug="<?=$slugPrefix . $document->slug?>" title="Open"> |
|
| 11 | + <a class="btn documentTitle openFolder" data-slug="<?=$slugPrefix.$document->slug?>" title="Open"> |
|
| 12 | 12 | <i class="fa fa-folder-o "></i> <?=$document->title?> |
| 13 | 13 | </a> |
| 14 | 14 | </h3> |
@@ -16,21 +16,21 @@ discard block |
||
| 16 | 16 | <div class="documentActions grid-box-4"> |
| 17 | 17 | <?renderAction('Edit', |
| 18 | 18 | '', |
| 19 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/edit-folder?slug=' . $slugPrefix . $document->slug, |
|
| 20 | - 'pencil');?> |
|
| 19 | + \library\cc\Request::$subfolders.$cmsPrefix.'/documents/edit-folder?slug='.$slugPrefix.$document->slug, |
|
| 20 | + 'pencil'); ?> |
|
| 21 | 21 | <?renderAction('Delete', |
| 22 | 22 | 'error', |
| 23 | - \library\cc\Request::$subfolders . $cmsPrefix . '/documents/delete-folder?slug=' . $slugPrefix . $document->slug, |
|
| 23 | + \library\cc\Request::$subfolders.$cmsPrefix.'/documents/delete-folder?slug='.$slugPrefix.$document->slug, |
|
| 24 | 24 | 'trash', |
| 25 | - 'return confirm(\'Are you sure you want to delete this document?\');');?> |
|
| 25 | + 'return confirm(\'Are you sure you want to delete this document?\');'); ?> |
|
| 26 | 26 | </div> |
| 27 | 27 | <ul class="documents grid-wrapper nested<?=$root ? ' root' : '' ?>"> |
| 28 | 28 | <? foreach ($document->content as $subDocument) : ?> |
| 29 | 29 | <li class="grid-container"> |
| 30 | 30 | <? if ($subDocument->type == 'document') : ?> |
| 31 | - <?renderDocument($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/');?> |
|
| 31 | + <?renderDocument($subDocument, $cmsPrefix, $slugPrefix.$document->slug.'/'); ?> |
|
| 32 | 32 | <? elseif ($subDocument->type == 'folder') : ?> |
| 33 | - <?renderFolder($subDocument, $cmsPrefix, $slugPrefix . $document->slug . '/');?> |
|
| 33 | + <?renderFolder($subDocument, $cmsPrefix, $slugPrefix.$document->slug.'/'); ?> |
|
| 34 | 34 | <? endif ?> |
| 35 | 35 | </li> |
| 36 | 36 | <? endforeach ?> |
@@ -12,83 +12,83 @@ |
||
| 12 | 12 | |
| 13 | 13 | class ValuelistsStorage extends AbstractStorage |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * Get all valuelists |
|
| 17 | - * |
|
| 18 | - * @return mixed |
|
| 19 | - */ |
|
| 20 | - public function getValuelists() |
|
| 21 | - { |
|
| 22 | - return $this->repository->valuelists; |
|
| 23 | - } |
|
| 15 | + /** |
|
| 16 | + * Get all valuelists |
|
| 17 | + * |
|
| 18 | + * @return mixed |
|
| 19 | + */ |
|
| 20 | + public function getValuelists() |
|
| 21 | + { |
|
| 22 | + return $this->repository->valuelists; |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - public function addValuelist($postValues) |
|
| 26 | - { |
|
| 27 | - $valueListObject = ValuelistFactory::createValuelistFromPostValues($postValues); |
|
| 28 | - $valuelists = $this->repository->valuelists; |
|
| 29 | - $valuelists[] = $valueListObject; |
|
| 30 | - $this->repository->valuelists = $valuelists; |
|
| 31 | - $this->save(); |
|
| 32 | - } |
|
| 25 | + public function addValuelist($postValues) |
|
| 26 | + { |
|
| 27 | + $valueListObject = ValuelistFactory::createValuelistFromPostValues($postValues); |
|
| 28 | + $valuelists = $this->repository->valuelists; |
|
| 29 | + $valuelists[] = $valueListObject; |
|
| 30 | + $this->repository->valuelists = $valuelists; |
|
| 31 | + $this->save(); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Save changes to a valuelist |
|
| 36 | - * |
|
| 37 | - * @param $slug |
|
| 38 | - * @param $postValues |
|
| 39 | - * |
|
| 40 | - * @throws \Exception |
|
| 41 | - */ |
|
| 42 | - public function saveValuelist($slug, $postValues) |
|
| 43 | - { |
|
| 44 | - $valuelistObject = ValuelistFactory::createValuelistFromPostValues($postValues); |
|
| 34 | + /** |
|
| 35 | + * Save changes to a valuelist |
|
| 36 | + * |
|
| 37 | + * @param $slug |
|
| 38 | + * @param $postValues |
|
| 39 | + * |
|
| 40 | + * @throws \Exception |
|
| 41 | + */ |
|
| 42 | + public function saveValuelist($slug, $postValues) |
|
| 43 | + { |
|
| 44 | + $valuelistObject = ValuelistFactory::createValuelistFromPostValues($postValues); |
|
| 45 | 45 | |
| 46 | - $valuelists = $this->repository->valuelists; |
|
| 47 | - foreach ($valuelists as $key => $valuelist) { |
|
| 48 | - if ($valuelist->slug == $slug) { |
|
| 49 | - $valuelists[$key] = $valuelistObject; |
|
| 50 | - } |
|
| 51 | - } |
|
| 52 | - $this->repository->valuelists = $valuelists; |
|
| 53 | - $this->save(); |
|
| 54 | - } |
|
| 46 | + $valuelists = $this->repository->valuelists; |
|
| 47 | + foreach ($valuelists as $key => $valuelist) { |
|
| 48 | + if ($valuelist->slug == $slug) { |
|
| 49 | + $valuelists[$key] = $valuelistObject; |
|
| 50 | + } |
|
| 51 | + } |
|
| 52 | + $this->repository->valuelists = $valuelists; |
|
| 53 | + $this->save(); |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * Get a valuelist by its slug |
|
| 58 | - * |
|
| 59 | - * @param $slug |
|
| 60 | - * |
|
| 61 | - * @return mixed |
|
| 62 | - */ |
|
| 63 | - public function getValuelistBySlug($slug) |
|
| 64 | - { |
|
| 65 | - $valuelists = $this->repository->valuelists; |
|
| 66 | - foreach ($valuelists as $valuelist) { |
|
| 67 | - if ($valuelist->slug == $slug) { |
|
| 68 | - return $valuelist; |
|
| 69 | - } |
|
| 70 | - } |
|
| 56 | + /** |
|
| 57 | + * Get a valuelist by its slug |
|
| 58 | + * |
|
| 59 | + * @param $slug |
|
| 60 | + * |
|
| 61 | + * @return mixed |
|
| 62 | + */ |
|
| 63 | + public function getValuelistBySlug($slug) |
|
| 64 | + { |
|
| 65 | + $valuelists = $this->repository->valuelists; |
|
| 66 | + foreach ($valuelists as $valuelist) { |
|
| 67 | + if ($valuelist->slug == $slug) { |
|
| 68 | + return $valuelist; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - return null; |
|
| 73 | - } |
|
| 72 | + return null; |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - /** |
|
| 76 | - * Delete a sitemap item by its slug |
|
| 77 | - * |
|
| 78 | - * @param $slug |
|
| 79 | - * |
|
| 80 | - * @throws \Exception |
|
| 81 | - */ |
|
| 82 | - public function deleteValuelistBySlug($slug) |
|
| 83 | - { |
|
| 84 | - $valuelists = $this->repository->valuelists; |
|
| 85 | - foreach ($valuelists as $key => $valuelist) { |
|
| 86 | - if ($valuelist->slug == $slug) { |
|
| 87 | - unset($valuelists[$key]); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - $valuelists = array_values($valuelists); |
|
| 91 | - $this->repository->valuelists = $valuelists; |
|
| 92 | - $this->save(); |
|
| 93 | - } |
|
| 75 | + /** |
|
| 76 | + * Delete a sitemap item by its slug |
|
| 77 | + * |
|
| 78 | + * @param $slug |
|
| 79 | + * |
|
| 80 | + * @throws \Exception |
|
| 81 | + */ |
|
| 82 | + public function deleteValuelistBySlug($slug) |
|
| 83 | + { |
|
| 84 | + $valuelists = $this->repository->valuelists; |
|
| 85 | + foreach ($valuelists as $key => $valuelist) { |
|
| 86 | + if ($valuelist->slug == $slug) { |
|
| 87 | + unset($valuelists[$key]); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + $valuelists = array_values($valuelists); |
|
| 91 | + $this->repository->valuelists = $valuelists; |
|
| 92 | + $this->save(); |
|
| 93 | + } |
|
| 94 | 94 | } |
| 95 | 95 | \ No newline at end of file |
@@ -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 |