2013-07-16 13:31:20 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group pholio
|
|
|
|
*/
|
2013-07-18 15:04:08 -07:00
|
|
|
final class PholioUploadedImageView extends AphrontView {
|
2013-07-16 13:31:20 -07:00
|
|
|
|
2013-07-18 15:04:08 -07:00
|
|
|
private $image;
|
2013-07-16 13:31:20 -07:00
|
|
|
|
2013-07-18 15:04:08 -07:00
|
|
|
public function setImage(PholioImage $image) {
|
|
|
|
$this->image = $image;
|
2013-07-16 13:31:20 -07:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('pholio-edit-css');
|
|
|
|
|
2013-07-18 15:04:08 -07:00
|
|
|
$image = $this->image;
|
|
|
|
$file = $image->getFile();
|
2013-07-16 13:31:20 -07:00
|
|
|
$phid = $file->getPHID();
|
|
|
|
|
|
|
|
$thumb = phutil_tag(
|
|
|
|
'img',
|
|
|
|
array(
|
|
|
|
'src' => $file->getThumb280x210URI(),
|
|
|
|
'width' => 280,
|
|
|
|
'height' => 210,
|
|
|
|
));
|
|
|
|
|
2013-07-18 15:04:08 -07:00
|
|
|
$remove = $this->renderRemoveElement();
|
2013-07-16 13:31:20 -07:00
|
|
|
|
|
|
|
$title = id(new AphrontFormTextControl())
|
|
|
|
->setName('title_'.$phid)
|
|
|
|
->setValue($image->getName())
|
|
|
|
->setLabel(pht('Title'));
|
|
|
|
|
|
|
|
$description = id(new AphrontFormTextAreaControl())
|
|
|
|
->setName('description_'.$phid)
|
|
|
|
->setValue($image->getDescription())
|
|
|
|
->setLabel(pht('Description'));
|
|
|
|
|
2013-07-18 15:04:08 -07:00
|
|
|
$content = hsprintf(
|
|
|
|
'<div class="thumb-box">
|
|
|
|
<div class="title">
|
|
|
|
<div class="text">%s</div>
|
|
|
|
<div class="remove">%s</div>
|
2013-07-16 13:31:20 -07:00
|
|
|
</div>
|
2013-07-18 15:04:08 -07:00
|
|
|
<div class="thumb">%s</div>
|
|
|
|
</div>
|
|
|
|
<div class="image-data">
|
|
|
|
<div class="title">%s</div>
|
|
|
|
<div class="description">%s</div>
|
|
|
|
</div>',
|
|
|
|
$file->getName(),
|
2013-07-16 13:31:20 -07:00
|
|
|
$remove,
|
|
|
|
$thumb,
|
|
|
|
$title,
|
|
|
|
$description);
|
|
|
|
|
2013-07-18 15:04:08 -07:00
|
|
|
$input = phutil_tag(
|
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'file_phids[]',
|
|
|
|
'value' => $phid,
|
|
|
|
));
|
|
|
|
|
|
|
|
return javelin_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'pholio-uploaded-image',
|
|
|
|
'sigil' => 'pholio-drop-image',
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
$content,
|
|
|
|
$input,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderRemoveElement() {
|
|
|
|
return javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'button grey',
|
|
|
|
'sigil' => 'pholio-drop-remove',
|
|
|
|
),
|
|
|
|
'X');
|
2013-07-16 13:31:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|