@@ -61,12 +61,12 @@ |
||
| 61 | 61 | public function factSourcePrepend(Tree $tree, $fact): string |
| 62 | 62 | { |
| 63 | 63 | $permission_level = $tree->getPreference('MAJ_CERTIF_SHOW_CERT'); |
| 64 | - if (is_numeric($permission_level) && Auth::accessLevel($tree) <= (int) $permission_level) { |
|
| 64 | + if (is_numeric($permission_level) && Auth::accessLevel($tree) <= (int)$permission_level) { |
|
| 65 | 65 | $path = $this->extractPath($fact); |
| 66 | 66 | |
| 67 | 67 | if ($path !== '') { |
| 68 | 68 | $certificate = new Certificate($tree, $path); |
| 69 | - return view($this->module->name() . '::components/certificate-icon', [ |
|
| 69 | + return view($this->module->name().'::components/certificate-icon', [ |
|
| 70 | 70 | 'module_name' => $this->module->name(), |
| 71 | 71 | 'certificate' => $certificate, |
| 72 | 72 | 'url_obfuscator_service' => $this->url_obfuscator_service, |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | bool $add_watermark = false, |
| 80 | 80 | Watermark $watermark = null |
| 81 | 81 | ): ResponseInterface { |
| 82 | - $filesystem = $this->filesystem_service->filesystem($certificate->tree()); |
|
| 82 | + $filesystem = $this->filesystem_service->filesystem($certificate->tree()); |
|
| 83 | 83 | $filename = $certificate->path(); |
| 84 | 84 | |
| 85 | 85 | if (!$add_watermark) { |
@@ -98,34 +98,34 @@ discard block |
||
| 98 | 98 | $height = $image->height(); |
| 99 | 99 | |
| 100 | 100 | $watermark->adjustSize($width); |
| 101 | - $watermark_x = (int) ceil($watermark->textLengthEstimate() * 1.5); |
|
| 101 | + $watermark_x = (int)ceil($watermark->textLengthEstimate() * 1.5); |
|
| 102 | 102 | $watermark_y = $watermark->size() * 12 + 1; |
| 103 | 103 | |
| 104 | - $font_definition = function (AbstractFont $font) use ($watermark): void { |
|
| 105 | - $font->file(Webtrees::ROOT_DIR . 'resources/fonts/DejaVuSans.ttf'); |
|
| 104 | + $font_definition = function(AbstractFont $font) use ($watermark): void { |
|
| 105 | + $font->file(Webtrees::ROOT_DIR.'resources/fonts/DejaVuSans.ttf'); |
|
| 106 | 106 | $font->color($watermark->color()); |
| 107 | 107 | $font->size($watermark->size()); |
| 108 | 108 | $font->valign('top'); |
| 109 | 109 | }; |
| 110 | 110 | |
| 111 | - for ($i = min((int) ceil($width * 0.1), $watermark_x); $i < $width; $i += $watermark_x) { |
|
| 112 | - for ($j = min((int) ceil($height * 0.1), $watermark_y); $j < $height; $j += $watermark_y) { |
|
| 111 | + for ($i = min((int)ceil($width * 0.1), $watermark_x); $i < $width; $i += $watermark_x) { |
|
| 112 | + for ($j = min((int)ceil($height * 0.1), $watermark_y); $j < $height; $j += $watermark_y) { |
|
| 113 | 113 | $image = $image->text($watermark->text(), $i, $j, $font_definition); |
| 114 | 114 | } |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $format = static::SUPPORTED_FORMATS[$image->mime()] ?? 'jpg'; |
| 118 | 118 | $quality = $this->extractImageQuality($image, static::GD_DEFAULT_IMAGE_QUALITY); |
| 119 | - $data = (string) $image->encode($format, $quality); |
|
| 119 | + $data = (string)$image->encode($format, $quality); |
|
| 120 | 120 | |
| 121 | 121 | return $this->imageResponse($data, $image->mime(), ''); |
| 122 | 122 | } catch (NotReadableException $ex) { |
| 123 | 123 | return $this->replacementImageResponse(pathinfo($filename, PATHINFO_EXTENSION)) |
| 124 | 124 | ->withHeader('X-Image-Exception', $ex->getMessage()); |
| 125 | 125 | } catch (FilesystemException | UnableToReadFile $ex) { |
| 126 | - return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND); |
|
| 126 | + return $this->replacementImageResponse((string)StatusCodeInterface::STATUS_NOT_FOUND); |
|
| 127 | 127 | } catch (Throwable $ex) { |
| 128 | - return $this->replacementImageResponse((string) StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR) |
|
| 128 | + return $this->replacementImageResponse((string)StatusCodeInterface::STATUS_INTERNAL_SERVER_ERROR) |
|
| 129 | 129 | ->withHeader('X-Image-Exception', $ex->getMessage()); |
| 130 | 130 | } |
| 131 | 131 | } |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function certificateNeedsWatermark(Certificate $certificate, UserInterface $user): bool |
| 141 | 141 | { |
| 142 | 142 | $tree = $certificate->tree(); |
| 143 | - $watermark_level = (int) ($tree->getPreference('MAJ_CERTIF_SHOW_NO_WATERMARK', (string) Auth::PRIV_HIDE)); |
|
| 143 | + $watermark_level = (int)($tree->getPreference('MAJ_CERTIF_SHOW_NO_WATERMARK', (string)Auth::PRIV_HIDE)); |
|
| 144 | 144 | |
| 145 | 145 | return Auth::accessLevel($tree, $user) > $watermark_level; |
| 146 | 146 | } |
@@ -71,10 +71,10 @@ |
||
| 71 | 71 | return collect(); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - $query = Validator::attributes($request)->string('query', ''); |
|
| 74 | + $query = Validator::attributes($request)->string('query', ''); |
|
| 75 | 75 | |
| 76 | 76 | /** @var Collection<int, string> $results */ |
| 77 | - $results = $this->certif_filesystem |
|
| 77 | + $results = $this->certif_filesystem |
|
| 78 | 78 | ->certificatesForCityContaining($tree, $city, $query) |
| 79 | 79 | ->map(fn(Certificate $certificate): string => $certificate->filename()); |
| 80 | 80 | |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | if ($certificate === null) { |
| 85 | 85 | return $this->certif_image_factory |
| 86 | - ->replacementImageResponse((string) StatusCodeInterface::STATUS_NOT_FOUND) |
|
| 86 | + ->replacementImageResponse((string)StatusCodeInterface::STATUS_NOT_FOUND) |
|
| 87 | 87 | ->withHeader('X-Image-Exception', I18N::translate('The certificate was not found in this family tree.')) |
| 88 | 88 | ; |
| 89 | 89 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | $size = $certificate->tree()->getPreference('MAJ_CERTIF_WM_FONT_MAXSIZE'); |
| 112 | 112 | $text = $this->watermarkText($request, $certificate); |
| 113 | 113 | |
| 114 | - return new Watermark($text, $color, is_numeric($size) ? (int) $size : Watermark::DEFAULT_SIZE); |
|
| 114 | + return new Watermark($text, $color, is_numeric($size) ? (int)$size : Watermark::DEFAULT_SIZE); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | /** |
@@ -62,11 +62,11 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $tree->setPreference( |
| 64 | 64 | 'MAJ_CERTIF_SHOW_CERT', |
| 65 | - (string) Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_CERT', Auth::PRIV_HIDE) |
|
| 65 | + (string)Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_CERT', Auth::PRIV_HIDE) |
|
| 66 | 66 | ); |
| 67 | 67 | $tree->setPreference( |
| 68 | 68 | 'MAJ_CERTIF_SHOW_NO_WATERMARK', |
| 69 | - (string) Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_NO_WATERMARK', Auth::PRIV_HIDE) |
|
| 69 | + (string)Validator::parsedBody($request)->integer('MAJ_CERTIF_SHOW_NO_WATERMARK', Auth::PRIV_HIDE) |
|
| 70 | 70 | ); |
| 71 | 71 | $tree->setPreference( |
| 72 | 72 | 'MAJ_CERTIF_WM_DEFAULT', |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | $tree->setPreference( |
| 77 | 77 | 'MAJ_CERTIF_WM_FONT_MAXSIZE', |
| 78 | - (string) ( |
|
| 78 | + (string)( |
|
| 79 | 79 | Validator::parsedBody($request)->isBetween(0, PHP_INT_MAX)->integer('MAJ_CERTIF_WM_FONT_MAXSIZE', 18) |
| 80 | 80 | ) |
| 81 | 81 | ); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | // Only accept valid folders for MAJ_CERT_ROOTDIR |
| 90 | 90 | $cert_root_dir = Validator::parsedBody($request)->string('MAJ_CERTIF_ROOTDIR', ''); |
| 91 | 91 | $cert_root_dir = preg_replace('/[:\/\\\\]+/', '/', $cert_root_dir) ?? ''; |
| 92 | - $cert_root_dir = trim($cert_root_dir, '/') . '/'; |
|
| 92 | + $cert_root_dir = trim($cert_root_dir, '/').'/'; |
|
| 93 | 93 | $tree->setPreference('MAJ_CERTIF_ROOTDIR', $cert_root_dir); |
| 94 | 94 | |
| 95 | 95 | FlashMessages::addMessage( |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | if (!isset($this->filesystem[$tree->id()])) { |
| 49 | 49 | $cert_dir = $tree->getPreference('MAJ_CERTIF_ROOTDIR', 'certificates/'); |
| 50 | - $adapter = new ChrootAdapter(Registry::filesystem()->data(), $cert_dir); |
|
| 50 | + $adapter = new ChrootAdapter(Registry::filesystem()->data(), $cert_dir); |
|
| 51 | 51 | |
| 52 | 52 | $this->filesystem[$tree->id()] = new FileSystem($adapter); |
| 53 | 53 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | */ |
| 90 | 90 | public function cities(Tree $tree): array |
| 91 | 91 | { |
| 92 | - $cities = $this->filesystem($tree) |
|
| 92 | + $cities = $this->filesystem($tree) |
|
| 93 | 93 | ->listContents('') |
| 94 | 94 | ->filter(fn (StorageAttributes $attributes): bool => $attributes->isDir()) |
| 95 | 95 | ->map(fn (StorageAttributes $attributes): string => $attributes->path()) |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | try { |
| 151 | 151 | $mime = $filesystem->mimeType($path); |
| 152 | 152 | return Registry::cache()->array()->remember( |
| 153 | - 'maj-certif-supportedfiles-' . $mime, |
|
| 153 | + 'maj-certif-supportedfiles-'.$mime, |
|
| 154 | 154 | fn (): bool => app(CertificateImageFactory::class)->isMimeTypeSupported($mime) |
| 155 | 155 | ); |
| 156 | 156 | } catch (UnableToRetrieveMetadata | FilesystemException $ex) { |
@@ -43,8 +43,7 @@ discard block |
||
| 43 | 43 | $server_software = $request->getServerParams()['SERVER_SOFTWARE'] ?? ''; |
| 44 | 44 | $this->encryption_key = str_pad(md5( |
| 45 | 45 | $server_name !== '' && $server_software !== '' ? |
| 46 | - $server_name . $server_software : |
|
| 47 | - 'STANDARDKEYIFNOSERVER' |
|
| 46 | + $server_name.$server_software : 'STANDARDKEYIFNOSERVER' |
|
| 48 | 47 | ), SODIUM_CRYPTO_SECRETBOX_KEYBYTES, "1234567890ABCDEF"); |
| 49 | 48 | } |
| 50 | 49 | return $this->encryption_key; |
@@ -77,7 +76,7 @@ discard block |
||
| 77 | 76 | } |
| 78 | 77 | |
| 79 | 78 | $encryted = sodium_crypto_secretbox($cleartext, $nonce, $key); |
| 80 | - return strtr(base64_encode($nonce . $encryted), '+/=', '._-'); |
|
| 79 | + return strtr(base64_encode($nonce.$encryted), '+/=', '._-'); |
|
| 81 | 80 | } |
| 82 | 81 | |
| 83 | 82 | /** |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function merge(GeoAnalysisResult $other): self |
| 136 | 136 | { |
| 137 | - $this->places->each(function (GeoAnalysisResultItem $item) use ($other): void { |
|
| 137 | + $this->places->each(function(GeoAnalysisResultItem $item) use ($other): void { |
|
| 138 | 138 | if ($other->places->has($item->key())) { |
| 139 | 139 | $item->place()->exclude( |
| 140 | 140 | $item->place()->isExcluded() |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | } |
| 144 | 144 | }); |
| 145 | 145 | |
| 146 | - $other->places->each(function (GeoAnalysisResultItem $item): void { |
|
| 146 | + $other->places->each(function(GeoAnalysisResultItem $item): void { |
|
| 147 | 147 | if (!$this->places->has($item->key())) { |
| 148 | 148 | $this->addPlace($item->place()); |
| 149 | 149 | } |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | // Permissions are configured |
| 48 | 48 | if (is_numeric($permission_level)) { |
| 49 | 49 | // Logged in with the correct role? |
| 50 | - if (Auth::accessLevel($tree, $user) <= (int) $permission_level) { |
|
| 50 | + if (Auth::accessLevel($tree, $user) <= (int)$permission_level) { |
|
| 51 | 51 | return $handler->handle($request); |
| 52 | 52 | } |
| 53 | 53 | |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | return Registry::responseFactory()->redirect( |
| 66 | 66 | LoginPage::class, |
| 67 | - ['tree' => $tree->name(), 'url' => (string) $request->getUri()] |
|
| 67 | + ['tree' => $tree->name(), 'url' => (string)$request->getUri()] |
|
| 68 | 68 | ); |
| 69 | 69 | } |
| 70 | 70 | } |