Example #1
0
    def getMenuItems(self, obj, request):
        """ Safely get menu items
        """
        res = super(FacetedDisplayMenu, self).getMenuItems(obj, request)
        if not IFacetedNavigable.providedBy(obj):
            return res

        faceted_adapter = queryAdapter(obj, IFacetedLayout)
        if not faceted_adapter:
            return res

        new = []
        template = {
            'submenu': None,
            'description': '',
            'extra': {
                'separator': None,
                'id': '',
                'class': ''
            },
            'selected': False,
            'action': '',
            'title': '',
            'icon': None
        }

        current = faceted_adapter.layout
        for name, label in faceted_adapter.layouts:
            layout = template.copy()
            layout['extra'] = template['extra'].copy()
            layout['extra']['id'] = name
            layout['title'] = label
            url = '%s/@@faceted_layout?layout=%s' % (obj.absolute_url(), name)
            layout['action'] = addTokenToUrl(url, request)

            if name == current:
                layout['selected'] = True
                layout['extra']['class'] = 'actionMenuSelected'

            new.append(layout)

        return new
Example #2
0
    def getMenuItems(self, obj, request):
        """ Safely get menu items
        """
        res = super(FacetedDisplayMenu, self).getMenuItems(obj, request)
        if not IFacetedNavigable.providedBy(obj):
            return res

        faceted_adapter = queryAdapter(obj, IFacetedLayout)
        if not faceted_adapter:
            return res

        new = []
        template = {
            'submenu': None,
            'description': '',
            'extra': {
                'separator': None,
                'id': '',
                'class': ''},
            'selected': False,
            'action': '',
            'title': '',
            'icon': None
        }

        current = faceted_adapter.layout
        for name, label in faceted_adapter.layouts:
            layout = template.copy()
            layout['extra'] = template['extra'].copy()
            layout['extra']['id'] = name
            layout['title'] = label
            url = '%s/@@faceted_layout?layout=%s' % (obj.absolute_url(), name)
            layout['action'] = addTokenToUrl(url, request)

            if name == current:
                layout['selected'] = True
                layout['extra']['class'] = 'actionMenuSelected'

            new.append(layout)

        return new
Example #3
0
    def getMenuItems(self, context, request):
        """ Return menu items
        """
        url = context.absolute_url()
        # use format to avoid messing with url with "%" in them like
        # 'http://foo/stones-1/foo%20bar%20moo/@@faceted_settings/%s'
        action = url + '/@@faceted_settings/{0}'
        action = addTokenToUrl(action, request)

        left_hidden = IHidePloneLeftColumn.providedBy(context)
        right_hidden = IHidePloneRightColumn.providedBy(context)
        smart_hidden = IDisableSmartFacets.providedBy(context)

        configure = url + '/configure_faceted.html'

        menu = [
            {
                'title': _('Configure'),
                'description': 'Configure faceted navigation',
                'action': addTokenToUrl(configure, request),
                'selected': 'configure_faceted' in request.URL,
                'icon': '',
                'extra': {
                    'id': 'configure_faceted_navigation',
                    'separator': None,
                    'class': ''
                    },
                'submenu': None,
            },
            {
                'title': (_('Enable left portlets') if left_hidden
                     else _('Disable left portlets')),
                'description': '',
                'action': action.format('toggle_left_column'),
                'selected': not left_hidden,
                'icon': '',
                'extra': {
                    'id': 'toggle_left_column',
                    'separator': None,
                    'class': ''
                    },
                'submenu': None,
            },
            {
                'title': (_('Enable right portlets') if right_hidden
                     else _('Disable right portlets')),
                'description': '',
                'action': action.format('toggle_right_column'),
                'selected': not right_hidden,
                'icon': '',
                'extra': {
                    'id': 'toggle_right_column',
                    'separator': None,
                    'class': ''
                    },
                'submenu': None,
            },
            {
                'title': (_('Enable smart facets hiding') if smart_hidden
                     else _('Disable smart facets hiding')),
                'description': '',
                'action': action.format('toggle_smart_facets'),
                'selected': not smart_hidden,
                'icon': '',
                'extra': {
                    'id': 'disable_smart_facets',
                    'separator': None,
                    'class': ''
                    },
                'submenu': None,
            },
        ]
        iscanonical = getattr(context, 'isCanonical', None)
        if callable(iscanonical) and not iscanonical():
            inherit_config = not IDontInheritConfiguration.providedBy(context)
            menu.append({
                'title': (_('Disable inheriting configuration')
                          if inherit_config
                          else _('Enable inheriting configuration ')),
                'description': '',
                'action': action.format('toggle_inherit_config'),
                'selected': not inherit_config,
                'icon': None,
                'extra': {
                    'id': 'toggle_inherit_config',
                    'separator': None,
                    'class': ''
                    },
                'submenu': None,
            })

        return menu