コード例 #1
0
ファイル: navbar.py プロジェクト: a25kk/hfph
 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