From 82efb0bdb6b20dfa5a76a3b4dcde48441ecf252a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 4 Jul 2016 07:46:42 +0200 Subject: Add popover with filenames of multipaste to history Signed-off-by: Florian Pritz --- application/controllers/file.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'application/controllers') diff --git a/application/controllers/file.php b/application/controllers/file.php index 1f07ae4ec..1888b7c06 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -738,8 +738,27 @@ class File extends MY_Controller { foreach ($history["multipaste_items"] as $key => $item) { $size = 0; + $filenames = array(); + $files = array(); + $max_filenames = 10; + foreach ($item["items"] as $i) { $size += $history["items"][$i["id"]]["filesize"]; + $files[] = array( + "filename" => $history["items"][$i["id"]]['filename'], + "sort_order" => $i["sort_order"], + ); + } + + uasort($files, function ($a, $b) { + return $a['sort_order'] - $b['sort_order']; + }); + + $filenames = array_map(function ($a) {return $a['filename'];}, $files); + + if (count($filenames) > $max_filenames) { + $filenames = array_slice($filenames, 0, $max_filenames); + $filenames[] = "..."; } $history["items"][] = array( @@ -749,6 +768,7 @@ class File extends MY_Controller { "date" => $item["date"], "hash" => "", "filesize" => $size, + "preview_text" => implode("\n", $filenames), ); } -- cgit v1.2.3-24-g4f1b