Commit 68502d12 authored by Brian Lloyd's avatar Brian Lloyd

Added image preview on Image edit form; Added Web form editing for File

object content if the content is a text type and under 64K; updated help
files.
parent d61a7c04
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
############################################################################## ##############################################################################
"""Image object""" """Image object"""
__version__='$Revision: 1.131 $'[11:-2] __version__='$Revision: 1.132 $'[11:-2]
import Globals, string, struct import Globals, string, struct
from OFS.content_types import guess_content_type from OFS.content_types import guess_content_type
...@@ -443,7 +443,8 @@ class File(Persistent, Implicit, PropertyManager, ...@@ -443,7 +443,8 @@ class File(Persistent, Implicit, PropertyManager,
self.ZCacheable_invalidate() self.ZCacheable_invalidate()
self.http__refreshEtag() self.http__refreshEtag()
def manage_edit(self, title, content_type, precondition='', REQUEST=None): def manage_edit(self, title, content_type, precondition='',
filedata=None, REQUEST=None):
""" """
Changes the title and content type attributes of the File or Image. Changes the title and content type attributes of the File or Image.
""" """
...@@ -454,6 +455,9 @@ class File(Persistent, Implicit, PropertyManager, ...@@ -454,6 +455,9 @@ class File(Persistent, Implicit, PropertyManager,
self.content_type=str(content_type) self.content_type=str(content_type)
if precondition: self.precondition=str(precondition) if precondition: self.precondition=str(precondition)
elif self.precondition: del self.precondition elif self.precondition: del self.precondition
if filedata is not None:
self.update_data(filedata, content_type, len(filedata))
else:
self.ZCacheable_invalidate() self.ZCacheable_invalidate()
if REQUEST: if REQUEST:
message="Saved changes." message="Saved changes."
......
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
<p class="form-help"> <p class="form-help">
You can update the data for this <dtml-var kind> using the form below. You can update the data for this file object using the form below.
Select a data file from your local computer by clicking the <em>browse</em> Select a data file from your local computer by clicking the <em>browse</em>
button and click <em>upload</em> to update the contents of the <dtml-var button and click <em>upload</em> to update the contents of the
kind>. file. You may also edit the file content directly if the content is a
text type and small enough to be edited in a text area.
</p> </p>
<form action="<dtml-var URL1>" method="post" enctype="multipart/form-data"> <form action="<dtml-var URL1>" method="post" enctype="multipart/form-data">
...@@ -47,6 +48,19 @@ kind>. ...@@ -47,6 +48,19 @@ kind>.
</td> </td>
</tr> </tr>
<dtml-if "this().getContentType()[:4] == 'text' and this().get_size() < 65536">
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<textarea name="filedata:text" wrap="off" style="width: 100%;"<dtml-if
dtpref_cols> cols="<dtml-var dtpref_cols>"<dtml-else
> cols="50"</dtml-if><dtml-if dtpref_rows> rows="<dtml-var
dtpref_rows>"<dtml-else> rows="20"</dtml-if>><dtml-var
__str__></textarea>
</div>
</td>
</tr>
<dtml-else>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
...@@ -59,7 +73,6 @@ kind>. ...@@ -59,7 +73,6 @@ kind>.
</div> </div>
</td> </td>
</tr> </tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
...@@ -72,6 +85,7 @@ kind>. ...@@ -72,6 +85,7 @@ kind>.
</div> </div>
</td> </td>
</tr> </tr>
</dtml-if>
<tr> <tr>
<td></td> <td></td>
......
...@@ -36,6 +36,21 @@ kind>. ...@@ -36,6 +36,21 @@ kind>.
</td> </td>
</tr> </tr>
<tr>
<td align="left" valign="top">
<div class="form-label">
Preview
</div>
</td>
<td align="left" valign="top">
<dtml-if "height < 250">
<dtml-var tag>
<dtml-else>
<dtml-var "tag(scale=250.0 / height)">
</dtml-if>
</td>
</tr>
<tr> <tr>
<td align="left" valign="top"> <td align="left" valign="top">
<div class="form-label"> <div class="form-label">
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment