source: products/qPloneDropDownMenu/trunk/utils.py @ 458

Last change on this file since 458 was 372, checked in by chervol, 18 years ago

fixed interfaces

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1""" Utility functions """
2
3from zope.component import getMultiAdapter
4
5from OFS.DTMLMethod import addDTMLMethod
6
7from Products.CMFCore.utils import getToolByName
8from Products.CMFPlone.migrations.migration_util import safeEditProperty
9from Products.CMFCore.Expression import Expression, createExprContext
10
11from config import PROPERTY_FIELD, PROPERTY_SHEET
12
13def addCSS(container, sheetId, title, csshovering):
14    """ Add DTML Method object to portal root """
15    addDTMLMethod(container, sheetId, title, csshovering)
16
17def updateMenu(site):
18    pu = getToolByName(site, 'plone_utils')
19    pa = getToolByName(site, 'portal_actions')
20    portal_props = getToolByName(site, 'portal_properties')
21
22    # collect all portal tabs
23    context_state = getMultiAdapter((site, site.REQUEST), name=u'plone_context_state')
24    actions = context_state.actions()
25    portal_tabs_view = getMultiAdapter((site, site.REQUEST), name='portal_tabs_view')
26    portal_tabs = portal_tabs_view.topLevelTabs(actions=actions)
27
28    # dump to html
29    value = ''
30    for tab in portal_tabs:
31        value += '<li id="portaltab-%s" class="plain">\n' % tab['id']
32        value += '  <a href="%s" accesskey="t" title="%s">%s</a>\n' % (tab['url'], tab['description'], tab['name'])
33        value += '</li>\n'
34
35    if not hasattr(portal_props.aq_base, PROPERTY_SHEET):
36        portal_props.addPropertySheet(PROPERTY_SHEET, 'DropDown Menu Properties')
37    ap = getattr(portal_props.aq_base, PROPERTY_SHEET)
38    safeEditProperty(ap, PROPERTY_FIELD, value, 'text')
Note: See TracBrowser for help on using the repository browser.