Example #1
0
    def breadcrumbs(self):
        real_context = aq_inner(self.context)
        request_path = self.request.get('PATH_INFO', '')

        if 'VirtualHostBase' in request_path:
            path = ('',) + re.search(r'VirtualHostBase/\w+/.*?/(.*?)/VirtualHostRoot/(.*)', request_path).groups()

            request_path = '/'.join(path)
        context_path = '/'.join(real_context.getPhysicalPath())

        if request_path == context_path:
            context = real_context
        else:
            self.context.plone_log(request_path)
            parent_path = request_path[:request_path.rfind('/')]
            self.context.plone_log(parent_path)
            context = self.context.restrictedTraverse(parent_path)
        request = self.request
        container = utils.parent(context)

        name, item_url = get_view_url(context)

        if container is None:
            return (
                {'absolute_url': item_url,
                 'Title': utils.pretty_title_or_id(context, context), },
            )

        view = getMultiAdapter((container, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        # Some things want to be hidden from the breadcrumbs
        if IHideFromBreadcrumbs.providedBy(context):
            return base

        if base:
            item_url = '%s/%s' % (base[-1]['absolute_url'], name)

        rootPath = getNavigationRoot(context)
        itemPath = '/'.join(context.getPhysicalPath())

        # don't show default pages in breadcrumbs or pages above the navigation
        # root
        if not utils.isDefaultPage(context, request) \
                and not rootPath.startswith(itemPath):
            base += ({'absolute_url': item_url,
                      'Title': utils.pretty_title_or_id(context, context), },
                     )

        if request_path != context_path:
            name, item_url = get_view_url(real_context)
            base += ({'absolute_url': item_url,
                      'Title': utils.pretty_title_or_id(real_context, real_context), },
                     )

        return base
        return True
Example #2
0
    def topLevelTabs(self, actions=None, category='portal_tabs'):
        context = aq_inner(self.context)

        mtool = getToolByName(context, 'portal_membership')
        member = mtool.getAuthenticatedMember().id

        portal_properties = getToolByName(context, 'portal_properties')
        self.navtree_properties = getattr(portal_properties,
                                          'navtree_properties')
        self.site_properties = getattr(portal_properties,
                                       'site_properties')
        self.portal_catalog = getToolByName(context, 'portal_catalog')

        if actions is None:
            context_state = getMultiAdapter((context, self.request),
                                            name=u'plone_context_state')
            actions = context_state.actions(category)

        # Build result dict
        result = []
        # first the actions
        if actions is not None:
            for actionInfo in actions:
                data = actionInfo.copy()
                data['name'] = data['title']
                result.append(data)

        # check whether we only want actions
        if self.site_properties.getProperty('disable_folder_sections', False):
            return result

        query = self._getNavQuery()

        rawresult = self.portal_catalog.searchResults(query)

        def get_link_url(item):
            linkremote = item.getRemoteUrl and not member == item.Creator
            if linkremote:
                return (get_id(item), item.getRemoteUrl)
            else:
                return False

        # now add the content to results
        idsNotToList = self.navtree_properties.getProperty('idsNotToList', ())
        for item in rawresult:
            if not (item.getId in idsNotToList or item.exclude_from_nav):
                id, item_url = get_link_url(item) or get_view_url(item)
                if item.Type == 'Link':
                    item_oinw = item.open_link_in_new_window
                else:
                    item_oinw = False
                data = {'name': utils.pretty_title_or_id(context, item),
                        'id': item.getId,
                        'url': item_url,
                        'description': item.Description,
                        'review_state': item.review_state,
                        'oinw': item_oinw}
                result.append(data)

        return result
Example #3
0
    def get_menu_items(self, actions=None, category='portal_tabs'):
        context = aq_inner(self.context)

        mtool = getToolByName(context, 'portal_membership')
        member = mtool.getAuthenticatedMember().id

        portal_properties = getToolByName(context, 'portal_properties')
        self.navtree_properties = getattr(portal_properties,
                                          'navtree_properties')
        self.site_properties = getattr(portal_properties,
                                       'site_properties')
        self.portal_catalog = getToolByName(context, 'portal_catalog')

        if actions is None:
            context_state = getMultiAdapter((context, self.request),
                                            name=u'plone_context_state')
            actions = context_state.actions(category)

        # Build result dict
        result = []
        # first the actions
        if actions is not None:
            for actionInfo in actions:
                data = actionInfo.copy()
                data['children'] = []
                result.append(data)

        # check whether we only want actions
        if self.site_properties.getProperty('disable_folder_sections', False):
            return result

        query = self._getNavQuery()

        rawresult = self.portal_catalog.searchResults(query)

        # now add the content to results
        idsNotToList = self.navtree_properties.getProperty('idsNotToList', ())
        current_path = '/'.join(self.context.getPhysicalPath())
        for item in rawresult:
            if not (item.getId in idsNotToList or item.exclude_from_nav):
                obj = item.getObject()
                children = self.get_children(obj, member, 2)
                id, item_url = (self._get_link_url(item, member) or
                                get_view_url(item))
                obj_path = '/'.join(obj.getPhysicalPath())
                is_current = is_parent = False
                if obj_path == current_path:
                    is_current = True
                elif (current_path.startswith(obj_path + '/') and
                      len(current_path) > len(obj_path)):
                    is_parent = True
                data = {'title': utils.pretty_title_or_id(context, item),
                        'id': item.getId,
                        'url': item_url,
                        'description': item.Description,
                        'children': children,
                        'is_current': is_current,
                        'is_parent': is_parent}
                result.append(data)
        return result
Example #4
0
    def breadcrumbs(self):
        context = self.context
        request = self.request
        parent = aq_parent(context)

        name, item_url = get_view_url(context)

        if parent is None:
            return ({'absolute_url': item_url,
                     'Title': utils.pretty_title_or_id(context, context), },)

        view = getMultiAdapter((parent, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        # Some things want to be hidden from breadcrumbs
        if IHideFromBreadcrumbs.providedBy(context):
            return base

        if base:
            item_url = '%s/%s' % (base[-1]['absolute_url'], name)
        else:
            item_url = '%s/%s' % (parent.absolute_url(), name)

        rootPath = getNavigationRoot(context)
        itemPath = '/'.join(context.getPhysicalPath())

        # Don't show default pages in breadcrumbs or pages above the navigation root
        if not utils.isDefaultPage(context, request) and not rootPath.startswith(itemPath):
            base += ({'absolute_url': item_url,
                      'Title': utils.pretty_title_or_id(context, context), },)

        return base
Example #5
0
 def brain_to_node(self, brain):
     return {'title': brain.Title,
             'id': brain.id,
             'description': brain.Description,
             'url': get_view_url(brain)[1],
             'absolute_path': brain.getPath(),
             'externallink': is_external_link(brain)}
Example #6
0
    def breadcrumbs(self):
        context = aq_inner(self.context)
        request = self.request

        if hasattr(context, 'route') and context.route.breadcrumbFactory:
            return context.route.breadcrumbFactory(context, request)

        # XXX this is the main part here:
        # to up 2 parents since the current context
        # is wrapped
        if IWrappedContext.providedBy(context):
            container = utils.parent(utils.parent(context))
        elif IFragmentContext.providedBy(context):
            container = getSite()
        name, item_url = get_view_url(context)

        view = getMultiAdapter((container, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        if base:
            item_url = '%s/%s' % (base[-1]['absolute_url'], name)

        base += ({'absolute_url': item_url,
                  'Title': utils.pretty_title_or_id(context, context)},)
        return base
Example #7
0
    def update(self):
        context = aq_inner(self.context)
        portal_tabs_view = getMultiAdapter((context, self.request),
                                           name='portal_tabs_view')
        portal_tabs = portal_tabs_view.topLevelTabs()
        self.portal_tabs = portal_tabs[:1]
        query = {}
        rootPath = getNavigationRoot(context)
        query['path'] = {'query' : rootPath, 'depth' : 1}
        query['portal_type'] = ['SectionFolder', 'AcademicFolder', 'TestimonialFolder']
        query['sort_on'] = 'getObjPositionInParent'
        query['review_state'] = 'published'
        portal_catalog = getToolByName(context, 'portal_catalog')
        results = portal_catalog.searchResults(query)
        for result in results:
            id, item_url = get_view_url(result)
            if id not in ['Members',]:
                data = {'name' : utils.pretty_title_or_id(context, result),
                        'id' : result.getId,
                        'url' : item_url,
                        'description': result.Description}
                self.portal_tabs.append(data)
        if len(portal_tabs) > 1:
            self.portal_tabs.append(portal_tabs[1])

        self.selected_tabs = self.selectedTabs(portal_tabs=self.portal_tabs)
        self.selected_portal_tab = self.selected_tabs['portal']
Example #8
0
    def breadcrumbs(self):
        context = aq_inner(self.context)
        request = self.request
        container = utils.parent(context)
        try:
            name, item_url = get_view_url(context)
        except AttributeError:
            print context
            raise

        if container is None:
            return ({'absolute_url': item_url,
                     'Title': utils.pretty_title_or_id(context, context),
                    },)

        view = getMultiAdapter((container, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        # Some things want to be hidden from the breadcrumbs
        if IHideFromBreadcrumbs.providedBy(context):
            return base

        rootPath = getNavigationRoot(context)
        itemPath = '/'.join(context.getPhysicalPath())

        # don't show default pages in breadcrumbs or pages above the navigation root
        if not utils.isDefaultPage(context, request) and not rootPath.startswith(itemPath):
            base += ({'absolute_url': _checkPermission('View', context) and item_url or None,
                      'Title': utils.pretty_title_or_id(context, context),
                     },)

        return base
    def breadcrumbs(self):

        context = aq_inner(self.context)
        request = self.request
        ct = getMultiAdapter((context, request), name=u"plone_tools").catalog()
        query = {}

        currentPath = context.getPath()

        query["path"] = {"query": currentPath, "navtree": 1, "depth": 0}
        rawresult = ct(**query)
        dec_result = [(len(r.getPath()), r) for r in rawresult]
        dec_result.sort()

        portal_state = getMultiAdapter((context, request), name=u"plone_portal_state")
        rootPath = portal_state.navigation_root_path()

        # Build result dict
        result = []
        for r_tuple in dec_result:
            item = r_tuple[1]

            # Don't include it if it would be above the navigation root
            itemPath = item.getPath()
            if rootPath.startswith(itemPath):
                continue

            id, item_url = get_view_url(item)
            data = {"Title": utils.pretty_title_or_id(context, item), "absolute_url": item_url}
            result.append(data)
        return result
Example #10
0
    def getRootTabs(self):
        """See interface"""
        context = aq_inner(self.context)

        portal_catalog = getToolByName(context, 'portal_catalog')
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')

        # Build result dict
        result = []

        # check whether tabs autogeneration is turned on
        if not self.isGeneratedTabs():
            return result

        query = {}
        rootPath = getNavigationRoot(context)
        query['path'] = {'query' : rootPath, 'depth' : 1}
        query['portal_type'] = utils.typesToList(context)

        sortAttribute = navtree_properties.getProperty('sortAttribute', None)
        if sortAttribute is not None:
            query['sort_on'] = sortAttribute

            sortOrder = navtree_properties.getProperty('sortOrder', None)
            if sortOrder is not None:
                query['sort_order'] = sortOrder

        if navtree_properties.getProperty('enable_wf_state_filtering', False):
            query['review_state'] = navtree_properties.getProperty(
                'wf_states_to_show', [])

        query['is_default_page'] = False

        if not self.isNotFoldersGenerated():
            query['is_folderish'] = True

        # Get ids not to list and make a dict to make the search fast
        idsNotToList = navtree_properties.getProperty('idsNotToList', ())
        excludedIds = {}
        for id in idsNotToList:
            excludedIds[id]=1

        rawresult = portal_catalog.searchResults(**query)

        # now add the content to results
        for item in rawresult:
            if not excludedIds.has_key(item.getId):
                id, item_url = get_view_url(item)
                data = {'name'       : utils.pretty_title_or_id(context, item),
                        'id'         : id,
                        'url'        : item_url,
                        'description': item.Description,
                        'exclude_from_nav' : item.exclude_from_nav}
                result.append(data)

        return result
    def getsublevel(self, context, *path):
        query = {}
        result = []
        raw_path = []

        portal_properties = getToolByName(context, "portal_properties")
        portal_catalog = getToolByName(context, "portal_catalog")
        navtree_properties = getattr(portal_properties, "navtree_properties")
        site_properties = getattr(portal_properties, "site_properties")

        rootPath = getNavigationRoot(context)
        raw_path.append(rootPath)
        for obj in path:
            raw_path.append(obj)

        dpath = "/".join(raw_path)
        query["path"] = {"query": dpath, "depth": 1}

        query["portal_type"] = ["RichDocument", "Folder", "GeoLocation"]

        sortAttribute = navtree_properties.getProperty("sortAttribute", None)
        if sortAttribute is not None:
            query["sort_on"] = sortAttribute

        sortOrder = navtree_properties.getProperty("sortOrder", None)
        if sortOrder is not None:
            query["sort_order"] = sortOrder

        if navtree_properties.getProperty("enable_wf_state_filtering", False):
            query["review_state"] = navtree_properties.getProperty("wf_states_to_show", [])

        query["is_default_page"] = False

        if site_properties.getProperty("disable_nonfolderish_sections", False) and len(path) == 1:
            query["is_folderish"] = False

        # Get ids not to list and make a dict to make the search fast
        idsNotToList = navtree_properties.getProperty("idsNotToList", ())
        excludedIds = {}
        for id in idsNotToList:
            excludedIds[id] = 1

        rawresult = portal_catalog.searchResults(**query)

        # now add the content to results
        for item in rawresult:
            if not (excludedIds.has_key(item.getId) or item.exclude_from_nav):
                id, item_url = get_view_url(item)
                data = {
                    "name": utils.pretty_title_or_id(context, item),
                    "id": item.getId,
                    "url": item_url,
                    "description": item.Description,
                }
                result.append(data)
        return result
 def getItem(self, item):
     """get item"""
     context = aq_inner(self.context)
     id_, item_url = get_view_url(item)
     data = {
         "name": utils.pretty_title_or_id(context, item),
         "id": id_,
         "url": item_url,
         "description": item.Description,
         "exclude_from_nav": item.exclude_from_nav,
     }
     return data
Example #13
0
 def getItem(self, item):
     """get item"""
     context = aq_inner(self.context)
     id_, item_url = get_view_url(item)
     data = {
         'name': utils.pretty_title_or_id(context, item),
         'id': id_,
         'url': item_url,
         'description': item.Description,
         'exclude_from_nav': item.exclude_from_nav,
     }
     return data
    def getsubtab(self, context, tab):
        query = {}
        result = []
        portal_properties = getToolByName(context, "portal_properties")
        portal_catalog = getToolByName(context, "portal_catalog")
        navtree_properties = getattr(portal_properties, "navtree_properties")
        site_properties = getattr(portal_properties, "site_properties")

        rootPath = getNavigationRoot(context)
        xpath = "/".join([rootPath, tab["id"]])
        if "path" in tab:
            xpath = tab["path"]
        query["path"] = {"query": xpath, "depth": 1}

        query["portal_type"] = utils.typesToList(context)

        sortAttribute = navtree_properties.getProperty("sortAttribute", None)
        if sortAttribute is not None:
            query["sort_on"] = sortAttribute

            sortOrder = navtree_properties.getProperty("sortOrder", None)
            if sortOrder is not None:
                query["sort_order"] = sortOrder

        if navtree_properties.getProperty("enable_wf_state_filtering", False):
            query["review_state"] = navtree_properties.getProperty("wf_states_to_show", [])

        # Get ids not to list
        idsNotToList = navtree_properties.getProperty("idsNotToList", ())
        excludedIds = {}
        for id in idsNotToList:
            excludedIds[id] = 1

        rawresult = portal_catalog.searchResults(**query)

        # now add the content to results
        for item in rawresult:
            if not (excludedIds.has_key(item.getId) or item.exclude_from_nav):
                id, item_url = get_view_url(item)
                data = {
                    "name": utils.pretty_title_or_id(context, item),
                    "id": item.getId,
                    "url": item_url,
                    "description": item.Description,
                    "current": "",
                    "path": item.getPath(),
                }
                if self.current_url.startswith(item_url):
                    data["current"] = "selected"
                data["subtabs"] = self.getsubtab(self.context, data)
                result.append(data)
        return result
    def breadcrumbs(self):
        base = super(ListingDetailsNavigationBreadcrumbs, self).breadcrumbs()

        name, item_url = get_view_url(self.context)

        listing_id = getattr(self.request, 'listing_id', None)
        last_item = self.request.steps[-2:-1]
        if listing_id is not None and self.context.id in last_item:
            base += ({
                'absolute_url': item_url + '/' + listing_id,
                'Title': listing_id.upper(),
            },)

        return base
Example #16
0
    def getsubtabs(self,context,tab):
        query={}
        result=[]
        portal_properties = getToolByName(context, 'portal_properties')
        portal_catalog = getToolByName(context, 'portal_catalog')
        navtree_properties = getattr(portal_properties, 'navtree_properties')
        site_properties = getattr(portal_properties, 'site_properties')

        rootPath = getNavigationRoot(context)
        dpath='/'.join([rootPath,tab['id']])
        query['path'] = {'query' : dpath, 'depth' : 1}

        query['portal_type'] = utils.typesToList(context)

        sortAttribute = navtree_properties.getProperty('sortAttribute', None)
        if sortAttribute is not None:
            query['sort_on'] = sortAttribute

            sortOrder = navtree_properties.getProperty('sortOrder', None)
            if sortOrder is not None:
                query['sort_order'] = sortOrder

        if navtree_properties.getProperty('enable_wf_state_filtering', False):
            query['review_state'] = navtree_properties.getProperty('wf_states_to_show', [])

        query['is_default_page'] = False

        if site_properties.getProperty('disable_nonfolderish_sections', False):
            query['is_folderish'] = True

        # Get ids not to list and make a dict to make the search fast
        idsNotToList = navtree_properties.getProperty('idsNotToList', ())
        excludedIds = {}
        for id in idsNotToList:
            excludedIds[id]=1

        rawresult = portal_catalog.searchResults(**query)

        # now add the content to results
        for item in rawresult:
            if not (excludedIds.has_key(item.getId) or item.exclude_from_nav):
                id, item_url = get_view_url(item)
                data = {'name'      : utils.pretty_title_or_id(context, item),
                        'id'         : item.getId,
                        'url'        : item_url,
                        'description': item.Description}
                result.append(data)
        return result
Example #17
0
    def breadcrumbs(self):
        base = super(
            DevelopmentDetailsNavigationBreadcrumbs,
            self,
        ).breadcrumbs()

        name, item_url = get_view_url(self.context)

        development_id = getattr(self.request, 'development_id', None)
        last_item = self.request.steps[-2:-1]
        if development_id is None or self.context.id not in last_item:
            return base

        cache = IAnnotations(self.request)
        item = cache.get('ps.plone.mls.development.traversed', None)
        if item is None:
            return base

        try:
            title = item.title.value
        except Exception:
            return base

        url = '/'.join([item_url, development_id])

        base += ({
            'absolute_url': url,
            'Title': title,
        },)

        listing_id = getattr(self.request, 'listing_id', None)
        if listing_id is not None:
            base += ({
                'absolute_url': '/'.join([url, listing_id]),
                'Title': listing_id.upper(),
            },)

        subpath = getattr(self.request, 'subpath', [])
        if subpath and len(subpath) == 1:
            item = subpath[0]
            title = TRAVERSE_TITLES.get(item, None)
            if title is not None:
                base += ({
                    'absolute_url': '/'.join([url, item]),
                    'Title': title,
                },)

        return base
def breadcrumbs(self):

    def getTitle(context):

        try:
            if hasattr(context, 'hasProperty'):
                if context.hasProperty('short_breadcrumb'):
                    alt_title = context.getProperty('short_breadcrumb')
                    if alt_title:
                        return alt_title
        except TypeError:
            pass

        return utils.pretty_title_or_id(context, context)        

    context = aq_inner(self.context)
    request = self.request
    container = utils.parent(context)

    name, item_url = get_view_url(context)

    if container is None:
        return ({'absolute_url': item_url,
                    'Title': getTitle(context),},
                )

    view = getMultiAdapter((container, request), name='breadcrumbs_view')
    base = tuple(view.breadcrumbs())

    # Some things want to be hidden from the breadcrumbs
    if IHideFromBreadcrumbs.providedBy(context):
        return base

    if base:
        item_url = '%s/%s' % (base[-1]['absolute_url'], name)

    rootPath = getNavigationRoot(context)
    itemPath = '/'.join(context.getPhysicalPath())

    # don't show default pages in breadcrumbs or pages above the navigation root
    if not utils.isDefaultPage(context, request) and not rootPath.startswith(itemPath):
        base += ({'absolute_url': item_url,
                    'Title': getTitle(context), },
                )

    return base
    def breadcrumbs(self):
        """ Breadcrumbs
        """
        if ISiteRoot.providedBy(self.context):
            return ()

        context = aq_inner(self.context)
        request = self.request
        container = utils.parent(context)

        try:
            name, item_url = get_view_url(context)
        except AttributeError:
            print context
            raise

        if container is None:
            return ({'absolute_url': item_url,
                     'Title': utils.pretty_title_or_id(context, context),
                    },)

        view = getMultiAdapter((container, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        # Some things want to be hidden from the breadcrumbs
        if IHideFromBreadcrumbs.providedBy(context):
            return base

        if base:
            item_url = '%s/%s' % (base[-1]['absolute_url'], name)

        # don't show default pages in breadcrumbs
        if not utils.isDefaultPage(context, request):
            base += ({'absolute_url': item_url,
                      'Title': utils.pretty_title_or_id(context, context),
                     },)

        return base
Example #20
0
    def breadcrumbs(self):
        context = aq_inner(self.context)
        request = self.request

        # XXX this is the main part here:
        # to up 2 parents since the current context
        # is wrapped
        container = utils.parent(utils.parent(context))
        try:
            name, item_url = get_view_url(context)
        except AttributeError:
            print context
            raise

        view = getMultiAdapter((container, request), name='breadcrumbs_view')
        base = tuple(view.breadcrumbs())

        if base:
            item_url = '%s/%s' % (base[-1]['absolute_url'], name)

        base += ({'absolute_url': item_url,
                  'Title': utils.pretty_title_or_id(context, context)},)
        return base
 def update(self):
     self.portal_state = getMultiAdapter((self.context, self.request), name=u"plone_portal_state")
     catalog = getToolByName(self.context, "portal_catalog")
     self.context_state = getMultiAdapter((self.context, self.request), name=u"plone_context_state")
     # portal_properties = getToolByName(self.context, 'portal_properties')
     # navtree_properties = getattr(portal_properties, 'navtree_properties')
     path = []
     path_raw = self.context.getPhysicalPath()
     self.path = []
     for obj in path_raw:
         path.append(obj)
         parent_path = "/".join(path)
         raw_results = catalog.searchResults({"path": {"query": parent_path, "depth": 0}, "is_default_page": False})
         for item in raw_results:
             id, item_url = get_view_url(item)
             data = {
                 "name": utils.pretty_title_or_id(self.context, item),
                 "url": item_url,
                 "is_last": False,
                 "is_suitable_view_mode": False,
             }
             # try:
             # item.getProperty('default_page')
             # data['is_suitable_view_mode'] = True
             # except :
             # pass
             if item.getObject().getProperty("default_page") is not None:
                 data["is_suitable_view_mode"] = True
             self.path.append(data)
     if len(self.path):
         self.path[len(self.path) - 1]["is_last"] = True
     self.root = self.portal_state.navigation_root_url()
     self.portal_search_url = self.root + "/search"
     self.current_page_url = self.context_state.current_page_url()
     self.view_path = True
     if self.current_page_url.count(self.portal_search_url):
         self.view_path = False
Example #22
0
 def get_children(self, item, member, level):
     """Return the children as a list of dictionaries."""
     navigation_depth = self.get_navigation_depth()
     if navigation_depth and level > navigation_depth:
         # We're already requesting more children than allowed.
         return []
     query = self._get_children_query(item)
     # Get the children
     rawresult = self.portal_catalog.searchResults(query)
     result = []
     idsNotToList = self.navtree_properties.getProperty('idsNotToList', ())
     current_path = '/'.join(self.context.getPhysicalPath())
     for child in rawresult:
         if not (child.getId in idsNotToList or child.exclude_from_nav):
             id, child_url = (self._get_link_url(child, member) or
                              get_view_url(child))
             children = []
             obj = child.getObject()
             if (not navigation_depth or level < navigation_depth):
                 children = self.get_children(obj, member, level + 1)
             obj_path = '/'.join(obj.getPhysicalPath())
             is_current = is_parent = False
             if obj_path == current_path:
                 is_current = True
             elif (current_path.startswith(obj_path + '/') and
                   len(current_path) > len(obj_path)):
                 is_parent = True
             data = {'title': utils.pretty_title_or_id(self.context, child),
                     'id': child.getId,
                     'url': child_url,
                     'description': child.Description,
                     'children': children,
                     'is_current': is_current,
                     'is_parent': is_parent}
             result.append(data)
     return result
Example #23
0
 def _get_url(item):
     if item.getRemoteUrl and not member == item.Creator:
         return (get_id(item), item.getRemoteUrl)
     return get_view_url(item)
Example #24
0
 def _get_url(item):
     member = self.portal_state.member()
     if item.getRemoteUrl and not member == item.Creator:
         return (get_id(item), item.getRemoteUrl)
     return get_view_url(item)
Example #25
0
    def topLevelTabs(self, actions=None, category='portal_tabs'):
        context = aq_inner(self.context)

        portal_catalog = getToolByName(context, 'portal_catalog')
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')
        site_properties = getattr(portal_properties, 'site_properties')

        # Build result dict
        result = []
        # first the actions
        if actions is not None:
            for actionInfo in actions.get(category, []):
                data = actionInfo.copy()
                data['name'] = data['title']
                result.append(data)

        # check whether we only want actions
        if site_properties.getProperty('disable_folder_sections', False):
            return result

        customQuery = getattr(context, 'getCustomNavQuery', False)
        if customQuery is not None and utils.safe_callable(customQuery):
            query = customQuery()
        else:
            query = {}

        rootPath = getNavigationRoot(context)
        query['path'] = {'query' : rootPath, 'depth' : 1}

        query['portal_type'] = utils.typesToList(context)

        sortAttribute = navtree_properties.getProperty('sortAttribute', None)
        if sortAttribute is not None:
            query['sort_on'] = sortAttribute

            sortOrder = navtree_properties.getProperty('sortOrder', None)
            if sortOrder is not None:
                query['sort_order'] = sortOrder

        if navtree_properties.getProperty('enable_wf_state_filtering', False):
            query['review_state'] = navtree_properties.getProperty('wf_states_to_show', [])

        query['is_default_page'] = False
        
        if site_properties.getProperty('disable_nonfolderish_sections', False):
            query['is_folderish'] = True

        # Get ids not to list and make a dict to make the search fast
        idsNotToList = navtree_properties.getProperty('idsNotToList', ())
        excludedIds = {}
        for id in idsNotToList:
            excludedIds[id]=1

        rawresult = portal_catalog.searchResults(**query)

        # now add the content to results
        for item in rawresult:
            if not (excludedIds.has_key(item.getId) or item.exclude_from_nav):
                id, item_url = get_view_url(item)
                data = {'name'      : utils.pretty_title_or_id(context, item),
                        'id'         : item.getId,
                        'url'        : item_url,
                        'description': item.Description}
                result.append(data)
        return result
Example #26
0
 def brain_to_node(self, brain):
     return {'title': brain.Title,
             'description': brain.Description,
             'url': get_view_url(brain)[1],
             'externallink': is_external_link(brain),
             'exclude_from_nav': brain.exclude_from_nav}
    def topLevelTabs(self, actions=None, category='portal_tabs'):
        
        context = aq_inner(self.context)

        portal_catalog = getToolByName(context, 'portal_catalog')
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')
        site_properties = getattr(portal_properties, 'site_properties')

        # Build result dict
        result = []
        
        if PLONE_VERSION == 3:
            # BBB to Plone 3, different actions input signature
            # http://svn.plone.org/svn/plone/Plone/tags/3.3.5/Products/CMFPlone/browser/navigation.py
            # first the actions
            if actions is not None:
                for actionInfo in actions.get(category, []):
                    data = actionInfo.copy()
                    data['name'] = data['title']
                    result.append(data)            
        else:
        
            if actions is None:
                context_state = getMultiAdapter((context, self.request),
                                                name=u'plone_context_state')
                actions = context_state.actions(category)

            # first the actions
            if actions is not None:
                for actionInfo in actions:
                    data = actionInfo.copy()
                    data['name'] = data['title']
                    result.append(data)

        # check whether we only want actions
        if site_properties.getProperty('disable_folder_sections', False):
            return result

        customQuery = getattr(context, 'getCustomNavQuery', False)
        if customQuery is not None and utils.safe_callable(customQuery):
            query = customQuery()
        else:
            query = {}

        rootPath = getNavigationRoot(context)
        query['path'] = {'query' : rootPath, 'depth' : 1}

        query['portal_type'] = utils.typesToList(context)
        
        sortAttribute = navtree_properties.getProperty('sortAttribute', None)
        if sortAttribute is not None:
            query['sort_on'] = sortAttribute

            sortOrder = navtree_properties.getProperty('sortOrder', None)
            if sortOrder is not None:
                query['sort_order'] = sortOrder

        if navtree_properties.getProperty('enable_wf_state_filtering', False):
            query['review_state'] = navtree_properties.getProperty('wf_states_to_show', [])

        query['is_default_page'] = False
        
        if site_properties.getProperty('disable_nonfolderish_sections', False):
            query['is_folderish'] = True

        # Get ids not to list and make a dict to make the search fast
        idsNotToList = navtree_properties.getProperty('idsNotToList', ())
        excludedIds = {}
        for id in idsNotToList:
            excludedIds[id]=1

        rawresult = portal_catalog.searchResults(**query)
                
        # apply mobile media filter for the results
        media_filter = queryUtility(IConvergenceMediaFilter, None)
        
        if media_filter is not None:
            strategy = media_filter.getContentMediaStrategy(self.context, self.request)        
            resolved_content_medias = media_filter.solveCatalogBrainContenMedia(self.context, rawresult)
        
        #import pdb ; pdb.set_trace()
        # now add the content to results
        for item in rawresult:
            
            if not (excludedIds.has_key(item.getId) or item.exclude_from_nav):
                id, item_url = get_view_url(item)
                data = {'name'      : utils.pretty_title_or_id(context, item),
                        'id'         : item.getId,
                        'url'        : item_url,
                        'description': item.Description}
        
                if media_filter is not None:
                    # Behavior with gomobile.convergence
                    media = resolved_content_medias[item]
                    if media_filter.checkMediaFilter(media, strategy):
                        result.append(data)
                else:
                    # The default behavior
                    result.append(data)                    
                                
        return result