Elgg  Version 4.3
AddFileHelpTextHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Elgg\Input;
4 
11 
21  public function __invoke(\Elgg\Hook $hook) {
22  $return = $hook->getValue();
23  if (elgg_extract('input_type', $return) !== 'file') {
24  return;
25  }
26 
27  if (!elgg_extract('show_upload_limit', $return, true)) {
28  return;
29  }
30 
31  $help = elgg_extract('help', $return, '');
32 
33  // Get post_max_size and upload_max_filesize
35  $upload_max_filesize = elgg_get_ini_setting_in_bytes('upload_max_filesize');
36 
37  // Determine the correct value
39 
40  $help .= ' ' . elgg_echo('input:file:upload_limit', [elgg_format_bytes($max_upload)]);
41 
42  $return['help'] = trim($help);
43 
44  return $return;
45  }
46 }
if(!$php_log) $post_max_size
Definition: php.php:11
Adds help text to input/file.
__invoke(\Elgg\Hook $hook)
Add a help text to input/file about upload limit.
elgg_echo($message_key, array $args=[], $language="")
Elgg language module Functions to manage language and translations.
Definition: languages.php:18
Models an event passed to hook handlers.
Definition: Hook.php:11
elgg_get_ini_setting_in_bytes($setting)
Returns a PHP INI setting in bytes.
Definition: elgglib.php:607
$help
Definition: field.php:27
elgg_format_bytes($size, $precision=2)
Format bytes to a human readable format.
Definition: output.php:92
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:547
$upload_max_filesize
Definition: php.php:12