[CMF-checkins] CVS: Products/CMFDefault/skins/zpt_generic -
folder_contents.py:1.1 folder_contents_template.pt:1.1
folder_rename_form.py:1.1 folder_rename_template.pt:1.1
folder_contents.pt:NONE folder_contents_control.py:NONE
folder_rename_control.py:NONE folder_rename_form.pt:NONE
Yvo Schubbe
y.2004_ at wcm-solutions.de
Tue Jul 6 16:34:17 EDT 2004
Update of /cvs-repository/Products/CMFDefault/skins/zpt_generic
In directory cvs.zope.org:/tmp/cvs-serv28233/CMFDefault/skins/zpt_generic
Added Files:
folder_contents.py folder_contents_template.pt
folder_rename_form.py folder_rename_template.pt
Removed Files:
folder_contents.pt folder_contents_control.py
folder_rename_control.py folder_rename_form.pt
Log Message:
- renamed folder_contents.pt and folder_rename_form.pt to folder_*_template.pt
- renamed folder_*_control.py to folder_contents.py and folder_rename_form.py: these scripts are now called directly
- renamed folder controllers to folder_*_control.py
- modified kw handling a bit to work with the new calling order
=== Added File Products/CMFDefault/skins/zpt_generic/folder_contents.py ===
##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=''
##
from ZTUtils import Batch
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import AddPortalContent
from Products.CMFDefault.permissions import DeleteObjects
from Products.CMFDefault.permissions import ListFolderContents
from Products.CMFDefault.permissions import ManageProperties
from Products.CMFDefault.permissions import ViewManagementScreens
from Products.CMFDefault.utils import html_marshal
mtool = getToolByName(script, 'portal_membership')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
form = context.REQUEST.form
default_target = 'object/folderContents'
default_kw = {'b_start': b_start, 'key': key, 'reverse': reverse}
if items_copy and \
context.validateItemIds(**form) and \
context.folder_copy_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_cut and \
context.validateItemIds(**form) and \
context.folder_cut_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_delete and \
context.validateItemIds(**form) and \
context.folder_delete_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_new and \
context.setRedirect(context, 'object/new'):
return
elif items_paste and \
context.folder_paste_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_rename and \
context.validateItemIds(**form) and \
context.setRedirect(context, 'object/rename_items', ids=ids,
**default_kw):
return
elif items_sort and \
context.folder_sort_control(**form) and \
context.setRedirect(context, default_target, b_start=b_start):
return
elif items_up and \
context.validateItemIds(**form) and \
context.folder_up_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_down and \
context.validateItemIds(**form) and \
context.folder_down_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_top and \
context.validateItemIds(**form) and \
context.folder_top_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
elif items_bottom and \
context.validateItemIds(**form) and \
context.folder_bottom_control(**form) and \
context.setRedirect(context, default_target, **default_kw):
return
options = {}
items_manage_allowed = mtool.checkPermission(ViewManagementScreens, context)
items_delete_allowed = mtool.checkPermission(DeleteObjects, context)
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:
up_obj = context.aq_parent
if hasattr(up_obj, 'portal_url'):
up_url = up_obj.getActionInfo('object/folderContents')['url']
up_info = { 'icon': '%s/UpFolder_icon.gif' % portal_url,
'id': up_obj.getId(),
'url': up_url }
else:
up_info = { 'icon': '',
'id': 'Root',
'url': '' }
options['up_info'] = up_info
target = context.getActionInfo(default_target)['url']
if not key:
(key, reverse) = context.getDefaultSorting()
is_default = 1
elif (key, reverse) == context.getDefaultSorting():
is_default = 1
else:
is_default = 0
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)
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
('cb_%s' % item_id) or '',
'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, **default_kw)
options['batch'] = { 'listColumnInfos': tuple(columns),
'listItemInfos': tuple(items),
'navigation': navigation }
hidden_vars = []
for name, value in html_marshal(**default_kw):
hidden_vars.append( {'name': name, 'value': value} )
buttons = []
if items_manage_allowed:
if items_add_allowed and context.allowedContentTypes():
buttons.append( {'name': 'items_new', 'value': 'New...'} )
if items:
buttons.append( {'name': 'items_rename', 'value': 'Rename'} )
if items:
buttons.append( {'name': 'items_cut', 'value': 'Cut'} )
buttons.append( {'name': 'items_copy', 'value': 'Copy'} )
if items_add_allowed and context.cb_dataValid():
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)
options['form'] = { 'action': target,
'listHiddenVarInfos': tuple(hidden_vars),
'listButtonInfos': tuple(buttons),
'listDeltas': tuple(deltas),
'is_orderable': is_orderable,
'is_sortable': is_sortable }
return context.folder_contents_template(**options)
=== Added File Products/CMFDefault/skins/zpt_generic/folder_contents_template.pt ===
<html metal:use-macro="context/main_template/macros/master">
<body>
<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
<h1 i18n:translate="">Folder Contents: <tal:span
tal:content="context/Title" i18n:name="obj_title">Title</tal:span></h1>
</metal:slot>
<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
tal:define="batch options/batch;
form options/form;
up_info options/up_info">
<div class="Desktop">
<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"
i18n:attributes="alt" /></a>
<span tal:omit-tag="" i18n:translate="">Up to</span>
<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></p>
<form action="folder_contents" method="post"
tal:attributes="action form/action"
><metal:macro metal:use-macro="context/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:list" 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>
<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>
<td
><tal:span tal:content="item_info/modified">2001</tal:span></td>
<td
><tal:span tal:content="item_info/position">1</tal:span></td>
</tr>
</tbody>
</table>
<metal:macro metal:use-macro="context/batch_widgets/macros/navigation" />
<metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
<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 context/folder_filter_form">Filter Form Here</div>
</div>
</metal:slot>
</body>
</html>
=== Added File Products/CMFDefault/skins/zpt_generic/folder_rename_form.py ===
##parameters=b_start=0, key='', reverse=0, ids=(), new_ids=(), rename='', cancel=''
##
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.utils import html_marshal
utool = getToolByName(script, 'portal_url')
portal_url = utool()
form = context.REQUEST.form
default_kw = {'b_start': b_start, 'key': key, 'reverse': reverse}
if rename and \
context.folder_rename_control(**form) and \
context.setRedirect(context, 'object/folderContents', **default_kw):
return
elif cancel and \
context.setRedirect(context, 'object/folderContents', **default_kw):
return
options = {}
c = context.aq_explicit
raw_items = [ getattr(c, id) for id in ids if hasattr(c, id) ]
raw_items = [ item for item in raw_items if item.cb_isMoveable() ]
items = []
for item in raw_items:
item_icon = item.getIcon(1)
items.append( { 'icon': item_icon and
( '%s/%s' % (portal_url, item_icon) ) or '',
'id': item.getId(),
'title': item.Title(),
'type': item.Type() or None } )
options['batch'] = { 'listItemInfos': tuple(items) }
target = context.getActionInfo('object/rename_items')['url']
hidden_vars = []
for name, value in html_marshal(**default_kw):
hidden_vars.append( {'name': name, 'value': value} )
buttons = []
buttons.append( {'name': 'rename', 'value': 'Rename'} )
buttons.append( {'name': 'cancel', 'value': 'Cancel'} )
options['form'] = { 'action': target,
'listHiddenVarInfos': tuple(hidden_vars),
'listButtonInfos': tuple(buttons) }
return context.folder_rename_template(**options)
=== Added File Products/CMFDefault/skins/zpt_generic/folder_rename_template.pt ===
<html metal:use-macro="context/main_template/macros/master">
<body>
<metal:slot metal:fill-slot="header" i18n:domain="cmf_default">
<h1 i18n:translate="">Rename Items</h1>
</metal:slot>
<metal:slot metal:fill-slot="main" i18n:domain="cmf_default"
tal:define="batch options/batch;
form options/form">
<div class="Desktop">
<form action="members_manage" method="post"
tal:attributes="action form/action"
><metal:macro metal:use-macro="context/form_widgets/macros/hidden_vars" />
<table class="FormLayout">
<tr tal:repeat="item_info batch/listItemInfos">
<td width="8%"
><img src="" alt="" border="0"
tal:attributes="src item_info/icon; alt item_info/type"
i18n:attributes="alt" /></td>
<td width="20%"
><tal:span tal:replace="item_info/id">ID</tal:span>
<input type="hidden" name="ids:list" value=""
tal:attributes="value item_info/id" /></td>
<td width="5%"
><strong i18n:translate="">to</strong></td>
<td
><input type="text" name="new_ids:list" value=""
tal:attributes="value item_info/id" size="20" /></td>
</tr>
</table>
<metal:macro metal:use-macro="context/form_widgets/macros/buttons" />
</form>
</div>
</metal:slot>
</body>
</html>
=== Removed File Products/CMFDefault/skins/zpt_generic/folder_contents.pt ===
=== Removed File Products/CMFDefault/skins/zpt_generic/folder_contents_control.py ===
=== Removed File Products/CMFDefault/skins/zpt_generic/folder_rename_control.py ===
=== Removed File Products/CMFDefault/skins/zpt_generic/folder_rename_form.pt ===
More information about the CMF-checkins
mailing list