<?php
// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Local template scope variables.

/**
 * Template for the file manager.
 *
 * @package NNAXFUF_Plugin
 */

if (! defined('ABSPATH')) {
    exit;
}

$settings      = NNAXFUF_Helpers::get_settings();
$load_plugin_uikit = ! empty( $settings['load_plugin_uikit'] ) && ! NNAXFUF_Helpers::is_yootheme_active();
wp_enqueue_style( 'nnax-fm-style' );
wp_enqueue_script( 'nnax-fm-script' );
if ( $load_plugin_uikit ) {
    wp_enqueue_style( 'nnax-fm-uikit-css' );
    wp_enqueue_script( 'nnax-fm-uikit-js' );
    wp_enqueue_script( 'nnax-fm-uikit-icons' );
}

$frontend_main_headline = isset( $settings['main_headline'] ) ? trim( (string) $settings['main_headline'] ) : '';
if ( '' === $frontend_main_headline ) {
    $frontend_main_headline = __( 'My Files', 'nnax-frontend-user-files' );
}
$allowed_types = array();
if (! empty($settings['allowed_types'])) {
    $allowed_types = NNAXFUF_Helpers::normalize_safe_upload_extension_list( $settings['allowed_types'] );
}
$accept_attr = '';
if (! empty($allowed_types)) {
    $accept_attr = implode(',', array_map(function ($ext) {
        return '.' . $ext;
    }, $allowed_types));
}

// Dynamic color tokens from central definitions.
$ui_colors   = isset($settings['ui_colors']) && is_array($settings['ui_colors']) ? $settings['ui_colors'] : array();
$badge_colors = isset($settings['badge_colors']) && is_array($settings['badge_colors']) ? $settings['badge_colors'] : array();

// Ensure template context variables always exist (also for static analysis).
$current_user_id = isset($current_user_id) ? (int) $current_user_id : (int) get_current_user_id();
$current_folder_id = isset($current_folder_id) ? (int) $current_folder_id : (int) get_query_var(NNAXFUF_Plugin::FOLDER_VAR);
$current_search = isset($current_search) ? (string) $current_search : (string) get_query_var(NNAXFUF_Plugin::SEARCH_VAR);
$current_search = sanitize_text_field($current_search);
$paged = isset($paged) ? max(1, (int) $paged) : max(1, (int) get_query_var(NNAXFUF_Plugin::PAGED_VAR));
$total_items = isset($total_items) ? max(0, (int) $total_items) : 0;
$total_pages = isset($total_pages) ? max(0, (int) $total_pages) : 0;

$current_view = get_query_var(NNAXFUF_Plugin::VIEW_VAR);
$current_view = $current_view ? sanitize_key($current_view) : 'default';
$current_filter = isset($current_filter) ? sanitize_key($current_filter) : 'all';
$current_type_filter = isset($current_type_filter) ? NNAXFUF_Helpers::sanitize_file_type_filter($current_type_filter) : NNAXFUF_Helpers::sanitize_file_type_filter(get_query_var(NNAXFUF_Plugin::TYPE_VAR));
$type_filter_options = NNAXFUF_Helpers::get_file_type_filter_options();
$is_filter_active = ($current_filter !== 'all' || $current_type_filter !== 'all');
$filter_button_icon = $is_filter_active ? 'check; ratio: 0.8' : 'settings';
$filter_button_class = $is_filter_active ? 'uk-button-secondary' : 'uk-button-default';

$all_filter_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::FILTER_VAR => 'all',
        NNAXFUF_Plugin::PAGED_VAR  => 1,
    )
);
$owned_filter_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::FILTER_VAR => 'owned',
        NNAXFUF_Plugin::PAGED_VAR  => 1,
    )
);
$shared_filter_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::FILTER_VAR => 'shared',
        NNAXFUF_Plugin::PAGED_VAR  => 1,
    )
);
$shared_by_me_filter_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::FILTER_VAR => 'shared_by_me',
        NNAXFUF_Plugin::PAGED_VAR  => 1,
    )
);
$reset_filter_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::FILTER_VAR => 'all',
        NNAXFUF_Plugin::TYPE_VAR   => 'all',
        NNAXFUF_Plugin::PAGED_VAR  => 1,
    )
);
$type_filter_urls = array();
foreach ($type_filter_options as $type_key => $type_label) {
    $type_filter_urls[$type_key] = NNAXFUF_Helpers::get_file_manager_url(
        array(
            NNAXFUF_Plugin::TYPE_VAR  => $type_key,
            NNAXFUF_Plugin::PAGED_VAR => 1,
        )
    );
}

$trash_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::VIEW_VAR   => 'trash',
        NNAXFUF_Plugin::FOLDER_VAR => 0,
    )
);
$normal_url = NNAXFUF_Helpers::get_file_manager_url(
    array(
        NNAXFUF_Plugin::VIEW_VAR   => 'default',
        NNAXFUF_Plugin::FOLDER_VAR => 0,
    )
);

$can_manage_current_folder = true;
if (! empty($current_folder_id)) {
    $can_manage_current_folder = NNAXFUF_Helpers::user_can_manage_item($current_user_id, (int) $current_folder_id);
}
$has_bulk_delete_capability = false;
if (! empty($items) && is_array($items)) {
    foreach ($items as $bulk_item_candidate) {
        if (isset($bulk_item_candidate->ID) && NNAXFUF_Helpers::user_can_delete_item($current_user_id, (int) $bulk_item_candidate->ID)) {
            $has_bulk_delete_capability = true;
            break;
        }
    }
}
$share_options = isset( $settings['share_options'] ) && is_array( $settings['share_options'] ) ? $settings['share_options'] : array();
$help_role_sharing_enabled = ! empty( $share_options['allow_role_sharing'] );
$help_share_time_limit_enabled = NNAXFUF_Helpers::is_share_time_limit_enabled();
$help_share_owner_rights_enabled = NNAXFUF_Helpers::is_share_owner_rights_enabled();
$help_shared_folder_file_delete_enabled = NNAXFUF_Helpers::is_shared_folder_file_delete_enabled();

// Frontend sharing UI is provided by the Sharing Addon. When the Addon is
// not active we must keep all share-related metadata intact but hide any
// UI elements that would allow sharing. This avoids exposing share
// controls from the core plugin when the Addon is deactivated.
$sharing_active = defined( 'NNAXFUF_SHARE_ADDON_PATH' ) && file_exists( rtrim( NNAXFUF_SHARE_ADDON_PATH, '/' ) . '/templates/partials/modals/share.php' );
$sharing_filters_enabled = $sharing_active;

?>

