@@ -9,8 +9,10 @@ |
||
| 9 | 9 | <? if (isset($dynamicBrick)) : |
| 10 | 10 | $fieldSlug = $field->slug; |
| 11 | 11 | $value = isset($dynamicBrick->fields->$fieldSlug) ? current($dynamicBrick->fields->$fieldSlug) : ''; |
| 12 | - else : |
|
| 12 | + else { |
|
| 13 | + : |
|
| 13 | 14 | $value = ''; |
| 15 | + } |
|
| 14 | 16 | endif ?> |
| 15 | 17 | <? if ($field->multiple == true && $field->type != 'Rich Text') : ?> |
| 16 | 18 | <ul class="grid-wrapper sortable"> |
@@ -59,8 +59,7 @@ discard block |
||
| 59 | 59 | return imagejpeg($imageResource, $path, $quality); |
| 60 | 60 | } elseif ($mimeTypeConstantValue == IMAGETYPE_PNG) { |
| 61 | 61 | return imagepng($imageResource, $path, (intval($quality / 10) -1)); |
| 62 | - } |
|
| 63 | - else { |
|
| 62 | + } else { |
|
| 64 | 63 | throw new \Exception('Not a valid mimetypeconstant given see function documentation'); |
| 65 | 64 | } |
| 66 | 65 | return false; |
@@ -101,8 +100,9 @@ discard block |
||
| 101 | 100 | // Load the image into a string |
| 102 | 101 | $file = fopen($p_sFile,"rb"); |
| 103 | 102 | $read = fread($file,10); |
| 104 | - while(!feof($file)&&($read<>"")) |
|
| 105 | - $read .= fread($file,1024); |
|
| 103 | + while(!feof($file)&&($read<>"")) { |
|
| 104 | + $read .= fread($file,1024); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | $temp = unpack("H*",$read); |
| 108 | 108 | $hex = $temp[1]; |
@@ -153,8 +153,9 @@ discard block |
||
| 153 | 153 | { |
| 154 | 154 | // If padding needed, ignore image-padding |
| 155 | 155 | // Shift i to the ending of the current 32-bit-block |
| 156 | - if ($usePadding) |
|
| 157 | - $i += $width%4; |
|
| 156 | + if ($usePadding) { |
|
| 157 | + $i += $width%4; |
|
| 158 | + } |
|
| 158 | 159 | |
| 159 | 160 | // Reset horizontal position |
| 160 | 161 | $x = 0; |
@@ -163,8 +164,9 @@ discard block |
||
| 163 | 164 | $y++; |
| 164 | 165 | |
| 165 | 166 | // Reached the image-height? Break the for-loop |
| 166 | - if ($y>$height) |
|
| 167 | - break; |
|
| 167 | + if ($y>$height) { |
|
| 168 | + break; |
|
| 169 | + } |
|
| 168 | 170 | } |
| 169 | 171 | |
| 170 | 172 | // Calculation of the RGB-pixel (defined as BGR in image-data) |
@@ -61,7 +61,9 @@ discard block |
||
| 61 | 61 | */ |
| 62 | 62 | protected function calculateX($imageResource) |
| 63 | 63 | { |
| 64 | - if (intval($this->_x) === $this->_x) return $this->_x; |
|
| 64 | + if (intval($this->_x) === $this->_x) { |
|
| 65 | + return $this->_x; |
|
| 66 | + } |
|
| 65 | 67 | |
| 66 | 68 | $x = strtolower($this->_x); |
| 67 | 69 | |
@@ -86,7 +88,9 @@ discard block |
||
| 86 | 88 | */ |
| 87 | 89 | public function calculateY($imageResource) |
| 88 | 90 | { |
| 89 | - if (intval($this->_y) === $this->_y) return $this->_y; |
|
| 91 | + if (intval($this->_y) === $this->_y) { |
|
| 92 | + return $this->_y; |
|
| 93 | + } |
|
| 90 | 94 | |
| 91 | 95 | $y = strtolower($this->_y); |
| 92 | 96 | |
@@ -123,7 +127,9 @@ discard block |
||
| 123 | 127 | */ |
| 124 | 128 | public function GetWatermark() |
| 125 | 129 | { |
| 126 | - if ($this->_watermark == null) throw new \Exception('A watermark is not set. Please supply a \library\image\Image using $this->SetWatermark'); |
|
| 130 | + if ($this->_watermark == null) { |
|
| 131 | + throw new \Exception('A watermark is not set. Please supply a \library\image\Image using $this->SetWatermark'); |
|
| 132 | + } |
|
| 127 | 133 | return $this->_watermark; |
| 128 | 134 | } |
| 129 | 135 | |
@@ -26,7 +26,9 @@ |
||
| 26 | 26 | |
| 27 | 27 | // Define which ratio will be used, depending on which is the smallest side |
| 28 | 28 | $ratio = min($hRatio, $wRatio); |
| 29 | - if($ratio > 1) $ratio = 1; |
|
| 29 | + if($ratio > 1) { |
|
| 30 | + $ratio = 1; |
|
| 31 | + } |
|
| 30 | 32 | |
| 31 | 33 | // Define sizes |
| 32 | 34 | $this->_destWidth = floor($originalWidth * $ratio); |
@@ -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 |
@@ -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 | |
@@ -40,7 +40,9 @@ |
||
| 40 | 40 | |
| 41 | 41 | // Define which ratio will be used, depending on which is the biggest side |
| 42 | 42 | $ratio = $wRatio < $hRatio ? $wRatio : $hRatio; |
| 43 | - if ($ratio < 1) $ratio = 1; |
|
| 43 | + if ($ratio < 1) { |
|
| 44 | + $ratio = 1; |
|
| 45 | + } |
|
| 44 | 46 | |
| 45 | 47 | // Calculate the destination width, height, x and y |
| 46 | 48 | $this->_destWidth = $originalWidth / $ratio; |
@@ -61,12 +61,15 @@ |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | function humanFileSize($size,$unit="") { |
| 64 | - if( (!$unit && $size >= 1<<30) || $unit == "GB") |
|
| 65 | - return number_format($size/(1<<30),2)."GB"; |
|
| 66 | - if( (!$unit && $size >= 1<<20) || $unit == "MB") |
|
| 67 | - return number_format($size/(1<<20),2)."MB"; |
|
| 68 | - if( (!$unit && $size >= 1<<10) || $unit == "KB") |
|
| 69 | - return number_format($size/(1<<10),2)."KB"; |
|
| 64 | + if( (!$unit && $size >= 1<<30) || $unit == "GB") { |
|
| 65 | + return number_format($size/(1<<30),2)."GB"; |
|
| 66 | + } |
|
| 67 | + if( (!$unit && $size >= 1<<20) || $unit == "MB") { |
|
| 68 | + return number_format($size/(1<<20),2)."MB"; |
|
| 69 | + } |
|
| 70 | + if( (!$unit && $size >= 1<<10) || $unit == "KB") { |
|
| 71 | + return number_format($size/(1<<10),2)."KB"; |
|
| 72 | + } |
|
| 70 | 73 | return number_format($size)." bytes"; |
| 71 | 74 | } |
| 72 | 75 | |
@@ -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 | |
@@ -786,7 +786,7 @@ discard block |
||
| 786 | 786 | /** |
| 787 | 787 | * @param $filename |
| 788 | 788 | * @return null |
| 789 | - */ |
|
| 789 | + */ |
|
| 790 | 790 | public function getImageByName($filename) |
| 791 | 791 | { |
| 792 | 792 | $images = $this->getImages(); |
@@ -876,7 +876,7 @@ discard block |
||
| 876 | 876 | /** |
| 877 | 877 | * @param $filename |
| 878 | 878 | * @return null |
| 879 | - */ |
|
| 879 | + */ |
|
| 880 | 880 | public function getFileByName($filename) |
| 881 | 881 | { |
| 882 | 882 | $files = $this->getFiles(); |
@@ -891,7 +891,7 @@ discard block |
||
| 891 | 891 | /** |
| 892 | 892 | * @param $filename |
| 893 | 893 | * @throws \Exception |
| 894 | - */ |
|
| 894 | + */ |
|
| 895 | 895 | public function deleteFileByName($filename) |
| 896 | 896 | { |
| 897 | 897 | $destinationPath = realpath(__DIR__ . '/../../www/files/'); |
@@ -7,118 +7,118 @@ |
||
| 7 | 7 | |
| 8 | 8 | class LanguageComponent implements Component |
| 9 | 9 | { |
| 10 | - protected $request; |
|
| 11 | - protected $parameters; |
|
| 12 | - |
|
| 13 | - protected $defaultLanguage = 'en'; |
|
| 14 | - protected $acceptedLanguages = null; |
|
| 15 | - protected $languageParameterName = 'language'; |
|
| 16 | - protected $forceRedirect = false; |
|
| 17 | - protected $sessionValues; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * Component constructor. |
|
| 21 | - * |
|
| 22 | - * @param $template |
|
| 23 | - * @param Request $request |
|
| 24 | - * @param $parameters |
|
| 25 | - * @param $matchedSitemapItem |
|
| 26 | - */ |
|
| 27 | - public function __construct($template, Request $request, $parameters, $matchedSitemapItem) |
|
| 28 | - { |
|
| 29 | - $this->parameters = (array) $parameters; |
|
| 30 | - $this->checkParameters(); |
|
| 31 | - |
|
| 32 | - $lang = substr(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $this->defaultLanguage, 0, 2); |
|
| 33 | - $_SESSION['LanguageComponent']['detectedLanguage'] = $lang; |
|
| 34 | - |
|
| 35 | - $this->checkLanguageSwitch($request); |
|
| 36 | - |
|
| 37 | - if (!isset($_SESSION['LanguageComponent'][$this->languageParameterName])) { |
|
| 38 | - $this->detectLanguage($lang, $request); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - $this->parameters[$this->languageParameterName] = $_SESSION['LanguageComponent'][$this->languageParameterName]; |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Checks to see if any parameters are given from the configuration in the CMS |
|
| 46 | - */ |
|
| 47 | - private function checkParameters() |
|
| 48 | - { |
|
| 49 | - if (isset($this->parameters['defaultLanguage'])) { |
|
| 50 | - $this->defaultLanguage = $this->parameters['defaultLanguage']; |
|
| 51 | - unset($this->parameters['defaultLanguage']); |
|
| 52 | - } |
|
| 53 | - if (isset($this->parameters['acceptedLanguages'])) { |
|
| 54 | - $this->acceptedLanguages = explode(',', $this->parameters['acceptedLanguages']); |
|
| 55 | - unset($this->parameters['acceptedLanguages']); |
|
| 56 | - } |
|
| 57 | - if (isset($this->parameters['languageParameterName'])) { |
|
| 58 | - $this->languageParameterName = $this->parameters['languageParameterName']; |
|
| 59 | - unset($this->parameters['languageParameterName']); |
|
| 60 | - } |
|
| 61 | - if (isset($this->parameters['forceRedirect'])) { |
|
| 62 | - $this->forceRedirect = (bool) $this->parameters['forceRedirect']; |
|
| 63 | - unset($this->parameters['forceRedirect']); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @return array |
|
| 69 | - */ |
|
| 70 | - public function getParameters() |
|
| 71 | - { |
|
| 72 | - return $this->parameters; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Check if the found language is allowed and |
|
| 78 | - * if an action is to be taken. |
|
| 79 | - * |
|
| 80 | - * @param $lang |
|
| 81 | - * @param $request |
|
| 82 | - */ |
|
| 83 | - private function detectLanguage($lang, $request) |
|
| 84 | - { |
|
| 85 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $this->defaultLanguage; |
|
| 86 | - |
|
| 87 | - if ($this->acceptedLanguages === null) { |
|
| 88 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 89 | - } else if (in_array($lang, $this->acceptedLanguages)) { |
|
| 90 | - $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 91 | - } else { |
|
| 92 | - $lang = $this->defaultLanguage; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $this->sessionValues = $_SESSION['LanguageComponent']; |
|
| 96 | - |
|
| 97 | - if ($this->forceRedirect === true) { |
|
| 98 | - if (substr($request::$relativeUri, 0, 2) !== $lang && $lang !== $this->defaultLanguage) { // if default language detected, no redirect |
|
| 99 | - header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 100 | - exit; |
|
| 101 | - } |
|
| 102 | - } |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Detect if the language is switched manually |
|
| 107 | - * |
|
| 108 | - * @param $request |
|
| 109 | - */ |
|
| 110 | - private function checkLanguageSwitch($request) |
|
| 111 | - { |
|
| 112 | - if (isset($request::$get['langSwitch'])) { |
|
| 113 | - $this->forceRedirect = true; |
|
| 114 | - $this->detectLanguage($request::$get['langSwitch'], $request); |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /* |
|
| 10 | + protected $request; |
|
| 11 | + protected $parameters; |
|
| 12 | + |
|
| 13 | + protected $defaultLanguage = 'en'; |
|
| 14 | + protected $acceptedLanguages = null; |
|
| 15 | + protected $languageParameterName = 'language'; |
|
| 16 | + protected $forceRedirect = false; |
|
| 17 | + protected $sessionValues; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * Component constructor. |
|
| 21 | + * |
|
| 22 | + * @param $template |
|
| 23 | + * @param Request $request |
|
| 24 | + * @param $parameters |
|
| 25 | + * @param $matchedSitemapItem |
|
| 26 | + */ |
|
| 27 | + public function __construct($template, Request $request, $parameters, $matchedSitemapItem) |
|
| 28 | + { |
|
| 29 | + $this->parameters = (array) $parameters; |
|
| 30 | + $this->checkParameters(); |
|
| 31 | + |
|
| 32 | + $lang = substr(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : $this->defaultLanguage, 0, 2); |
|
| 33 | + $_SESSION['LanguageComponent']['detectedLanguage'] = $lang; |
|
| 34 | + |
|
| 35 | + $this->checkLanguageSwitch($request); |
|
| 36 | + |
|
| 37 | + if (!isset($_SESSION['LanguageComponent'][$this->languageParameterName])) { |
|
| 38 | + $this->detectLanguage($lang, $request); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + $this->parameters[$this->languageParameterName] = $_SESSION['LanguageComponent'][$this->languageParameterName]; |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Checks to see if any parameters are given from the configuration in the CMS |
|
| 46 | + */ |
|
| 47 | + private function checkParameters() |
|
| 48 | + { |
|
| 49 | + if (isset($this->parameters['defaultLanguage'])) { |
|
| 50 | + $this->defaultLanguage = $this->parameters['defaultLanguage']; |
|
| 51 | + unset($this->parameters['defaultLanguage']); |
|
| 52 | + } |
|
| 53 | + if (isset($this->parameters['acceptedLanguages'])) { |
|
| 54 | + $this->acceptedLanguages = explode(',', $this->parameters['acceptedLanguages']); |
|
| 55 | + unset($this->parameters['acceptedLanguages']); |
|
| 56 | + } |
|
| 57 | + if (isset($this->parameters['languageParameterName'])) { |
|
| 58 | + $this->languageParameterName = $this->parameters['languageParameterName']; |
|
| 59 | + unset($this->parameters['languageParameterName']); |
|
| 60 | + } |
|
| 61 | + if (isset($this->parameters['forceRedirect'])) { |
|
| 62 | + $this->forceRedirect = (bool) $this->parameters['forceRedirect']; |
|
| 63 | + unset($this->parameters['forceRedirect']); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @return array |
|
| 69 | + */ |
|
| 70 | + public function getParameters() |
|
| 71 | + { |
|
| 72 | + return $this->parameters; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Check if the found language is allowed and |
|
| 78 | + * if an action is to be taken. |
|
| 79 | + * |
|
| 80 | + * @param $lang |
|
| 81 | + * @param $request |
|
| 82 | + */ |
|
| 83 | + private function detectLanguage($lang, $request) |
|
| 84 | + { |
|
| 85 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $this->defaultLanguage; |
|
| 86 | + |
|
| 87 | + if ($this->acceptedLanguages === null) { |
|
| 88 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 89 | + } else if (in_array($lang, $this->acceptedLanguages)) { |
|
| 90 | + $_SESSION['LanguageComponent'][$this->languageParameterName] = $lang; |
|
| 91 | + } else { |
|
| 92 | + $lang = $this->defaultLanguage; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $this->sessionValues = $_SESSION['LanguageComponent']; |
|
| 96 | + |
|
| 97 | + if ($this->forceRedirect === true) { |
|
| 98 | + if (substr($request::$relativeUri, 0, 2) !== $lang && $lang !== $this->defaultLanguage) { // if default language detected, no redirect |
|
| 99 | + header('Location: ' . $request::$subfolders . $lang . '/' . $request::$relativeUri); |
|
| 100 | + exit; |
|
| 101 | + } |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Detect if the language is switched manually |
|
| 107 | + * |
|
| 108 | + * @param $request |
|
| 109 | + */ |
|
| 110 | + private function checkLanguageSwitch($request) |
|
| 111 | + { |
|
| 112 | + if (isset($request::$get['langSwitch'])) { |
|
| 113 | + $this->forceRedirect = true; |
|
| 114 | + $this->detectLanguage($request::$get['langSwitch'], $request); |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /* |
|
| 119 | 119 | * These functions are required by the interface, but not for the functionality |
| 120 | 120 | */ |
| 121 | - public function run(Storage $storage) {} |
|
| 122 | - public function render() {} |
|
| 123 | - public function get() {} |
|
| 121 | + public function run(Storage $storage) {} |
|
| 122 | + public function render() {} |
|
| 123 | + public function get() {} |
|
| 124 | 124 | } |
| 125 | 125 | \ No newline at end of file |