new.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. elgg_gatekeeper();
  3. $page_owner = elgg_get_page_owner_entity();
  4. if (empty($page_owner)) {
  5. forward();
  6. }
  7. // build breadcrumb
  8. elgg_push_breadcrumb(elgg_echo("file"), "file/all");
  9. if (elgg_instanceof($page_owner, "group", null, "ElggGroup")) {
  10. elgg_push_breadcrumb($page_owner->name, "file/group/" . $page_owner->getGUID() . "/all");
  11. } else {
  12. elgg_push_breadcrumb($page_owner->name, "file/owner/" . $page_owner->username);
  13. }
  14. elgg_push_breadcrumb(elgg_echo("file:upload"));
  15. // get data
  16. $upload_type = get_input("upload_type", "single");
  17. // build page elements
  18. $title_text = elgg_echo("file:upload");
  19. // body
  20. $form_vars = array(
  21. "enctype" => "multipart/form-data",
  22. "class" => "hidden"
  23. );
  24. $body_vars = array();
  25. $multi_vars = $form_vars;
  26. $multi_vars["id"] = "file-tools-multi-form";
  27. $multi_vars["action"] = "action/file/upload";
  28. $zip_vars = $form_vars;
  29. $zip_vars["id"] = "file-tools-zip-form";
  30. $single_vars = $form_vars;
  31. $single_vars["id"] = "file-tools-single-form";
  32. switch ($upload_type) {
  33. case "multi":
  34. unset($multi_vars["class"]);
  35. break;
  36. case "zip":
  37. unset($zip_vars["class"]);
  38. break;
  39. default:
  40. elgg_load_library("elgg:file");
  41. $body_vars = file_prepare_form_vars();
  42. unset($single_vars["class"]);
  43. break;
  44. }
  45. // build different forms
  46. $body = "<div id='file-tools-upload-wrapper'>";
  47. $body .= elgg_view_form("file/upload", $single_vars, $body_vars);
  48. $body .= elgg_view_form("file_tools/upload/multi", $multi_vars);
  49. $body .= elgg_view_form("file_tools/upload/zip", $zip_vars);
  50. $body .= "</div>";
  51. $tabs = elgg_view("file_tools/upload_tabs", array("upload_type" => $upload_type));
  52. // build page
  53. $page_data = elgg_view_layout("content", array(
  54. "title" => $title_text,
  55. "content" => $body,
  56. "filter" => $tabs
  57. ));
  58. // draw page
  59. echo elgg_view_page($title_text, $page_data);