Commit ced97df9 authored by Hanno Schlichting's avatar Hanno Schlichting

Drop dtpref_* cookie values to influence size of ZMI edit boxes.

parent 34e6f304
......@@ -128,14 +128,18 @@ class DTMLDocument(PropertyManager, DTMLMethod):
InitializeClass(DTMLDocument)
default_dd_html = """<html>
<head><title><dtml-var title_or_id></title>
default_dd_html = """\
<!DOCTYPE html>
<html>
<head>
<title><dtml-var title_or_id></title>
<meta charset="utf-8" />
</head>
<body bgcolor="#FFFFFF">
<body>
<h2><dtml-var title_or_id></h2>
<p>
This is the <dtml-var id> Document.
</p>
<p>
This is the <dtml-var id> Document.
</p>
</body>
</html>"""
......
......@@ -233,49 +233,11 @@ class DTMLMethod(RestrictedDTML,
security.declareProtected(change_proxy_roles, 'manage_proxyForm')
manage_proxyForm = DTMLFile('dtml/documentProxy', globals())
_size_changes = {
'Bigger': (5, 5),
'Smaller': (-5, -5),
'Narrower': (0, -5),
'Wider': (0, 5),
'Taller': (5, 0),
'Shorter': (-5, 0),
}
def _er(self, data, title, SUBMIT, dtpref_cols, dtpref_rows, REQUEST):
dr, dc = self._size_changes[SUBMIT]
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols": cols, "dtpref_rows": rows})
return self.manage_main(self, REQUEST, title=title,
__str__=self.quotedHTML(data))
security.declareProtected(change_dtml_methods, 'manage_edit')
def manage_edit(self, data, title,
SUBMIT='Change',
dtpref_cols='100%',
dtpref_rows='20',
REQUEST=None):
def manage_edit(self, data, title, SUBMIT='Change', REQUEST=None):
""" Replace contents with 'data', title with 'title'.
The SUBMIT parameter is also used to change the size of the editing
area on the default Document edit screen. If the value is "Smaller",
the rows and columns decrease by 5. If the value is "Bigger", the
rows and columns increase by 5. If any other or no value is supplied,
the data gets checked for DTML errors and is saved.
"""
self._validateProxy(REQUEST)
if SUBMIT in self._size_changes:
return self._er(data, title,
SUBMIT, dtpref_cols, dtpref_rows, REQUEST)
if self.wl_isLocked():
raise ResourceLockedError('This item is locked.')
......@@ -421,15 +383,19 @@ def decapitate(html, RESPONSE=None):
return html[spos + eolen:]
default_dm_html = """<html>
<head><title><dtml-var title_or_id></title>
default_dm_html = """\
<!DOCTYPE html>
<html>
<head>
<title><dtml-var title_or_id></title>
<meta charset="utf-8" />
</head>
<body bgcolor="#FFFFFF">
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p>
This is the <dtml-var document_id> Document
in the <dtml-var title_and_id> Folder.
</p>
<body>
<h2><dtml-var title_or_id> <dtml-var document_title></h2>
<p>
This is the <dtml-var document_id> Document
in the <dtml-var title_and_id> Folder.
</p>
</body>
</html>"""
......
......@@ -792,13 +792,15 @@ class Image(File):
# FIXME: Redundant, already in base class
security.declareProtected(change_images_and_files, 'manage_edit')
security.declareProtected(change_images_and_files, 'manage_upload')
security.declareProtected(change_images_and_files, 'PUT')
security.declareProtected(View, 'index_html')
security.declareProtected(View, 'get_size')
security.declareProtected(View, 'getContentType')
security.declareProtected(ftp_access, 'manage_FTPstat')
security.declareProtected(ftp_access, 'manage_FTPlist')
security.declareProtected(ftp_access, 'manage_FTPget')
if bbb.HAS_ZSERVER:
security.declareProtected(change_images_and_files, 'PUT')
security.declareProtected(ftp_access, 'manage_FTPstat')
security.declareProtected(ftp_access, 'manage_FTPlist')
security.declareProtected(ftp_access, 'manage_FTPget')
_properties = (
{'id': 'title', 'type': 'string'},
......
......@@ -25,15 +25,8 @@ the <em>browse</em> button to select a local file to upload.
<tr>
<td align="left" valign="top" colspan="2">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if expr="cols[-1]=='%'">
<textarea name="data:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="data:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var __str__></textarea>
</dtml-let>
<textarea name="data:text" wrap="off" style="width: 100%;"
rows="20"><dtml-var __str__></textarea>
</td>
</tr>
</dtml-with>
......@@ -46,11 +39,6 @@ the <em>browse</em> button to select a local file to upload.
<dtml-else>
<input class="form-element" type="submit" name="SUBMIT" value="Save Changes">
</dtml-if>
&nbsp;&nbsp;
<input class="form-element" type="submit" name="SUBMIT" value="Taller">
<input class="form-element" type="submit" name="SUBMIT" value="Shorter">
<input class="form-element" type="submit" name="SUBMIT" value="Wider">
<input class="form-element" type="submit" name="SUBMIT" value="Narrower">
</div>
</td>
</tr>
......
......@@ -54,15 +54,8 @@ text type and small enough to be edited in a text area.
<tr>
<td align="left" valign="top" colspan="2">
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="filedata:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="filedata:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-var __str__ html_quote></textarea>
</dtml-let>
<textarea name="filedata:text" wrap="off" style="width: 100%;"
rows="20"><dtml-var __str__ html_quote></textarea>
</div>
</td>
</tr>
......
......@@ -235,30 +235,6 @@ class ZopePageTemplate(Script, PageTemplate, Cacheable,
self.pt_edit(text, content_type)
return self.pt_editForm(manage_tabs_message='Saved changes')
security.declareProtected(change_page_templates, 'pt_changePrefs')
def pt_changePrefs(self, REQUEST, height=None, width=None,
dtpref_cols="100%", dtpref_rows="20"):
"""Change editing preferences."""
dr = {"Taller": 5, "Shorter": -5}.get(height, 0)
dc = {"Wider": 5, "Narrower": -5}.get(width, 0)
if isinstance(height, int):
dtpref_rows = height
if isinstance(width, int) or \
isinstance(width, str) and width.endswith('%'):
dtpref_cols = width
rows = str(max(1, int(dtpref_rows) + dr))
cols = str(dtpref_cols)
if cols.endswith('%'):
cols = str(min(100, max(25, int(cols[:-1]) + dc))) + '%'
else:
cols = str(max(35, int(cols) + dc))
e = (DateTime("GMT") + 365).rfc822()
setCookie = REQUEST["RESPONSE"].setCookie
setCookie("dtpref_rows", rows, path='/', expires=e)
setCookie("dtpref_cols", cols, path='/', expires=e)
REQUEST.other.update({"dtpref_cols": cols, "dtpref_rows": rows})
return self.pt_editForm()
def ZScriptHTML_tryParams(self):
"""Parameters to test the script with."""
return []
......
......@@ -5,7 +5,6 @@
<tal:block define="global body request/other/text | request/form/text
| context/read" />
<form action="" method="post" tal:attributes="action request/URL1">
<input type="hidden" name=":default_method" value="pt_changePrefs" />
<input type="hidden" name="encoding" value="utf-8" />
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
......@@ -46,17 +45,8 @@
</td>
</tr>
<tr>
<td align="left" valign="top" colspan="4"
tal:define="width request/dtpref_cols | string:100%;
relative_width python:str(width).endswith('%')">
<td align="left" valign="top" colspan="4">
<textarea name="text:text" wrap="off" style="width: 100%;" rows="20"
tal:condition="relative_width"
tal:attributes="style string:width: $width;;;
rows request/dtpref_rows | default"
tal:content="body">Template Body</textarea>
<textarea name="text:text" wrap="off" rows="20" cols="50"
tal:condition="not:relative_width"
tal:attributes="cols width; rows request/dtpref_rows | default"
tal:content="body">Template Body</textarea>
</td>
</tr>
......@@ -69,10 +59,6 @@
class="form-element" type="submit"
name="pt_editAction:method" value="Save Changes"/>
&nbsp;&nbsp;
<input class="form-element" type="submit" name="height" value="Taller" />
<input class="form-element" type="submit" name="height" value="Shorter" />
<input class="form-element" type="submit" name="width" value="Wider" />
<input class="form-element" type="submit" name="width" value="Narrower" />
</div>
</td>
</tr>
......
......@@ -21,16 +21,9 @@ probably need to manage Zope using its raw IP address to fix things.
(<strong>host/path</strong>),
or a set of hosts (<strong>*.host/path</strong>).
<div style="width: 100%;">
<dtml-let cols="REQUEST.get('dtpref_cols', '100%')"
rows="REQUEST.get('dtpref_rows', '20')">
<dtml-if "cols[-1]=='%'">
<textarea name="map_text:text" wrap="off" style="width: &dtml-cols;;"
<dtml-else>
<textarea name="map_text:text" wrap="off" cols="&dtml-cols;"
</dtml-if>
rows="&dtml-rows;"><dtml-in lines>&dtml-sequence-item;
<textarea name="map_text:text" wrap="off" style="width: 100%;"
rows="20"><dtml-in lines>&dtml-sequence-item;
</dtml-in></textarea>
</dtml-let>
</div>
</td>
</tr>
......@@ -44,11 +37,6 @@ probably need to manage Zope using its raw IP address to fix things.
<dtml-else>
<input class="form-element" type="submit" name="SUBMIT" value="Save Changes">
</dtml-if>
&nbsp;&nbsp;
<input class="form-element" type="submit" name="SUBMIT" value="Taller">
<input class="form-element" type="submit" name="SUBMIT" value="Shorter">
<input class="form-element" type="submit" name="SUBMIT" value="Wider">
<input class="form-element" type="submit" name="SUBMIT" value="Narrower">
</div>
</td>
</tr>
......
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