Fixed typos

This commit is contained in:
Jan Böhmer 2023-04-15 23:14:53 +02:00
parent 63df16a369
commit d04d743520
144 changed files with 263 additions and 265 deletions

View file

@ -140,7 +140,7 @@ class AttachmentManager
}
/**
* Returns a human readable version of the attachment file size.
* Returns a human-readable version of the attachment file size.
* For external attachments, null is returned.
*
* @param int $decimals The number of decimals numbers that should be printed

View file

@ -30,7 +30,7 @@ use SplFileInfo;
use Symfony\Component\Filesystem\Filesystem;
/**
* This service provides functions to find attachments via an reverse search based on a file.
* This service provides functions to find attachments via a reverse search based on a file.
*/
class AttachmentReverseSearch
{
@ -53,7 +53,7 @@ class AttachmentReverseSearch
*
* @param SplFileInfo $file The file for which is searched
*
* @return Attachment[] an list of attachments that use the given file
* @return Attachment[] a list of attachments that use the given file
*/
public function findAttachmentsByFile(SplFileInfo $file): array
{
@ -75,11 +75,11 @@ class AttachmentReverseSearch
* @param SplFileInfo $file The file that should be removed
* @param int $threshold the threshold used, to determine if a file should be deleted or not
*
* @return bool True, if the file was delete. False if not.
* @return bool True, if the file was deleted. False if not.
*/
public function deleteIfNotUsed(SplFileInfo $file, int $threshold = 1): bool
{
/* When the file is used more then $threshold times, don't delete it */
/* When the file is used more than $threshold times, don't delete it */
if (count($this->findAttachmentsByFile($file)) > $threshold) {
return false;
}

View file

@ -108,7 +108,7 @@ class AttachmentSubmitHandler
*/
public function isValidFileExtension(AttachmentType $attachment_type, UploadedFile $uploadedFile): bool
{
//Only validate if the attachment type has specified an filetype filter:
//Only validate if the attachment type has specified a filetype filter:
if (empty($attachment_type->getFiletypeFilter())) {
return true;
}
@ -121,10 +121,10 @@ class AttachmentSubmitHandler
/**
* Generates a filename for the given attachment and extension.
* The filename contains a random id, so every time this function is called you get an unique name.
* The filename contains a random id, so every time this function is called you get a unique name.
*
* @param Attachment $attachment The attachment that should be used for generating an attachment
* @param string $extension The extension that the new file should have (must only contain chars allowed in pathes)
* @param string $extension The extension that the new file should have (must only contain chars allowed in paths)
*
* @return string the new filename
*/
@ -136,7 +136,7 @@ class AttachmentSubmitHandler
$extension
);
//Use the (sanatized) attachment name as an filename part
//Use the (sanatized) attachment name as a filename part
$safeName = transliterator_transliterate(
'Any-Latin; Latin-ASCII; [^A-Za-z0-9_] remove; Lower()',
$attachment->getName()
@ -177,12 +177,12 @@ class AttachmentSubmitHandler
}
/**
* Handle the submit of an attachment form.
* Handle submission of an attachment form.
* This function will move the uploaded file or download the URL file to server, if needed.
*
* @param Attachment $attachment the attachment that should be used for handling
* @param UploadedFile|null $file If given, that file will be moved to the right location
* @param array $options The options to use with the upload. Here you can specify that an URL should be downloaded,
* @param array $options The options to use with the upload. Here you can specify that a URL should be downloaded,
* or an file should be moved to a secure location.
*
* @return Attachment The attachment with the new filename (same instance as passed $attachment)
@ -219,7 +219,7 @@ class AttachmentSubmitHandler
}
/**
* Rename attachments with an unsafe extension (meaning files which would be runned by a to a safe one.
* Rename attachments with an unsafe extension (meaning files which would be run by a to a safe one).
* @param Attachment $attachment
* @return Attachment
*/
@ -261,7 +261,7 @@ class AttachmentSubmitHandler
$resolver->setDefaults([
//If no preview image was set yet, the new uploaded file will become the preview image
'become_preview_if_empty' => true,
//When an URL is given download the URL
//When a URL is given download the URL
'download_url' => false,
'secure_attachment' => false,
]);
@ -357,17 +357,17 @@ class AttachmentSubmitHandler
//File download should be finished here, so determine the new filename and extension
$headers = $response->getHeaders();
//Try to determine an filename
//Try to determine a filename
$filename = '';
//If an content disposition header was set try to extract the filename out of it
//If a content disposition header was set try to extract the filename out of it
if (isset($headers['content-disposition'])) {
$tmp = [];
preg_match('/[^;\\n=]*=([\'\"])*(.*)(?(1)\1|)/', $headers['content-disposition'][0], $tmp);
$filename = $tmp[2];
}
//If we dont know filename yet, try to determine it out of url
//If we don't know filename yet, try to determine it out of url
if ('' === $filename) {
$filename = basename(parse_url($url, PHP_URL_PATH));
}
@ -375,7 +375,7 @@ class AttachmentSubmitHandler
//Set original file
$attachment->setFilename($filename);
//Check if we have a extension given
//Check if we have an extension given
$pathinfo = pathinfo($filename);
if (!empty($pathinfo['extension'])) {
$new_ext = $pathinfo['extension'];

View file

@ -57,7 +57,7 @@ class AttachmentURLGenerator
}
/**
* Converts the absolute file path to a version relative to the public folder, that can be passed to asset
* Converts the absolute file path to a version relative to the public folder, that can be passed to the
* Asset Component functions.
*
* @param string $absolute_path the absolute path that should be converted
@ -77,7 +77,7 @@ class AttachmentURLGenerator
$public_path = $this->public_path;
}
//Our absolute path must begin with public path or we can not use it for asset pathes.
//Our absolute path must begin with public path, or we can not use it for asset pathes.
if (0 !== strpos($absolute_path, $public_path)) {
return null;
}
@ -87,7 +87,7 @@ class AttachmentURLGenerator
}
/**
* Converts a placeholder path to a path to a image path.
* Converts a placeholder path to a path to an image path.
*
* @param string $placeholder_path the placeholder path that should be converted
*/
@ -120,7 +120,7 @@ class AttachmentURLGenerator
}
/**
* Returns a URL to an thumbnail of the attachment file.
* Returns a URL to a thumbnail of the attachment file.
* @return string|null The URL or null if the attachment file is not existing
*/
public function getThumbnailURL(Attachment $attachment, string $filter_name = 'thumbnail_sm'): ?string
@ -155,7 +155,7 @@ class AttachmentURLGenerator
//So we remove the schema manually
return preg_replace('/^https?:/', '', $tmp);
} catch (\Imagine\Exception\RuntimeException $e) {
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log an warning
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log a warning
$this->logger->warning('Could not open thumbnail for attachment with ID ' . $attachment->getID() . ': ' . $e->getMessage());
return $this->assets->getUrl($asset_path);
}

View file

@ -29,7 +29,7 @@ use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface;
/**
* An servive that helps working with filetype filters (based on the format <input type=file> accept uses.
* A service that helps to work with filetype filters (based on the format <input type=file> accept uses).
* See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers for
* more details.
*/