Elgg  Version 4.3
filestore.php
Go to the documentation of this file.
1 <?php
8 
37 function elgg_save_resized_image($source, $destination = null, array $params = []) {
38  return _elgg_services()->imageService->resize($source, $destination, $params);
39 }
40 
51 function elgg_delete_directory(string $directory, bool $leave_base_directory = false) {
52 
53  if (!file_exists($directory)) {
54  return true;
55  }
56 
57  if (!is_dir($directory)) {
58  return false;
59  }
60 
61  // sanity check: must be a directory
62  if (!$handle = opendir($directory)) {
63  return false;
64  }
65 
66  // loop through all files
67  while (($file = readdir($handle)) !== false) {
68  if (in_array($file, ['.', '..'])) {
69  continue;
70  }
71 
72  $path = "$directory/$file";
73  if (is_dir($path)) {
74  // recurse down through directory
76  return false;
77  }
78  } else {
79  // delete file
80  unlink($path);
81  }
82  }
83 
84  // close file handler
85  closedir($handle);
86 
87  if ($leave_base_directory) {
88  return true;
89  }
90 
91  // remove empty directory
92  return rmdir($directory);
93 }
94 
105 function elgg_get_download_url(\ElggFile $file, $use_cookie = true, $expires = '+2 hours') {
106  return $file->getDownloadURL($use_cookie, $expires);
107 }
108 
120 function elgg_get_inline_url(\ElggFile $file, $use_cookie = false, $expires = '') {
121  return $file->getInlineURL($use_cookie, $expires);
122 }
123 
137  return elgg_generate_url('serve-icon', [
138  'guid' => $entity->guid,
139  'size' => $size,
140  ]);
141 }
142 
150  return _elgg_services()->uploads->getFiles($input_name);
151 }
152 
161 function elgg_get_uploaded_file($input_name, $check_for_validity = true) {
162  return _elgg_services()->uploads->getFile($input_name, $check_for_validity);
163 }
164 
171 function elgg_get_temp_file() {
172  return new ElggTempFile();
173 }
$source
$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_download_url(\ElggFile $file, $use_cookie=true, $expires= '+2 hours')
Returns file&#39;s download URL.
Definition: filestore.php:105
elgg_get_embed_url(\ElggEntity $entity, $size)
Returns a URL suitable for embedding entity&#39;s icon in a text editor.
Definition: filestore.php:136
elgg_get_uploaded_files($input_name)
Returns an array of uploaded file objects regardless of upload status/errors.
Definition: filestore.php:149
$path
Definition: details.php:68
elgg_get_inline_url(\ElggFile $file, $use_cookie=false, $expires= '')
Returns file&#39;s URL for inline display Suitable for displaying cacheable resources, such as user avatars.
Definition: filestore.php:120
elgg_get_uploaded_file($input_name, $check_for_validity=true)
Returns a single valid uploaded file object.
Definition: filestore.php:161
$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:171
elgg_generate_url($name, array $parameters=[])
Generate a URL for named route.
getDownloadURL($use_cookie=true, $expires= '+2 hours')
Returns file&#39;s download URL.
Definition: ElggFile.php:502
$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
getInlineURL($use_cookie=false, $expires= '')
Returns file&#39;s URL for inline display Suitable for displaying cacheable resources, such as user avatars.
Definition: ElggFile.php:528
elgg_save_resized_image($source, $destination=null, array $params=[])
Crops and resizes an image.
Definition: filestore.php:37
_elgg_services()
Get the global service provider.
Definition: elgglib.php:638