Back to index

plone3  3.1.7
navigationLocalRelated.py
Go to the documentation of this file.
00001 ## Script (Python) "navigationLocalRelated"
00002 ##bind container=container
00003 ##bind context=context
00004 ##bind namespace=
00005 ##bind script=script
00006 ##bind subpath=traverse_subpath
00007 ##parameters=obj=None
00008 ##title=encapsulates the related box
00009 ##
00010 
00011 context.plone_log("The navigationLocalRelated script is deprecated and will be "
00012                   "removed in Plone 4.0.")
00013 
00014 local = []
00015 remote = []
00016 subjects=None
00017 isURLInPortal = context.portal_url.isURLInPortal
00018 
00019 if obj is None:
00020     obj=context
00021 
00022 abs_url = obj.absolute_url()
00023 portal_url = context.portal_url.getPortalObject().absolute_url()
00024 pretty_title_or_id = context.plone_utils.pretty_title_or_id
00025 
00026 if hasattr(obj.aq_explicit, 'Subject'):
00027     subjects=obj.Subject()
00028 
00029 if subjects:
00030     for o in context.portal_catalog( Subject = subjects
00031                                    , sort_on = 'portal_type'
00032                                    , sort_order = 'reverse'  ):
00033         url=o.getURL()
00034         if url == abs_url: continue # s/b if o is obj but fails
00035         rurl = o.getRemoteUrl # getRemoteUrl is indexed as getRemoteUrl
00036         title=pretty_title_or_id(o)
00037 
00038         lnk = {'title' : title,
00039                'url'  : url,
00040                'rurl' : rurl,
00041                'icon' : o.getIcon,
00042               }
00043         if rurl and not isURLInPortal(rurl): #we need UIDs
00044             remote.append(lnk)
00045         else:
00046             local.append(lnk)
00047 
00048 return {'local':local, 'remote':remote}