folder_select.php 870 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. $folder_guid = (int) get_input("folder_guid");
  3. $container_guid = elgg_extract("container_guid", $vars, elgg_get_page_owner_guid());
  4. $current_folder = elgg_extract("folder", $vars, $folder_guid);
  5. $type = elgg_extract("type", $vars);
  6. unset($vars["folder"]);
  7. unset($vars["type"]);
  8. unset($vars["container_guid"]);
  9. if ($type == "folder") {
  10. if (!elgg_extract("value", $vars)) {
  11. if (!empty($current_folder)) {
  12. $vars["value"] = get_entity($current_folder)->parent_guid;
  13. }
  14. }
  15. } elseif (!elgg_extract("value", $vars)) {
  16. $vars["value"] = $current_folder;
  17. }
  18. $folders = file_tools_get_folders($container_guid);
  19. $options = array(
  20. 0 => elgg_echo("file_tools:input:folder_select:main")
  21. );
  22. if (!empty($folders)) {
  23. $options = $options + file_tools_build_select_options($folders, 1);
  24. }
  25. $vars["options_values"] = $options;
  26. echo elgg_view("input/dropdown", $vars);