file.php 804 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * File helper functions
  4. *
  5. * @package ElggFile
  6. */
  7. /**
  8. * Prepare the upload/edit form variables
  9. *
  10. * @param FilePluginFile $file
  11. * @return array
  12. */
  13. function file_prepare_form_vars($file = null) {
  14. // input names => defaults
  15. $values = array(
  16. 'title' => '',
  17. 'description' => '',
  18. 'access_id' => ACCESS_DEFAULT,
  19. 'tags' => '',
  20. 'container_guid' => elgg_get_page_owner_guid(),
  21. 'guid' => null,
  22. 'entity' => $file,
  23. );
  24. if ($file) {
  25. foreach (array_keys($values) as $field) {
  26. if (isset($file->$field)) {
  27. $values[$field] = $file->$field;
  28. }
  29. }
  30. }
  31. if (elgg_is_sticky_form('file')) {
  32. $sticky_values = elgg_get_sticky_values('file');
  33. foreach ($sticky_values as $key => $value) {
  34. $values[$key] = $value;
  35. }
  36. }
  37. elgg_clear_sticky_form('file');
  38. return $values;
  39. }