Back to index

plone3  3.1.7
folder_rename_form.py
Go to the documentation of this file.
00001 ##parameters=b_start=0, key='', reverse=0, ids=(), new_ids=(), rename='', cancel=''
00002 ##
00003 from Products.CMFCore.utils import getToolByName
00004 from Products.CMFDefault.utils import decode
00005 from Products.CMFDefault.utils import html_marshal
00006 from Products.CMFDefault.utils import Message as _
00007 
00008 utool = getToolByName(script, 'portal_url')
00009 portal_url = utool()
00010 
00011 
00012 form = context.REQUEST.form
00013 default_kw = {'b_start': b_start, 'key': key, 'reverse': reverse}
00014 if rename and \
00015         context.folder_rename_control(**form) and \
00016         context.setRedirect(context, 'object/folderContents', **default_kw):
00017     return
00018 elif cancel and \
00019         context.setRedirect(context, 'object/folderContents', **default_kw):
00020     return
00021 
00022 
00023 options = {}
00024 
00025 c = context.aq_explicit
00026 raw_items = [ getattr(c, id) for id in ids if hasattr(c, id) ]
00027 raw_items = [ item for item in raw_items if item.cb_isMoveable() ]
00028 items = []
00029 for item in raw_items:
00030     item_icon = item.getIcon(1)
00031     items.append( { 'icon': item_icon and
00032                             ( '%s/%s' % (portal_url, item_icon) ) or '',
00033                     'id': item.getId(),
00034                     'title': item.Title(),
00035                     'type': item.Type() or None } )
00036 options['batch'] = { 'listItemInfos': tuple(items) }
00037 
00038 target = context.getActionInfo('object/rename_items')['url']
00039 hidden_vars = []
00040 for name, value in html_marshal(**default_kw):
00041     hidden_vars.append( {'name': name, 'value': value} )
00042 buttons = []
00043 buttons.append( {'name': 'rename', 'value': _(u'Rename')} )
00044 buttons.append( {'name': 'cancel', 'value': _(u'Cancel')} )
00045 options['form'] = { 'action': target,
00046                     'listHiddenVarInfos': tuple(hidden_vars),
00047                     'listButtonInfos': tuple(buttons) }
00048 
00049 return context.folder_rename_template(**decode(options, script))