upload.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * Elgg file upload/save form
  4. *
  5. * @package ElggFile
  6. */
  7. // once elgg_view stops throwing all sorts of junk into $vars, we can use
  8. $title = elgg_extract('title', $vars, '');
  9. $desc = elgg_extract('description', $vars, '');
  10. $tags = elgg_extract('tags', $vars, '');
  11. $access_id = elgg_extract('access_id', $vars, ACCESS_DEFAULT);
  12. $container_guid = elgg_extract('container_guid', $vars);
  13. if (!$container_guid) {
  14. $container_guid = elgg_get_logged_in_user_guid();
  15. }
  16. $guid = elgg_extract('guid', $vars, null);
  17. if ($guid) {
  18. $file_label = elgg_echo("file:replace");
  19. $submit_label = elgg_echo('save');
  20. } else {
  21. $file_label = elgg_echo("file:file");
  22. $submit_label = elgg_echo('upload');
  23. }
  24. ?>
  25. <div>
  26. <label><?php echo $file_label; ?></label><br />
  27. <?php echo elgg_view('input/file', array('name' => 'upload')); ?>
  28. </div>
  29. <div>
  30. <label><?php echo elgg_echo('title'); ?></label><br />
  31. <?php echo elgg_view('input/text', array('name' => 'title', 'value' => $title)); ?>
  32. </div>
  33. <div>
  34. <label><?php echo elgg_echo('description'); ?></label>
  35. <?php echo elgg_view('input/longtext', array('name' => 'description', 'value' => $desc)); ?>
  36. </div>
  37. <div>
  38. <label><?php echo elgg_echo('tags'); ?></label>
  39. <?php echo elgg_view('input/tags', array('name' => 'tags', 'value' => $tags)); ?>
  40. </div>
  41. <?php
  42. if (file_tools_use_folder_structure()) {
  43. $parent_guid = 0;
  44. if ($file = elgg_extract("entity", $vars)) {
  45. if($folders = $file->getEntitiesFromRelationship(array('relationship'=>FILE_TOOLS_RELATIONSHIP, 'inverse_relationship'=>true, 'limit'=>1))){
  46. $parent_guid = $folders[0]->getGUID();
  47. }
  48. }
  49. ?>
  50. <div>
  51. <label><?php echo elgg_echo("file_tools:forms:edit:parent"); ?><br />
  52. <?php
  53. echo elgg_view("input/folder_select", array("name" => "folder_guid", "value" => $parent_guid));
  54. ?>
  55. </label>
  56. </div>
  57. <?php
  58. }
  59. $categories = elgg_view('input/categories', $vars);
  60. if ($categories) {
  61. echo $categories;
  62. }
  63. ?>
  64. <div>
  65. <label><?php echo elgg_echo('access'); ?></label><br />
  66. <?php echo elgg_view('input/access', array('name' => 'access_id', 'value' => $access_id)); ?>
  67. </div>
  68. <div class="elgg-foot">
  69. <?php
  70. echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid));
  71. if ($guid) {
  72. echo elgg_view('input/hidden', array('name' => 'file_guid', 'value' => $guid));
  73. }
  74. echo elgg_view('input/submit', array('value' => $submit_label));
  75. ?>
  76. </div>