Back to index

plone3  3.1.7
getBatchNavigation.py
Go to the documentation of this file.
00001 ##parameters=batch_obj, target, type_singular='item', type_plural='items', previous_text='Previous', next_text='Next', **kw
00002 ##
00003 from ZTUtils import make_query
00004 if kw.has_key('portal_status_message'):
00005     del kw['portal_status_message']
00006 
00007 navigation = {}
00008 
00009 items = []
00010 for batch in (batch_obj.previous, batch_obj.next):
00011     length = batch and batch.length or 0
00012     if length:
00013         kw['b_start'] = batch.first
00014         for k, v in kw.items():
00015             if not v:
00016                 del kw[k]
00017 
00018         query = kw and ( '?%s' % make_query(kw) ) or ''
00019         url = '%s%s' % (target, query)
00020     items.append( {'length': length > 1 and length or '',
00021                    'type': length == 1 and type_singular or type_plural,
00022                    'url': length and url or ''} )
00023 navigation['previous'] = items[0]
00024 navigation['previous']['text'] = previous_text
00025 navigation['next'] = items[1]
00026 navigation['next']['text'] = next_text
00027 
00028 return navigation