* Retrieves shared folder data based on a share token. */
(string $token, ?string $providedPass, int $page = 1, int $itemsPerPage = 10, string $subPath = '')
| 2686 | * Retrieves shared folder data based on a share token. |
| 2687 | */ |
| 2688 | public static function getSharedFolderData(string $token, ?string $providedPass, int $page = 1, int $itemsPerPage = 10, string $subPath = ''): array |
| 2689 | { |
| 2690 | $ctx = self::resolveSharedFolderContext($token, $providedPass, $subPath); |
| 2691 | if (isset($ctx['error']) || isset($ctx['needs_password'])) { |
| 2692 | return $ctx; |
| 2693 | } |
| 2694 | |
| 2695 | if (!empty($ctx['hideListing'])) { |
| 2696 | $ctx['entries'] = []; |
| 2697 | $ctx['currentPage'] = 1; |
| 2698 | $ctx['totalPages'] = 1; |
| 2699 | $ctx['totalEntries'] = 0; |
| 2700 | return $ctx; |
| 2701 | } |
| 2702 | |
| 2703 | $allEntries = $ctx['entries'] ?? []; |
| 2704 | |
| 2705 | $totalEntries = count($allEntries); |
| 2706 | $totalPages = max(1, (int)ceil($totalEntries / max(1, $itemsPerPage))); |
| 2707 | $currentPage = min(max(1, $page), $totalPages); |
| 2708 | $startIndex = ($currentPage - 1) * $itemsPerPage; |
| 2709 | $entriesOnPage = array_slice($allEntries, $startIndex, $itemsPerPage); |
| 2710 | |
| 2711 | $ctx['entries'] = $entriesOnPage; |
| 2712 | $ctx['currentPage'] = $currentPage; |
| 2713 | $ctx['totalPages'] = $totalPages; |
| 2714 | $ctx['totalEntries'] = $totalEntries; |
| 2715 | return $ctx; |
| 2716 | } |
| 2717 | |
| 2718 | public static function getSharedUploadContext(string $token, ?string $providedPass, string $subPath = ''): array |
| 2719 | { |
no test coverage detected