Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/controller/PhabricatorFileViewController.php
| Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| $file_content = $this->newFileContent($file); | $file_content = $this->newFileContent($file); | ||||
| $view = id(new PHUITwoColumnView()) | $view = id(new PHUITwoColumnView()) | ||||
| ->setHeader($header) | ->setHeader($header) | ||||
| ->setCurtain($curtain) | ->setCurtain($curtain) | ||||
| ->setMainColumn( | ->setMainColumn( | ||||
| array( | array( | ||||
| $object_box, | |||||
| $file_content, | $file_content, | ||||
| $object_box, | |||||
| $timeline, | $timeline, | ||||
| )); | )); | ||||
| return $this->newPage() | return $this->newPage() | ||||
| ->setTitle($title) | ->setTitle($title) | ||||
| ->setCrumbs($crumbs) | ->setCrumbs($crumbs) | ||||
| ->setPageObjectPHIDs(array($file->getPHID())) | ->setPageObjectPHIDs(array($file->getPHID())) | ||||
| ->appendChild($view); | ->appendChild($view); | ||||
| ▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | $curtain->addAction( | ||||
| ->setDisabled(!$can_edit)); | ->setDisabled(!$can_edit)); | ||||
| $curtain->addAction( | $curtain->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName(pht('View Transforms')) | ->setName(pht('View Transforms')) | ||||
| ->setIcon('fa-crop') | ->setIcon('fa-crop') | ||||
| ->setHref($this->getApplicationURI("/transforms/{$id}/"))); | ->setHref($this->getApplicationURI("/transforms/{$id}/"))); | ||||
| $phids = array(); | |||||
| $viewer_phid = $viewer->getPHID(); | |||||
| $author_phid = $file->getAuthorPHID(); | |||||
| if ($author_phid) { | |||||
| $phids[] = $author_phid; | |||||
| } | |||||
| $handles = $viewer->loadHandles($phids); | |||||
| if ($author_phid) { | |||||
| $author_refs = id(new PHUICurtainObjectRefListView()) | |||||
| ->setViewer($viewer); | |||||
| $author_ref = $author_refs->newObjectRefView() | |||||
| ->setHandle($handles[$author_phid]) | |||||
| ->setEpoch($file->getDateCreated()) | |||||
| ->setHighlighted($author_phid === $viewer_phid); | |||||
| $curtain->newPanel() | |||||
| ->setHeaderText(pht('Authored By')) | |||||
| ->appendChild($author_refs); | |||||
| } | |||||
| $curtain->newPanel() | |||||
| ->setHeaderText(pht('Size')) | |||||
| ->appendChild(phutil_format_bytes($file->getByteSize())); | |||||
| $width = $file->getImageWidth(); | |||||
| $height = $file->getImageHeight(); | |||||
| if ($width || $height) { | |||||
| $curtain->newPanel() | |||||
| ->setHeaderText(pht('Dimensions')) | |||||
| ->appendChild( | |||||
| pht( | |||||
| "%spx \xC3\x97 %spx", | |||||
| new PhutilNumber($width), | |||||
| new PhutilNumber($height))); | |||||
| } | |||||
| return $curtain; | return $curtain; | ||||
| } | } | ||||
| private function buildPropertyViews( | private function buildPropertyViews( | ||||
| PHUIObjectBoxView $box, | PHUIObjectBoxView $box, | ||||
| PhabricatorFile $file) { | PhabricatorFile $file) { | ||||
| $request = $this->getRequest(); | $request = $this->getRequest(); | ||||
| $viewer = $request->getUser(); | $viewer = $request->getUser(); | ||||
| $tab_group = id(new PHUITabGroupView()); | $tab_group = id(new PHUITabGroupView()); | ||||
| $box->addTabGroup($tab_group); | $box->addTabGroup($tab_group); | ||||
| $properties = id(new PHUIPropertyListView()); | $finfo = new PHUIPropertyListView(); | ||||
| $tab_group->addTab( | $tab_group->addTab( | ||||
| id(new PHUITabView()) | id(new PHUITabView()) | ||||
| ->setName(pht('Details')) | ->setName(pht('Details')) | ||||
| ->setKey('details') | ->setKey('details') | ||||
| ->appendChild($properties)); | |||||
| if ($file->getAuthorPHID()) { | |||||
| $properties->addProperty( | |||||
| pht('Author'), | |||||
| $viewer->renderHandle($file->getAuthorPHID())); | |||||
| } | |||||
| $properties->addProperty( | |||||
| pht('Created'), | |||||
| phabricator_datetime($file->getDateCreated(), $viewer)); | |||||
| $finfo = id(new PHUIPropertyListView()); | |||||
| $tab_group->addTab( | |||||
| id(new PHUITabView()) | |||||
| ->setName(pht('File Info')) | |||||
| ->setKey('info') | |||||
| ->appendChild($finfo)); | ->appendChild($finfo)); | ||||
| $finfo->addProperty( | $finfo->addProperty( | ||||
| pht('Size'), | |||||
| phutil_format_bytes($file->getByteSize())); | |||||
| $finfo->addProperty( | |||||
| pht('Mime Type'), | pht('Mime Type'), | ||||
| $file->getMimeType()); | $file->getMimeType()); | ||||
| $ttl = $file->getTtl(); | $ttl = $file->getTtl(); | ||||
| if ($ttl) { | if ($ttl) { | ||||
| $delta = $ttl - PhabricatorTime::getNow(); | $delta = $ttl - PhabricatorTime::getNow(); | ||||
| $finfo->addProperty( | $finfo->addProperty( | ||||
| pht('Expires'), | pht('Expires'), | ||||
| pht( | pht( | ||||
| '%s (%s)', | '%s (%s)', | ||||
| phabricator_datetime($ttl, $viewer), | phabricator_datetime($ttl, $viewer), | ||||
| phutil_format_relative_time_detailed($delta))); | phutil_format_relative_time_detailed($delta))); | ||||
| } | } | ||||
| $width = $file->getImageWidth(); | |||||
| if ($width) { | |||||
| $finfo->addProperty( | |||||
| pht('Width'), | |||||
| pht('%s px', new PhutilNumber($width))); | |||||
| } | |||||
| $height = $file->getImageHeight(); | |||||
| if ($height) { | |||||
| $finfo->addProperty( | |||||
| pht('Height'), | |||||
| pht('%s px', new PhutilNumber($height))); | |||||
| } | |||||
| $is_image = $file->isViewableImage(); | $is_image = $file->isViewableImage(); | ||||
| if ($is_image) { | if ($is_image) { | ||||
| $image_string = pht('Yes'); | $image_string = pht('Yes'); | ||||
| $cache_string = $file->getCanCDN() ? pht('Yes') : pht('No'); | $cache_string = $file->getCanCDN() ? pht('Yes') : pht('No'); | ||||
| } else { | } else { | ||||
| $image_string = pht('No'); | $image_string = pht('No'); | ||||
| $cache_string = pht('Not Applicable'); | $cache_string = pht('Not Applicable'); | ||||
| } | } | ||||
| Show All 24 Lines | if ($file->getIsProfileImage()) { | ||||
| $types[] = pht('Profile'); | $types[] = pht('Profile'); | ||||
| } | } | ||||
| if ($types) { | if ($types) { | ||||
| $types = implode(', ', $types); | $types = implode(', ', $types); | ||||
| $finfo->addProperty(pht('Attributes'), $types); | $finfo->addProperty(pht('Attributes'), $types); | ||||
| } | } | ||||
| $storage_properties = new PHUIPropertyListView(); | $finfo->addProperty( | ||||
| pht('Storage Engine'), | |||||
| $tab_group->addTab( | |||||
| id(new PHUITabView()) | |||||
| ->setName(pht('Storage')) | |||||
| ->setKey('storage') | |||||
| ->appendChild($storage_properties)); | |||||
| $storage_properties->addProperty( | |||||
| pht('Engine'), | |||||
| $file->getStorageEngine()); | $file->getStorageEngine()); | ||||
| $engine = $this->loadStorageEngine($file); | $engine = $this->loadStorageEngine($file); | ||||
| if ($engine && $engine->isChunkEngine()) { | if ($engine && $engine->isChunkEngine()) { | ||||
| $format_name = pht('Chunks'); | $format_name = pht('Chunks'); | ||||
| } else { | } else { | ||||
| $format_key = $file->getStorageFormat(); | $format_key = $file->getStorageFormat(); | ||||
| $format = PhabricatorFileStorageFormat::getFormat($format_key); | $format = PhabricatorFileStorageFormat::getFormat($format_key); | ||||
| if ($format) { | if ($format) { | ||||
| $format_name = $format->getStorageFormatName(); | $format_name = $format->getStorageFormatName(); | ||||
| } else { | } else { | ||||
| $format_name = pht('Unknown ("%s")', $format_key); | $format_name = pht('Unknown ("%s")', $format_key); | ||||
| } | } | ||||
| } | } | ||||
| $storage_properties->addProperty(pht('Format'), $format_name); | $finfo->addProperty(pht('Storage Format'), $format_name); | ||||
| $storage_properties->addProperty( | $finfo->addProperty( | ||||
| pht('Handle'), | pht('Storage Handle'), | ||||
| $file->getStorageHandle()); | $file->getStorageHandle()); | ||||
| $phids = $file->getObjectPHIDs(); | $phids = $file->getObjectPHIDs(); | ||||
| if ($phids) { | if ($phids) { | ||||
| $attached = new PHUIPropertyListView(); | $attached = new PHUIPropertyListView(); | ||||
| $tab_group->addTab( | $tab_group->addTab( | ||||
| ▲ Show 20 Lines • Show All 96 Lines • Show Last 20 Lines | |||||