示例#1
0
def calculateTopLevel(context, portlet, request=None):
    """Calculate top level of navigation menu to take care of 4th level menu
    NB : IFourthLevelNavigation is activated on the third level folder
    """
    if portlet.topLevel != 3 or not HAS_MENU:
        return portlet.topLevel
    portal = api.portal.get()
    contextPhyPath = context.getPhysicalPath()
    portalPhyPath = portal.getPhysicalPath()
    path = [
        elem for elem in list(contextPhyPath)
        if elem not in list(portalPhyPath)
    ]  # noqa
    depth = len(path)
    if depth >= 3 and 'dexterity-types' not in path:
        subLevels = depth - 3
        if subLevels:
            thirdLevelPath = '/'.join(contextPhyPath[:-subLevels])
        else:
            thirdLevelPath = '/'.join(contextPhyPath)
        thirdLevelFolder = portal.unrestrictedTraverse(thirdLevelPath)
        if IFourthLevelNavigation.providedBy(thirdLevelFolder):
            return 4
        if request:
            if IInMinisiteBase.providedBy(request):
                minisite_obj = get_minisite_object(request)
                if minisite_obj and IHNavigationActivated.providedBy(
                        minisite_obj):  # noqa
                    return get_minisite_navigation_level(minisite_obj) + 1
    return portlet.topLevel
示例#2
0
    def can_enable_fourth_level(self):
        """ Helper method used by the actions to know if they should
        be displayed or not
        """
        context = self._get_real_context()

        sm = getSecurityManager()
        if not sm.checkPermission("Portlets: Manage portlets", context):
            return False
        contextPhyPath = context.getPhysicalPath()
        portalPhyPath = api.portal.get().getPhysicalPath()
        path = [elem for elem in list(contextPhyPath) if elem not in list(portalPhyPath)]
        depth = len(path)
        if depth == 3 and not IFourthLevelNavigation.providedBy(context):
            return True
        else:
            return False
示例#3
0
def calculateTopLevel(context, portlet):
    """Calculate top level of navigation menu to take care of 4th level menu
    NB : IFourthLevelNavigation is activated on the third level folder
    """
    if portlet.topLevel != 3 or not HAS_MENU:
        return portlet.topLevel
    portal = api.portal.get()
    contextPhyPath = context.getPhysicalPath()
    portalPhyPath = portal.getPhysicalPath()
    path = [elem for elem in list(contextPhyPath) if elem not in list(portalPhyPath)]
    depth = len(path)
    if depth >= 3:
        subLevels = depth - 3
        if subLevels:
            thirdLevelPath = '/'.join(contextPhyPath[:-subLevels])
        else:
            thirdLevelPath = '/'.join(contextPhyPath)
        thirdLevelFolder = portal.unrestrictedTraverse(thirdLevelPath)
        if IFourthLevelNavigation.providedBy(thirdLevelFolder):
            return 4
    return portlet.topLevel
示例#4
0
 def is_enabled(self):
     context = self._get_real_context()
     return IFourthLevelNavigation.providedBy(context)