Back to index

plone3  3.1.7
search_form.py
Go to the documentation of this file.
00001 ##parameters=search=''
00002 ##
00003 from Products.CMFCore.utils import getToolByName
00004 from Products.CMFDefault.permissions import ReviewPortalContent
00005 from Products.CMFDefault.utils import decode
00006 from Products.CMFDefault.utils import Message as _
00007 
00008 ctool = getToolByName(script, 'portal_catalog')
00009 mtool = getToolByName(script, 'portal_membership')
00010 ttool = getToolByName(script, 'portal_types')
00011 utool = getToolByName(script, 'portal_url')
00012 portal_url = utool()
00013 
00014 
00015 options = {}
00016 options['title'] = context.Title()
00017 
00018 is_review_allowed = mtool.checkPermission(ReviewPortalContent, context)
00019 options['is_review_allowed'] = is_review_allowed
00020 options['listAvailableSubjects'] = ctool.uniqueValuesFor('Subject')
00021 
00022 created = []
00023 today = context.ZopeTime().earliestTime()
00024 created.append({'value': '1970/01/01 00:00:01 GMT', 'title': _(u'Ever')})
00025 if not mtool.isAnonymousUser():
00026     created.append({'value': mtool.getAuthenticatedMember().last_login_time,
00027                     'title': _(u'Last login')})
00028 created.append({'value': (today-1).Date(), 'title': _(u'Yesterday')})
00029 created.append({'value': (today-7).Date(), 'title': _(u'Last week')})
00030 created.append({'value': (today-31).Date(), 'title': _(u'Last month')})
00031 options['listCreatedInfos'] = tuple(created)
00032 
00033 options['listTypeInfos'] = ttool.listTypeInfo()
00034 
00035 buttons = []
00036 target = '%s/search' % portal_url
00037 buttons.append( {'name': 'search', 'value': _(u'Search')} )
00038 options['form'] = { 'action': target,
00039                     'listButtonInfos': tuple(buttons) }
00040 
00041 return context.search_form_template(**decode(options, script))