Changeset View
Changeset View
Standalone View
Standalone View
src/view/layout/PhabricatorFileLinkView.php
Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | return array( | ||||
'name' => $this->getFileName(), | 'name' => $this->getFileName(), | ||||
'monogram' => $this->getFileMonogram(), | 'monogram' => $this->getFileMonogram(), | ||||
'icon' => $this->getFileIcon(), | 'icon' => $this->getFileIcon(), | ||||
'size' => $this->getFileSize(), | 'size' => $this->getFileSize(), | ||||
); | ); | ||||
} | } | ||||
protected function getTagName() { | protected function getTagName() { | ||||
if ($this->getFileDownloadURI()) { | |||||
return 'div'; | return 'div'; | ||||
} else { | |||||
return 'a'; | |||||
} | |||||
} | } | ||||
protected function getTagAttributes() { | protected function getTagAttributes() { | ||||
$mustcapture = true; | |||||
$sigil = 'lightboxable'; | |||||
$meta = $this->getMeta(); | |||||
$class = 'phabricator-remarkup-embed-layout-link'; | $class = 'phabricator-remarkup-embed-layout-link'; | ||||
if ($this->getCustomClass()) { | if ($this->getCustomClass()) { | ||||
$class = $this->getCustomClass(); | $class = $this->getCustomClass(); | ||||
} | } | ||||
return array( | $attributes = array( | ||||
'href' => $this->getFileViewURI(), | 'href' => $this->getFileViewURI(), | ||||
'target' => '_blank', | |||||
'rel' => 'noreferrer', | |||||
'class' => $class, | 'class' => $class, | ||||
); | |||||
if ($this->getFilePHID()) { | |||||
$mustcapture = true; | |||||
$sigil = 'lightboxable'; | |||||
$meta = $this->getMeta(); | |||||
$attributes += array( | |||||
'sigil' => $sigil, | 'sigil' => $sigil, | ||||
'meta' => $meta, | 'meta' => $meta, | ||||
'mustcapture' => $mustcapture, | 'mustcapture' => $mustcapture, | ||||
); | ); | ||||
} | } | ||||
return $attributes; | |||||
} | |||||
protected function getTagContent() { | protected function getTagContent() { | ||||
require_celerity_resource('phabricator-remarkup-css'); | require_celerity_resource('phabricator-remarkup-css'); | ||||
require_celerity_resource('phui-lightbox-css'); | require_celerity_resource('phui-lightbox-css'); | ||||
$icon = id(new PHUIIconView()) | $icon = id(new PHUIIconView()) | ||||
->setIcon($this->getFileIcon()) | ->setIcon($this->getFileIcon()) | ||||
->addClass('phabricator-remarkup-embed-layout-icon'); | ->addClass('phabricator-remarkup-embed-layout-icon'); | ||||
$download_link = null; | |||||
$download_uri = $this->getFileDownloadURI(); | |||||
if ($download_uri) { | |||||
$dl_icon = id(new PHUIIconView()) | $dl_icon = id(new PHUIIconView()) | ||||
->setIcon('fa-download'); | ->setIcon('fa-download'); | ||||
$download_link = phutil_tag( | $download_link = phutil_tag( | ||||
'a', | 'a', | ||||
array( | array( | ||||
'class' => 'phabricator-remarkup-embed-layout-download', | 'class' => 'phabricator-remarkup-embed-layout-download', | ||||
'href' => $this->getFileDownloadURI(), | 'href' => $download_uri, | ||||
), | ), | ||||
pht('Download')); | pht('Download')); | ||||
} | |||||
$info = phutil_tag( | $info = phutil_tag( | ||||
'span', | 'span', | ||||
array( | array( | ||||
'class' => 'phabricator-remarkup-embed-layout-info', | 'class' => 'phabricator-remarkup-embed-layout-info', | ||||
), | ), | ||||
$this->getFileSize()); | $this->getFileSize()); | ||||
Show All 24 Lines |