2 from Products
.CMFCore
.utils
import getUtilityByInterfaceName
3 from Products
.Portfolio
.utils
import translate
4 def _(message
) : return translate(message
, context
).encode('utf-8')
7 utool
= getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool')
8 portal
= utool
.getPortalObject()
13 sd
= context
.session_data_manager
.getSessionData(create
= 1)
15 # check if a lightbox is currently selected
16 lightboxpath
= sd
.get('lightboxpath', None)
17 selectionIsLightbox
= False
18 if lightboxpath
is not None :
20 lightbox
= portal
.restrictedTraverse(lightboxpath
)
21 selectionIsLightbox
= True
23 sd
['lightboxpath'] = None
26 if fg('delete.x') or form
.has_key('delete') :
27 selection
= sd
.get('objects_selection', [])
28 selDict
= sd
.get('objects_selection_dict', {})
30 # get selection from session data or from selected lightbox
31 if not selectionIsLightbox
:
32 selection
= sd
.get('objects_selection', [])
35 lightbox
= portal
.restrictedTraverse(lightboxpath
)
36 selection
= lightbox
.getUidList()
38 sd
['lightboxpath'] = None
39 selection
= sd
.get('objects_selection', [])
41 # remove items from selection
43 for uid
in [int(uid
) for uid
in fg('uids', [])] :
44 if selDict
.has_key(uid
) :
47 if selectionIsLightbox
:
50 sd
['objects_selection'] = selection
51 sd
['objects_selection_dict'] = selDict
56 msg
= _('Photo deselected.')
58 msg
= _('Deselected photos.')
60 msg
= _('Nothing to deselect.')
63 req
.RESPONSE
.setHeader('Content-Type', 'text/xml;;charset=utf-8')
64 return '<deleted>%s</deleted>' % msg
66 context
.setStatus(True, msg
)
68 # breadcrumbs customization
69 if selectionIsLightbox
:
70 lastBcTitle
= '%s (%s)' % (_('My selection'), lightbox
.title_or_id())
72 lastBcTitle
= _('My selection')
76 , 'title' : portal
.title
77 , 'url' : portal_url
},
79 {'id' : 'selection_view'
80 ,'title' : lastBcTitle
81 , 'url' : '%s/selection_view' % portal_url
}
86 options
.update(context
.getSelectionPhotosInfos())
87 options
['container_type'] = 'selection'
88 options
['selectionIsLightbox'] = selectionIsLightbox
89 options
['breadcrumbs'] = breadcrumbs
91 if selectionIsLightbox
:
92 options
['lightbox'] = lightbox
94 options
['selectionName'] = 'not saved yet'
96 return context
.selection_view_template(**options
)