Versement catalogue solr dans Plinn core
[Plinn.git] / skins / custom_content / document_edit_form.py
1 ##parameters=change='', change_and_view='', ajax=''
2 from Products.CMFCore.utils import getToolByName
3 atool = getToolByName(context, 'portal_attachment')
4 attachments = atool.getAttachmentsFor(context)
5
6 form = context.REQUEST.form
7 text = form.get('text')
8 if text and same_type(text, []) :
9 # when javascript is disabled,
10 # there's a hidden textarea from epoz
11 # and an other from <noscript> tag
12 form.update({'text' : text[1]})
13
14 if change and \
15 context.validateTextFile(**form) and \
16 context.validateHTML(**form) and \
17 context.document_edit_control(text=form.get('text'), text_format='html') and \
18 context.setRedirect(context, 'object/edit', **{'ajax':ajax}):
19 return
20 elif change_and_view and \
21 context.validateTextFile(**form) and \
22 context.validateHTML(**form) and \
23 context.document_edit_control(text=form.get('text'), text_format='html') :
24 attachments.removeUnusedAttachments(context.EditableBody())
25 return context.setRedirect(context, 'object/view', **{'ajax':ajax})
26
27
28 options = {}
29
30 buttons = []
31 target = context.getActionInfo('object/edit')['url']
32 buttons.append( {'name': 'change', 'value': 'Change'} )
33 buttons.append( {'name': 'change_and_view', 'value': 'Change and View'} )
34 options['form'] = { 'action': target,
35 'listButtonInfos': tuple(buttons) }
36
37 return context.document_edit_template(**options)