[CMF-checkins] CVS: CMF/CMFDefault/skins/zpt_generic -
folder_contents.pt:1.15 folder_contents_control.py:1.6
folder_rename_control.py:1.4 folder_rename_form.pt:1.11
form_widgets.pt:1.2 getBatchNavigation.py:1.2
zpt_stylesheet.css:1.10
Yvo Schubbe
y.2004_ at wcm-solutions.de
Thu Apr 15 09:43:00 EDT 2004
Update of /cvs-repository/CMF/CMFDefault/skins/zpt_generic
In directory cvs.zope.org:/tmp/cvs-serv13224/CMFDefault/skins/zpt_generic
Modified Files:
folder_contents.pt folder_contents_control.py
folder_rename_control.py folder_rename_form.pt form_widgets.pt
getBatchNavigation.py zpt_stylesheet.css
Log Message:
- added OrderSupport for PortalFolder (part 2: folder_contents)
=== CMF/CMFDefault/skins/zpt_generic/folder_contents.pt 1.14 => 1.15 ===
--- CMF/CMFDefault/skins/zpt_generic/folder_contents.pt:1.14 Mon Feb 2 11:50:32 2004
+++ CMF/CMFDefault/skins/zpt_generic/folder_contents.pt Thu Apr 15 09:42:59 2004
@@ -6,15 +6,19 @@
><html metal:use-macro="here/main_template/macros/master">
<body>
+<metal:block metal:fill-slot="header">
+<h1 i18n:translate=""
+>Folder Contents: <span tal:replace="here/Title" i18n:name="objectid"
+ >My Title</span></h1>
+</metal:block>
+
<metal:block metal:fill-slot="main"
tal:define="batch control/batch;
form control/form;
up_info control/up_info">
<div class="Desktop" i18n:domain="cmf_default">
-<h2 i18n:translate="">Desktop</h2>
-
-<tal:case tal:condition="up_info"
+<p tal:condition="up_info"
><tal:case tal:condition="up_info/url"
><a href="" tal:attributes="href up_info/url"
><img src="" alt="[Link]" border="0" tal:attributes="src up_info/icon"
@@ -23,15 +27,24 @@
<a href="" tal:attributes="href up_info/url"
tal:content="up_info/id">ID</a></tal:case
><tal:case tal:condition="not: up_info/url"
- ><span class="mild" i18n:translate="">Root</span></tal:case></tal:case>
+ ><span class="mild" i18n:translate="">Root</span></tal:case></p>
<form action="folder_contents" method="post"
- tal:attributes="action control/form/action">
- <table class="ContentsList" tal:condition="batch/listItemInfos1">
- <tr>
- <td width="49%">
- <table>
- <tr tal:repeat="item_info batch/listItemInfos1">
+ tal:attributes="action control/form/action"
+><metal:block metal:use-macro="here/form_widgets/macros/hidden_vars" />
+ <table class="BatchTable"
+ tal:condition="batch/listItemInfos">
+ <thead>
+ <tr class="list-header">
+ <th width="80" tal:repeat="column_info batch/listColumnInfos"
+ tal:attributes="width column_info/width; colspan column_info/colspan"
+ ><a href="" tal:attributes="href column_info/url"
+ tal:content="column_info/title" i18n:translate="">Type</a></th>
+ </tr>
+ </thead>
+ <tbody tal:repeat="item_info batch/listItemInfos">
+ <tr class="" tal:define="even repeat/item_info/even"
+ tal:attributes="class python: (even and 'row-hilite') or 'row-normal'">
<td width="5"
><input type="checkbox" name="ids:tuple" value="" id=""
tal:attributes="value item_info/id; id item_info/checkbox"
@@ -48,37 +61,40 @@
<tal:case tal:condition="item_info/title"
tal:content="string:(${item_info/title})">(Title)</tal:case
></a></td>
- </tr>
- </table>
- </td>
- <td width="2%"> </td>
- <td width="49%" tal:condition="batch/listItemInfos2">
- <table>
- <tr tal:repeat="item_info batch/listItemInfos2">
- <td width="5"
- ><input type="checkbox" name="ids:tuple" value="" id=""
- tal:attributes="value item_info/id; id item_info/checkbox"
- tal:condition="item_info/checkbox" /></td>
<td
- ><a href="" tal:attributes="href item_info/url"
- tal:condition="item_info/icon"
- ><img src="" alt="" border="0"
- tal:attributes="src item_info/icon; alt item_info/type"
- i18n:attributes="alt" /></a></td>
+ ><tal:span tal:content="item_info/modified">2001</tal:span></td>
<td
- ><a href="" tal:attributes="href item_info/url"
- ><tal:span tal:content="item_info/id">ID</tal:span>
- <tal:case tal:condition="item_info/title"
- tal:content="string:(${item_info/title})">(Title)</tal:case
- ></a></td>
- </tr>
- </table>
- </td>
- </tr>
+ ><tal:span tal:content="item_info/position">1</tal:span></td>
+ </tr>
+ </tbody>
</table>
<metal:block metal:use-macro="here/batch_widgets/macros/navigation" />
<metal:block metal:use-macro="here/form_widgets/macros/buttons" />
-</form>
+<tal:case tal:condition="python: form['is_orderable'] or form['is_sortable']"
+> <div class="FormButtons"
+ ><tal:case tal:condition="form/is_orderable">
+ <input type="submit" name="items_up" value="Up"
+ i18n:attributes="value" />
+ /
+ <input type="submit" name="items_down" value="Down"
+ i18n:attributes="value" />
+ by
+ <select name="delta:int">
+ <option value=""
+ tal:repeat="delta form/listDeltas"
+ tal:attributes="value delta"
+ tal:content="delta">
+ </option>
+ </select>
+ <input type="submit" name="items_top" value="Top"
+ i18n:attributes="value" />
+ <input type="submit" name="items_bottom" value="Bottom"
+ i18n:attributes="value" /></tal:case
+ ><tal:case tal:condition="form/is_sortable">
+ <input type="submit" name="items_sort" value="Set Sorting as Default"
+ i18n:attributes="value" /></tal:case
+></div>
+</tal:case></form>
<div tal:replace="structure here/folder_filter_form">Filter Form Here</div>
=== CMF/CMFDefault/skins/zpt_generic/folder_contents_control.py 1.5 => 1.6 ===
--- CMF/CMFDefault/skins/zpt_generic/folder_contents_control.py:1.5 Mon Feb 23 07:55:04 2004
+++ CMF/CMFDefault/skins/zpt_generic/folder_contents_control.py Thu Apr 15 09:42:59 2004
@@ -4,7 +4,7 @@
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
-##parameters=ids=(), b_start=0, items_copy='', items_cut='', items_delete='', items_new='', items_paste='', items_rename='', **kw
+##parameters=b_start=0, key='', reverse=0, ids=(), delta=1, items_copy='', items_cut='', items_delete='', items_new='', items_paste='', items_rename='', items_up='', items_down='', items_top='', items_bottom='', items_sort='', **kw
##title=
##
from ZTUtils import Batch
@@ -14,23 +14,38 @@
from Products.CMFCore.CMFCorePermissions import AddPortalContent
from Products.CMFCore.CMFCorePermissions import DeleteObjects
from Products.CMFCore.CMFCorePermissions import ListFolderContents
+from Products.CMFCore.CMFCorePermissions import ManageProperties
from Products.CMFCore.CMFCorePermissions import ViewManagementScreens
from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.utils import html_marshal
mtool = getToolByName(script, 'portal_membership')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
+target_action = 'object/folderContents'
+status = ''
message = ''
+if not key:
+ (key, reverse) = context.getDefaultSorting()
+ is_default = 1
+elif (key, reverse) == context.getDefaultSorting():
+ is_default = 1
+else:
+ kw['key'] = key
+ if reverse:
+ kw['reverse'] = reverse
+ is_default = 0
+if b_start:
+ kw['b_start'] = b_start
if not mtool.checkPermission(ListFolderContents, context):
- target = context.getActionInfo('object/view')['url']
- context.REQUEST.RESPONSE.redirect(target)
- return None
-
+ status = 'success'
+ target_action = 'object/view'
-if items_copy:
+elif items_copy:
if ids:
context.manage_copyObjects(ids, context.REQUEST)
+ status = 'success'
message = 'Item%s copied.' % ( len(ids) != 1 and 's' or '' )
else:
message = 'Please select one or more items to copy first.'
@@ -38,6 +53,7 @@
elif items_cut:
if ids:
context.manage_cutObjects(ids, context.REQUEST)
+ status = 'success'
message = 'Item%s cut.' % ( len(ids) != 1 and 's' or '' )
else:
message = 'Please select one or more items to cut first.'
@@ -45,19 +61,20 @@
elif items_delete:
if ids:
context.manage_delObjects( list(ids) )
+ status = 'success'
message = 'Item%s deleted.' % ( len(ids) != 1 and 's' or '' )
else:
message = 'Please select one or more items to delete first.'
elif items_new:
- target = context.getActionInfo('object/new')['url']
- context.REQUEST.RESPONSE.redirect(target)
- return None
+ status = 'success'
+ target_action = 'object/new'
elif items_paste:
if context.cb_dataValid:
try:
result = context.manage_pasteObjects(context.REQUEST['__cp'])
+ status = 'success'
message = 'Item%s pasted.' % ( len(result) != 1 and 's' or '' )
except CopyError:
message = 'CopyError: Paste failed.'
@@ -68,13 +85,62 @@
elif items_rename:
if ids:
- target = context.getActionInfo('object/rename_items')['url']
- query = make_query( ids=list(ids) )
- context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
- return None
+ status = 'success'
+ target_action = 'object/rename_items'
+ kw['ids'] = list(ids)
else:
message = 'Please select one or more items to rename first.'
+elif items_sort:
+ context.setDefaultSorting(key, reverse)
+ status = 'success'
+ if kw.has_key('key'):
+ del kw['key']
+ if kw.has_key('reverse'):
+ del kw['reverse']
+
+elif items_up or items_down or items_top or items_bottom:
+ if ids:
+ subset_ids = [ obj.getId() for obj in context.listFolderContents() ]
+ try:
+ if items_up:
+ attempt = context.moveObjectsUp(ids, delta,
+ subset_ids=subset_ids)
+ move = 'up'
+ elif items_down:
+ attempt = context.moveObjectsDown(ids, delta,
+ subset_ids=subset_ids)
+ move = 'down'
+ elif items_top:
+ attempt = context.moveObjectsToTop(ids, subset_ids=subset_ids)
+ move = 'to top'
+ elif items_bottom:
+ attempt = context.moveObjectsToBottom(ids,
+ subset_ids=subset_ids)
+ move = 'to bottom'
+ status = 'success'
+ if attempt:
+ message = '%d item%s moved %s.' % ( attempt,
+ ( (attempt!=1) and 's' or '' ), move )
+ else:
+ message = 'Nothing to change.'
+ except ValueError, errmsg:
+ message = 'ValueError: %s' % (errmsg)
+ else:
+ message = 'Please select one or more items to move first.'
+
+
+if status == 'success':
+ target = context.getActionInfo(target_action)['url']
+ if message:
+ kw['portal_status_message'] = message
+ if kw:
+ query = make_query(kw)
+ context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
+ else:
+ context.REQUEST.RESPONSE.redirect(target)
+ return None
+
if message:
context.REQUEST.set('portal_status_message', message)
@@ -86,6 +152,7 @@
items_add_allowed = mtool.checkPermission(AddPortalContent, context)
upitems_list_allowed = mtool.checkPermission(ListFolderContents, context,
'aq_parent')
+items_move_allowed = mtool.checkPermission(ManageProperties, context)
up_info = {}
if upitems_list_allowed:
@@ -102,15 +169,44 @@
control['up_info'] = up_info
target = context.getActionInfo('object/folderContents')['url']
+
+columns = ( {'key': 'Type',
+ 'title': 'Type',
+ 'width': '20',
+ 'colspan': '2'}
+ , {'key': 'getId',
+ 'title': 'Name',
+ 'width': '380',
+ 'colspan': None}
+ , {'key': 'modified',
+ 'title': 'Last Modified',
+ 'width': '160',
+ 'colspan': None}
+ , {'key': 'position',
+ 'title': 'Position',
+ 'width': '80',
+ 'colspan': None }
+ )
+for column in columns:
+ if key == column['key'] and not reverse and key != 'position':
+ query = make_query(key=column['key'], reverse=1)
+ else:
+ query = make_query(key=column['key'])
+ column['url'] = '%s?%s' % (target, query)
+
context.filterCookie()
folderfilter = context.REQUEST.get('folderfilter', '')
filter = context.decodeFolderFilter(folderfilter)
items = context.listFolderContents(contentFilter=filter)
-batch_obj = Batch(items, 40, b_start, orphan=0)
+items = sequence.sort( items, ((key, 'cmp', reverse and 'desc' or 'asc'),) )
+batch_obj = Batch(items, 25, b_start, orphan=0)
items = []
+i = 1
for item in batch_obj:
item_icon = item.getIcon(1)
item_id = item.getId()
+ item_position = key == 'position' and str(b_start + i) or '...'
+ i += 1
item_url = item.getActionInfo( ('object/folderContents',
'object/view') )['url']
items.append( { 'checkbox': items_manage_allowed and
@@ -118,14 +214,19 @@
'icon': item_icon and
( '%s/%s' % (portal_url, item_icon) ) or '',
'id': item_id,
+ 'modified': item.ModificationDate(),
+ 'position': item_position,
'title': item.Title(),
'type': item.Type() or None,
'url': item_url } )
-navigation = context.getBatchNavigation(batch_obj, target)
-control['batch'] = { 'listItemInfos1': tuple(items[:20]),
- 'listItemInfos2': tuple(items[20:]),
+navigation = context.getBatchNavigation(batch_obj, target, **kw)
+control['batch'] = { 'listColumnInfos': tuple(columns),
+ 'listItemInfos': tuple(items),
'navigation': navigation }
+hidden_vars = []
+for name, value in html_marshal(**kw):
+ hidden_vars.append( {'name': name, 'value': value} )
buttons = []
if items_manage_allowed:
if items_add_allowed and context.allowedContentTypes():
@@ -139,7 +240,15 @@
buttons.append( {'name': 'items_paste', 'value': 'Paste'} )
if items_delete_allowed and items:
buttons.append( {'name': 'items_delete', 'value': 'Delete'} )
+length = batch_obj.sequence_length
+is_orderable = items_move_allowed and (key == 'position') and length > 1
+is_sortable = items_move_allowed and not is_default
+deltas = range( 1, min(5, length) ) + range(5, length, 5)
control['form'] = { 'action': target,
- 'listButtonInfos': tuple(buttons) }
+ 'listHiddenVarInfos': tuple(hidden_vars),
+ 'listButtonInfos': tuple(buttons),
+ 'listDeltas': tuple(deltas),
+ 'is_orderable': is_orderable,
+ 'is_sortable': is_sortable }
return control
=== CMF/CMFDefault/skins/zpt_generic/folder_rename_control.py 1.3 => 1.4 ===
--- CMF/CMFDefault/skins/zpt_generic/folder_rename_control.py:1.3 Mon Feb 23 07:55:04 2004
+++ CMF/CMFDefault/skins/zpt_generic/folder_rename_control.py Thu Apr 15 09:42:59 2004
@@ -4,27 +4,44 @@
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
-##parameters=ids=(), new_ids=(), rename='', cancel=''
+##parameters=ids=(), new_ids=(), rename='', cancel='', **kw
##title=
##
from ZTUtils import make_query
+from Products.CMFCore.CMFCoreExceptions import CopyError
from Products.CMFCore.utils import getToolByName
+from Products.CMFDefault.utils import html_marshal
utool = getToolByName(script, 'portal_url')
portal_url = utool()
+target_action = 'object/folderContents'
+status = ''
message = ''
if rename:
- context.manage_renameObjects(ids, new_ids)
- target = context.getActionInfo('object/folderContents')['url']
- message = 'Item%s renamed.' % ( len(ids) != 1 and 's' or '' )
- query = make_query(portal_status_message=message)
- context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
- return None
+ if not ids == new_ids:
+ try:
+ context.manage_renameObjects(ids, new_ids)
+ status = 'success'
+ message = 'Item%s renamed.' % ( len(ids) != 1 and 's' or '' )
+ except CopyError:
+ message = 'CopyError: Rename failed.'
+ else:
+ message = 'Nothing to change.'
elif cancel:
- target = context.getActionInfo('object/folderContents')['url']
- context.REQUEST.RESPONSE.redirect(target)
+ status = 'success'
+
+
+if status == 'success':
+ target = context.getActionInfo(target_action)['url']
+ if message:
+ kw['portal_status_message'] = message
+ if kw:
+ query = make_query(kw)
+ context.REQUEST.RESPONSE.redirect( '%s?%s' % (target, query) )
+ else:
+ context.REQUEST.RESPONSE.redirect(target)
return None
if message:
@@ -46,11 +63,15 @@
'type': item.Type() or None } )
control['batch'] = { 'listItemInfos': tuple(items) }
-buttons = []
target = context.getActionInfo('object/rename_items')['url']
+hidden_vars = []
+for name, value in html_marshal(**kw):
+ hidden_vars.append( {'name': name, 'value': value} )
+buttons = []
buttons.append( {'name': 'rename', 'value': 'Rename'} )
buttons.append( {'name': 'cancel', 'value': 'Cancel'} )
control['form'] = { 'action': target,
+ 'listHiddenVarInfos': tuple(hidden_vars),
'listButtonInfos': tuple(buttons) }
return control
=== CMF/CMFDefault/skins/zpt_generic/folder_rename_form.pt 1.10 => 1.11 ===
--- CMF/CMFDefault/skins/zpt_generic/folder_rename_form.pt:1.10 Mon Feb 2 11:50:32 2004
+++ CMF/CMFDefault/skins/zpt_generic/folder_rename_form.pt Thu Apr 15 09:42:59 2004
@@ -14,7 +14,8 @@
<h2 i18n:translate="">Rename Items</h2>
<form action="members_manage" method="post"
- tal:attributes="action form/action">
+ tal:attributes="action form/action"
+><metal:block metal:use-macro="here/form_widgets/macros/hidden_vars" />
<table class="FormLayout">
<tr tal:repeat="item_info batch/listItemInfos">
<td width="8%"
=== CMF/CMFDefault/skins/zpt_generic/form_widgets.pt 1.1 => 1.2 ===
--- CMF/CMFDefault/skins/zpt_generic/form_widgets.pt:1.1 Mon Nov 3 05:23:25 2003
+++ CMF/CMFDefault/skins/zpt_generic/form_widgets.pt Thu Apr 15 09:42:59 2004
@@ -1,6 +1,17 @@
<html>
<body>
+<tal:test tal:define="hidden_vars python: ( {'name': 'b_start:int',
+ 'value': 25}, );
+ global form python: {'listHiddenVarInfos': hidden_vars}
+ " />
+
+<metal:block metal:define-macro="hidden_vars">
+ <tal:loop tal:repeat="hidden_var form/listHiddenVarInfos"
+ ><input type="hidden" name="HiddenVarName" value=""
+ tal:attributes="name hidden_var/name; value hidden_var/value" /></tal:loop
+></metal:block>
+
<tal:test tal:define="buttons python: ( {'name': 'delete_items',
'value': 'Delete'}, );
global form python: {'listButtonInfos': buttons}" />
=== CMF/CMFDefault/skins/zpt_generic/getBatchNavigation.py 1.1 => 1.2 ===
--- CMF/CMFDefault/skins/zpt_generic/getBatchNavigation.py:1.1 Sat Nov 1 11:42:00 2003
+++ CMF/CMFDefault/skins/zpt_generic/getBatchNavigation.py Thu Apr 15 09:42:59 2004
@@ -10,6 +10,8 @@
from ZTUtils import make_query
if kw.has_key('b_start'):
del kw['b_start']
+if kw.has_key('portal_status_message'):
+ del kw['portal_status_message']
navigation = {}
=== CMF/CMFDefault/skins/zpt_generic/zpt_stylesheet.css 1.9 => 1.10 ===
--- CMF/CMFDefault/skins/zpt_generic/zpt_stylesheet.css:1.9 Mon Nov 3 05:23:25 2003
+++ CMF/CMFDefault/skins/zpt_generic/zpt_stylesheet.css Thu Apr 15 09:42:59 2004
@@ -367,9 +367,29 @@
}
.BatchTable tr.list-header {
- background-color: #c0c0c0;
+ background-color: #aaaaaa;
text-align: left;
font: 90%/120% sans-serif;
+}
+
+.BatchTable tr.list-header a:link {
+ color: #ffffff;
+ text-decoration: none;
+}
+
+.BatchTable tr.list-header a:visited {
+ color: #ffffff;
+ text-decoration: none;
+}
+
+.BatchTable tr.list-header a:active {
+ color: #ffffff;
+ text-decoration: none;
+}
+
+.BatchTable tr.list-header a:hover {
+ color: #336699;
+ text-decoration: none;
}
.BatchTable tr.row-normal {
More information about the CMF-checkins
mailing list