<?php $files = elgg_extract('files', $vars, []); $folder = elgg_extract('folder', $vars); $show_more = (bool) elgg_extract('show_more', $vars, false); $limit = (int) elgg_extract('limit', $vars, file_tools_get_list_length()); $offset = (int) elgg_extract('offset', $vars, 0); // only show the header if offset == 0 $folder_content = ''; if (empty($offset)) { $folder_content = elgg_view('file_tools/breadcrumb', ['entity' => $folder]); $sub_folders = file_tools_get_sub_folders($folder); if (empty($sub_folders)) { $sub_folders = []; } $entities = array_merge($sub_folders, $files); } else { $entities = $files; } $files_content = ''; if (!empty($entities)) { $params = ['full_view' => false, 'pagination' => false]; elgg_push_context('file_tools_selector'); $files_content = elgg_view_entity_list($entities, $params); elgg_pop_context(); } if (empty($files_content)) { $files_content = elgg_echo('file_tools:list:files:none'); } else { if ($show_more) { $more = elgg_view('input/button', ['value' => elgg_echo('file_tools:show_more'), 'class' => 'elgg-button-action', 'id' => 'file-tools-show-more-files']);
$container = get_entity($folder->container_guid); } else { $container = get_entity(elgg_get_page_owner_guid()); } //only show sort control if container is a group and user is an admin of the group if (elgg_instanceof($container, "group") && $container->canEdit()) { //get current sort $sort = explode(" ", $container->folderSort); $sort = $sort[0]; $sort_control = "<div><label class='normal'>" . elgg_echo('file_tools:sort:sortBy') . "</label><select class='normal' name='sort_option'>"; $sort_control .= "<option value='oe.title' " . ($sort == 'oe.title' ? "selected" : "") . ">" . elgg_echo('file_tools:sort:title') . "</option>"; $sort_control .= "<option value='e.last_action' " . ($sort == 'e.last_action' ? "selected" : "") . ">" . elgg_echo('file_tools:sort:lastAction') . "</option>"; $sort_control .= "</select><p id='sort-message'></p></div>"; } $folder_content = elgg_view("file_tools/breadcrumb", array("entity" => $folder)); if (!($sub_folders = file_tools_get_sub_folders($folder))) { $sub_folders = array(); } $entities = array_merge($sub_folders, $files); if (!empty($entities)) { $params = array("full_view" => false, "pagination" => false); elgg_push_context("file_tools_selector"); $files_content = elgg_view_entity_list($entities, $params); elgg_pop_context(); } if (empty($files_content)) { $files_content = elgg_echo("file_tools:list:files:none"); } else { $files_content .= "<div class='clearfix'>"; if (elgg_get_page_owner_entity()->canEdit()) { $files_content .= '<a id="file_tools_action_bulk_delete" href="javascript:void(0);">' . elgg_echo("file_tools:list:delete_selected") . '</a> | ';