Commit b6471fca authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

erp5_xhtml_style: do not use getToolByName to access tools

Also some code refactoring.
parent ee64d50c
"Modified version for ERP5 to append the default action (/view) in the URL." "Modified version for ERP5 to append the default action (/view) in the URL."
from Products.CMFCore.utils import getToolByName portal = context.getPortalObject()
ptool = getToolByName(script, 'portal_properties')
utool = getToolByName(script, 'portal_url') utool = portal.portal_url
portal_url = utool() portal_url = utool()
result = [] param = '?ignore_layout:int=1' if int(portal.REQUEST.get('ignore_layout', 0)) else ''
param = int(context.REQUEST.get('ignore_layout', 0)) and '?ignore_layout:int=1' or ''
if include_root: if include_root:
result.append( { 'id' : 'root' result = [{
, 'title' : ptool.title() 'id' : 'root',
, 'url' : '%s/view%s' % (portal_url, param) 'title' : portal.portal_properties.title(),
} 'url' : '%s/view%s' % (portal_url, param),
) }]
else:
relative = utool.getRelativeContentPath(context) result = []
portal = utool.getPortalObject()
obj = portal obj = portal
now = [] now = []
for name in relative: for name in utool.getRelativeContentPath(context):
obj = obj.restrictedTraverse(name) obj = obj.restrictedTraverse(name)
now.append(name) now.append(name)
title = ( title = (
getattr(obj, "getCompactTranslatedTitle", lambda: None)() or getattr(obj, "getCompactTranslatedTitle", lambda: None)() or
obj.getTitle() or obj.getId() obj.getTitle() or obj.getId()
) )
if not name == 'talkback': if name != 'talkback':
result.append( { 'id' : name result.append( { 'id' : name
, 'title' : title , 'title' : title
, 'url' : '%s/%s/view%s' % (portal_url, '/'.join(now), param) , 'url' : '%s/%s/view%s' % (portal_url, '/'.join(now), param)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment