eggification
[PlinnDocument.git] / Products / PlinnDocument / skins / plinn_attachment_form.py
diff --git a/Products/PlinnDocument/skins/plinn_attachment_form.py b/Products/PlinnDocument/skins/plinn_attachment_form.py
new file mode 100644 (file)
index 0000000..090c57b
--- /dev/null
@@ -0,0 +1,28 @@
+##parameters=
+form = context.REQUEST.form
+formId = form.get('formId')
+epozInsert = form.get('epozInsert', False)
+file = form.get('file', None)
+fileOb = None
+
+if file : fileOb = context.addAttachment(file, formId)
+
+onload = None
+if fileOb is not None :
+       if fileOb.meta_type == 'Photo' :
+               fileUrl = 'attachments/%s/getThumbnail' % fileOb.getId()
+               if epozInsert :
+                       onload = "dispatchImageAndHideUploadForm('%s', '%s', true);" % (fileUrl, formId)
+               else :
+                       ratio = float(fileOb.height)/fileOb.width
+                       dispatchValue = "%f_%s" % (ratio, fileUrl)
+                       onload = "dispatchImageAndHideUploadForm('%s','%s', false);" % (dispatchValue, formId)
+       else :
+               dispatchValue = '%s[%s]' % (fileOb.getId(), 'attachments/'+fileOb.getId())
+               onload = "dispatchFileAndHideUploadForm('%s', '%s');" % (dispatchValue, formId)
+
+hideFormCode = "hideUploadForm('%s');" % formId
+
+return context.plinn_attachment_template(onload=onload,
+                                                                                hideFormCode=hideFormCode,
+                                                                                formId=formId)
\ No newline at end of file