Пример #1
0
    def bodyClass(self, template, view):
        """Return the CSS class to be used on the body tag,
        with additional classes as required by the OSHA theme"""
        context = self.context
        portal_state = getMultiAdapter((context, self.request),
                                       name=u'plone_portal_state')
        navroot = portal_state.navigation_root()

        body_class = super(OSHALayoutPolicy, self).bodyClass(template, view)
        # is there a marker interface for full width on the context?
        if IFullWidth.providedBy(self.context):
            body_class = u"%s full-width" % body_class
        # the marker interface can also be set on the view
        if IFullWidth.providedBy(view):
            body_class = u"%s full-width" % body_class

        contentPath = context.getPhysicalPath()[len( \
            navroot.getPhysicalPath()):]
        if contentPath:
            for i in range(len(contentPath)):
                body_class += " subsection%s-%s" % (i, contentPath[i])

        subsite_path = getSubsiteRoot(self.context)
        body_class = u"%s subsite-%s" % (body_class, \
            subsite_path.split('/')[-1])

        return body_class
Пример #2
0
    def bodyClass(self, template, view):
        """Return the CSS class to be used on the body tag,
        with additional classes as required by the OSHA theme"""
        context = self.context
        portal_state = getMultiAdapter(
            (context, self.request), name=u'plone_portal_state')
        navroot = portal_state.navigation_root()

        body_class = super(OSHALayoutPolicy, self).bodyClass(template, view)
        # is there a marker interface for full width on the context?
        if IFullWidth.providedBy(self.context):
            body_class = u"%s full-width" % body_class
        # the marker interface can also be set on the view
        if IFullWidth.providedBy(view):
            body_class = u"%s full-width" % body_class

        contentPath = context.getPhysicalPath()[len( \
            navroot.getPhysicalPath()):]
        if contentPath:
            for i in range(len(contentPath)):
                body_class += " subsection%s-%s" % (i, contentPath[i])

        subsite_path = getSubsiteRoot(self.context)
        body_class = u"%s subsite-%s" % (body_class, \
            subsite_path.split('/')[-1])

        return body_class
Пример #3
0
    def __call__(self):
        subsite_root = getSubsiteRoot(self.context)

        if subsite_root.find("belgium") > 0:
            return u"parliament_question_author"

        return u"European Agency for Safety and Health at Work"
Пример #4
0
 def __init__(self, context, request=None):
     self.context = context
     self.ptool = getToolByName(context, 'portal_url')
     self.ltool = getToolByName(context, 'portal_languages')
     self.pref_lang = self.ltool.getPreferredLanguage()
     self.supported_langs = self.ltool.getSupportedLanguages()
     self.available_langs = self.ltool.getAvailableLanguages()
     self.subsite_path = getSubsiteRoot(aq_inner(context))
     self.root = self.context.restrictedTraverse(self.subsite_path)
     self.langroot = getattr(self.root, self.pref_lang, getattr(self.root, 'en'))
Пример #5
0
 def __init__(self, context, request, **kw):
     self.context = context
     self.request = request
     db_util = getUtility(IDatabaseSettings)
     dsn = "%(driver)s://%(username)s:%(password)s@%(host)s:%(port)s/%(database)s" % dict(
         driver=db_util.drivername, username=db_util.username, host=db_util.hostname,
         password=db_util.password, database=db_util.database, port=db_util.port)
     engine = sqlalchemy.create_engine(dsn)
     self.conn = engine.connect()
     self.subsite_path = getSubsiteRoot(Acquisition.aq_inner(context))
     self.root = self.context.restrictedTraverse(self.subsite_path)
Пример #6
0
    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.result = []
        self.portal_url = getToolByName(context, 'portal_url')
	# Need to be mindful of a potential subsite!
	self.portal_path = getSubsiteRoot(self.context)
        ###self.portal_path = self.portal_url.getPortalPath()
        ###self.portal = self.portal_url.getPortalObject()
	self.portal = context.restrictedTraverse(self.portal_path)
        self.portal_languages = getToolByName(context, 'portal_languages')
        self.langs = self.portal_languages.getSupportedLanguages()
        self.dynamic_path = self.portal_path + '/%s/' + "/".join(context.getPhysicalPath()[len(self.portal.getPhysicalPath())+1:])
        if self.dynamic_path[-1]== "/":
            self.dynamic_path = self.dynamic_path[:-1]
Пример #7
0
 def __init__(self, context, request):
     self.context = context
     self.request = request
     self.result = []
     self.portal_url = getToolByName(context, 'portal_url')
     # Need to be mindful of a potential subsite!
     self.portal_path = getSubsiteRoot(self.context)
     ###self.portal_path = self.portal_url.getPortalPath()
     ###self.portal = self.portal_url.getPortalObject()
     self.portal = context.restrictedTraverse(self.portal_path)
     self.portal_languages = getToolByName(context, 'portal_languages')
     self.langs = self.portal_languages.getSupportedLanguages()
     self.dynamic_path = self.portal_path + '/%s/' + "/".join(
         context.getPhysicalPath()[len(self.portal.getPhysicalPath()) + 1:])
     if self.dynamic_path[-1] == "/":
         self.dynamic_path = self.dynamic_path[:-1]
Пример #8
0
    def __init__(self, context, request):
        self.context = context
        self.request = request
        self.portal_url = getToolByName(context, "portal_url")

        # Need to be mindful of a potential subsite!
        self.portal_path = self.portal_url.getPortalPath()
        if getSubsiteRoot is not None:
            self.portal_path = getSubsiteRoot(self.context)
        self.portal = context.restrictedTraverse(self.portal_path)
        self.portal_languages = getToolByName(context, "portal_languages")
        self.langs = self.portal_languages.getSupportedLanguages()

        portal_path = self.portal.getPhysicalPath()
        context_path = context.getPhysicalPath()

        self.dynamic_path = self.portal_path + "/%s/" + "/".join(context_path[len(portal_path) + 1 :])

        if self.dynamic_path[-1] == "/":
            self.dynamic_path = self.dynamic_path[:-1]
Пример #9
0
 def subsiteRootPath(self):
     """ return URL of subsite """
     return getSubsiteRoot(Acquisition.aq_inner(self.context))