mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-14 10:52:41 +01:00
b592630d72
Summary: Three changes here. - Add `setActionList()`, and use that to set the action list. - Add `setPropertyList()`, and use that to set the property list. These will let us add some apropriate CSS so we can fix the border issue, and get rid of a bunch of goofy `.x + .y` selectors. - Replace `addContent()` with `appendChild()`. This is just a consistency thing; `AphrontView` already provides `appendChild()`, and `addContent()` did the same thing. Test Plan: - Viewed "All Config". - Viewed a countdown. - Viewed a revision (add comment, change list, table of contents, comment, local commits, open revisions affecting these files, update history). - Viewed Diffusion (browse, change, history, repository, lint). - Viewed Drydock (resource, lease). - Viewed Files. - Viewed Herald. - Viewed Legalpad. - Viewed macro (edit, edit audio, view). - Viewed Maniphest. - Viewed Applications. - Viewed Paste. - Viewed People. - Viewed Phulux. - Viewed Pholio. - Viewed Phame (blog, post). - Viewed Phortune (account, product). - Viewed Ponder (questions, answers, comments). - Viewed Releeph. - Viewed Projects. - Viewed Slowvote. NOTE: Images in Files aren't on a black background anymore -- I assume that's on purpose? NOTE: Some jankiness in Phortune, I'll clean that up when I get back to it. Not related to this diff. Reviewers: chad Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D7174
246 lines
6.3 KiB
PHP
246 lines
6.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorFileInfoController extends PhabricatorFileController {
|
|
|
|
private $phid;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->phid = $data['phid'];
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$file = id(new PhabricatorFileQuery())
|
|
->setViewer($user)
|
|
->withPHIDs(array($this->phid))
|
|
->executeOne();
|
|
|
|
if (!$file) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$phid = $file->getPHID();
|
|
$xactions = id(new PhabricatorFileTransactionQuery())
|
|
->setViewer($user)
|
|
->withObjectPHIDs(array($phid))
|
|
->execute();
|
|
|
|
$this->loadHandles(array($file->getAuthorPHID()));
|
|
$header = id(new PHUIHeaderView())
|
|
->setHeader($file->getName());
|
|
|
|
$ttl = $file->getTTL();
|
|
if ($ttl !== null) {
|
|
$ttl_tag = id(new PhabricatorTagView())
|
|
->setType(PhabricatorTagView::TYPE_OBJECT)
|
|
->setName(pht("Temporary"));
|
|
$header->addTag($ttl_tag);
|
|
}
|
|
|
|
$actions = $this->buildActionView($file);
|
|
$properties = $this->buildPropertyView($file);
|
|
$timeline = $this->buildTransactionView($file, $xactions);
|
|
$crumbs = $this->buildApplicationCrumbs();
|
|
$crumbs->setActionList($actions);
|
|
$crumbs->addCrumb(
|
|
id(new PhabricatorCrumbView())
|
|
->setName('F'.$file->getID())
|
|
->setHref($this->getApplicationURI("/info/{$phid}/")));
|
|
|
|
$object_box = id(new PHUIObjectBoxView())
|
|
->setHeader($header)
|
|
->setActionList($actions)
|
|
->setPropertyList($properties);
|
|
|
|
return $this->buildApplicationPage(
|
|
array(
|
|
$crumbs,
|
|
$object_box,
|
|
$timeline
|
|
),
|
|
array(
|
|
'title' => $file->getName(),
|
|
'device' => true,
|
|
'pageObjects' => array($file->getPHID()),
|
|
));
|
|
}
|
|
|
|
private function buildTransactionView(
|
|
PhabricatorFile $file,
|
|
array $xactions) {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
$engine = id(new PhabricatorMarkupEngine())
|
|
->setViewer($user);
|
|
foreach ($xactions as $xaction) {
|
|
if ($xaction->getComment()) {
|
|
$engine->addObject(
|
|
$xaction->getComment(),
|
|
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
|
|
}
|
|
}
|
|
$engine->process();
|
|
|
|
$timeline = id(new PhabricatorApplicationTransactionView())
|
|
->setUser($user)
|
|
->setObjectPHID($file->getPHID())
|
|
->setTransactions($xactions)
|
|
->setMarkupEngine($engine);
|
|
|
|
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
|
|
|
|
$add_comment_header = id(new PHUIHeaderView())
|
|
->setHeader(
|
|
$is_serious
|
|
? pht('Add Comment')
|
|
: pht('Question File Integrity'));
|
|
|
|
$submit_button_name = $is_serious
|
|
? pht('Add Comment')
|
|
: pht('Debate the Bits');
|
|
|
|
$draft = PhabricatorDraft::newFromUserAndKey($user, $file->getPHID());
|
|
|
|
$add_comment_form = id(new PhabricatorApplicationTransactionCommentView())
|
|
->setUser($user)
|
|
->setObjectPHID($file->getPHID())
|
|
->setDraft($draft)
|
|
->setAction($this->getApplicationURI('/comment/'.$file->getID().'/'))
|
|
->setSubmitButtonName($submit_button_name);
|
|
|
|
$comment_box = id(new PHUIObjectBoxView())
|
|
->setFlush(true)
|
|
->setHeader($add_comment_header)
|
|
->appendChild($add_comment_form);
|
|
|
|
return array(
|
|
$timeline,
|
|
$comment_box);
|
|
}
|
|
|
|
private function buildActionView(PhabricatorFile $file) {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$id = $file->getID();
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
->setUser($user)
|
|
->setObjectURI($this->getRequest()->getRequestURI())
|
|
->setObject($file);
|
|
|
|
if ($file->isViewableInBrowser()) {
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('View File'))
|
|
->setIcon('preview')
|
|
->setHref($file->getViewURI()));
|
|
} else {
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setUser($user)
|
|
->setRenderAsForm(true)
|
|
->setDownload(true)
|
|
->setName(pht('Download File'))
|
|
->setIcon('download')
|
|
->setHref($file->getViewURI()));
|
|
}
|
|
|
|
$view->addAction(
|
|
id(new PhabricatorActionView())
|
|
->setName(pht('Delete File'))
|
|
->setIcon('delete')
|
|
->setHref($this->getApplicationURI("/delete/{$id}/"))
|
|
->setWorkflow(true));
|
|
|
|
return $view;
|
|
}
|
|
|
|
private function buildPropertyView(PhabricatorFile $file) {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$view = id(new PhabricatorPropertyListView());
|
|
|
|
if ($file->getAuthorPHID()) {
|
|
$view->addProperty(
|
|
pht('Author'),
|
|
$this->getHandle($file->getAuthorPHID())->renderLink());
|
|
}
|
|
|
|
$view->addProperty(
|
|
pht('Created'),
|
|
phabricator_datetime($file->getDateCreated(), $user));
|
|
|
|
$view->addProperty(
|
|
pht('Size'),
|
|
phabricator_format_bytes($file->getByteSize()));
|
|
|
|
$view->addSectionHeader(pht('Technical Details'));
|
|
|
|
$view->addProperty(
|
|
pht('Mime Type'),
|
|
$file->getMimeType());
|
|
|
|
$view->addProperty(
|
|
pht('Engine'),
|
|
$file->getStorageEngine());
|
|
|
|
$view->addProperty(
|
|
pht('Format'),
|
|
$file->getStorageFormat());
|
|
|
|
$view->addProperty(
|
|
pht('Handle'),
|
|
$file->getStorageHandle());
|
|
|
|
$metadata = $file->getMetadata();
|
|
if (!empty($metadata)) {
|
|
$view->addSectionHeader(pht('Metadata'));
|
|
|
|
foreach ($metadata as $key => $value) {
|
|
$view->addProperty(
|
|
PhabricatorFile::getMetadataName($key),
|
|
$value);
|
|
}
|
|
}
|
|
|
|
if ($file->isViewableImage()) {
|
|
|
|
$image = phutil_tag(
|
|
'img',
|
|
array(
|
|
'src' => $file->getViewURI(),
|
|
'class' => 'phabricator-property-list-image',
|
|
));
|
|
|
|
$linked_image = phutil_tag(
|
|
'a',
|
|
array(
|
|
'href' => $file->getViewURI(),
|
|
),
|
|
$image);
|
|
|
|
$view->addImageContent($linked_image);
|
|
} else if ($file->isAudio()) {
|
|
$audio = phutil_tag(
|
|
'audio',
|
|
array(
|
|
'controls' => 'controls',
|
|
'class' => 'phabricator-property-list-audio',
|
|
),
|
|
phutil_tag(
|
|
'source',
|
|
array(
|
|
'src' => $file->getViewURI(),
|
|
'type' => $file->getMimeType(),
|
|
)));
|
|
$view->addImageContent($audio);
|
|
}
|
|
|
|
return $view;
|
|
}
|
|
|
|
}
|