[CMF-checkins] CVS: CMF/CMFDefault/skins/zpt_generic - folder_rename_control.py:1.1 folder_rename_form.pt:1.8

Yvo Schubbe schubbe at web.de
Mon Jan 12 07:42:41 EST 2004


Update of /cvs-repository/CMF/CMFDefault/skins/zpt_generic
In directory cvs.zope.org:/tmp/cvs-serv20591/CMFDefault/skins/zpt_generic

Modified Files:
	folder_rename_form.pt 
Added Files:
	folder_rename_control.py 
Log Message:
- refactored folder_rename_form
- folder_rename_control replaces folder_rename and folder_rename_items scripts


=== Added File CMF/CMFDefault/skins/zpt_generic/folder_rename_control.py ===
## Script (Python) "folder_rename_control"
##bind container=container
##bind context=context
##bind namespace=
##bind script=script
##bind subpath=traverse_subpath
##parameters=ids=(), new_ids=(), rename='', cancel=''
##title=
##
from ZTUtils import make_query
from Products.CMFCore.utils import getToolByName
atool = getToolByName(script, 'portal_actions')
utool = getToolByName(script, 'portal_url')
portal_url = utool()
message = ''


if rename:
    context.manage_renameObjects(ids, new_ids)
    target = atool.getActionInfo('folder/folderContents', context)['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

elif cancel:
    target = atool.getActionInfo('folder/folderContents', context)['url']
    context.REQUEST.RESPONSE.redirect(target)
    return None

if message:
    context.REQUEST.set('portal_status_message', message)


control = {}

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 } )
control['batch'] = { 'listItemInfos': tuple(items) }

buttons = []
ti = context.getTypeInfo()
target = ti.getActionInfo('folder/rename_items', context)['url']
buttons.append( {'name': 'rename', 'value': 'Rename'} )
buttons.append( {'name': 'cancel', 'value': 'Cancel'} )
control['form'] = { 'action': target,
                    'listButtonInfos': tuple(buttons) }

return control


=== CMF/CMFDefault/skins/zpt_generic/folder_rename_form.pt 1.7 => 1.8 ===
--- CMF/CMFDefault/skins/zpt_generic/folder_rename_form.pt:1.7	Sun Nov  2 09:30:38 2003
+++ CMF/CMFDefault/skins/zpt_generic/folder_rename_form.pt	Mon Jan 12 07:42:40 2004
@@ -1,68 +1,42 @@
-<html xmlns:tal="http://xml.zope.org/namespaces/tal"
-      xmlns:metal="http://xml.zope.org/namespaces/metal"
-      metal:use-macro="here/main_template/macros/master">
+<tal:page
+   xmlns:tal="http://xml.zope.org/namespaces/tal"
+   xmlns:metal="http://xml.zope.org/namespaces/metal"
+   xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+   tal:define="control python: here.folder_rename_control(**request.form)"
+   tal:condition="control"
+><html metal:use-macro="here/main_template/macros/master">
 <body>
-<div metal:fill-slot="main" i18n:domain="cmf_default">
 
+<metal:block metal:fill-slot="main" i18n:domain="cmf_default"
+   tal:define="batch control/batch;
+               form control/form">
 <div class="Desktop">
 
-<h3 i18n:translate="">Rename Items</h3>
-
-<div tal:condition="here/folder_rename_items" >
-
-<form action="folder_rename" method="post"
-      tal:attributes="action string:${here/absolute_url}/folder_rename"
->
+<h2 i18n:translate="">Rename Items</h2>
 
+<form action="members_manage" method="post"
+   tal:attributes="action form/action">
  <table class="FormLayout">
-
-  <tr tal:repeat="item here/folder_rename_items">
-
-    <td align="left" valign="top" width="8%">
-      <span tal:replace="structure item/iconHTML">Type Image</span>
-    </td>
-
-    <td width="20%">
-      <span tal:replace="item/getId">ID</span>
-      <input type="hidden" name="ids:list" value=""
-             tal:attributes="value item/getId" />
-    </td>
-
-    <td align="left" valign="top" width="5%">
-      <strong i18n:translate="">to</strong>
-    </td>
-
-    <td align="left" valign="top">
-      <input type="text" name="new_ids:list" value=""
-             tal:attributes="value item/getId" size="20" />
-    </td>
-  </tr>
-
-  <tr>
-    <td colspan="4">
-      <input type="submit" value=" Ok " i18n:attributes="value" />
-    </td>
+  <tr tal:repeat="item batch/listItemInfos">
+   <td width="8%"
+   ><img src="" alt="" border="0"
+       tal:attributes="src item/icon; alt item/type"
+       i18n:attributes="alt" /></td>
+   <td width="20%"
+   ><tal:span tal:replace="item/id">ID</tal:span>
+    <input type="hidden" name="ids:list" value=""
+       tal:attributes="value item/id" /></td>
+   <td width="5%"
+   ><strong i18n:translate="">to</strong></td>
+   <td
+   ><input type="text" name="new_ids:list" value=""
+       tal:attributes="value item/id" size="20" /></td>
   </tr>
-
  </table>
-
-</form>
-
-</div><!-- tal:condition="here/folder_rename_items" -->
-
-<div tal:condition="not: here/folder_rename_items">
-
-<form action="folder_contents" method="get"
-      tal:attributes="action string:${here/absolute_url}/folder_contents"
->
-  <p i18n:translate="">You must select one or more items to rename.</p>
-  <input type="submit" value=" Ok " i18n:attributes="value" />
+ <metal:block metal:use-macro="here/form_widgets/macros/buttons" />
 </form>
 </div>
-
-</div><!-- class="Desktop"-->
-
-</div><!-- metal:fill-slot="main" -->
+</metal:block>
 
 </body>
-</html>
+</html></tal:page>




More information about the CMF-checkins mailing list