def siteNavStrategy(self): context = aq_inner(self.context) selected_tab = self.selected_portal_tab obj = api.portal.get()[selected_tab] path = {'query': '/'.join(obj.getPhysicalPath()), 'navtree': 1, 'navtree_start': 2, 'depth': 2} query = { 'path': path, 'review_state': 'published', 'portal_type': ('hph.sitecontent.mainsection', 'hph.sitecontent.contentpage', 'hph.lectures.coursefolder') } strategy = SitemapNavtreeStrategy(obj) strategy.rootPath = '/'.join(obj.getPhysicalPath()) strategy.showAllParents = True strategy.bottomLevel = 999 tree = buildFolderTree(context, obj, query, strategy) items = [] for c in tree['children']: item = {} item['item'] = c['item'] item['children'] = c.get('children', '') item['itemid'] = c['normalized_id'] item_id = c['normalized_id'] if item_id == context.getId(): item['class'] = 'active' else: item['class'] = '' item['parent'] = self.compute_parent_marker(item_id) items.append(item) return items
def update(self): query = self.request.get('q', None) self.tab = self.request.get('tab', None) uids = None if self.tab == 'recent': pass elif self.tab == 'clipboard': brains = list(self.search(''))[:2] uids = [b.UID for b in brains] result = self.search(query, uids=uids) strategy = SitemapNavtreeStrategy(self.context) result = [strategy.decoratorFactory({'item': node}) for node in result] if self.tab == 'content-tree': portal_state = getMultiAdapter((self.context, self.request), name=u'plone_portal_state') portal = portal_state.portal() query_tree = {'sort_on': 'getObjPositionInParent', 'sort_order': 'asc', 'is_default_page': False} strategy.rootPath = '/Plone' data = buildFolderTree(portal, obj=portal, query=query_tree, strategy=strategy) result = data.get('children', []) self.level = 1 self.children = result