phid = $data['phid']; $this->view = $data['view']; } public function processRequest() { $file = id(new PhabricatorFile())->loadOneWhere( 'phid = %s', $this->phid); if (!$file) { return new Aphront404Response(); } switch ($this->view) { case 'download': case 'view': $data = $file->loadFileData(); $response = new AphrontFileResponse(); $response->setContent($data); $response->setMimeType($file->getMimeType()); if ($this->view == 'download') { $response->setDownload($file->getName()); } return $response; default: break; } $form = new AphrontFormView(); $form->setAction('/file/view/'.$file->getPHID().'/'); $form->setUser($this->getRequest()->getUser()); $form ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Name') ->setName('name') ->setValue($file->getName())) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('PHID') ->setName('phid') ->setValue($file->getPHID())) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Created') ->setName('created') ->setValue(date('Y-m-d g:i:s A', $file->getDateCreated()))) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Mime Type') ->setName('mime') ->setValue($file->getMimeType())) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Size') ->setName('size') ->setValue($file->getByteSize().' bytes')) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Engine') ->setName('storageEngine') ->setValue($file->getStorageEngine())) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Format') ->setName('storageFormat') ->setValue($file->getStorageFormat())) ->appendChild( id(new AphrontFormStaticControl()) ->setLabel('Handle') ->setName('storageHandle') ->setValue($file->getStorageHandle())) ->appendChild( id(new AphrontFormSubmitControl()) ->setValue('View File')); $panel = new AphrontPanelView(); $panel->setHeader('File Info - '.$file->getName()); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); return $this->buildStandardPageResponse( array($panel), array( 'title' => 'File Info - '.$file->getName(), )); } }