<div class="nnaxfuf-file-manager uk-section uk-section-small" id="nnaxfuf-file-manager-container">
    <div class="uk-container">

        <div class="uk-card uk-card-default uk-card-body">
            <?php
            $notices = isset($notices) && is_array($notices) ? $notices : array();
            ?>
            <?php if (! empty($notices)) : ?>
                <div class="uk-margin-small-bottom">
                    <?php foreach ($notices as $notice) :
                        $notice_status  = isset($notice['status']) ? sanitize_html_class($notice['status']) : 'primary';
                        $notice_message = isset($notice['message']) ? (string) $notice['message'] : '';
                        if ($notice_message === '') continue;
                    ?>
                        <div class="uk-alert-<?php echo esc_attr($notice_status); ?> uk-margin-small" uk-alert>
                            <a class="uk-alert-close" uk-close></a>
                            <p class="uk-margin-remove"><?php echo esc_html($notice_message); ?></p>
                        </div>
                    <?php endforeach; ?>
                </div>
            <?php endif; ?>

            <div class="uk-margin-medium-bottom uk-flex uk-flex-between uk-flex-middle nnaxfuf-title-block">
                <div>
                    <?php if ($current_view !== 'trash') : ?>
                        <h3 class="uk-card-title"><?php echo esc_html( $frontend_main_headline ); ?></h3>
                    <?php else : ?>
                        <h3 class="uk-card-title"><?php esc_html_e('My Trash', 'nnax-frontend-user-files'); ?></h3>
                    <?php endif; ?>
                </div>
                <div>
                    <?php if ( true ) : ?>
                    <div>
                        <!-- Papierkorb Ansicht -->
                        <?php if ($current_view !== 'trash') : ?>
                            <a class="uk-button uk-button-default uk-button-small" href="<?php echo esc_url($trash_url); ?>" title="<?php esc_html_e('Go to "My Trash"', 'nnax-frontend-user-files'); ?>">
                                <span uk-icon="icon: trash"></span>
                                <span class="uk-margin-small-left uk-visible@l"><?php esc_html_e('Go to "My Trash"', 'nnax-frontend-user-files'); ?></span>
                            </a>
                        <?php else : ?>
                            <a class="uk-button uk-button-default uk-button-small" href="<?php echo esc_url($normal_url); ?>" title="<?php esc_html_e('Go to "My Trash"', 'nnax-frontend-user-files'); ?>">
                                <span uk-icon="icon: file-text"></span>
                                <span class="uk-margin-small-left uk-visible@l"><?php esc_html_e('Back to "My Files"', 'nnax-frontend-user-files'); ?></span>
                            </a>
                            <form
                                method="post"
                                action="<?php echo esc_url( $frontend_form_action_url ); ?>"
                                id="nnaxfuf-empty-trash-form"
                                class="uk-display-inline-block uk-margin-small-left nnaxfuf-confirm-submit"
                                data-nnaxfuf-confirm-message="<?php echo esc_attr__( 'Do you really want to permanently delete all items in the trash?', 'nnax-frontend-user-files' ); ?>"
                                data-nnaxfuf-confirm-ok-label="<?php echo esc_attr__( 'Delete', 'nnax-frontend-user-files' ); ?>"
                                data-nnaxfuf-confirm-cancel-label="<?php echo esc_attr__( 'Cancel', 'nnax-frontend-user-files' ); ?>"
                            >
                                <?php wp_nonce_field( 'nnaxfuf_empty_trash', 'nnaxfuf_nonce' ); ?>
                                <input type="hidden" name="action" value="nnaxfuf_empty_trash">
                                <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                <button type="submit" class="uk-button uk-button-danger uk-button-small" title="<?php esc_attr_e( 'Empty trash', 'nnax-frontend-user-files' ); ?>">
                                    <span uk-icon="icon: trash"></span>
                                    <span class="uk-margin-small-left uk-visible@l"><?php esc_html_e( 'Empty trash', 'nnax-frontend-user-files' ); ?></span>
                                </button>
                            </form>
                        <?php endif; ?>
                        <a href="#"
                           title="<?php echo esc_attr__( 'Help', 'nnax-frontend-user-files' ); ?>"
                           aria-label="<?php echo esc_attr__( 'Help', 'nnax-frontend-user-files' ); ?>"
                           class="uk-button uk-button-default uk-button-small uk-margin-small-left"
                           uk-toggle="target: #nnaxfuf-help-modal">
                            <span uk-icon="question"></span>
                        </a>
                        <?php do_action( 'nnaxfuf_file_manager_toolbar_after_help' ); ?>
                    </div>
                    <?php endif; ?>
                </div>
            </div>

            <?php
            // Sicherstellen, dass die Variablen existieren (falls das Template mal separat genutzt würde)
            $usage                 = isset($usage) ? $usage : array('file_count' => 0, 'total_bytes' => 0);
            $quota                 = isset($quota) ? $quota : array('max_files' => 0, 'max_mb' => 0);
            $used_mb_display       = isset($used_mb_display) ? $used_mb_display : '0,0';
            $remaining_files       = isset($remaining_files) ? $remaining_files : null;
            $remaining_mb_display  = isset($remaining_mb_display) ? $remaining_mb_display : null;
            $quota_max_mb_display  = isset($quota_max_mb_display) ? $quota_max_mb_display : null;
            $info_view_label       = ($current_view === 'trash') ? __('Trash', 'nnax-frontend-user-files') : __('My Files', 'nnax-frontend-user-files');
            $info_filter_labels    = array(
                'all'    => __('All Files', 'nnax-frontend-user-files'),
                'owned'  => __('My Files', 'nnax-frontend-user-files'),
            );
            if ( $sharing_filters_enabled ) {
                $info_filter_labels['shared'] = __('Shared with Me', 'nnax-frontend-user-files');
                $info_filter_labels['shared_by_me'] = __('Shared by Me', 'nnax-frontend-user-files');
            }
            $info_filter_label     = isset($info_filter_labels[$current_filter]) ? $info_filter_labels[$current_filter] : $info_filter_labels['all'];
            $info_type_label       = isset($type_filter_options[$current_type_filter]) ? $type_filter_options[$current_type_filter] : $type_filter_options['all'];
            $allowed_types_display = ! empty($allowed_types) ? implode(', ', array_map('strtoupper', $allowed_types)) : __('All', 'nnax-frontend-user-files');
            $share_time_limit_enabled = NNAXFUF_Helpers::is_share_time_limit_enabled();
            ?>

            <?php
            // Helper: Ordner-Breadcrumb
            function nnax_file_manager_get_folder_breadcrumb(int $current_folder_id): array
            {
                $crumbs = array();

                while ($current_folder_id) {
                    $folder = get_post($current_folder_id);
                    if (! $folder || $folder->post_type !== NNAXFUF_Plugin::CPT_FOLDER) {
                        break;
                    }
                    $crumbs[] = array(
                        'id'    => $folder->ID,
                        'title' => $folder->post_title,
                    );
                    $current_folder_id = $folder->post_parent;
                }

                $crumbs = array_reverse($crumbs);
                return $crumbs;
            }

            $breadcrumb = nnax_file_manager_get_folder_breadcrumb(isset($current_folder_id) ? $current_folder_id : 0);
            $breadcrumb_labels = array_map(function ($crumb) {
                return isset($crumb['title']) ? (string) $crumb['title'] : '';
            }, $breadcrumb);
            $info_current_path = ($current_view !== 'trash') ? __('Root', 'nnax-frontend-user-files') : __('My Trash', 'nnax-frontend-user-files');
            if (! empty($breadcrumb_labels)) {
                $info_current_path .= ' / ' . implode(' / ', array_filter($breadcrumb_labels));
            }
            ?>

            <?php if ( true ) : ?>
            <div class="uk-margin-small nnaxfuf-folder-bar">
                <?php
                $parent_folder_id = 0;
                if (! empty($current_folder_id)) {
                    $current_folder = get_post($current_folder_id);
                    if ($current_folder && $current_folder->post_type === NNAXFUF_Plugin::CPT_FOLDER) {
                        $parent_folder_id = (int) $current_folder->post_parent;
                    }
                }

                $back_url = '';
                if (! empty($current_folder_id)) {
                    $back_url = NNAXFUF_Helpers::get_file_manager_url(
                        array(
                            NNAXFUF_Plugin::FOLDER_VAR => ($parent_folder_id > 0) ? $parent_folder_id : 0,
                        )
                    );
                }
                ?>

                <div class="uk-flex uk-flex-middle uk-flex-between uk-margin-small-bottom">
                    <div class="uk-flex uk-flex-middle">

                        <?php if (! empty($current_folder_id)) : ?>
                            <a href="<?php echo esc_url($back_url); ?>"
                                class="uk-button uk-button-default uk-button-small uk-margin-right nnaxfuf-back-button"
                                title="<?php echo esc_attr__('Back', 'nnax-frontend-user-files'); ?>">
                                <span uk-icon="icon: chevron-left"></span>
                            </a>
                        <?php endif; ?>

                        <div>
                            <span class="uk-margin-small-right uk-text-muted" uk-icon="icon: home; ratio: 0.9" aria-hidden="true" style="vertical-align: center;" title="<?php esc_html_e('Current folder:', 'nnax-frontend-user-files'); ?>" uk-tooltip></span>
                            <?php
                                $root_folder_url = NNAXFUF_Helpers::get_file_manager_url(
                                    array( NNAXFUF_Plugin::FOLDER_VAR => 0 )
                                );
                            ?>
                            <a href="<?php echo esc_url($root_folder_url); ?>">
                                <?php echo esc_html(($current_view !== 'trash') ? __('Root', 'nnax-frontend-user-files') : __('My Trash', 'nnax-frontend-user-files')); ?>
                            </a>
                            <?php foreach ($breadcrumb as $crumb) : ?>
                                &nbsp;/&nbsp;
                                <a href="<?php echo esc_url(NNAXFUF_Helpers::get_file_manager_url(
                                    array( NNAXFUF_Plugin::FOLDER_VAR => (int) $crumb['id'] )
                                )); ?>">
                                    <?php echo esc_html($crumb['title']); ?>
                                </a>
                            <?php endforeach; ?>
                        </div>

                    </div>
                </div>
            </div>

            <hr class="uk-divider-icon">
            <?php endif; ?>


            <!-- Ordner + Dateien -->
            <?php if ($current_view !== 'trash') : ?>
                    <div class="nnaxfuf-actions-menu uk-flex uk-flex-between uk-margin-small-bottom">
                        <div class="uk-flex uk-flex-left">
                            <!-- Filter -->
                            <?php if ($current_view !== 'trash') : ?>
                            <div
                                class="nnaxfuf-filter-actions">
                                <button type="button" class="uk-button <?php echo esc_attr($filter_button_class); ?> uk-button-small" id="nnaxfuf_filter_actions_btn">
                                    <span uk-icon="icon: <?php echo esc_attr($filter_button_icon); ?>"></span> <?php esc_html_e('Filter', 'nnax-frontend-user-files'); ?>
                                </button>
                                <div class="uk-padding-small nnaxfuf-actions-dropdown" uk-dropdown="mode: click; pos: bottom-right; boundary: !.nnaxfuf-file-manager; boundary-align: true; flip: true; container: body">
                                    <ul class="uk-nav uk-dropdown-nav">
                                        <?php if ( $sharing_filters_enabled ) : ?>
                                            <li>
                                                <a class="uk-button uk-button-text <?php echo $current_filter === 'all' ? 'is-active' : ''; ?>" href="<?php echo esc_url($all_filter_url); ?>">
                                                    <span><?php esc_html_e('All Files', 'nnax-frontend-user-files'); ?></span>
                                                </a>
                                            </li>
                                            <li>
                                                <a class="uk-button uk-button-text <?php echo $current_filter === 'owned' ? 'is-active' : ''; ?>" href="<?php echo esc_url($owned_filter_url); ?>">
                                                    <span><?php esc_html_e('My Files', 'nnax-frontend-user-files'); ?></span>
                                                </a>
                                            </li>
                                            <li>
                                                <a class="uk-button uk-button-text <?php echo $current_filter === 'shared' ? 'is-active' : ''; ?>" href="<?php echo esc_url($shared_filter_url); ?>">
                                                    <span><?php esc_html_e('Shared with Me', 'nnax-frontend-user-files'); ?></span>
                                                </a>
                                            </li>
                                            <li>
                                                <a class="uk-button uk-button-text <?php echo $current_filter === 'shared_by_me' ? 'is-active' : ''; ?>" href="<?php echo esc_url($shared_by_me_filter_url); ?>">
                                                    <span><?php esc_html_e('Shared by Me', 'nnax-frontend-user-files'); ?></span>
                                                </a>
                                            </li>
                                        <?php endif; ?>
                                        <li class="nnaxfuf-settings-submenu-item">
                                            <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-settings-submenu-trigger<?php echo $current_type_filter !== 'all' ? ' is-active' : ''; ?>" aria-haspopup="true" aria-expanded="false">
                                                <span><?php esc_html_e('File type', 'nnax-frontend-user-files'); ?></span>
                                                <span class="uk-margin-small-left uk-text-muted"><?php echo esc_html($info_type_label); ?></span>
                                                <span class="nnaxfuf-settings-submenu-caret" uk-icon="icon: chevron-right; ratio: 0.8"></span>
                                            </button>
                                            <div class="nnaxfuf-settings-submenu" hidden>
                                                <ul class="uk-nav uk-dropdown-nav">
                                                    <?php foreach ($type_filter_options as $type_key => $type_label) : ?>
                                                        <li>
                                                            <a class="uk-button uk-button-text <?php echo $current_type_filter === $type_key ? 'is-active' : ''; ?>" href="<?php echo esc_url(isset($type_filter_urls[$type_key]) ? $type_filter_urls[$type_key] : NNAXFUF_Helpers::get_file_manager_url(array(NNAXFUF_Plugin::TYPE_VAR => 'all', NNAXFUF_Plugin::PAGED_VAR => 1))); ?>">
                                                                <span><?php echo esc_html($type_label); ?></span>
                                                            </a>
                                                        </li>
                                                    <?php endforeach; ?>
                                                </ul>
                                            </div>
                                        </li>
                                        <?php if ($is_filter_active) : ?>
                                            <li>
                                                <a class="uk-button uk-button-text" href="<?php echo esc_url($reset_filter_url); ?>" style="color: var(--nnaxfuf-color-focus);">
                                                    <span><?php esc_html_e('Reset filters', 'nnax-frontend-user-files'); ?></span>
                                                </a>
                                            </li>
                                        <?php endif; ?>
                                    </ul>
                                </div>
                            <?php endif; ?>
                            </div>

                            <!-- Suche -->
                            <div class="uk-margin-small-left nnaxfuf-search-wrap uk-width-expand uk-width-auto@l">
                                <?php $search_open = ( '' !== $current_search ); ?>
                                <div class="nnaxfuf-search-panel">
                                    <form method="get" action="<?php echo esc_url( NNAXFUF_Helpers::get_file_manager_url( array( NNAXFUF_Plugin::SEARCH_VAR => '', NNAXFUF_Plugin::PAGED_VAR => 1 ) ) ); ?>" class="nnaxfuf-search-form uk-flex uk-flex-middle">
                                        <div class="uk-width-expand">
                                            <div class="uk-search uk-search-default">
                                                <?php
                                                    // Hidden inputs to maintain current context if permalinks are disabled
                                                    if ( empty( get_option( 'permalink_structure' ) ) ) {
                                                        $page_id = get_queried_object_id();
                                                        if ( $page_id ) {
                                                            echo '<input type="hidden" name="page_id" value="' . esc_attr( $page_id ) . '">';
                                                        }
                                                        echo '<input type="hidden" name="' . esc_attr( NNAXFUF_Plugin::VIEW_VAR ) . '" value="' . esc_attr( $current_view ) . '">';
                                                        echo '<input type="hidden" name="' . esc_attr( NNAXFUF_Plugin::FILTER_VAR ) . '" value="' . esc_attr( $current_filter ) . '">';
                                                        echo '<input type="hidden" name="' . esc_attr( NNAXFUF_Plugin::FOLDER_VAR ) . '" value="' . esc_attr( (int) $current_folder_id ) . '">';
                                                        echo '<input type="hidden" name="' . esc_attr( NNAXFUF_Plugin::TYPE_VAR ) . '" value="' . esc_attr( $current_type_filter ) . '">';
                                                    }
                                                    echo '<input type="hidden" name="' . esc_attr( NNAXFUF_Plugin::PAGED_VAR ) . '" value="1">';
                                                ?>
                                                <span uk-search-icon></span>
                                                <input class="uk-search-input uk-form-small nnaxfuf-search-input"
                                                       type="search"
                                                       name="<?php echo esc_attr( NNAXFUF_Plugin::SEARCH_VAR ); ?>"
                                                       placeholder="<?php esc_html_e( 'Search...', 'nnax-frontend-user-files' ); ?>"
                                                       value="<?php echo esc_attr( $current_search ); ?>">
                                            </div>
                                        </div>
                                        <div class="uk-width-auto">
                                            <button type="submit" class="uk-button uk-button-default uk-button-small">
                                                <?php esc_html_e( 'Search', 'nnax-frontend-user-files' ); ?>
                                            </button>
                                        </div>
                                        <?php if ( '' !== $current_search ) : ?>
                                            <div class="uk-width-auto">
                                                <a href="<?php echo esc_url( NNAXFUF_Helpers::get_file_manager_url( array( NNAXFUF_Plugin::SEARCH_VAR => '', NNAXFUF_Plugin::PAGED_VAR => 1 ) ) ); ?>"
                                                   class="uk-button uk-button-secondary uk-button-small nnaxfuf-search-reset"
                                                   title="<?php esc_html_e( 'Reset search', 'nnax-frontend-user-files' ); ?>">
                                                    <span uk-icon="refresh"></span>
                                                </a>
                                            </div>
                                        <?php endif; ?>
                                    </form>
                                </div>
                            </div>
                        </div>
                        <div class="uk-flex uk-flex-right">
                            <!-- Mehrfachaktionen -->
                            <div
                                class="nnaxfuf-bulk-actions uk-width-expand uk-width-auto@l"
                                data-zip-url="<?php echo esc_url(NNAXFUF_Helpers::get_zip_download_base_url()); ?>">
                                <button type="button" class="uk-button uk-button-default uk-button-small" id="nnaxfuf_bulk_actions_btn" title="<?php esc_html_e('Bulk Actions (0)', 'nnax-frontend-user-files'); ?>">
                                    <?php esc_html_e('Bulk Actions (0)', 'nnax-frontend-user-files'); ?>
                                </button>
                                <div class="uk-padding-small nnaxfuf-actions-dropdown" uk-dropdown="mode: click; pos: bottom-right; boundary: !.nnaxfuf-file-manager; boundary-align: true; flip: true; container: body">
                                    <ul class="uk-nav uk-dropdown-nav">
                                        <li>
                                            <a href="#" id="nnaxfuf_bulk_zip_download" class="uk-button-text uk-disabled" aria-disabled="true">
                                                <span uk-icon="icon: download"></span>
                                                <span class="uk-margin-small-left"><?php esc_html_e('Download selection as ZIP', 'nnax-frontend-user-files'); ?></span>
                                            </a>
                                        </li>
                                        <li>
                                            <button
                                                type="button"
                                                class="uk-button uk-button-text uk-width-1-1 uk-disabled"
                                                id="nnaxfuf_bulk_move_btn"
                                                aria-disabled="true"
                                                title="<?php echo esc_attr__( 'Select at least one item.', 'nnax-frontend-user-files' ); ?>"
                                                uk-tooltip
                                                uk-toggle="target: #nnaxfuf-bulk-move-modal"
                                                >
                                                <span uk-icon="icon: move"></span>
                                                <span class="uk-margin-small-left"><?php esc_html_e('Move selection', 'nnax-frontend-user-files'); ?></span>
                                            </button>
                                        </li>
                                        <li class="uk-nav-divider"></li>
                                        <?php if ($has_bulk_delete_capability) : ?>
                                            <li class="uk-text-danger">
                                                <form method="post" action="<?php echo esc_url( $frontend_form_action_url ); ?>" id="nnaxfuf_bulk_delete_form" class="uk-margin-remove" title="<?php echo esc_attr__('Deletes selected items. Subfolders and files within subfolders will be moved to the root directory.', 'nnax-frontend-user-files'); ?>" uk-tooltip>
                                                    <?php wp_nonce_field('nnaxfuf_bulk_delete', 'nnaxfuf_nonce'); ?>
                                                    <input type="hidden" name="action" value="nnaxfuf_bulk_delete">
                                                    <input type="hidden" name="nnaxfuf_bulk_items" id="nnaxfuf_bulk_delete_items" value="">
                                                    <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                                    <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                                    <button type="submit" class="uk-button uk-button-text uk-text-danger uk-width-1-1 uk-disabled" id="nnaxfuf_bulk_delete_btn" disabled>
                                                        <span uk-icon="icon: trash"></span>
                                                        <span class="uk-margin-small-left"><?php esc_html_e('Delete selection', 'nnax-frontend-user-files'); ?></span>
                                                    </button>
                                                </form>
                                            </li>
                                            <li class="uk-text-danger">
                                                <form method="post" action="<?php echo esc_url( $frontend_form_action_url ); ?>" id="nnaxfuf_bulk_delete_recursive_form" class="uk-margin-remove" title="<?php echo esc_attr__('Deletes selected items including subfolders and files inside selected folders.', 'nnax-frontend-user-files'); ?>" uk-tooltip>
                                                    <?php wp_nonce_field('nnaxfuf_bulk_delete_recursive', 'nnaxfuf_nonce'); ?>
                                                    <input type="hidden" name="action" value="nnaxfuf_bulk_delete_recursive">
                                                    <input type="hidden" name="nnaxfuf_bulk_items" id="nnaxfuf_bulk_delete_recursive_items" value="">
                                                    <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                                    <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                                    <button
                                                        type="submit"
                                                        class="uk-button uk-button-text uk-text-danger uk-width-1-1 uk-disabled"
                                                        id="nnaxfuf_bulk_delete_recursive_btn"
                                                        disabled>
                                                        <span uk-icon="icon: warning"></span>
                                                        <span class="uk-margin-small-left"><?php esc_html_e('Delete selection recursively', 'nnax-frontend-user-files'); ?></span>
                                                    </button>
                                                </form>
                                            </li>
                                        <?php endif; ?>
                                    </ul>
                                </div>
                            </div>
                            <!-- Einstellungen -->
                            <div
                                class="nnaxfuf-settings-actions" >
                                <button type="button" class="uk-button uk-button-default uk-button-small" id="nnaxfuf_settings_actions_btn" aria-label="<?php echo esc_attr__('View and sorting', 'nnax-frontend-user-files'); ?>">
                                    <span uk-icon="icon: more"></span>
                                </button>
                                <div class="uk-padding-small nnaxfuf-actions-dropdown" uk-dropdown="mode: click; pos: bottom-right; boundary: !.nnaxfuf-file-manager; boundary-align: true; flip: true; container: body">
                                    <ul class="uk-nav uk-dropdown-nav">
                                        <li class="nnaxfuf-settings-submenu-item">
                                            <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-settings-submenu-trigger" aria-haspopup="true" aria-expanded="false">
                                                <span uk-icon="icon: list"></span>
                                                <span class="uk-margin-small-left"><?php esc_html_e('Sort by', 'nnax-frontend-user-files'); ?></span>
                                                <span class="nnaxfuf-settings-submenu-caret" uk-icon="icon: chevron-right; ratio: 0.8"></span>
                                            </button>
                                            <div class="nnaxfuf-settings-submenu" hidden>
                                                <ul class="uk-nav uk-dropdown-nav">
                                                    <li>
                                                        <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-sort-option" data-sort-key="name" data-sort-direction="asc">
                                                            <span uk-icon="icon: arrow-up"></span>
                                                            <span class="uk-margin-small-left"><?php esc_html_e('Name ascending', 'nnax-frontend-user-files'); ?></span>
                                                        </button>
                                                    </li>
                                                    <li>
                                                        <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-sort-option" data-sort-key="name" data-sort-direction="desc">
                                                            <span uk-icon="icon: arrow-down"></span>
                                                            <span class="uk-margin-small-left"><?php esc_html_e('Name descending', 'nnax-frontend-user-files'); ?></span>
                                                        </button>
                                                    </li>
                                                    <li>
                                                        <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-sort-option" data-sort-key="size" data-sort-direction="asc">
                                                            <span uk-icon="icon: arrow-up"></span>
                                                            <span class="uk-margin-small-left"><?php esc_html_e('Size ascending', 'nnax-frontend-user-files'); ?></span>
                                                        </button>
                                                    </li>
                                                    <li>
                                                        <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-sort-option" data-sort-key="size" data-sort-direction="desc">
                                                            <span uk-icon="icon: arrow-down"></span>
                                                            <span class="uk-margin-small-left"><?php esc_html_e('Size descending', 'nnax-frontend-user-files'); ?></span>
                                                        </button>
                                                    </li>
                                                    <li>
                                                        <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-sort-option" data-sort-key="date" data-sort-direction="asc">
                                                            <span uk-icon="icon: arrow-up"></span>
                                                            <span class="uk-margin-small-left"><?php esc_html_e('Date ascending', 'nnax-frontend-user-files'); ?></span>
                                                        </button>
                                                    </li>
                                                    <li>
                                                        <button type="button" class="uk-button uk-button-text uk-width-1-1 nnaxfuf-sort-option" data-sort-key="date" data-sort-direction="desc">
                                                            <span uk-icon="icon: arrow-down"></span>
                                                            <span class="uk-margin-small-left"><?php esc_html_e('Date descending', 'nnax-frontend-user-files'); ?></span>
                                                        </button>
                                                    </li>
                                                </ul>
                                            </div>
                                        </li>
                                        <li>
                                            <button type="button" class="uk-button uk-button-text uk-width-1-1" uk-toggle="target: #nnaxfuf-info-modal">
                                                <span uk-icon="icon: info"></span>
                                                <span class="uk-margin-small-left"><?php esc_html_e('Information', 'nnax-frontend-user-files'); ?></span>
                                            </button>
                                        </li>
                                        <li>
                                            <button type="button" class="uk-button uk-button-text uk-width-1-1" id="nnaxfuf-toggle-previews" aria-pressed="false">
                                                <span uk-icon="icon: image"></span>
                                                <span class="uk-margin-small-left" data-nnaxfuf-preview-label><?php esc_html_e('Show image preview', 'nnax-frontend-user-files'); ?></span>
                                            </button>
                                        </li>
                                        <li>
                                            <button
                                                type="button"
                                                class="uk-button uk-button-text uk-width-1-1"
                                                id="nnaxfuf-toggle-show-all"
                                                data-show-all="<?php echo esc_attr( ! empty( $show_all_items ) ? '1' : '0' ); ?>"
                                                data-label-enable="<?php echo esc_attr__( 'Show all', 'nnax-frontend-user-files' ); ?>"
                                                data-label-disable="<?php echo esc_attr__( 'Paginated view', 'nnax-frontend-user-files' ); ?>">
                                                <span uk-icon="icon: expand"></span>
                                                <span class="uk-margin-small-left"><?php echo ! empty( $show_all_items ) ? esc_html__( 'Paginated view', 'nnax-frontend-user-files' ) : esc_html__( 'Show all', 'nnax-frontend-user-files' ); ?></span>
                                            </button>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
            <?php endif; ?>

            <?php if($current_view !== 'trash'): ?>
                <hr class="uk-divider-icon uk-hidden@m">
            <?php endif; ?>

            <?php if ( '' !== $current_search ) : ?>
                <div class="uk-alert-primary uk-margin-small-top uk-margin-bottom" uk-alert>
                    <p>
                        <span uk-icon="icon: search; ratio: 0.8"></span>
                        <?php
                        /* translators: %s: current search term (HTML <strong> wrapper). */
                        $nnaxfuf_search_results_text = __( 'Search results for: "%s"', 'nnax-frontend-user-files' );
                        printf(
                            wp_kses_post( $nnaxfuf_search_results_text ),
                            '<strong>' . esc_html( $current_search ) . '</strong>'
                        );
                        ?>
                        <?php if ( $current_type_filter !== 'all' ) : ?>
                            <?php echo ' '; ?>
                            <span class="uk-text-muted"><?php
                            /* translators: %s: selected type label. */
                            printf( esc_html__( '(Type: %s)', 'nnax-frontend-user-files' ), esc_html( $info_type_label ) );
                            ?></span>
                        <?php endif; ?>
                    </p>
                </div>
            <?php endif; ?>

            <?php if ( true ) : ?>
                <div class="nnaxfuf-file-table-wrap uk-height-max-large">
                    <table class="nnaxfuf-file-table uk-table uk-table-divider uk-table-striped uk-table-middle">
                        <thead>
                            <tr>
                                <th class="uk-table-shrink">
                                    <?php if ($current_view !== 'trash') : ?>
                                        <input class="uk-checkbox" type="checkbox" id="nnaxfuf_bulk_select_all" aria-label="<?php echo esc_attr__('Select all', 'nnax-frontend-user-files'); ?>">
                                    <?php endif; ?>
                                </th>
                                <th>
                                    <button type="button"
                                            class="uk-button uk-button-text nnaxfuf-table-sort"
                                            data-sort-key="name"
                                            data-sort-direction="asc"
                                            aria-label="<?php echo esc_attr( esc_html__( 'Sort by', 'nnax-frontend-user-files' ) . ' ' . esc_html__( 'Name', 'nnax-frontend-user-files' ) ); ?>"
                                            aria-pressed="false">
                                        <?php esc_html_e('Name', 'nnax-frontend-user-files'); ?>
                                    </button>
                                </th>
                                <th>
                                    <button type="button"
                                            class="uk-button uk-button-text nnaxfuf-table-sort"
                                            data-sort-key="size"
                                            data-sort-direction="asc"
                                            aria-label="<?php echo esc_attr( esc_html__( 'Sort by', 'nnax-frontend-user-files' ) . ' ' . esc_html__( 'Size', 'nnax-frontend-user-files' ) ); ?>"
                                            aria-pressed="false">
                                        <?php esc_html_e('Size', 'nnax-frontend-user-files'); ?>
                                    </button>
                                </th>
                                <th>
                                    <button type="button"
                                            class="uk-button uk-button-text nnaxfuf-table-sort"
                                            data-sort-key="date"
                                            data-sort-direction="asc"
                                            aria-label="<?php echo esc_attr( esc_html__( 'Sort by', 'nnax-frontend-user-files' ) . ' ' . esc_html__( 'Modified', 'nnax-frontend-user-files' ) ); ?>"
                                            aria-pressed="false">
                                        <?php esc_html_e('Modified', 'nnax-frontend-user-files'); ?>
                                    </button>
                                </th>
                                <?php do_action( 'nnaxfuf_file_manager_table_header_after_modified' ); ?>
                                <th class="uk-text-right"><?php esc_html_e('Actions', 'nnax-frontend-user-files'); ?></th>
                            </tr>
                        </thead>
                        <tbody>

                            <?php if (! empty($items)) : ?>
                            <?php foreach ($items as $item) :

                                $is_folder = ($item->post_type === NNAXFUF_Plugin::CPT_FOLDER);

                                $item_id   = $item->ID;
                                $owner_id  = (int) get_post_meta($item_id, NNAXFUF_Plugin::META_OWNER, true);
                                $owner     = get_user_by('id', $owner_id);
                                $owner_name = $owner ? $owner->display_name : __('Unknown', 'nnax-frontend-user-files');
                                $is_foreign = ($owner_id > 0 && (int)$owner_id !== (int)$current_user_id);
                                $can_edit_item   = NNAXFUF_Helpers::user_can_manage_item($current_user_id, $item_id);
                                $can_delete_item = NNAXFUF_Helpers::user_can_delete_item($current_user_id, $item_id);
                                $can_share_item  = NNAXFUF_Helpers::can_user_do($current_user_id, $item_id, 'share');
                                $can_restore_item = NNAXFUF_Helpers::can_user_do($current_user_id, $item_id, 'restore');
                                $can_permanent_delete_item = NNAXFUF_Helpers::can_user_do($current_user_id, $item_id, 'permanent_delete');
                                $share_ctx_current = NNAXFUF_Helpers::get_share_context_for_user($current_user_id, $item_id);

                                $shared_with  = NNAXFUF_Helpers::get_active_shared_user_ids($item_id);
                                $shared_count = count($shared_with);

                                $changed_date = get_the_modified_date('d.m.Y H:i', $item);
                                $trash_parent_tooltip = '';
                                if ($current_view === 'trash' && ! $is_folder) {
                                    $trash_parent_id = (int) $item->post_parent;
                                    if ($trash_parent_id > 0) {
                                        $trash_parent = get_post($trash_parent_id);
                                        $restore_target_label = __('Root (My Files)', 'nnax-frontend-user-files');
                                        if ($trash_parent && $trash_parent->post_type === NNAXFUF_Plugin::CPT_FOLDER) {
                                            $trash_parent_title = isset( $trash_parent->post_title ) ? (string) $trash_parent->post_title : '';
                                            $trash_parent_label = $trash_parent_title !== '' ? $trash_parent_title : sprintf(
                                                /* translators: %d: folder ID. */
                                                __( 'Folder #%d', 'nnax-frontend-user-files' ),
                                                $trash_parent_id
                                            );
                                            if ($trash_parent->post_status === 'publish') {
                                                $restore_target_label = $trash_parent_label;
                                            }
                                        } else {
                                            $trash_parent_label = sprintf(
                                                /* translators: %d: folder ID. */
                                                __( 'Folder ID %d (not available)', 'nnax-frontend-user-files' ),
                                                $trash_parent_id
                                            );
                                        }
                                        /* translators: 1: original folder label, 2: restore target label. */
                                        $nnaxfuf_restore_target_text = __( 'Deleted from folder: %1$s. Restore target: %2$s.', 'nnax-frontend-user-files' );
                                        $trash_parent_tooltip = sprintf(
                                            $nnaxfuf_restore_target_text,
                                            $trash_parent_label,
                                            $restore_target_label
                                        );
                                    }
                                }

                                $row_open_url = '';
                                $row_type     = $is_folder ? 'folder' : 'file';
                                $sort_size_bytes = 0;

                                $folder_size_bytes      = 0;
                                $size_bytes   = 0;
                                $size_human   = '-';

                                if ($is_folder) {
                                    $row_open_url = NNAXFUF_Helpers::get_file_manager_url(
                                        array( NNAXFUF_Plugin::FOLDER_VAR => $item_id )
                                    );
                                    $folder_size_bytes      = NNAXFUF_Helpers::sum_folder_size_recursive( $item_id );
                                    $sort_size_bytes = $folder_size_bytes;
                                    $size_human      = size_format( $folder_size_bytes, 2 );
                                } else {
                                    $row_open_url = NNAXFUF_Helpers::get_download_url($item_id);
                                    $file_path = get_post_meta( $item_id, NNAXFUF_Plugin::META_FILEPATH, true );
                                    if ( ! empty( $file_path ) && file_exists( $file_path ) ) {
                                        $size_bytes = (int) filesize( $file_path );
                                        $sort_size_bytes = $size_bytes;
                                        $size_human = size_format( $size_bytes, 2 );
                                    }
                                }

                                $share_time_tooltip = '';
                                if ($share_time_limit_enabled && $is_foreign && !empty($share_ctx_current['is_shared'])) {
                                    $starts_ts = isset($share_ctx_current['starts_ts']) ? (int) $share_ctx_current['starts_ts'] : 0;
                                    $expires_ts = isset($share_ctx_current['expires_ts']) ? (int) $share_ctx_current['expires_ts'] : 0;

                                    if ($starts_ts > 0 || $expires_ts > 0) {
                                        $tooltip_parts = array();
                                        if ($starts_ts > 0) {
                                            $tooltip_parts[] = sprintf(
                                                /* translators: %s: start date. */
                                                __( 'From: %s', 'nnax-frontend-user-files' ),
                                                wp_date( 'd.m.Y', $starts_ts, wp_timezone() )
                                            );
                                        }
                                        if ($expires_ts > 0) {
                                            $tooltip_parts[] = sprintf(
                                                /* translators: %s: end date. */
                                                __( 'Until: %s', 'nnax-frontend-user-files' ),
                                                wp_date( 'd.m.Y', $expires_ts, wp_timezone() )
                                            );
                                        }

                                        $share_time_tooltip = __('Access period', 'nnax-frontend-user-files');
                                        if (!empty($tooltip_parts)) {
                                            $share_time_tooltip .= ' - ' . implode(' | ', $tooltip_parts);
                                        }

                                        if ($expires_ts > 0) {
                                            $now_ts = current_time('timestamp');
                                            if ($expires_ts >= $now_ts) {
                                                $remaining_days = (int) ceil(max(0, $expires_ts - $now_ts) / DAY_IN_SECONDS);
                                                $share_time_tooltip .= ' | ' . sprintf(
                                                    /* translators: %s: number of days remaining. */
                                                    _n( '%s day remaining', '%s days remaining', $remaining_days, 'nnax-frontend-user-files' ),
                                                    number_format_i18n($remaining_days)
                                                );
                                            }
                                        }
                                    }
                                }

                            ?>

                                <tr class="nnaxfuf-item-row <?php echo $is_folder ? 'nnaxfuf-row-folder' : 'nnaxfuf-row-file'; ?>"
                                    tabindex="0"
                                    data-nnaxfuf-row-type="<?php echo esc_attr($row_type); ?>"
                                    data-nnaxfuf-open-url="<?php echo esc_url($row_open_url); ?>"
                                    data-nnaxfuf-id="<?php echo esc_attr($item_id); ?>"
                                    data-nnaxfuf-sort-name="<?php echo esc_attr(wp_strip_all_tags($item->post_title)); ?>"
                                    data-nnaxfuf-sort-size="<?php echo esc_attr((string) $sort_size_bytes); ?>"
                                    data-nnaxfuf-sort-date="<?php echo esc_attr((string) get_post_modified_time('U', true, $item)); ?>"
                                    data-nnaxfuf-sort-group="<?php echo esc_attr($is_folder ? '0' : '1'); ?>">

                                    <td class="uk-table-shrink nnaxfuf-col-select" data-label="">
                                        <?php if ($current_view !== 'trash') : ?>
                                            <input
                                                class="uk-checkbox nnaxfuf-bulk-item-checkbox"
                                                type="checkbox"
                                                value="<?php echo esc_attr(($is_folder ? 'folder:' : 'file:') . $item_id); ?>"
                                                data-nnaxfuf-can-move="<?php echo esc_attr( $can_edit_item ? '1' : '0' ); ?>"
                                                data-nnaxfuf-can-delete="<?php echo esc_attr( $can_delete_item ? '1' : '0' ); ?>"
                                                aria-label="<?php echo esc_attr__('Select item', 'nnax-frontend-user-files'); ?>">
                                        <?php else : ?>
                                            <input
                                                class="uk-checkbox nnaxfuf-bulk-item-checkbox uk-hidden"
                                                type="checkbox"
                                                value=""
                                                data-nnaxfuf-can-move="0"
                                                data-nnaxfuf-can-delete="0"
                                                aria-hidden="true"
                                                tabindex="-1"
                                                disabled>
                                        <?php endif; ?>

                                        <span class="nnaxfuf-row-mobile-tooltip-slot" data-nnaxfuf-mobile-tooltip-slot></span>
                                        
                                        <button type="button"
                                            class="uk-button uk-button-text uk-padding-remove nnaxfuf-row-mobile-toggle uk-hidden@m"
                                            aria-expanded="false"
                                            aria-label="<?php echo esc_attr__('Details', 'nnax-frontend-user-files'); ?>">
                                            <span class="nnaxfuf-row-mobile-toggle-icon" uk-icon="icon: chevron-down; ratio: 0.9"></span>
                                        </button>
                                    </td>

                                    <!-- NAME -->
                                    <td class="nnaxfuf-col-name" data-label="<?php echo esc_attr__('Name', 'nnax-frontend-user-files'); ?>">
                                        <?php $full_title = isset( $item->post_title ) ? (string) $item->post_title : ''; ?>
                                        <!-- FOLDER -->
                                        <?php if ($is_folder) : ?>
                                            <a class="nnaxfuf-item-link"
                                                href="<?php echo esc_url(NNAXFUF_Helpers::get_file_manager_url(
                                                    array( NNAXFUF_Plugin::FOLDER_VAR => $item_id )
                                                )); ?>"
                                                title="<?php echo esc_attr($full_title); ?>">
                                                <span uk-icon="icon: folder"></span>
                                                <span class="uk-margin-small-left nnaxfuf-name-ellipsis">
                                                    <?php echo esc_html($full_title); ?>
                                                </span>

                                                <?php if ( $sharing_active && ($is_foreign || (!$is_foreign && $shared_count > 0)) ) : ?>
                                                    <span class="nnaxfuf-row-mobile-tooltip-anchor" data-nnaxfuf-mobile-tooltip-anchor></span>
                                                    <span class="nnaxfuf-row-mobile-tooltip-group" data-nnaxfuf-mobile-tooltip-group>
                                                        <?php if ($is_foreign) : ?>
                                                            <?php $shared_with_you_tooltip = $owner ? sprintf(
                                                                /* translators: %s: owner display name. */
                                                                __( 'Shared with you: %s', 'nnax-frontend-user-files' ),
                                                                $owner->display_name
                                                            ) : __( 'Shared with you', 'nnax-frontend-user-files' ); ?>
                                                            <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                    title="<?php echo esc_attr($shared_with_you_tooltip); ?>"
                                                                    uk-tooltip>
                                                                <span uk-icon="icon: user; ratio: 0.9"></span>
                                                            </span>
                                                            <?php if ($share_time_tooltip !== '') : ?>
                                                                <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                        title="<?php echo esc_attr($share_time_tooltip); ?>"
                                                                        uk-tooltip>
                                                                    <span uk-icon="icon: future; ratio: 0.85"></span>
                                                                </span>
                                                            <?php endif; ?>
                                                        <?php endif; ?>

                                                        <?php if (!$is_foreign && $shared_count > 0) : ?>
                                                            <?php
                                                                $shared_with_tooltip = sprintf(
                                                                    /* translators: %d: number of users. */
                                                                    _n( 'Shared with %d user', 'Shared with %d users', $shared_count, 'nnax-frontend-user-files' ),
                                                                    $shared_count
                                                                );
                                                            ?>
                                                            <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                    title="<?php echo esc_attr($shared_with_tooltip); ?>"
                                                                    uk-tooltip>
                                                                <span uk-icon="icon: users; ratio: 0.9"></span>
                                                            </span>
                                                        <?php endif; ?>
                                                    </span>
                                                <?php endif; ?>
                                            </a>
                                            
                                        <!-- FILE -->
                                        <?php else : ?>

                                            <?php
                                            $file_url = get_post_meta($item_id, NNAXFUF_Plugin::META_FILEURL, true);
                                            $file_url = set_url_scheme($file_url);

                                            $download_link = NNAXFUF_Helpers::get_download_url($item_id);

                                            $file_type_info = NNAXFUF_Helpers::nnaxfuf_get_file_type_from_url($file_url);
                                            $type_slug      = $file_type_info['type'];
                                            $type_label     = $file_type_info['label'];
                                            ?>

                                            <span class="nnaxfuf-file-badge nnaxfuf-file-badge--<?php echo esc_attr($type_slug); ?>">
                                                <?php echo esc_html($type_label); ?>
                                            </span>

                                            <?php if ($type_slug === 'image') : ?>
                                                <div class="nnaxfuf-list-thumb">
                                                    <img src="<?php echo esc_url(NNAXFUF_Helpers::get_download_url($item_id, 'inline')); ?>" alt="">
                                                </div>
                                            <?php endif; ?>

                                            <span class="nnaxfuf-file-title uk-margin-small-left nnaxfuf-name-ellipsis"
                                                title="<?php echo esc_attr($full_title); ?>">
                                                <?php echo esc_html($full_title); ?>
                                            </span>

                                            <?php if ( ( $sharing_active && ($is_foreign || (!$is_foreign && $shared_count > 0)) ) || $trash_parent_tooltip !== '' ) : ?>
                                                <span class="nnaxfuf-row-mobile-tooltip-anchor" data-nnaxfuf-mobile-tooltip-anchor></span>
                                                <span class="nnaxfuf-row-mobile-tooltip-group" data-nnaxfuf-mobile-tooltip-group>
                                                    <?php if ($is_foreign) : ?>
                                                        <?php $shared_with_you_tooltip = $owner ? sprintf(
                                                            /* translators: %s: owner display name. */
                                                            __( 'Shared with you: %s', 'nnax-frontend-user-files' ),
                                                            $owner->display_name
                                                        ) : __( 'Shared with you', 'nnax-frontend-user-files' ); ?>
                                                        <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                title="<?php echo esc_attr($shared_with_you_tooltip); ?>"
                                                                uk-tooltip>
                                                            <span uk-icon="icon: user; ratio: 0.9"></span>
                                                        </span>
                                                        <?php if ($share_time_tooltip !== '') : ?>
                                                            <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                    title="<?php echo esc_attr($share_time_tooltip); ?>"
                                                                    uk-tooltip>
                                                                <span uk-icon="icon: future; ratio: 0.85"></span>
                                                            </span>
                                                        <?php endif; ?>
                                                    <?php endif; ?>
                                                    <?php if (!$is_foreign && $shared_count > 0) : ?>
                                                        <?php
                                                            $shared_with_tooltip = sprintf(
                                                                /* translators: %d: number of users. */
                                                                _n( 'Shared with %d user', 'Shared with %d users', $shared_count, 'nnax-frontend-user-files' ),
                                                                $shared_count
                                                            );
                                                        ?>
                                                        <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                title="<?php echo esc_attr($shared_with_tooltip); ?>"
                                                                uk-tooltip>
                                                            <span uk-icon="icon: users; ratio: 0.9"></span>
                                                        </span>
                                                    <?php endif; ?>
                                                    <?php if ($trash_parent_tooltip !== '') : ?>
                                                        <span class="uk-margin-small-left uk-text-muted nnaxfuf-tooltip"
                                                                title="<?php echo esc_attr($trash_parent_tooltip); ?>"
                                                                uk-tooltip>
                                                            <span uk-icon="icon: folder; ratio: 0.9"></span>
                                                        </span>
                                                    <?php endif; ?>
                                                </span>
                                            <?php endif; ?>

                                        <?php endif; ?>
                                    </td>

                                    <!-- SIZE -->
                                    <td class="nnaxfuf-col-size" data-label="<?php echo esc_attr__('Size', 'nnax-frontend-user-files'); ?>"><?php echo esc_html($size_human); ?></td>

                                    <!-- MODIFIED -->
                                    <td class="nnaxfuf-col-modified" data-label="<?php echo esc_attr__('Modified', 'nnax-frontend-user-files'); ?>"><?php echo esc_html($changed_date); ?></td>

                                    <?php do_action( 'nnaxfuf_file_manager_table_row_after_modified', $item, $current_user_id ); ?>

                                    <!-- ACTIONS -->
                                    <td class="uk-text-right nnaxfuf-col-actions" data-label="<?php echo esc_attr__('Actions', 'nnax-frontend-user-files'); ?>">
                                        <div class="nnaxfuf-actions">
                                            <button type="button"
                                                class="uk-button uk-button-default uk-button-small nnaxfuf-actions-btn"
                                                aria-label="<?php echo esc_attr__('Actions', 'nnax-frontend-user-files'); ?>">
                                                <span uk-icon="icon: more-vertical"></span>
                                            </button>

                                            <div class="nnaxfuf-actions-dropdown uk-padding-small"
                                                uk-dropdown="mode: click; pos: bottom-right; boundary: !.nnaxfuf-file-manager; boundary-align: true; flip: true; container: body">

                                                <ul class="uk-nav uk-dropdown-nav">
                                                    <?php if ($current_view === 'trash') : ?>

                                                        <?php if ($can_restore_item) : ?>
                                                            <li>
                                                                <form method="post" action="<?php echo esc_url( $frontend_form_action_url ); ?>" class="uk-margin-remove">
                                                                    <?php wp_nonce_field('nnaxfuf_restore_item', 'nnaxfuf_nonce'); ?>
                                                                    <input type="hidden" name="action" value="nnaxfuf_restore_item">
                                                                    <input type="hidden" name="nnaxfuf_item_id" value="<?php echo esc_attr($item_id); ?>">
                                                                    <input type="hidden" name="nnaxfuf_item_type" value="<?php echo $is_folder ? 'folder' : 'file'; ?>">
                                                                    <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                                                    <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                                                    <button type="submit" class="uk-button uk-button-text uk-width-1-1">
                                                                        <span uk-icon="icon: reply"></span>
                                                                        <span class="uk-margin-small-left"><?php esc_html_e('Restore', 'nnax-frontend-user-files'); ?></span>
                                                                    </button>
                                                                </form>
                                                            </li>
                                                        <?php endif; ?>

                                                        <?php if ($can_permanent_delete_item) : ?>
                                                            <li class="uk-text-danger">
                                                                <form method="post"
                                                                    action="<?php echo esc_url( $frontend_form_action_url ); ?>"
                                                                    class="uk-margin-remove nnaxfuf-confirm-submit"
                                                                    data-nnaxfuf-confirm-message="<?php echo esc_attr__('Delete permanently?', 'nnax-frontend-user-files'); ?>">
                                                                    <?php wp_nonce_field('nnaxfuf_delete_item_permanently', 'nnaxfuf_nonce'); ?>
                                                                    <input type="hidden" name="action" value="nnaxfuf_delete_item_permanently">
                                                                    <input type="hidden" name="nnaxfuf_item_id" value="<?php echo esc_attr($item_id); ?>">
                                                                    <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                                                    <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                                                    <button type="submit" class="uk-button uk-button-text uk-text-danger uk-width-1-1">
                                                                        <span uk-icon="icon: close"></span>
                                                                        <span class="uk-margin-small-left"><?php esc_html_e('Delete Permanently', 'nnax-frontend-user-files'); ?></span>
                                                                    </button>
                                                                </form>
                                                            </li>
                                                        <?php endif; ?>

                                                        <?php if (!$can_restore_item && !$can_permanent_delete_item) : ?>
                                                            <li class="uk-text-muted"><?php esc_html_e('No actions available.', 'nnax-frontend-user-files'); ?></li>
                                                        <?php endif; ?>

                                                    <?php else : ?>

                                                        <?php if ($is_folder) : ?>

                                                            <?php $folder_zip_download_link = NNAXFUF_Helpers::get_folder_zip_download_url($item_id); ?>
                                                            <li>
                                                                <button type="button"
                                                                    class="uk-button uk-button-text nnaxfuf-open-detail-modal uk-width-1-1"
                                                                    uk-toggle="target: #nnaxfuf-detail-modal"
                                                                    data-nnaxfuf-item-id="<?php echo esc_attr($item_id); ?>">
                                                                    <span uk-icon="icon: info"></span>
                                                                    <span class="uk-margin-small-left"><?php echo esc_html($can_edit_item ? __('Details / Rename', 'nnax-frontend-user-files') : __('Details', 'nnax-frontend-user-files')); ?></span>
                                                                </button>
                                                            </li>

                                                            <li>
                                                                <a class="uk-button uk-button-text" href="<?php echo esc_url($folder_zip_download_link); ?>">
                                                                    <span uk-icon="icon: download"></span>
                                                                    <span class="uk-margin-small-left"><?php esc_html_e('Download as ZIP', 'nnax-frontend-user-files'); ?></span>
                                                                </a>
                                                            </li>

                                                            <?php if ($can_edit_item) : ?>
                                                                <li>
                                                                    <button type="button"
                                                                        class="uk-button uk-button-text nnaxfuf-open-move-folder-modal uk-width-1-1"
                                                                        uk-toggle="target: #nnaxfuf-move-folder-modal"
                                                                        data-nnaxfuf-folder-id="<?php echo esc_attr($item_id); ?>"
                                                                        data-nnaxfuf-folder-title="<?php echo esc_attr( isset( $item->post_title ) ? (string) $item->post_title : '' ); ?>"
                                                                        data-nnaxfuf-folder-parent-id="<?php echo esc_attr((int) $item->post_parent); ?>">
                                                                        <span uk-icon="icon: move"></span>
                                                                        <span class="uk-margin-small-left"><?php esc_html_e('Move Folder', 'nnax-frontend-user-files'); ?></span>
                                                                    </button>
                                                                </li>
                                                            <?php endif; ?>

                                                            <?php if ( $sharing_active && $can_share_item ) : ?>
                                                                <li>
                                                                    <button type="button"
                                                                        class="uk-button uk-button-text nnaxfuf-open-share-modal uk-width-1-1"
                                                                        uk-toggle="target: #nnaxfuf-share-modal"
                                                                        data-nnaxfuf-item-type="folder"
                                                                        data-nnaxfuf-folder-id="<?php echo esc_attr($item_id); ?>"
                                                                        data-nnaxfuf-item-title="<?php echo esc_attr( isset( $item->post_title ) ? (string) $item->post_title : '' ); ?>">
                                                                        <span uk-icon="icon: users"></span>
                                                                        <span class="uk-margin-small-left"><?php esc_html_e('Share Folder', 'nnax-frontend-user-files'); ?></span>
                                                                    </button>
                                                                </li>

                                                                <li>
                                                                    <form method="post"
                                                                        action="<?php echo esc_url( $frontend_form_action_url ); ?>"
                                                                        class="uk-margin-remove nnaxfuf-confirm-submit"
                                                                        data-nnaxfuf-confirm-message="<?php echo esc_attr__('This applies the current folder shares to all subfolders and files. Existing shares in subfolders/files may be overwritten. Continue?', 'nnax-frontend-user-files'); ?>"
                                                                        data-nnaxfuf-confirm-ok-label="<?php echo esc_attr__('Apply shares', 'nnax-frontend-user-files'); ?>"
                                                                        data-nnaxfuf-confirm-ok-class="uk-button uk-button-primary">
                                                                        <?php wp_nonce_field('nnaxfuf_sync_folder_share', 'nnaxfuf_nonce'); ?>
                                                                        <input type="hidden" name="action" value="nnaxfuf_sync_folder_share">
                                                                        <input type="hidden" name="nnaxfuf_folder_id" value="<?php echo esc_attr($item_id); ?>">
                                                                        <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                                                        <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                                                        <button type="submit"
                                                                            class="uk-button uk-button-text uk-width-1-1"
                                                                            title="<?php echo esc_attr__('Applies this folder\'s shares to all subfolders and files.', 'nnax-frontend-user-files'); ?>"
                                                                            uk-tooltip>
                                                                            <span uk-icon="icon: refresh"></span>
                                                                            <span class="uk-margin-small-left"><?php esc_html_e('Sync Shares', 'nnax-frontend-user-files'); ?></span>
                                                                        </button>
                                                                    </form>
                                                                </li>
                                                            <?php endif; ?>

                                                            <?php if ($can_delete_item) : ?>
                                                                <li class="uk-text-danger">
                                                                    <button type="button"
                                                                        class="uk-button uk-button-text uk-text-danger nnaxfuf-open-delete-folder-modal uk-width-1-1"
                                                                        uk-toggle="target: #nnaxfuf-delete-folder-modal"
                                                                        data-nnaxfuf-folder-id="<?php echo esc_attr($item_id); ?>"
                                                                        data-nnaxfuf-folder-title="<?php echo esc_attr( isset( $item->post_title ) ? (string) $item->post_title : '' ); ?>">
                                                                        <span uk-icon="icon: trash"></span>
                                                                        <span class="uk-margin-small-left"><?php esc_html_e('Delete Folder', 'nnax-frontend-user-files'); ?></span>
                                                                    </button>
                                                                </li>
                                                            <?php endif; ?>

                                                        <?php else : ?>
                                                            <?php
                                                            $download_link = NNAXFUF_Helpers::get_download_url($item_id);
                                                            ?>

                                                            <li>
                                                                <button type="button"
                                                                    class="uk-button uk-button-text nnaxfuf-open-detail-modal uk-width-1-1"
                                                                    uk-toggle="target: #nnaxfuf-detail-modal"
                                                                    data-nnaxfuf-item-id="<?php echo esc_attr($item_id); ?>">
                                                                    <span uk-icon="icon: info"></span>
                                                                    <span class="uk-margin-small-left"><?php esc_html_e('Details', 'nnax-frontend-user-files'); ?></span>
                                                                </button>
                                                            </li>

                                                            <li>
                                                                <a class="uk-button uk-button-text" href="<?php echo esc_url($download_link); ?>">
                                                                    <span uk-icon="icon: download"></span>
                                                                    <span class="uk-margin-small-left"><?php esc_html_e('Download', 'nnax-frontend-user-files'); ?></span>
                                                                </a>
                                                            </li>

                                                            <?php if ($can_edit_item) : ?>
                                                                <li>
                                                                    <button type="button"
                                                                        class="uk-button uk-button-text nnaxfuf-open-move-file-modal uk-width-1-1"
                                                                        uk-toggle="target: #nnaxfuf-move-file-modal"
                                                                        data-nnaxfuf-file-id="<?php echo esc_attr($item_id); ?>"
                                                                        data-nnaxfuf-file-title="<?php echo esc_attr( isset( $item->post_title ) ? (string) $item->post_title : '' ); ?>"
                                                                        data-nnaxfuf-file-owner-id="<?php echo esc_attr((int) $owner_id); ?>"
                                                                        data-nnaxfuf-file-parent-id="<?php echo esc_attr((int) $item->post_parent); ?>">
                                                                        <span uk-icon="icon: move"></span>
                                                                        <span class="uk-margin-small-left"><?php esc_html_e('Move File', 'nnax-frontend-user-files'); ?></span>
                                                                    </button>
                                                                </li>

                                                                <?php if ( $sharing_active && $can_share_item ) : ?>
                                                                    <li>
                                                                        <button type="button"
                                                                            class="uk-button uk-button-text nnaxfuf-open-share-modal uk-width-1-1"
                                                                            uk-toggle="target: #nnaxfuf-share-modal"
                                                                            data-nnaxfuf-item-type="file"
                                                                            data-nnaxfuf-file-id="<?php echo esc_attr($item_id); ?>"
                                                                            data-nnaxfuf-item-title="<?php echo esc_attr( isset( $item->post_title ) ? (string) $item->post_title : '' ); ?>">
                                                                            <span uk-icon="icon: users"></span>
                                                                            <span class="uk-margin-small-left"><?php esc_html_e('Share', 'nnax-frontend-user-files'); ?></span>
                                                                        </button>
                                                                    </li>
                                                                <?php endif; ?>

                                                                <?php if ($can_delete_item) : ?>
                                                                    <li class="uk-text-danger">
                                                                        <form method="post"
                                                                            action="<?php echo esc_url( $frontend_form_action_url ); ?>"
                                                                            class="uk-margin-remove nnaxfuf-confirm-submit"
                                                                            data-nnaxfuf-confirm-message="<?php echo esc_attr__('Delete file?', 'nnax-frontend-user-files'); ?>">
                                                                            <?php wp_nonce_field('nnaxfuf_delete_file', 'nnaxfuf_nonce'); ?>
                                                                            <input type="hidden" name="action" value="nnaxfuf_delete_file">
                                                                            <input type="hidden" name="nnaxfuf_file_id" value="<?php echo esc_attr($item_id); ?>">
                                                                            <input type="hidden" name="nnaxfuf_redirect_to" value="<?php echo esc_url( $frontend_redirect_url ); ?>">
                                                                            <input type="hidden" name="nnaxfuf_notice_key" value="<?php echo esc_attr( $frontend_notice_key ); ?>">
                                                                            <button type="submit" class="uk-button uk-button-text uk-text-danger uk-width-1-1">
                                                                                <span uk-icon="icon: trash"></span>
                                                                                <span class="uk-margin-small-left"><?php esc_html_e('Delete', 'nnax-frontend-user-files'); ?></span>
                                                                            </button>
                                                                        </form>
                                                                    </li>
                                                                <?php endif; ?>
                                                            <?php else : ?>
                                                                <li class="uk-text-muted"><?php esc_html_e('Only download/details available', 'nnax-frontend-user-files'); ?></li>
                                                            <?php endif; ?>

                                                        <?php endif; ?>

                                                    <?php endif; ?>
                                                </ul>
                                            </div>
                                        </div>
                                    </td>
                                </tr>

                            <?php endforeach; ?>
                            <?php else : ?>
                                <tr>
                                    <td colspan="6" class="uk-text-center uk-text-muted">
                                        <?php esc_html_e('No files or folders found.', 'nnax-frontend-user-files'); ?>
                                    </td>
                                </tr>
                            <?php endif; ?>

                        </tbody>
                    </table>
                </div>

                <?php if ( empty( $show_all_items ) && $total_pages > 1 ) : ?>
                    <div class="uk-margin-medium-top uk-flex uk-flex-between uk-flex-middle nnaxfuf-pagination-wrapper">
                        <div class="uk-text-small uk-text-muted">
                            <?php
                            /* translators: %d: total number of items. */
                            echo esc_html( sprintf( _n( '%d item total', '%d items total', $total_items, 'nnax-frontend-user-files' ), $total_items ) );
                            ?>
                        </div>
                        <ul class="uk-pagination uk-margin-remove" uk-margin>
                            <?php if ( $paged > 1 ) : ?>
                                <li>
                                    <a href="<?php echo esc_url( NNAXFUF_Helpers::get_file_manager_url( array( NNAXFUF_Plugin::PAGED_VAR => $paged - 1 ) ) ); ?>">
                                        <span uk-pagination-previous></span>
                                    </a>
                                </li>
                            <?php endif; ?>

                            <?php
                            $range = 2; // Number of pages to show before and after current
                            for ( $i = 1; $i <= $total_pages; $i++ ) {
                                if ( $i === 1 || $i === $total_pages || ( $i >= $paged - $range && $i <= $paged + $range ) ) {
                                    if ( $i === $paged ) {
                                        echo '<li class="uk-active"><span>' . esc_html( (string) $i ) . '</span></li>';
                                    } else {
                                        echo '<li><a href="' . esc_url( NNAXFUF_Helpers::get_file_manager_url( array( NNAXFUF_Plugin::PAGED_VAR => $i ) ) ) . '">' . esc_html( (string) $i ) . '</a></li>';
                                    }
                                } elseif ( ( $i === 2 && $paged > $range + 2 ) || ( $i === $total_pages - 1 && $paged < $total_pages - $range - 1 ) ) {
                                    echo '<li class="uk-disabled"><span>...</span></li>';
                                }
                            }
                            ?>

                            <?php if ( $paged < $total_pages ) : ?>
                                <li>
                                    <a href="<?php echo esc_url( NNAXFUF_Helpers::get_file_manager_url( array( NNAXFUF_Plugin::PAGED_VAR => $paged + 1 ) ) ); ?>">
                                        <span uk-pagination-next></span>
                                    </a>
                                </li>
                            <?php endif; ?>
                        </ul>
                    </div>
                <?php endif; ?>
            <?php endif; ?>

            <?php if ( $current_view !== 'trash' ) : ?>
            <!-- Aktionen -->
            <div class="uk-margin-medium-top uk-flex uk-flex-right uk-flex-middle">
                <div class="uk-flex uk-flex-middle uk-flex-right uk-grid-small" uk-grid>

                    <?php if ($can_manage_current_folder) : ?>
                        <!-- Neuer Ordner -->
                        <div class="uk-width-1-1 uk-width-auto@s">
                            <button
                                type="button"
                                class="uk-button uk-button-secondary uk-button-small uk-width-1-1"
                                uk-toggle="target: #nnaxfuf-create-folder-modal">
                                <span uk-icon="icon: folder"></span>
                                <span class="uk-margin-small-left"><?php esc_html_e('New Folder', 'nnax-frontend-user-files'); ?></span>
                            </button>
                        </div>

                        <!-- Dateien hochladen -->
                        <div class="uk-width-1-1 uk-width-auto@s">
                            <button
                                type="button"
                                class="uk-button uk-button-primary uk-button-small uk-width-1-1"
                                uk-toggle="target: #nnaxfuf-upload-modal">
                                <span uk-icon="icon: upload"></span>
                                <span class="uk-margin-small-left"><?php esc_html_e('Upload File(s)', 'nnax-frontend-user-files'); ?></span>
                            </button>
                        </div>
                    <?php else : ?>
                        <div class="uk-text-muted uk-text-small">
                            <?php esc_html_e('In this shared folder you cannot upload files or create subfolders without admin permissions.', 'nnax-frontend-user-files'); ?>
                        </div>
                    <?php endif; ?>

                </div>
            </div>
            <?php endif; ?>

        </div>

    </div>
</div>

<?php
// Only include the share modal when the Sharing Addon is active. We must
// keep stored share metadata intact even when the Addon is deactivated,
// but the UI should be hidden to avoid exposing sharing controls.
if ( ! empty( $sharing_active ) ) {
    require rtrim( NNAXFUF_SHARE_ADDON_PATH, '/' ) . '/templates/partials/modals/share.php';
}
require __DIR__ . '/partials/modals/detail.php';
require __DIR__ . '/partials/modals/upload.php';
require __DIR__ . '/partials/modals/create-folder.php';
require __DIR__ . '/partials/modals/delete-folder.php';
require __DIR__ . '/partials/modals/move-folder.php';
require __DIR__ . '/partials/modals/move-file.php';
require __DIR__ . '/partials/modals/bulk-move.php';
require __DIR__ . '/partials/modals/info.php';
require __DIR__ . '/partials/modals/help.php';
do_action( 'nnaxfuf_file_manager_after_modals' );
?>
