Utilisation png24 transparent pour le logo de Plinn.
[Plinn.git] / skins / custom_control / folder_delete_control.py
1 ##parameters=ids, **kw
2 ##title=Delete objects from a folder
3 ##
4 request = context.REQUEST
5 response = request.RESPONSE
6
7 if request.cookies.has_key('__cp'):
8 contextPath = context.getPhysicalPath()
9 depth = len(contextPath) + 1
10 strContextPath = ''.join(contextPath)
11
12 cp = context.getCPInfo()
13
14 deletedObPaths = {}
15 for id in ids :
16 deletedObPaths[strContextPath + id] = True
17
18 indexes, paths = [], cp[1]
19
20 for i in range(len(paths)) :
21 path = paths[i]
22 try :
23 firstPart = path[:depth]
24 if deletedObPaths.has_key(''.join(firstPart)) :
25 indexes.append(i)
26 except IndexError : continue
27
28 context.popCP(indexes)
29
30
31 ret = context.manage_delObjects( list(ids) )
32 msg=''
33 if ret :
34 ignored = []
35 for id in ret :
36 o = getattr(context, id, None)
37 if o :
38 ignored.append(o.title_or_id())
39 #TODO : translate messages
40 #from Products.PlacelessTranslationService.MessageID import MessageIDFactory
41 #_ = MessageIDFactory('plinn')
42 _ = lambda x : lambda : x
43 translate = lambda msg : _(msg)().decode('iso-8859-1').encode('utf-8')
44 msg = translate('You are not allowed to delete: ') + ', '.join(ignored)
45
46 msg = msg or 'Item%s deleted.' % ( len(ids) != 1 and 's' or '' )
47 return context.setStatus( True, msg)