2013-03-08 19:40:06 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class ConpherenceFileWidgetView extends AphrontView {
|
|
|
|
|
|
|
|
private $conpherence;
|
|
|
|
private $updateURI;
|
|
|
|
|
|
|
|
public function setUpdateURI($update_uri) {
|
|
|
|
$this->updateURI = $update_uri;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getUpdateURI() {
|
|
|
|
return $this->updateURI;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setConpherence(ConpherenceThread $conpherence) {
|
|
|
|
$this->conpherence = $conpherence;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
public function getConpherence() {
|
|
|
|
return $this->conpherence;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
2013-03-16 07:41:36 +01:00
|
|
|
require_celerity_resource('sprite-docs-css');
|
2013-03-08 19:40:06 +01:00
|
|
|
$conpherence = $this->getConpherence();
|
|
|
|
$widget_data = $conpherence->getWidgetData();
|
|
|
|
$files = $widget_data['files'];
|
2013-03-16 07:41:36 +01:00
|
|
|
$files_authors = $widget_data['files_authors'];
|
|
|
|
$files_html = array();
|
2013-03-08 19:40:06 +01:00
|
|
|
|
|
|
|
foreach ($files as $file) {
|
2013-03-16 07:41:36 +01:00
|
|
|
$icon_class = $file->getDisplayIconForMimeType();
|
|
|
|
$icon_view = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'file-icon sprite-docs '.$icon_class
|
|
|
|
),
|
|
|
|
'');
|
2013-03-08 19:40:06 +01:00
|
|
|
$file_view = id(new PhabricatorFileLinkView())
|
|
|
|
->setFilePHID($file->getPHID())
|
2013-03-19 00:31:38 +01:00
|
|
|
->setFileName(phutil_utf8_shorten($file->getName(), 38))
|
2013-03-16 07:41:36 +01:00
|
|
|
->setFileViewable($file->isViewableImage())
|
|
|
|
->setFileViewURI($file->getBestURI())
|
|
|
|
->setCustomClass('file-title');
|
|
|
|
|
|
|
|
$who_done_it_text = '';
|
|
|
|
// system generated files don't have authors
|
|
|
|
if ($file->getAuthorPHID()) {
|
|
|
|
$who_done_it_text = pht(
|
|
|
|
'by %s ',
|
|
|
|
$files_authors[$file->getPHID()]->renderLink());
|
|
|
|
}
|
|
|
|
$date_text = phabricator_relative_date(
|
|
|
|
$file->getDateCreated(),
|
|
|
|
$this->getUser());
|
|
|
|
|
|
|
|
$who_done_it = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'file-uploaded-by'
|
|
|
|
),
|
|
|
|
pht('Uploaded %s%s.', $who_done_it_text, $date_text));
|
2013-03-08 19:40:06 +01:00
|
|
|
|
2013-03-16 07:41:36 +01:00
|
|
|
$extra = '';
|
|
|
|
if ($file->isViewableImage()) {
|
|
|
|
$meta = $file_view->getMetadata();
|
|
|
|
$extra = javelin_tag(
|
2013-03-08 19:40:06 +01:00
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'sigil' => 'lightboxable',
|
2013-03-16 07:41:36 +01:00
|
|
|
'meta' => $meta,
|
|
|
|
'class' => 'file-extra',
|
2013-03-08 19:40:06 +01:00
|
|
|
),
|
|
|
|
phutil_tag(
|
|
|
|
'img',
|
|
|
|
array(
|
2013-03-16 07:41:36 +01:00
|
|
|
'src' => $file->getThumb160x120URI()
|
2013-03-08 19:40:06 +01:00
|
|
|
),
|
2013-03-16 07:41:36 +01:00
|
|
|
''));
|
|
|
|
}
|
|
|
|
|
|
|
|
$divider = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'divider'
|
|
|
|
),
|
|
|
|
'');
|
|
|
|
|
|
|
|
$files_html[] = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'file-entry'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$icon_view,
|
|
|
|
$file_view,
|
|
|
|
$who_done_it,
|
|
|
|
$extra,
|
|
|
|
$divider
|
|
|
|
));
|
2013-03-08 19:40:06 +01:00
|
|
|
}
|
2013-03-16 07:41:36 +01:00
|
|
|
|
|
|
|
return phutil_tag(
|
|
|
|
'div',
|
|
|
|
array('class' => 'file-list'),
|
|
|
|
$files_html);
|
2013-03-08 19:40:06 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|