@@ -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 |
@@ -11,37 +11,37 @@ |
||
| 11 | 11 | |
| 12 | 12 | abstract class StopWordsFilter implements Filter |
| 13 | 13 | { |
| 14 | - protected $tokens; |
|
| 15 | - protected $stopWords = array(); |
|
| 14 | + protected $tokens; |
|
| 15 | + protected $stopWords = array(); |
|
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * StopWordsFilter constructor. |
|
| 19 | - * @param array $tokens |
|
| 20 | - */ |
|
| 21 | - public function __construct($tokens) |
|
| 22 | - { |
|
| 23 | - $this->tokens = $tokens; |
|
| 24 | - } |
|
| 17 | + /** |
|
| 18 | + * StopWordsFilter constructor. |
|
| 19 | + * @param array $tokens |
|
| 20 | + */ |
|
| 21 | + public function __construct($tokens) |
|
| 22 | + { |
|
| 23 | + $this->tokens = $tokens; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @return array |
|
| 28 | - */ |
|
| 29 | - public function getFilterResults() |
|
| 30 | - { |
|
| 31 | - foreach ($this->stopWords as $stopWord) { |
|
| 32 | - foreach ($this->tokens as $field => $tokens) { |
|
| 33 | - if (isset($tokens[$stopWord])) { |
|
| 34 | - $tokens[$stopWord] = null; |
|
| 35 | - unset($tokens[$stopWord]); |
|
| 36 | - $tokens = array_filter($tokens); |
|
| 37 | - asort($tokens); |
|
| 38 | - } |
|
| 26 | + /** |
|
| 27 | + * @return array |
|
| 28 | + */ |
|
| 29 | + public function getFilterResults() |
|
| 30 | + { |
|
| 31 | + foreach ($this->stopWords as $stopWord) { |
|
| 32 | + foreach ($this->tokens as $field => $tokens) { |
|
| 33 | + if (isset($tokens[$stopWord])) { |
|
| 34 | + $tokens[$stopWord] = null; |
|
| 35 | + unset($tokens[$stopWord]); |
|
| 36 | + $tokens = array_filter($tokens); |
|
| 37 | + asort($tokens); |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $this->tokens[$field] = $tokens; |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - $this->tokens = array_filter($this->tokens); |
|
| 44 | - asort($this->tokens); |
|
| 45 | - return $this->tokens; |
|
| 46 | - } |
|
| 40 | + $this->tokens[$field] = $tokens; |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + $this->tokens = array_filter($this->tokens); |
|
| 44 | + asort($this->tokens); |
|
| 45 | + return $this->tokens; |
|
| 46 | + } |
|
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -32,11 +32,11 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | function shutdownHandler () { |
| 34 | 34 | $error = error_get_last(); |
| 35 | - if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
|
| 35 | + if (isset($error['type'], $error['message'], $error['file'], $error['line'])) { |
|
| 36 | 36 | \library\cc\ErrorHandlingUtil::renderError($error['message'],$error['file'],$error['line'], $error['type']); |
| 37 | - }elseif ($error['type'] == 1) { |
|
| 38 | - dump($error); |
|
| 39 | - } |
|
| 37 | + }elseif ($error['type'] == 1) { |
|
| 38 | + dump($error); |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | * @param string $imagePath |
| 77 | 77 | * @param bool $getExtension |
| 78 | 78 | * |
| 79 | - * @return bool|int|string |
|
| 79 | + * @return integer |
|
| 80 | 80 | */ |
| 81 | 81 | public function getImageMimeType($imagePath, $getExtension = false) |
| 82 | 82 | { |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | - * @param $pathToBitmapFile |
|
| 152 | + * @param string $pathToBitmapFile |
|
| 153 | 153 | * |
| 154 | 154 | * @return string |
| 155 | 155 | */ |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | - * @param $header |
|
| 168 | + * @param string $header |
|
| 169 | 169 | * |
| 170 | 170 | * @return array |
| 171 | 171 | */ |
@@ -195,14 +195,14 @@ discard block |
||
| 195 | 195 | * Loop through the data in the body of the bitmap |
| 196 | 196 | * file and calculate each individual pixel based on the |
| 197 | 197 | * bytes |
| 198 | - * @param $bodySize |
|
| 199 | - * @param $x |
|
| 198 | + * @param integer $bodySize |
|
| 199 | + * @param integer $x |
|
| 200 | 200 | * @param $width |
| 201 | - * @param $usePadding |
|
| 202 | - * @param $y |
|
| 201 | + * @param boolean $usePadding |
|
| 202 | + * @param integer $y |
|
| 203 | 203 | * @param $height |
| 204 | - * @param $body |
|
| 205 | - * @param $image |
|
| 204 | + * @param string $body |
|
| 205 | + * @param resource $image |
|
| 206 | 206 | */ |
| 207 | 207 | private function loopThroughBodyAndCalculatePixels($bodySize, $x, $width, $usePadding, $y, $height, $body, $image) |
| 208 | 208 | { |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | - * @param $request |
|
| 71 | + * @param Request $request |
|
| 72 | 72 | * @param CmsComponent $cmsComponent |
| 73 | 73 | */ |
| 74 | 74 | private function newRoute($request, $cmsComponent) |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | - * @param $request |
|
| 86 | + * @param Request $request |
|
| 87 | 87 | * @param CmsComponent $cmsComponent |
| 88 | 88 | */ |
| 89 | 89 | private function deleteRoute($request, $cmsComponent) |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * submitting the form |
| 148 | 148 | * |
| 149 | 149 | * @param $postValues |
| 150 | - * @param $storage |
|
| 150 | + * @param Storage $storage |
|
| 151 | 151 | */ |
| 152 | 152 | protected function postSubmit($postValues, $storage) |
| 153 | 153 | {} |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | /** |
| 320 | - * @param $form |
|
| 320 | + * @param string|null $form |
|
| 321 | 321 | */ |
| 322 | 322 | private function setFormParameter($form) |
| 323 | 323 | { |
@@ -13,26 +13,26 @@ |
||
| 13 | 13 | class ImagesRouting implements CmsRouting |
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * ImagesRouting constructor. |
|
| 18 | - * @param \library\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 \library\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 |
@@ -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 | <?}?> |
@@ -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 |