Affichage bordure à droite de la cible du dépôt.
[Portfolio.git] / skins / lightbox_view.py
1 ##parameters=
2 from Products.Portfolio.utils import translate
3 _ = lambda msg : translate(msg, context)
4 options = {}
5
6 sd = context.session_data_manager.getSessionData(create = 1)
7 path = context.getPhysicalPath()
8 req = context.REQUEST
9 form = req.form
10 fg = form.get
11
12 # check if lighbox is selected
13 sessionpath = sd.get('lightboxpath', None)
14 lightboxSelected = False
15 if sessionpath == path :
16 lightboxSelected = True
17
18 # form processing
19 if fg('load') :
20 sd.set('lightboxpath', path)
21 selection = context.getUidList()
22 sd.set('objects_selection', selection)
23 sd.set('objects_selection_dict', dict([(uid, True) for uid in selection]))
24 lightboxSelected = True
25
26 elif fg('unload') :
27 sd.set('lightboxpath', None)
28 sd.set('objects_selection', [])
29 sd.set('objects_selection_dict', {})
30 lightboxSelected = False
31
32 elif fg('delete.x') or form.has_key('delete') :
33 uids = fg('uids', [])
34 if not lightboxSelected :
35 for uid in [int(uid) for uid in uids] :
36 context.remove(uid)
37 else :
38 selection = sd.get('objects_selection', [])
39 selDict = sd.get('objects_selection_dict', {})
40 for uid in [int(uid) for uid in uids] :
41 context.remove(uid)
42 selection.remove(uid)
43 del selDict[uid]
44
45 sd['objects_selection'] = selection
46 sd['objects_selection_dict'] = selDict
47
48 # ui feedback message
49 if uids :
50 if len(uids) == 1 :
51 msg = _('Photo removed.')
52 else :
53 msg = _('Removed photos.')
54 else :
55 msg = _('Nothing to remove.')
56
57 if fg('ajax') :
58 context.REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml;;charset=utf-8')
59 return '<deleted>%s</deleted>' % msg
60 else :
61 context.setStatus(True, msg)
62
63 buttons=[]
64 if lightboxSelected :
65 buttons.append({'name': 'unload', 'value': 'Unload from my selection'})
66 else :
67 buttons.append({'name':'load', 'value': 'Load in my selection'})
68
69 options['buttons'] = buttons
70 options['lightboxSelected'] = lightboxSelected
71 options['container_type'] = 'lightbox'
72 options.update(context.getLightboxPhotosInfos(context))
73
74 return context.lightbox_view_template(**options)