2013-07-16 22:31:20 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group pholio
|
|
|
|
*/
|
2013-07-19 00:04:08 +02:00
|
|
|
final class PholioUploadedImageView extends AphrontView {
|
2013-07-16 22:31:20 +02:00
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
private $image;
|
2013-07-19 23:07:22 +02:00
|
|
|
private $replacesPHID;
|
|
|
|
|
|
|
|
public function setReplacesPHID($replaces_phid) {
|
|
|
|
$this->replacesPHID = $replaces_phid;
|
|
|
|
return $this;
|
|
|
|
}
|
2013-07-16 22:31:20 +02:00
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
public function setImage(PholioImage $image) {
|
|
|
|
$this->image = $image;
|
2013-07-16 22:31:20 +02:00
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function render() {
|
|
|
|
require_celerity_resource('pholio-edit-css');
|
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
$image = $this->image;
|
|
|
|
$file = $image->getFile();
|
2013-07-16 22:31:20 +02:00
|
|
|
$phid = $file->getPHID();
|
2013-07-19 23:07:22 +02:00
|
|
|
$replaces_phid = $this->replacesPHID;
|
2013-07-16 22:31:20 +02:00
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
$remove = $this->renderRemoveElement();
|
2013-07-16 22:31:20 +02:00
|
|
|
|
|
|
|
$title = id(new AphrontFormTextControl())
|
|
|
|
->setName('title_'.$phid)
|
|
|
|
->setValue($image->getName())
|
2013-07-19 23:07:22 +02:00
|
|
|
->setSigil('image-title')
|
2013-07-16 22:31:20 +02:00
|
|
|
->setLabel(pht('Title'));
|
|
|
|
|
|
|
|
$description = id(new AphrontFormTextAreaControl())
|
|
|
|
->setName('description_'.$phid)
|
|
|
|
->setValue($image->getDescription())
|
2013-07-19 23:07:22 +02:00
|
|
|
->setSigil('image-description')
|
2013-07-16 22:31:20 +02:00
|
|
|
->setLabel(pht('Description'));
|
|
|
|
|
2013-07-19 23:09:27 +02:00
|
|
|
$thumb_frame = phutil_tag(
|
2013-07-19 23:07:22 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'pholio-thumb-frame',
|
2013-07-19 23:09:27 +02:00
|
|
|
'style' => 'background-image: url('.$file->getThumb280x210URI().');',
|
|
|
|
));
|
2013-07-19 23:07:22 +02:00
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
$content = hsprintf(
|
2013-07-19 23:09:27 +02:00
|
|
|
'<div class="pholio-thumb-box">
|
|
|
|
<div class="pholio-thumb-title">
|
|
|
|
%s
|
|
|
|
<div class="pholio-thumb-name">%s</div>
|
2013-07-16 22:31:20 +02:00
|
|
|
</div>
|
2013-07-19 23:09:27 +02:00
|
|
|
%s
|
2013-07-19 00:04:08 +02:00
|
|
|
</div>
|
2013-07-19 23:09:27 +02:00
|
|
|
<div class="pholio-image-details">
|
|
|
|
%s
|
|
|
|
%s
|
2013-07-19 00:04:08 +02:00
|
|
|
</div>',
|
2013-07-16 22:31:20 +02:00
|
|
|
$remove,
|
2013-07-19 23:09:27 +02:00
|
|
|
$file->getName(),
|
2013-07-19 23:07:22 +02:00
|
|
|
$thumb_frame,
|
2013-07-16 22:31:20 +02:00
|
|
|
$title,
|
|
|
|
$description);
|
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
$input = phutil_tag(
|
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'file_phids[]',
|
|
|
|
'value' => $phid,
|
|
|
|
));
|
|
|
|
|
2013-07-19 23:07:22 +02:00
|
|
|
$replaces_input = phutil_tag(
|
|
|
|
'input',
|
|
|
|
array(
|
|
|
|
'type' => 'hidden',
|
|
|
|
'name' => 'replaces['.$replaces_phid.']',
|
|
|
|
'value' => $phid,
|
|
|
|
));
|
|
|
|
|
2013-07-19 00:04:08 +02:00
|
|
|
return javelin_tag(
|
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'pholio-uploaded-image',
|
|
|
|
'sigil' => 'pholio-drop-image',
|
2013-07-19 23:07:22 +02:00
|
|
|
'meta' => array(
|
|
|
|
'filePHID' => $file->getPHID(),
|
|
|
|
'replacesPHID' => $replaces_phid,
|
|
|
|
),
|
2013-07-19 00:04:08 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
$content,
|
|
|
|
$input,
|
2013-07-19 23:07:22 +02:00
|
|
|
$replaces_input,
|
2013-07-19 00:04:08 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
private function renderRemoveElement() {
|
|
|
|
return javelin_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'class' => 'button grey',
|
|
|
|
'sigil' => 'pholio-drop-remove',
|
|
|
|
),
|
|
|
|
'X');
|
2013-07-16 22:31:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|