52 class EmailAttachmentFieldRenderer
extends FieldRenderer
57 var $cssClass =
"attachment";
58 var $deleteIcon =
"/fakoli/images/delete.gif";
64 $this->FieldRenderer(
$form);
65 $this->label = ($label) ? $label :
$form->prettifyFieldName(
$field);
69 die(
"field $field already exists in form");
74 if (isset(
$form->attachment_delete_icon)) $this->deleteIcon =
$form->attachment_delete_icon;
77 function renderField(
$field =
"")
81 $this->_startField(
$field);
83 echo
"<input id='{$this->parent->id}_{$field}' type='hidden' name='{$field}' value='' />\n";
84 echo
"<ul id='{$this->parent->id}_{$field}_list' class='{$this->cssClass}' style='display: table-cell'>\n</ul>\n";
85 echo
"<a href='#' onclick='emailAttachmentMgr.showAddAttachmentDialog(); return false'>Add an Attachment</a>\n";
90 function renderScript(
$field)
94 if ($this->parent->readOnlyForm || $this->parent->isReadOnly(
$field) || array_key_exists(
$field, $this->parent->hidden))
return "";
100 <div
class=
"dialog" id=
"attachmentDialog" style=
"width: 260px">
101 <div
class=
"dialog_header" id=
"attachmentDialogHeader">
102 <div
style=
"padding: 4px;">
103 <div
style=
"float: right">&
nbsp;<a
id=
'closeAttachmentDialog'>Close ×</a></div>
104 <span
"style="font-weight: bold
" id="attachmentDialogTitle
">Add an Attachment</span>
107 <div class="dialog_body
">
108 <p id="attachmentDialogMessage
"></p>
109 <form id="attachmentForm
" method="POST
" enctype="multipart/form-data
" action="/
action/attachment/upload
" >
111 <label>Attachment File</label><br/>
112 <input type="file
" name="attachmentFile
"/>
114 <br/><input type="submit
" class="button
" name="submit
" value="Upload
Attachment" style="float: right; margin-bottom: 4px
"/>
119 $dialogs .= ob_get_contents();
122 echo "<script type=
'text/javascript'>\n
";
123 echo "var emailAttachmentMgr;\n
";
124 echo "window.addEvent(
'domready',
function()\n
";
126 echo "\temailAttachmentMgr =
new EmailAttachmentManager(
'{$this->parent->id}_{$field}_list',
'{$this->parent->id}_{$field}',
'{$this->cssClass}',
'{$this->deleteIcon}');\n
";
139 function preProcess($field = "")
141 if (!$field) $field = $this->field;
142 if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field) || array_key_exists($field, $this->parent->hidden)) return "";
144 if (isset($_POST[$field]) && $_POST[$field] != "")
146 $ids = explode(",
", $_POST[$field]);
150 $attachment = new Attachment($id);
151 $file = sanitizePath($this->formatFilePath($attachment));
152 $attachments[$attachment->filename] = $file;
154 $this->parent->data->set($field, $attachments);
166 function postProcess($field = "")
168 if (!$field) $field = $this->field;
170 if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field) || array_key_exists($field, $this->parent->hidden)) return "";
172 if (isset($_POST[$field]) && $_POST[$field] != "")
174 $ids = explode(",
", $_POST[$field]);
178 $attachment = new Attachment($id);
179 $file = $this->formatFilePath($attachment);
180 if (file_exists($file))
184 $attachment->delete();
189 function formatFilePath($attachment)
193 $dir = $config["attachmentdir
"];
194 $base = $config['uploadbase'];
200 } // end EmailAttachmentFieldRenderer
212 class EmailLibraryAttachmentFieldRenderer extends FieldRenderer
217 var $cssClass = "attachment
";
218 var $deleteIcon = "/fakoli/images/
delete.gif
";
220 function __construct(&$form, $field, $label)
222 $this->field = $field;
224 $this->FieldRenderer($form);
225 $this->label = ($label) ? $label : $form->prettifyFieldName($field);
227 if($form->hasAdditional($field))
233 if (isset($form->attachment_css_class)) $this->cssClass = $form->attachment_css_class;
234 if (isset($form->attachment_delete_icon)) $this->deleteIcon = $form->attachment_delete_icon;
238 function getAttachmentType()
243 function renderField($field = "")
245 if (!$field) $field = $this->field;
247 $this->_startField($field);
249 echo "<input
id=
'{$this->parent->id}_{$field}' type=
'hidden' name=
'{$field}' value=
'' />\n
";
250 echo "<ul
id=
'{$this->parent->id}_{$field}_list' class=
'{$this->cssClass}' style=
'display: table-cell'>\n</ul>\n
";
251 echo "<a href=
'#' onclick=
'emailDocAttachmentMgr.showDocumentSelectDialog(); return false'>Add an
Attachment</a>\n
";
253 $this->_endField($field);
256 function renderReadOnly($field = "")
268 function preProcess($field = "")
270 if (!$field) $field = $this->field;
272 trace("EmailAttachmentFieldRenderer preProcess
field $field value
". $_POST[$field], 3);
273 if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field) || array_key_exists($field, $this->parent->hidden)) return "";
275 if (isset($_POST[$field]) && $_POST[$field] != "")
277 $ids = explode(",
", $_POST[$field]);
281 $document = new Document($id);
282 $library = $document->DocumentLibrary();
283 $file = sanitizePath($library->getLibraryDirectory() . DIRECTORY_SEPARATOR . $document->file);
284 $attachments[basename($document->file)] = $file;
286 $this->parent->data->set($field, $attachments);
291 function renderScript($field)
293 if ($this->parent->readOnlyForm || $this->parent->isReadOnly($field) || array_key_exists($field, $this->parent->hidden)) return "";
295 if (!$field) $field = $this->field;
297 echo "<script type=
'text/javascript' src=
'/components/email/js/email_attachment_manager.js'></script>\n
";
298 echo "<script type=
'text/javascript'>\n
";
299 echo "var emailDocAttachmentMgr;\n
";
300 echo "window.addEvent(
'load',
function()\n
";
302 echo "\temailDocAttachmentMgr =
new EmailDocumentAttachmentManager(
'{$this->parent->id}_{$field}_list',
'{$this->parent->id}_{$field}',
'{$this->cssClass}',
'{$this->deleteIcon}');\n
";
311 static function getLibraryOptions()
313 $libraries = Query::create(DocumentLibrary, "ORDER BY name
")->execute();
314 $libraries = filterByRole($libraries, "allow_access
");
317 if (count($libraries) > 0)
319 foreach($libraries as $library)
321 $options[$library->document_library_id] = $library->name;
330 static function getDocumentOptions()
332 $documents = Query::create(Document, "ORDER BY
title")->execute();
333 $documents = filterByRole($documents, "allow_access
");
335 if (count($documents) > 0)
337 $documents = regroupList($documents, "document_library_id
");
if(! $attachment_id) $attachment
static using()
Import the datamodels, views and manifest for the specified component(s).
static usingFile()
Uses the specified framework file(s) from the framework directory.