Page MenuHomePhabricator

D16980.id40859.diff
No OneTemporary

D16980.id40859.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -7633,7 +7633,7 @@
'PhabricatorFileImageTransform' => 'PhabricatorFileTransform',
'PhabricatorFileInfoController' => 'PhabricatorFileController',
'PhabricatorFileLightboxController' => 'PhabricatorFileController',
- 'PhabricatorFileLinkView' => 'AphrontView',
+ 'PhabricatorFileLinkView' => 'AphrontTagView',
'PhabricatorFileListController' => 'PhabricatorFileController',
'PhabricatorFileQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'PhabricatorFileROT13StorageFormat' => 'PhabricatorFileStorageFormat',
diff --git a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
--- a/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
+++ b/src/applications/files/markup/PhabricatorEmbedFileRemarkupRule.php
@@ -3,6 +3,8 @@
final class PhabricatorEmbedFileRemarkupRule
extends PhabricatorObjectRemarkupRule {
+ private $viewer;
+
const KEY_EMBED_FILE_PHIDS = 'phabricator.embedded-file-phids';
protected function getObjectNamePrefix() {
@@ -12,9 +14,9 @@
protected function loadObjects(array $ids) {
$engine = $this->getEngine();
- $viewer = $engine->getConfig('viewer');
+ $this->viewer = $engine->getConfig('viewer');
$objects = id(new PhabricatorFileQuery())
- ->setViewer($viewer)
+ ->setViewer($this->viewer)
->withIDs($ids)
->needTransforms(
array(
@@ -282,6 +284,7 @@
array $options) {
return id(new PhabricatorFileLinkView())
+ ->setViewer($this->viewer)
->setFilePHID($file->getPHID())
->setFileName($this->assertFlatText($options['name']))
->setFileDownloadURI($file->getDownloadURI())
diff --git a/src/view/layout/PhabricatorFileLinkView.php b/src/view/layout/PhabricatorFileLinkView.php
--- a/src/view/layout/PhabricatorFileLinkView.php
+++ b/src/view/layout/PhabricatorFileLinkView.php
@@ -1,6 +1,6 @@
<?php
-final class PhabricatorFileLinkView extends AphrontView {
+final class PhabricatorFileLinkView extends AphrontTagView {
private $fileName;
private $fileDownloadURI;
@@ -87,7 +87,7 @@
return FileTypeIcon::getFileIcon($this->getFileName());
}
- public function getMetadata() {
+ public function getMeta() {
return array(
'phid' => $this->getFilePHID(),
'viewable' => $this->getFileViewable(),
@@ -100,22 +100,57 @@
);
}
- public function render() {
- require_celerity_resource('phabricator-remarkup-css');
- require_celerity_resource('phui-lightbox-css');
+ protected function getTagName() {
+ return 'a';
+ }
+ protected function getTagAttributes() {
$mustcapture = true;
$sigil = 'lightboxable';
- $meta = $this->getMetadata();
+ $meta = $this->getMeta();
$class = 'phabricator-remarkup-embed-layout-link';
if ($this->getCustomClass()) {
$class = $this->getCustomClass();
}
+ return array(
+ 'href' => $this->getFileViewURI(),
+ 'class' => $class,
+ 'sigil' => $sigil,
+ 'meta' => $meta,
+ 'mustcapture' => $mustcapture,
+ );
+ }
+
+ protected function getTagContent() {
+ require_celerity_resource('phabricator-remarkup-css');
+ require_celerity_resource('phui-lightbox-css');
+
$icon = id(new PHUIIconView())
->setIcon($this->getFileIcon());
+ $dl_icon = id(new PHUIIconView())
+ ->setIcon('fa-download');
+
+ $download_form = phabricator_form(
+ $this->getViewer(),
+ array(
+ 'action' => '#',
+ 'method' => 'POST',
+ 'class' => 'embed-download-form',
+ 'sigil' => 'embed-download-form',
+ ),
+ phutil_tag(
+ 'a',
+ array(
+ 'class' => 'phui-icon-circle hover-green',
+ 'href' => '#',
+ ),
+ array(
+ $dl_icon,
+ )));
+
$info = phutil_tag(
'span',
array(
@@ -140,18 +175,10 @@
$info,
));
- return javelin_tag(
- 'a',
- array(
- 'href' => $this->getFileViewURI(),
- 'class' => $class,
- 'sigil' => $sigil,
- 'meta' => $meta,
- 'mustcapture' => $mustcapture,
- ),
- array(
- $icon,
- $inner,
- ));
+ return array(
+ $icon,
+ $inner,
+ $download_form,
+ );
}
}

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 23, 11:37 PM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7719210
Default Alt Text
D16980.id40859.diff (4 KB)

Event Timeline