@@ -4,9 +4,9 @@ |
||
| 4 | 4 | </div> |
| 5 | 5 | <label><?= $brick->title ?></label> |
| 6 | 6 | <? if ($static == true) { |
| 7 | - $fieldPrefix = 'bricks[' . $myBrickSlug . '][' . str_replace('.', '', str_replace(' ', '', microtime())) . '][fields]'; |
|
| 7 | + $fieldPrefix = 'bricks[' . $myBrickSlug . '][' . str_replace('.', '', str_replace(' ', '', microtime())) . '][fields]'; |
|
| 8 | 8 | } else { |
| 9 | - $fieldPrefix = 'dynamicBricks[' . $brick->slug . '][' . str_replace('.', '', str_replace(' ', '', microtime())) . ']'; |
|
| 9 | + $fieldPrefix = 'dynamicBricks[' . $brick->slug . '][' . str_replace('.', '', str_replace(' ', '', microtime())) . ']'; |
|
| 10 | 10 | } ?> |
| 11 | 11 | <? foreach ($brick->fields as $field) : ?> |
| 12 | 12 | <div class="form-element"> |
@@ -1,8 +1,8 @@ discard block |
||
| 1 | 1 | <? |
| 2 | 2 | if (isset($summernoteInstances)) { |
| 3 | - $summernoteInstances += 1; |
|
| 3 | + $summernoteInstances += 1; |
|
| 4 | 4 | } else { |
| 5 | - $summernoteInstances = 1; |
|
| 5 | + $summernoteInstances = 1; |
|
| 6 | 6 | } |
| 7 | 7 | ?> |
| 8 | 8 | <div class="rte"> |
@@ -26,6 +26,6 @@ discard block |
||
| 26 | 26 | </script> |
| 27 | 27 | <? |
| 28 | 28 | if (!isset($GLOBALS['rteList'])) { |
| 29 | - $GLOBALS['rteList'] = array(); |
|
| 29 | + $GLOBALS['rteList'] = array(); |
|
| 30 | 30 | } |
| 31 | 31 | $GLOBALS['rteList'][] = 'summernote_' . str_replace(']', '-', str_replace('[', '-', $fieldPrefix)) . $field->slug . '_rte_' . $summernoteInstances ?> |
@@ -17,14 +17,14 @@ |
||
| 17 | 17 | </div> |
| 18 | 18 | <div class="documentActions grid-box-4"> |
| 19 | 19 | <? renderAction('Edit', |
| 20 | - '', |
|
| 21 | - $request::$subfolders . $cmsPrefix . '/documents/edit-folder?slug=' . $slugPrefix . $document->slug, |
|
| 22 | - 'pencil'); ?> |
|
| 20 | + '', |
|
| 21 | + $request::$subfolders . $cmsPrefix . '/documents/edit-folder?slug=' . $slugPrefix . $document->slug, |
|
| 22 | + 'pencil'); ?> |
|
| 23 | 23 | <? renderAction('Delete', |
| 24 | - 'error', |
|
| 25 | - $request::$subfolders . $cmsPrefix . '/documents/delete-folder?slug=' . $slugPrefix . $document->slug, |
|
| 26 | - 'trash', |
|
| 27 | - 'return confirm(\'Are you sure you want to delete this document?\');'); ?> |
|
| 24 | + 'error', |
|
| 25 | + $request::$subfolders . $cmsPrefix . '/documents/delete-folder?slug=' . $slugPrefix . $document->slug, |
|
| 26 | + 'trash', |
|
| 27 | + 'return confirm(\'Are you sure you want to delete this document?\');'); ?> |
|
| 28 | 28 | </div> |
| 29 | 29 | <ul class="documents grid-wrapper nested<?= $root ? ' root' : '' ?>"> |
| 30 | 30 | <? foreach ($document->getContent() as $subDocument) : ?> |
@@ -12,10 +12,10 @@ |
||
| 12 | 12 | |
| 13 | 13 | class NotFoundComponent extends BaseComponent |
| 14 | 14 | { |
| 15 | - public function run(Storage $storage) |
|
| 16 | - { |
|
| 17 | - parent::run($storage); |
|
| 18 | - header("HTTP/1.0 404 Not Found"); |
|
| 19 | - } |
|
| 15 | + public function run(Storage $storage) |
|
| 16 | + { |
|
| 17 | + parent::run($storage); |
|
| 18 | + header("HTTP/1.0 404 Not Found"); |
|
| 19 | + } |
|
| 20 | 20 | |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -6,124 +6,124 @@ |
||
| 6 | 6 | |
| 7 | 7 | class LanguageComponent implements Component |
| 8 | 8 | { |
| 9 | - protected $request; |
|
| 10 | - protected $parameters; |
|
| 11 | - |
|
| 12 | - protected $defaultLanguage = 'en'; |
|
| 13 | - protected $acceptedLanguages = null; |
|
| 14 | - protected $languageParameterName = 'language'; |
|
| 15 | - protected $forceRedirect = false; |
|
| 16 | - protected $sessionValues; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * Component constructor. |
|
| 20 | - * |
|
| 21 | - * @param $template |
|
| 22 | - * @param Request $request |
|
| 23 | - * @param $parameters |
|
| 24 | - * @param $matchedSitemapItem |
|
| 25 | - */ |
|
| 26 | - public function __construct($template, Request $request, $parameters, $matchedSitemapItem) |
|
| 27 | - { |
|
| 28 | - $this->parameters = (array) $parameters; |
|
| 29 | - $this->checkParameters(); |
|
| 30 | - |
|
| 31 | - $lang = substr(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $this->defaultLanguage, 0, 2); |
|
| 32 | - $_SESSION['LanguageComponent']['detectedLanguage'] = $lang; |
|
| 33 | - |
|
| 34 | - $this->checkLanguageSwitch($request); |
|
| 35 | - |
|
| 36 | - if (!isset($_SESSION['LanguageComponent'][$this->languageParameterName])) { |
|
| 37 | - $this->detectLanguage($lang, $request); |
|
| 38 | - } else { |
|
| 39 | - if ($this->forceRedirect === true) { |
|
| 40 | - $this->detectLanguage($_SESSION['LanguageComponent'][$this->languageParameterName], $request); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - $this->parameters[$this->languageParameterName] = $_SESSION['LanguageComponent'][$this->languageParameterName]; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * Checks to see if any parameters are given from the configuration in the CMS |
|
| 49 | - */ |
|
| 50 | - private function checkParameters() |
|
| 51 | - { |
|
| 52 | - if (isset($this->parameters['defaultLanguage'])) { |
|
| 53 | - $this->defaultLanguage = $this->parameters['defaultLanguage']; |
|
| 54 | - unset($this->parameters['defaultLanguage']); |
|
| 55 | - } |
|
| 56 | - if (isset($this->parameters['acceptedLanguages'])) { |
|
| 57 | - $this->acceptedLanguages = explode(',', $this->parameters['acceptedLanguages']); |
|
| 58 | - unset($this->parameters['acceptedLanguages']); |
|
| 59 | - } |
|
| 60 | - if (isset($this->parameters['languageParameterName'])) { |
|
| 61 | - $this->languageParameterName = $this->parameters['languageParameterName']; |
|
| 62 | - unset($this->parameters['languageParameterName']); |
|
| 63 | - } |
|
| 64 | - if (isset($this->parameters['forceRedirect'])) { |
|
| 65 | - $this->forceRedirect = (bool) $this->parameters['forceRedirect']; |
|
| 66 | - unset($this->parameters['forceRedirect']); |
|
| 67 | - } |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * @return array |
|
| 72 | - */ |
|
| 73 | - public function getParameters() |
|
| 74 | - { |
|
| 75 | - return $this->parameters; |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Check if the found language is allowed and |
|
| 81 | - * if an action is to be taken. |
|
| 82 | - * |
|
| 83 | - * @param $lang |
|
| 84 | - * @param $request |
|
| 85 | - */ |
|
| 86 | - private function detectLanguage($lang, $request) |
|
| 87 | - { |
|
| 88 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $this->defaultLanguage; |
|
| 89 | - |
|
| 90 | - if ($this->acceptedLanguages === null) { |
|
| 91 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 92 | - } else if (in_array($lang, $this->acceptedLanguages)) { |
|
| 93 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 94 | - } else { |
|
| 95 | - $lang = $this->defaultLanguage; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $this->sessionValues = $_SESSION['LanguageComponent']; |
|
| 99 | - |
|
| 100 | - if ($this->forceRedirect === true) { |
|
| 101 | - if (substr($request::$relativeUri, 0, 2) !== $lang ) { |
|
| 102 | - if ($lang !== $this->defaultLanguage) { |
|
| 103 | - header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 104 | - exit; |
|
| 105 | - } |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Detect if the language is switched manually |
|
| 112 | - * |
|
| 113 | - * @param $request |
|
| 114 | - */ |
|
| 115 | - private function checkLanguageSwitch($request) |
|
| 116 | - { |
|
| 117 | - if (isset($request::$get['langSwitch'])) { |
|
| 118 | - $this->forceRedirect = true; |
|
| 119 | - $this->detectLanguage($request::$get['langSwitch'], $request); |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /* |
|
| 9 | + protected $request; |
|
| 10 | + protected $parameters; |
|
| 11 | + |
|
| 12 | + protected $defaultLanguage = 'en'; |
|
| 13 | + protected $acceptedLanguages = null; |
|
| 14 | + protected $languageParameterName = 'language'; |
|
| 15 | + protected $forceRedirect = false; |
|
| 16 | + protected $sessionValues; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * Component constructor. |
|
| 20 | + * |
|
| 21 | + * @param $template |
|
| 22 | + * @param Request $request |
|
| 23 | + * @param $parameters |
|
| 24 | + * @param $matchedSitemapItem |
|
| 25 | + */ |
|
| 26 | + public function __construct($template, Request $request, $parameters, $matchedSitemapItem) |
|
| 27 | + { |
|
| 28 | + $this->parameters = (array) $parameters; |
|
| 29 | + $this->checkParameters(); |
|
| 30 | + |
|
| 31 | + $lang = substr(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $this->defaultLanguage, 0, 2); |
|
| 32 | + $_SESSION['LanguageComponent']['detectedLanguage'] = $lang; |
|
| 33 | + |
|
| 34 | + $this->checkLanguageSwitch($request); |
|
| 35 | + |
|
| 36 | + if (!isset($_SESSION['LanguageComponent'][$this->languageParameterName])) { |
|
| 37 | + $this->detectLanguage($lang, $request); |
|
| 38 | + } else { |
|
| 39 | + if ($this->forceRedirect === true) { |
|
| 40 | + $this->detectLanguage($_SESSION['LanguageComponent'][$this->languageParameterName], $request); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + $this->parameters[$this->languageParameterName] = $_SESSION['LanguageComponent'][$this->languageParameterName]; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * Checks to see if any parameters are given from the configuration in the CMS |
|
| 49 | + */ |
|
| 50 | + private function checkParameters() |
|
| 51 | + { |
|
| 52 | + if (isset($this->parameters['defaultLanguage'])) { |
|
| 53 | + $this->defaultLanguage = $this->parameters['defaultLanguage']; |
|
| 54 | + unset($this->parameters['defaultLanguage']); |
|
| 55 | + } |
|
| 56 | + if (isset($this->parameters['acceptedLanguages'])) { |
|
| 57 | + $this->acceptedLanguages = explode(',', $this->parameters['acceptedLanguages']); |
|
| 58 | + unset($this->parameters['acceptedLanguages']); |
|
| 59 | + } |
|
| 60 | + if (isset($this->parameters['languageParameterName'])) { |
|
| 61 | + $this->languageParameterName = $this->parameters['languageParameterName']; |
|
| 62 | + unset($this->parameters['languageParameterName']); |
|
| 63 | + } |
|
| 64 | + if (isset($this->parameters['forceRedirect'])) { |
|
| 65 | + $this->forceRedirect = (bool) $this->parameters['forceRedirect']; |
|
| 66 | + unset($this->parameters['forceRedirect']); |
|
| 67 | + } |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * @return array |
|
| 72 | + */ |
|
| 73 | + public function getParameters() |
|
| 74 | + { |
|
| 75 | + return $this->parameters; |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Check if the found language is allowed and |
|
| 81 | + * if an action is to be taken. |
|
| 82 | + * |
|
| 83 | + * @param $lang |
|
| 84 | + * @param $request |
|
| 85 | + */ |
|
| 86 | + private function detectLanguage($lang, $request) |
|
| 87 | + { |
|
| 88 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $this->defaultLanguage; |
|
| 89 | + |
|
| 90 | + if ($this->acceptedLanguages === null) { |
|
| 91 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 92 | + } else if (in_array($lang, $this->acceptedLanguages)) { |
|
| 93 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 94 | + } else { |
|
| 95 | + $lang = $this->defaultLanguage; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $this->sessionValues = $_SESSION['LanguageComponent']; |
|
| 99 | + |
|
| 100 | + if ($this->forceRedirect === true) { |
|
| 101 | + if (substr($request::$relativeUri, 0, 2) !== $lang ) { |
|
| 102 | + if ($lang !== $this->defaultLanguage) { |
|
| 103 | + header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 104 | + exit; |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Detect if the language is switched manually |
|
| 112 | + * |
|
| 113 | + * @param $request |
|
| 114 | + */ |
|
| 115 | + private function checkLanguageSwitch($request) |
|
| 116 | + { |
|
| 117 | + if (isset($request::$get['langSwitch'])) { |
|
| 118 | + $this->forceRedirect = true; |
|
| 119 | + $this->detectLanguage($request::$get['langSwitch'], $request); |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /* |
|
| 124 | 124 | * These functions are required by the interface, but not for the functionality |
| 125 | 125 | */ |
| 126 | - public function run(JsonStorage $storage) {} |
|
| 127 | - public function render() {} |
|
| 128 | - public function get() {} |
|
| 126 | + public function run(JsonStorage $storage) {} |
|
| 127 | + public function render() {} |
|
| 128 | + public function get() {} |
|
| 129 | 129 | } |
| 130 | 130 | \ No newline at end of file |
@@ -12,33 +12,33 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | class DocumentRouting implements CmsRouting |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * DocumentRouting constructor. |
|
| 17 | - * @param $request |
|
| 18 | - * @param $relativeCmsUri |
|
| 19 | - * @param CmsComponent $cmsComponent |
|
| 20 | - */ |
|
| 21 | - public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 22 | - { |
|
| 23 | - if ($relativeCmsUri == '/documents') { |
|
| 24 | - $cmsComponent->subTemplate = 'documents'; |
|
| 25 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments()->getDocumentsWithState()); |
|
| 26 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
|
| 27 | - } |
|
| 28 | - $this->documentRouting($request, $relativeCmsUri, $cmsComponent); |
|
| 29 | - $this->folderRouting($request, $relativeCmsUri, $cmsComponent); |
|
| 15 | + /** |
|
| 16 | + * DocumentRouting constructor. |
|
| 17 | + * @param $request |
|
| 18 | + * @param $relativeCmsUri |
|
| 19 | + * @param CmsComponent $cmsComponent |
|
| 20 | + */ |
|
| 21 | + public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 22 | + { |
|
| 23 | + if ($relativeCmsUri == '/documents') { |
|
| 24 | + $cmsComponent->subTemplate = 'documents'; |
|
| 25 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_DOCUMENTS, $cmsComponent->storage->getDocuments()->getDocumentsWithState()); |
|
| 26 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_DOCUMENTS); |
|
| 27 | + } |
|
| 28 | + $this->documentRouting($request, $relativeCmsUri, $cmsComponent); |
|
| 29 | + $this->folderRouting($request, $relativeCmsUri, $cmsComponent); |
|
| 30 | 30 | $this->valuelistsRouting($request, $relativeCmsUri, $cmsComponent); |
| 31 | - } |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @param $request |
|
| 36 | - * @param $relativeCmsUri |
|
| 37 | - * @param CmsComponent $cmsComponent |
|
| 38 | - * @throws \Exception |
|
| 39 | - */ |
|
| 40 | - private function documentRouting($request, $relativeCmsUri, $cmsComponent) |
|
| 41 | - { |
|
| 34 | + /** |
|
| 35 | + * @param $request |
|
| 36 | + * @param $relativeCmsUri |
|
| 37 | + * @param CmsComponent $cmsComponent |
|
| 38 | + * @throws \Exception |
|
| 39 | + */ |
|
| 40 | + private function documentRouting($request, $relativeCmsUri, $cmsComponent) |
|
| 41 | + { |
|
| 42 | 42 | if ($relativeCmsUri == '/documents/new-document' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
| 43 | 43 | $this->documentNewRoute($request, $cmsComponent); |
| 44 | 44 | } elseif (isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])){ |
@@ -50,23 +50,23 @@ discard block |
||
| 50 | 50 | case '/documents/unpublish-document': $this->unpublishDocumentRoute($request, $cmsComponent); break; |
| 51 | 51 | } |
| 52 | 52 | } |
| 53 | - } |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * @param $request |
|
| 57 | - * @param $relativeCmsUri |
|
| 58 | - * @param CmsComponent $cmsComponent |
|
| 59 | - */ |
|
| 60 | - private function folderRouting($request, $relativeCmsUri, $cmsComponent) |
|
| 61 | - { |
|
| 62 | - if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
| 55 | + /** |
|
| 56 | + * @param $request |
|
| 57 | + * @param $relativeCmsUri |
|
| 58 | + * @param CmsComponent $cmsComponent |
|
| 59 | + */ |
|
| 60 | + private function folderRouting($request, $relativeCmsUri, $cmsComponent) |
|
| 61 | + { |
|
| 62 | + if ($relativeCmsUri == '/documents/new-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_PATH])) { |
|
| 63 | 63 | $this->newFolderRoute($request, $cmsComponent); |
| 64 | - } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 64 | + } else if ($relativeCmsUri == '/documents/edit-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 65 | 65 | $this->editFolderRoute($request, $cmsComponent); |
| 66 | - } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 66 | + } else if ($relativeCmsUri == '/documents/delete-folder' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 67 | 67 | $this->deleteFolderRoute($request, $cmsComponent); |
| 68 | - } |
|
| 69 | - } |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | 71 | private function valuelistsRouting($request, $relativeCmsUri, $cmsComponent) |
| 72 | 72 | { |
@@ -13,26 +13,26 @@ |
||
| 13 | 13 | class ImagesRouting implements CmsRouting |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * ImagesRouting constructor. |
|
| 18 | - * @param \CloudControl\Cms\cc\Request $request |
|
| 19 | - * @param mixed|string $relativeCmsUri |
|
| 20 | - * @param CmsComponent $cmsComponent |
|
| 21 | - */ |
|
| 22 | - public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 23 | - { |
|
| 24 | - if ($relativeCmsUri == '/images') { |
|
| 16 | + /** |
|
| 17 | + * ImagesRouting constructor. |
|
| 18 | + * @param \CloudControl\Cms\cc\Request $request |
|
| 19 | + * @param mixed|string $relativeCmsUri |
|
| 20 | + * @param CmsComponent $cmsComponent |
|
| 21 | + */ |
|
| 22 | + public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 23 | + { |
|
| 24 | + if ($relativeCmsUri == '/images') { |
|
| 25 | 25 | $this->overviewRoute($cmsComponent); |
| 26 | - } elseif ($relativeCmsUri == '/images.json') { |
|
| 26 | + } elseif ($relativeCmsUri == '/images.json') { |
|
| 27 | 27 | $this->jsonRoute($cmsComponent); |
| 28 | - } elseif ($relativeCmsUri == '/images/new') { |
|
| 28 | + } elseif ($relativeCmsUri == '/images/new') { |
|
| 29 | 29 | $this->newRoute($request, $cmsComponent); |
| 30 | - } elseif ($relativeCmsUri == '/images/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 30 | + } elseif ($relativeCmsUri == '/images/delete' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 31 | 31 | $this->deleteRoute($request, $cmsComponent); |
| 32 | - } elseif ($relativeCmsUri == '/images/show' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 32 | + } elseif ($relativeCmsUri == '/images/show' && isset($request::$get[CmsComponent::FILES_PARAMETER_FILE])) { |
|
| 33 | 33 | $this->showRoute($request, $cmsComponent); |
| 34 | - } |
|
| 35 | - } |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param CmsComponent $cmsComponent |
@@ -14,26 +14,26 @@ discard block |
||
| 14 | 14 | class SitemapRouting implements CmsRouting |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * SitemapRouting constructor. |
|
| 19 | - * @param \CloudControl\Cms\cc\Request $request |
|
| 20 | - * @param mixed|string $relativeCmsUri |
|
| 21 | - * @param CmsComponent $cmsComponent |
|
| 22 | - */ |
|
| 23 | - public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 24 | - { |
|
| 25 | - if ($relativeCmsUri == '/sitemap') { |
|
| 17 | + /** |
|
| 18 | + * SitemapRouting constructor. |
|
| 19 | + * @param \CloudControl\Cms\cc\Request $request |
|
| 20 | + * @param mixed|string $relativeCmsUri |
|
| 21 | + * @param CmsComponent $cmsComponent |
|
| 22 | + */ |
|
| 23 | + public function __construct($request, $relativeCmsUri, $cmsComponent) |
|
| 24 | + { |
|
| 25 | + if ($relativeCmsUri == '/sitemap') { |
|
| 26 | 26 | $this->overviewRoute($request, $cmsComponent); |
| 27 | - } elseif ($relativeCmsUri == '/sitemap/new') { |
|
| 27 | + } elseif ($relativeCmsUri == '/sitemap/new') { |
|
| 28 | 28 | $this->newRoute($request, $cmsComponent); |
| 29 | - } elseif ($relativeCmsUri == '/sitemap/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 29 | + } elseif ($relativeCmsUri == '/sitemap/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 30 | 30 | $this->editRoute($request, $cmsComponent); |
| 31 | - } elseif ($relativeCmsUri == '/sitemap/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 31 | + } elseif ($relativeCmsUri == '/sitemap/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 32 | 32 | $this->deleteRoute($request, $cmsComponent); |
| 33 | - } else { |
|
| 34 | - $this->redirectRoutes($relativeCmsUri, $request, $cmsComponent); |
|
| 35 | - } |
|
| 36 | - } |
|
| 33 | + } else { |
|
| 34 | + $this->redirectRoutes($relativeCmsUri, $request, $cmsComponent); |
|
| 35 | + } |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | 38 | /** |
| 39 | 39 | * @param $request |
@@ -92,54 +92,54 @@ discard block |
||
| 92 | 92 | exit; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - private function redirectRoutes($relativeCmsUri, $request, $cmsComponent) |
|
| 96 | - { |
|
| 97 | - if ($relativeCmsUri == '/sitemap/redirects') { |
|
| 98 | - $this->redirectsOverviewRoute($cmsComponent); |
|
| 99 | - } elseif ($relativeCmsUri == '/sitemap/redirects/new') { |
|
| 100 | - $this->redirectsNewRoute($request, $cmsComponent); |
|
| 101 | - } elseif ($relativeCmsUri == '/sitemap/redirects/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 102 | - $this->redirectEditRoute($request, $cmsComponent); |
|
| 103 | - } elseif ($relativeCmsUri == '/sitemap/redirects/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 104 | - $this->redirectDeleteRoute($request, $cmsComponent); |
|
| 105 | - } |
|
| 106 | - } |
|
| 95 | + private function redirectRoutes($relativeCmsUri, $request, $cmsComponent) |
|
| 96 | + { |
|
| 97 | + if ($relativeCmsUri == '/sitemap/redirects') { |
|
| 98 | + $this->redirectsOverviewRoute($cmsComponent); |
|
| 99 | + } elseif ($relativeCmsUri == '/sitemap/redirects/new') { |
|
| 100 | + $this->redirectsNewRoute($request, $cmsComponent); |
|
| 101 | + } elseif ($relativeCmsUri == '/sitemap/redirects/edit' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 102 | + $this->redirectEditRoute($request, $cmsComponent); |
|
| 103 | + } elseif ($relativeCmsUri == '/sitemap/redirects/delete' && isset($request::$get[CmsComponent::GET_PARAMETER_SLUG])) { |
|
| 104 | + $this->redirectDeleteRoute($request, $cmsComponent); |
|
| 105 | + } |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - private function redirectsOverviewRoute($cmsComponent) |
|
| 109 | - { |
|
| 110 | - $cmsComponent->subTemplate = 'sitemap/redirects'; |
|
| 111 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_SITEMAP); |
|
| 112 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_REDIRECTS, $cmsComponent->storage->getRedirects()->getRedirects()); |
|
| 113 | - } |
|
| 108 | + private function redirectsOverviewRoute($cmsComponent) |
|
| 109 | + { |
|
| 110 | + $cmsComponent->subTemplate = 'sitemap/redirects'; |
|
| 111 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_SITEMAP); |
|
| 112 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_REDIRECTS, $cmsComponent->storage->getRedirects()->getRedirects()); |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | - private function redirectsNewRoute($request, $cmsComponent) |
|
| 116 | - { |
|
| 117 | - $cmsComponent->subTemplate = 'sitemap/redirects-form'; |
|
| 118 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_SITEMAP); |
|
| 119 | - if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::POST_PARAMETER_FROM_URL], $request::$post[CmsComponent::POST_PARAMETER_TO_URL])) { |
|
| 120 | - $cmsComponent->storage->getRedirects()->addRedirect($request::$post); |
|
| 121 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/sitemap/redirects'); |
|
| 122 | - exit; |
|
| 123 | - } |
|
| 124 | - } |
|
| 115 | + private function redirectsNewRoute($request, $cmsComponent) |
|
| 116 | + { |
|
| 117 | + $cmsComponent->subTemplate = 'sitemap/redirects-form'; |
|
| 118 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_SITEMAP); |
|
| 119 | + if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::POST_PARAMETER_FROM_URL], $request::$post[CmsComponent::POST_PARAMETER_TO_URL])) { |
|
| 120 | + $cmsComponent->storage->getRedirects()->addRedirect($request::$post); |
|
| 121 | + header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/sitemap/redirects'); |
|
| 122 | + exit; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - private function redirectEditRoute($request, $cmsComponent) |
|
| 127 | - { |
|
| 128 | - $cmsComponent->subTemplate = 'sitemap/redirects-form'; |
|
| 129 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_SITEMAP); |
|
| 130 | - $redirect = $cmsComponent->storage->getRedirects()->getRedirectBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
|
| 131 | - if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::POST_PARAMETER_FROM_URL], $request::$post[CmsComponent::POST_PARAMETER_TO_URL])) { |
|
| 132 | - $cmsComponent->storage->getRedirects()->saveRedirect($request::$get[CmsComponent::GET_PARAMETER_SLUG], $request::$post); |
|
| 133 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/sitemap/redirects'); |
|
| 134 | - exit; |
|
| 135 | - } |
|
| 136 | - $cmsComponent->setParameter(CmsComponent::PARAMETER_REDIRECT, $redirect); |
|
| 137 | - } |
|
| 126 | + private function redirectEditRoute($request, $cmsComponent) |
|
| 127 | + { |
|
| 128 | + $cmsComponent->subTemplate = 'sitemap/redirects-form'; |
|
| 129 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_MAIN_NAV_CLASS, CmsComponent::PARAMETER_SITEMAP); |
|
| 130 | + $redirect = $cmsComponent->storage->getRedirects()->getRedirectBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
|
| 131 | + if (isset($request::$post[CmsComponent::POST_PARAMETER_TITLE], $request::$post[CmsComponent::POST_PARAMETER_FROM_URL], $request::$post[CmsComponent::POST_PARAMETER_TO_URL])) { |
|
| 132 | + $cmsComponent->storage->getRedirects()->saveRedirect($request::$get[CmsComponent::GET_PARAMETER_SLUG], $request::$post); |
|
| 133 | + header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/sitemap/redirects'); |
|
| 134 | + exit; |
|
| 135 | + } |
|
| 136 | + $cmsComponent->setParameter(CmsComponent::PARAMETER_REDIRECT, $redirect); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - private function redirectDeleteRoute($request, $cmsComponent) |
|
| 140 | - { |
|
| 141 | - $cmsComponent->storage->getRedirects()->deleteRedirectBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
|
| 142 | - header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/sitemap/redirects'); |
|
| 143 | - exit; |
|
| 144 | - } |
|
| 139 | + private function redirectDeleteRoute($request, $cmsComponent) |
|
| 140 | + { |
|
| 141 | + $cmsComponent->storage->getRedirects()->deleteRedirectBySlug($request::$get[CmsComponent::GET_PARAMETER_SLUG]); |
|
| 142 | + header('Location: ' . $request::$subfolders . $cmsComponent->getParameter(CmsComponent::PARAMETER_CMS_PREFIX) . '/sitemap/redirects'); |
|
| 143 | + exit; |
|
| 144 | + } |
|
| 145 | 145 | } |
| 146 | 146 | \ No newline at end of file |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | namespace CloudControl\Cms\components { |
| 3 | 3 | |
| 4 | - use storage\Storage; |
|
| 4 | + use storage\Storage; |
|
| 5 | 5 | |
| 6 | - /** |
|
| 6 | + /** |
|
| 7 | 7 | * Class DocumentComponent |
| 8 | 8 | * |
| 9 | 9 | * Has optional parameter `folder` to prefix the relative url with a folder |