@@ -109,8 +109,8 @@ |
||
| 109 | 109 | |
| 110 | 110 | // Preserve transparency |
| 111 | 111 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
| 112 | - imagealphablending($new, false); |
|
| 113 | - imagesavealpha($new, true); |
|
| 112 | + imagealphablending($new, false); |
|
| 113 | + imagesavealpha($new, true); |
|
| 114 | 114 | |
| 115 | 115 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $this->_destWidth, $this->_destHeight); |
| 116 | 116 | |
@@ -62,8 +62,8 @@ |
||
| 62 | 62 | |
| 63 | 63 | // Preserve transparency |
| 64 | 64 | imagecolortransparent($new, imagecolorallocatealpha($new, 0, 0, 0, 127)); |
| 65 | - imagealphablending($new, false); |
|
| 66 | - imagesavealpha($new, true); |
|
| 65 | + imagealphablending($new, false); |
|
| 66 | + imagesavealpha($new, true); |
|
| 67 | 67 | |
| 68 | 68 | imagecopyresampled($new, $imageResource, $this->_destX, $this->_destY, $this->_x, $this->_y, $this->_destWidth, $this->_destHeight, $originalWidth, $originalHeight); |
| 69 | 69 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | /** |
| 18 | 18 | * @param resource $imageResource |
| 19 | 19 | * @return resource |
| 20 | - */ |
|
| 20 | + */ |
|
| 21 | 21 | public function Execute($imageResource) |
| 22 | 22 | { |
| 23 | 23 | // Define the origial width and height |
@@ -105,7 +105,7 @@ |
||
| 105 | 105 | /** |
| 106 | 106 | * Detect if the language is switched manually |
| 107 | 107 | * |
| 108 | - * @param $request |
|
| 108 | + * @param Request $request |
|
| 109 | 109 | */ |
| 110 | 110 | private function checkLanguageSwitch($request) |
| 111 | 111 | { |
@@ -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 |
@@ -14,24 +14,24 @@ |
||
| 14 | 14 | class SitemapRouting implements CmsRouting |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * SitemapRouting constructor. |
|
| 19 | - * @param \library\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 \library\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 | - } |
|
| 34 | - } |
|
| 33 | + } |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @param $request |
@@ -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) |