2013-03-08 19:40:06 +01:00
|
|
|
<?php
|
|
|
|
|
2013-04-02 18:32:40 +02:00
|
|
|
final class ConpherenceFileWidgetView extends ConpherenceWidgetView {
|
2013-03-08 19:40:06 +01:00
|
|
|
|
|
|
|
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())
|
2014-08-30 00:15:13 +02:00
|
|
|
->setFileName(id(new PhutilUTF8StringTruncator())
|
|
|
|
->setMaximumGlyphs(28)
|
|
|
|
->truncateString($file->getName()))
|
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(
|
2013-05-27 18:56:45 +02:00
|
|
|
'By %s ',
|
2013-03-16 07:41:36 +01:00
|
|
|
$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'
|
|
|
|
),
|
2013-05-27 18:56:45 +02:00
|
|
|
pht('%s%s.', $who_done_it_text, $date_text));
|
2013-03-16 07:41:36 +01:00
|
|
|
|
|
|
|
$files_html[] = phutil_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'file-entry'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$icon_view,
|
|
|
|
$file_view,
|
2013-05-27 18:56:45 +02:00
|
|
|
$who_done_it
|
2013-03-16 07:41:36 +01:00
|
|
|
));
|
2013-03-08 19:40:06 +01:00
|
|
|
}
|
2013-03-16 07:41:36 +01:00
|
|
|
|
2013-05-24 19:50:18 +02:00
|
|
|
if (empty($files)) {
|
|
|
|
$files_html[] = javelin_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'no-files',
|
|
|
|
'sigil' => 'no-files'),
|
|
|
|
pht('No files.'));
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|