b2418087776d1a7d9f65f7c2719ceae5e903a4de
2 from ZTUtils
import make_query
as mq
3 from Products
.CMFCore
.utils
import getToolByName
4 pptool
= getToolByName(context
, 'portal_photo_print', None)
5 uidtool
= getToolByName(context
, 'portal_uidhandler')
6 utool
= getToolByName(context
, 'portal_url')
7 portal
= utool
.getPortalObject()
8 form
= context
.REQUEST
.form
9 portfolio
= context
.getParentNode()
10 bsize
= portal
.getProperty('default_batch_size', 20)
14 sd
= context
.session_data_manager
.getSessionData(create
= 1)
15 selDict
= sd
.get('objects_selection_dict', {})
16 cart
= sd
.get('cart', None)
18 contextUid
= getattr(context
, 'cmf_uid', None)
19 if contextUid
is not None :
20 contextUid
= contextUid()
22 uidh
= getToolByName(context
, 'portal_uidhandler')
23 contextUid
= uidtool
.register(context
)
24 isSelected
= selDict
.has_key(contextUid
)
26 for i
, p
in enumerate(portfolio
.listNearestFolderContents(contentFilter
={'portal_type' : ['Photo']}, sorted=True)) :
29 uid
= getattr(p
, 'cmf_uid', None)
32 selected
= selDict
.has_key(uid
)
33 size
= p
.getThumbnailSize()
34 size
= {'width':int(size
['width']/2.0), 'height':int(size
['height']/2.0)}
35 purl
= p
.absolute_url()
36 d
= {'src': '%s/getThumbnail' % purl
39 ,'title' : p
.Description()
40 ,'displayed' : p
== context
41 ,'className': (selected
and 'selected' or '') + ((p
== context
) and ' displayed' or '')
50 buyable
= bool(pptool
.getPrintingOptionsFor(context
))
51 if cart
and cart
.locked
:
57 previous
= infos
[index
- 1]['href']
61 if index
< len(infos
) -1 :
62 next
= infos
[index
+ 1]['href']
66 return {'infos' : infos
,
67 'isSelected' : isSelected
,
69 'backUrl' : '%s?%s' % (portfolio
.absolute_url(), mq(pho_start
= index
/bsize
*bsize
)),
71 'previous' : previous
,
73 'reBaseCtxUrl':'null',
74 'canonicalUrl':'null'}