58 $this->FieldRenderer(
$form);
63 if (isset(
$form->attachment_delete_icon)) $this->deleteIcon =
$form->attachment_delete_icon;
69 $pks =
$obj->getPrimaryKeyList();
72 if ($xref->hasField(
$pk))
return $pk;
75 throw new DataItemException(
"No matching foreign key in xref table");
82 <div
class=
"dialog" id=
"attachmentDialog" style=
"width: 260px">
83 <div
class=
"dialog_header" id=
"attachmentDialogHeader">
84 <div
style=
"padding: 4px;">
85 <div
style=
"float: right">&
nbsp;<a
id=
'closeAttachmentDialog'>Close ×</a></div>
86 <span
style=
"font-weight: bold" id=
"attachmentDialogTitle">Add an
Attachment</span>
89 <div
class=
"dialog_body">
97 $dialog = ob_get_contents();
106 <p
id=
"attachmentDialogMessage"></p>
107 <form
id=
"attachmentForm" method=
"POST" enctype=
"multipart/form-data" action=
"/action/attachment/upload" >
110 <input type=
"file" name=
"attachmentFile"<?
if (
$useCamera) { echo
' accept="image/*" capture="camera"'; }?>/>
112 <br/><input type=
"submit" class=
"button" name=
"submit" value=
"Upload Attachment" style=
"float: right; margin-bottom: 4px"/>
114 $body = ob_get_contents();
121 if ($this->parent->readOnlyForm || $this->parent->isReadOnly(
$field) || array_key_exists(
$field, $this->parent->hidden))
return "";
128 <script type=
"text/javascript">
129 window.addEvent(
'domready',
function()
131 new AttachmentUploader().setup(
'attachmentForm',
'<?echo $this->parent->id?>_<?echo $field?>_list',
'<?echo $this->parent->id?>_<?echo $field?>',
'<?echo $this->cssClass?>',
'<?echo $this->deleteIcon?>');
143 $this->_startField(
$field);
147 $ids = displayFieldAsList($attachments,
"attachment_id");
149 <input type=
"hidden" value=
"<?echo $ids?>" name=
"<?echo $field?>" id=
"<?echo $this->parent->id?>_<?echo $field?>"/>
150 <ul
id=
"<?echo $this->parent->id?>_<?echo $field?>_list" class=
"<?echo $this->cssClass?>" style=
'display: table-cell'>
155 ?> <li
id=
'attachment_<?echo $attachment->attachment_id?>' class=
'<?echo $this->cssClass?>'><span>
160 <a href=
"#" onclick=
'new AttachmentUploader().deleteAttachment("<?echo $attachment->filename?>", <?echo $attachment->attachment_id?>); return false' title=
'Delete this Attachment'><img src=
'<?echo $this->deleteIcon?>' style=
'display:inline-block; vertical-align: middle' alt=
'Delete this Attachment'/></a>
166 <a
class=
'add_attachment_label' href=
"#" onclick=
"new AttachmentUploader().addAttachment(); return false"> <?echo $this->addLabel?> </a>
177 if(count($attachments) < 2) $this->
colspan = 1;
179 $this->_startField(
$field);
181 if (count($attachments) == 0)
183 echo
"<p>{$this->emptyMessage}</p>";
185 else if(count($attachments) == 1)
191 else if(count($attachments) > 0)
194 <ul
id=
"<?echo $this->parent->id?>_<?echo $field?>_list" class=
"<?echo $this->cssClass?>">
198 ?> <li
id=
'attachment_<?echo $attachment->attachment_id?>' class=
'<?echo $this->cssClass?>'><span>
216 $pkv = $this->parent->data->get(
$pk);
220 $attachments = query(
Attachment,
"WHERE attachment_id in (select attachment_id from {$xref->table} where $pk=$pkv) ORDER BY attachment_id");
224 $attachments = array();
234 <img src=
"<?echo $icon?>" alt=
"Icon" style=
"display:inline-block;vertical-align:middle"/>&
nbsp;
235 <a href=
'/action/attachment/download?attachment_id=<?echo $attachment->attachment_id?>'><?echo
$attachment->filename?></a>&
nbsp;
244 return $attachment->format(
"<img src='{$icon}' alt='Icon' style='display:inline-block;vertical-align:middle'/> <a href='/action/attachment/download?attachment_id={attachment_id}'>{filename}</a> ({file_size})");
251 if ($this->parent->readOnlyForm || $this->parent->isReadOnly(
$field) || array_key_exists(
$field, $this->parent->hidden))
return "";
252 trace(
"AttachmentFieldRenderer postProcess field $field value ".
$_POST[
$field], 3);
256 $obj = $this->parent->data;
262 $xref->delete(
"WHERE {$pk}=".
$obj->get(
$pk));
266 trace(
"AttachmentFieldRenderer postProcess _POST attachment field is ".
$_POST[
$field], 3);
273 $xref->set(
"attachment_id",
$id);
279 trace(
"AttachmentFieldRenderer postProcess _POST attachment field is empty", 3);
if(! $attachment_id) $attachment
static formatAttachment($attachment)
getMatchingPK($xref, $obj)
static renderDialog($useCamera)
renderReadOnly($field="")
drawOneAttachment($attachment)
AttachmentFieldRenderer(&$form, $field, $xrefClass)
static renderDialogBody($useCamera)
static usingFile()
Uses the specified framework file(s) from the framework directory.