Upgrade de swfobject, de 1.5 à 2.2.
[Plinn.git] / skins / control / add_content.py
1 ##parameters=
2 from Products.Plinn.utils import makeValidId
3 form = context.REQUEST.form
4
5 for k in form.keys() :
6 item = form[k]
7 if hasattr(item, 'keys') and item.has_key('type') :
8 typeDic = item.copy()
9 typeDic['type'] = k
10 break
11
12 if typeDic.has_key('id') :
13 title = typeDic['id']
14 newid = makeValidId(context, title)
15
16 context.invokeFactory( typeDic['type'], newid, title=title)
17 newOb = getattr(context, newid)
18 ti = newOb.getTypeInfo()
19 immediate_view = ti.immediate_view
20
21 if immediate_view.find('/') > 0 :
22 newOb.setStatus('True', 'Object created.')
23 return newOb.setRedirect(newOb, immediate_view, syncFragments = ['Breadcrumbs', 'rightCell'], **form)
24 else :
25 from ZTUtils import make_query
26 ob_url = newOb.absolute_url()
27 query = make_query(portal_status_message = 'Object created.', ajax = form.get('ajax'), syncFragments = ['Breadcrumbs', 'rightCell'])
28 url = "%s/%s?%s" % (ob_url, immediate_view, query)
29 response = context.REQUEST.RESPONSE
30 return response.redirect(url)
31
32 elif typeDic.has_key('create_form') :
33 from Products.CMFCore.utils import getToolByName
34 ttool = getToolByName(context, 'portal_types')
35 typeName = typeDic['type']
36 ti = getattr(ttool, typeName)
37 ai = ti.getActionInfo('object/create', object=context)
38 url = ai['url']
39
40 from ZTUtils import make_query
41 query = make_query(ajax=form.get('ajax'))
42 url = '%s?%s' % (url, query)
43 response = context.REQUEST.RESPONSE
44 return response.redirect(url)