Provide a rudimentary "Attached Files" curtain UI panel
[phabricator.git] / src / applications / files / controller / PhabricatorFileUICurtainListController.php
blob25d6fd65ed372b3fa90230c31cba8e2f59d090c6
1 <?php
3 final class PhabricatorFileUICurtainListController
4 extends PhabricatorFileController {
6 public function shouldAllowPublic() {
7 return true;
10 public function handleRequest(AphrontRequest $request) {
11 $viewer = $request->getViewer();
13 $object_phid = $request->getURIData('phid');
15 $object = id(new PhabricatorObjectQuery())
16 ->setViewer($viewer)
17 ->withPHIDs(array($object_phid))
18 ->executeOne();
19 if (!$object) {
20 return new Aphront404Response();
23 $attachments = id(new PhabricatorFileAttachmentQuery())
24 ->setViewer($viewer)
25 ->withObjectPHIDs(array($object->getPHID()))
26 ->needFiles(true)
27 ->execute();
29 $handles = $viewer->loadHandles(array($object_phid));
30 $object_handle = $handles[$object_phid];
32 $file_phids = mpull($attachments, 'getFilePHID');
33 $file_handles = $viewer->loadHandles($file_phids);
35 $list = id(new PHUIObjectItemListView())
36 ->setUser($viewer);
37 foreach ($attachments as $attachment) {
38 $file_phid = $attachment->getFilePHID();
39 $handle = $file_handles[$file_phid];
41 $item = id(new PHUIObjectItemView())
42 ->setHeader($handle->getFullName())
43 ->setHref($handle->getURI())
44 ->setDisabled($handle->isDisabled());
46 if ($handle->getImageURI()) {
47 $item->setImageURI($handle->getImageURI());
50 $list->addItem($item);
53 return $this->newDialog()
54 ->setViewer($viewer)
55 ->setWidth(AphrontDialogView::WIDTH_FORM)
56 ->setTitle(pht('Attached Files'))
57 ->setObjectList($list)
58 ->addCancelButton($object_handle->getURI(), pht('Close'));