Elgg  Version 6.1
filestore.php
Go to the documentation of this file.
1 <?php
9 
38 function elgg_save_resized_image(string $source, string $destination = null, array $params = []): bool {
39  return _elgg_services()->imageService->resize($source, $destination, $params);
40 }
41 
51 function elgg_delete_directory(string $directory, bool $leave_base_directory = false): bool {
52  $directory = Paths::sanitize($directory);
53  if (!file_exists($directory)) {
54  return true;
55  }
56 
57  if (!is_dir($directory)) {
58  return false;
59  }
60 
61  $dh = new \DirectoryIterator($directory);
62  /* @var $file_info \DirectoryIterator */
63  foreach ($dh as $file_info) {
64  if ($file_info->isDot()) {
65  continue;
66  }
67 
68  if ($file_info->isDir()) {
69  // recurse down through directory
70  if (!elgg_delete_directory($directory . $file_info->getFilename())) {
71  return false;
72  }
73  } elseif ($file_info->isFile()) {
74  unlink($file_info->getPathname());
75  }
76  }
77 
78  if ($leave_base_directory) {
79  return true;
80  }
81 
82  // remove empty directory
83  return rmdir($directory);
84 }
85 
97 function elgg_get_download_url(\ElggFile $file, bool $use_cookie = true, string $expires = '+2 hours'): ?string {
98  return $file->getDownloadURL($use_cookie, $expires);
99 }
100 
113 function elgg_get_inline_url(\ElggFile $file, bool $use_cookie = false, string $expires = ''): ?string {
114  return $file->getInlineURL($use_cookie, $expires);
115 }
116 
130 function elgg_get_embed_url(\ElggEntity $entity, string $size): string {
131  return elgg_generate_url('serve-icon', [
132  'guid' => $entity->guid,
133  'size' => $size,
134  ]);
135 }
136 
144 function elgg_get_uploaded_files(string $input_name): array {
145  return _elgg_services()->uploads->getFiles($input_name);
146 }
147 
156 function elgg_get_uploaded_file(string $input_name, bool $check_for_validity = true): ?UploadedFile {
157  return _elgg_services()->uploads->getFile($input_name, $check_for_validity);
158 }
159 
167  return new ElggTempFile();
168 }
$source
elgg_get_embed_url(\ElggEntity $entity, string $size)
Returns a URL suitable for embedding entity&#39;s icon in a text editor.
Definition: filestore.php:130
$input_name
Definition: crop.php:24
$params
Saves global plugin settings.
Definition: save.php:13
This class represents a physical file (by default in the system temp directory).
elgg_get_uploaded_file(string $input_name, bool $check_for_validity=true)
Returns a single valid uploaded file object.
Definition: filestore.php:156
getInlineURL(bool $use_cookie=false, string $expires= '')
Returns file&#39;s URL for inline display Suitable for displaying cacheable resources, such as user avatars.
Definition: ElggFile.php:520
if($item instanceof\ElggEntity) elseif($item instanceof\ElggRiverItem) elseif($item instanceof\ElggRelationship) elseif(is_callable([$item, 'getType']))
Definition: item.php:48
elgg_get_inline_url(\ElggFile $file, bool $use_cookie=false, string $expires= '')
Returns file&#39;s URL for inline display Suitable for displaying cacheable resources, such as user avatars.
Definition: filestore.php:113
$entity
Definition: reset.php:8
elgg_get_temp_file()
Returns a ElggTempFile which can handle writing/reading of data to a temporary file location...
Definition: filestore.php:166
elgg_save_resized_image(string $source, string $destination=null, array $params=[])
Crops and resizes an image.
Definition: filestore.php:38
$expires
getDownloadURL(bool $use_cookie=true, string $expires= '+2 hours')
Returns file&#39;s download URL.
Definition: ElggFile.php:491
$size
Definition: thumb.php:23
elgg_delete_directory(string $directory, bool $leave_base_directory=false)
Delete a directory and all its contents.
Definition: filestore.php:51
elgg_generate_url(string $name, array $parameters=[])
Generate a URL for named route.
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
elgg_get_download_url(\ElggFile $file, bool $use_cookie=true, string $expires= '+2 hours')
Returns file&#39;s download URL.
Definition: filestore.php:97
elgg_get_uploaded_files(string $input_name)
Returns an array of uploaded file objects regardless of upload status/errors.
Definition: filestore.php:144