@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | // Get image information using getimagesize |
| 53 | 53 | $imageInfo = getimagesize($file); |
| 54 | 54 | if (!$imageInfo) { |
| 55 | - return 'dark'; |
|
| 55 | + return 'dark'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | // Get the image type |
@@ -60,14 +60,14 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | // Load the image based on its type |
| 62 | 62 | switch ($type) { |
| 63 | - case IMAGETYPE_JPEG: |
|
| 63 | + case IMAGETYPE_JPEG: |
|
| 64 | 64 | case IMAGETYPE_JPEG2000: |
| 65 | 65 | $img = imagecreatefromjpeg($file); |
| 66 | 66 | break; |
| 67 | - case IMAGETYPE_PNG: |
|
| 67 | + case IMAGETYPE_PNG: |
|
| 68 | 68 | $img = imagecreatefrompng($file); |
| 69 | 69 | break; |
| 70 | - default: |
|
| 70 | + default: |
|
| 71 | 71 | return 'dark'; |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,29 +78,29 @@ discard block |
||
| 78 | 78 | // Calculate the average brightness of the image |
| 79 | 79 | $total_brightness = 0; |
| 80 | 80 | for ($x=0; $x<$width; $x++) { |
| 81 | - for ($y=0; $y<$height; $y++) { |
|
| 81 | + for ($y=0; $y<$height; $y++) { |
|
| 82 | 82 | $rgb = imagecolorat($img, $x, $y); |
| 83 | 83 | $r = ($rgb >> 16) & 0xFF; |
| 84 | 84 | $g = ($rgb >> 8) & 0xFF; |
| 85 | 85 | $b = $rgb & 0xFF; |
| 86 | 86 | $brightness = (int)(($r + $g + $b) / 3); |
| 87 | 87 | $total_brightness += $brightness; |
| 88 | - } |
|
| 88 | + } |
|
| 89 | 89 | } |
| 90 | 90 | $avg_brightness = $total_brightness / ($width * $height); |
| 91 | 91 | |
| 92 | 92 | // Determine if the image is more dark or light |
| 93 | 93 | if ($avg_brightness < 128) { |
| 94 | - return 'dark'; |
|
| 94 | + return 'dark'; |
|
| 95 | 95 | } else { |
| 96 | - return 'light'; |
|
| 96 | + return 'light'; |
|
| 97 | + } |
|
| 98 | + } catch (\Throwable $th) { |
|
| 99 | + return null; |
|
| 100 | + } |
|
| 97 | 101 | } |
| 98 | - } catch (\Throwable $th) { |
|
| 99 | - return null; |
|
| 100 | - } |
|
| 101 | - } |
|
| 102 | 102 | |
| 103 | - function infoIcon($tip) { |
|
| 103 | + function infoIcon($tip) { |
|
| 104 | 104 | echo ' |
| 105 | 105 | <div class="d-flex justify-content-center align-items-center"> |
| 106 | 106 | <a data-bs-toggle="tooltip" data-bs-placement="bottom" title="' . $tip . '"> |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | </a> |
| 111 | 111 | </div> |
| 112 | 112 | '; |
| 113 | - } |
|
| 113 | + } |
|
| 114 | 114 | |
| 115 | 115 | function external_file_get_contents($url) { |
| 116 | 116 | $ch = curl_init(); |
@@ -153,43 +153,43 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | if(!function_exists('setBlockAssetContext')) { |
| 156 | - function setBlockAssetContext($type = null) { |
|
| 157 | - static $currentType = null; |
|
| 158 | - if ($type !== null) { |
|
| 159 | - $currentType = $type; |
|
| 160 | - } |
|
| 161 | - return $currentType; |
|
| 162 | - } |
|
| 156 | + function setBlockAssetContext($type = null) { |
|
| 157 | + static $currentType = null; |
|
| 158 | + if ($type !== null) { |
|
| 159 | + $currentType = $type; |
|
| 160 | + } |
|
| 161 | + return $currentType; |
|
| 162 | + } |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Get custom block assets |
| 166 | 166 | if(!function_exists('block_asset')) { |
| 167 | - function block_asset($file) { |
|
| 168 | - $type = setBlockAssetContext(); // Retrieve the current type context |
|
| 169 | - return url("block-asset/$type?asset=$file"); |
|
| 170 | - } |
|
| 167 | + function block_asset($file) { |
|
| 168 | + $type = setBlockAssetContext(); // Retrieve the current type context |
|
| 169 | + return url("block-asset/$type?asset=$file"); |
|
| 170 | + } |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | if(!function_exists('get_block_file_contents')) { |
| 174 | - function get_block_file_contents($file) { |
|
| 175 | - $type = setBlockAssetContext(); // Retrieve the current type context |
|
| 176 | - return file_get_contents(base_path("blocks/$type/$file")); |
|
| 177 | - } |
|
| 174 | + function get_block_file_contents($file) { |
|
| 175 | + $type = setBlockAssetContext(); // Retrieve the current type context |
|
| 176 | + return file_get_contents(base_path("blocks/$type/$file")); |
|
| 177 | + } |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | function block_text_translation_check($text) { |
| 181 | - if (empty($text)) { |
|
| 181 | + if (empty($text)) { |
|
| 182 | 182 | return false; |
| 183 | - } |
|
| 184 | - $translate = __("messages.$text"); |
|
| 185 | - return $translate === "messages.$text" ? true : false; |
|
| 183 | + } |
|
| 184 | + $translate = __("messages.$text"); |
|
| 185 | + return $translate === "messages.$text" ? true : false; |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | function block_text($text) { |
| 189 | - $translate = __("messages.$text"); |
|
| 190 | - return $translate === "messages.$text" ? $text : $translate; |
|
| 189 | + $translate = __("messages.$text"); |
|
| 190 | + return $translate === "messages.$text" ? $text : $translate; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | function bt($text) { |
| 194 | - return block_text($text); |
|
| 194 | + return block_text($text); |
|
| 195 | 195 | } |
| 196 | 196 | \ No newline at end of file |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | function analyzeImageBrightness($file) { |
| 49 | 49 | try { |
| 50 | - $file = base_path('assets/img/background-img/'.$file); |
|
| 50 | + $file = base_path('assets/img/background-img/' . $file); |
|
| 51 | 51 | |
| 52 | 52 | // Get image information using getimagesize |
| 53 | 53 | $imageInfo = getimagesize($file); |
@@ -77,8 +77,8 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | // Calculate the average brightness of the image |
| 79 | 79 | $total_brightness = 0; |
| 80 | - for ($x=0; $x<$width; $x++) { |
|
| 81 | - for ($y=0; $y<$height; $y++) { |
|
| 80 | + for ($x = 0; $x < $width; $x++) { |
|
| 81 | + for ($y = 0; $y < $height; $y++) { |
|
| 82 | 82 | $rgb = imagecolorat($img, $x, $y); |
| 83 | 83 | $r = ($rgb >> 16) & 0xFF; |
| 84 | 84 | $g = ($rgb >> 8) & 0xFF; |
@@ -132,10 +132,10 @@ discard block |
||
| 132 | 132 | function footer($key) |
| 133 | 133 | { |
| 134 | 134 | $upperStr = strtoupper($key); |
| 135 | - if (env('TITLE_FOOTER_'.$upperStr) == "") { |
|
| 136 | - $title = __('messages.footer.'.$key); |
|
| 135 | + if (env('TITLE_FOOTER_' . $upperStr) == "") { |
|
| 136 | + $title = __('messages.footer.' . $key); |
|
| 137 | 137 | } else { |
| 138 | - $title = env('TITLE_FOOTER_'.$upperStr); |
|
| 138 | + $title = env('TITLE_FOOTER_' . $upperStr); |
|
| 139 | 139 | } |
| 140 | 140 | return $title; |
| 141 | 141 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | return $str; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | -if(!function_exists('setBlockAssetContext')) { |
|
| 155 | +if (!function_exists('setBlockAssetContext')) { |
|
| 156 | 156 | function setBlockAssetContext($type = null) { |
| 157 | 157 | static $currentType = null; |
| 158 | 158 | if ($type !== null) { |
@@ -163,14 +163,14 @@ discard block |
||
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Get custom block assets |
| 166 | -if(!function_exists('block_asset')) { |
|
| 166 | +if (!function_exists('block_asset')) { |
|
| 167 | 167 | function block_asset($file) { |
| 168 | 168 | $type = setBlockAssetContext(); // Retrieve the current type context |
| 169 | 169 | return url("block-asset/$type?asset=$file"); |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | -if(!function_exists('get_block_file_contents')) { |
|
| 173 | +if (!function_exists('get_block_file_contents')) { |
|
| 174 | 174 | function get_block_file_contents($file) { |
| 175 | 175 | $type = setBlockAssetContext(); // Retrieve the current type context |
| 176 | 176 | return file_get_contents(base_path("blocks/$type/$file")); |