Ejemplo n.º 1
0
 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
 def __init__(self, context, portlet):
     SitemapNavtreeStrategy.__init__(self, context, portlet)
     self.bottomLevel = 0
     currentFolderOnly = True
     topLevel = 0
     root = getattr(portlet, 'root', uuidToObject(portlet.root_uid))
     self.rootPath = getRootPath(context, currentFolderOnly, topLevel, root)
Ejemplo n.º 3
0
 def __init__(self, context, view=None):
     SitemapNavtreeStrategy.__init__(self, context, view)
     self.rootPath = '/'.join(context.getPhysicalPath())
     self.excludeIds = {}
     portal_properties = getToolByName(context, 'portal_properties')
     navtree_properties = getattr(portal_properties, 'navtree_properties')
     self.bottomLevel = navtree_properties.getProperty('bottomLevel', 0)
Ejemplo n.º 4
0
Archivo: navbar.py Proyecto: 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
Ejemplo n.º 5
0
    def update(self):
        query = self.request.get('q', None)
        self.tab = self.request.get('tab', None)
        b_size = 10
        page = int(self.request.get('page', 0))
        strategy = SitemapNavtreeStrategy(self.context)

        uids = None
        if self.tab == 'content-tree':
            # XXX: not implemented
            pass
#            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 = portal.absolute_url_path()
#            data = buildFolderTree(portal,
#                                   obj=portal,
#                                   query=query_tree,
#                                   strategy=strategy)
#            result = data.get('children', [])
        else:
            if self.tab == 'clipboard':
                # XXX: not implemented
                pass
#                brains = list(self.search(''))[:2]
#                uids = [b.UID for b in brains]
            result = self.search(query, uids=uids,
                                 b_start=page * b_size,
                                 b_size=b_size)
            result = [strategy.decoratorFactory({'item': node}) for node in result]
        self.level = 1
        self.children = result
Ejemplo n.º 6
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or 0

        self.rootPath = getRootPath(context, portlet.currentFolderOnly,
                                    portlet.topLevel, portlet.root_uid)
 def __init__(self, context, portlet):
     SitemapNavtreeStrategy.__init__(self, context, portlet)
     currentFolderOnly = True
     topLevel = 0
     if hasattr(portlet, 'root'):
         root = portlet.root
     else:
         root = uuidToObject(portlet.root_uid)
     self.rootPath = getRootPath(context, currentFolderOnly, topLevel, root)
Ejemplo n.º 8
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or 0

        self.rootPath = getRootPath(context,
                                    portlet.currentFolderOnly,
                                    portlet.topLevel,
                                    portlet.root_uid)
Ejemplo n.º 9
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)

        # XXX: We can't do this with a 'depth' query to EPI...
        membership = getToolByName(context, 'portal_membership')
        self.memberId = membership.getAuthenticatedMember().getId()
        self.bottomLevel = portlet.bottomLevel or 0

        self.rootPath = getRootPath(context, portlet.currentFolderOnly,
                                    portlet.topLevel, portlet.root_uid)
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')
        
        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or navtree_properties.getProperty('bottomLevel', 0)

        currentFolderOnly = portlet.currentFolderOnly or navtree_properties.getProperty('currentFolderOnlyInNavtree', False)
        topLevel = portlet.topLevel or navtree_properties.getProperty('topLevel', 0)
        self.rootPath = getRootPath(context, currentFolderOnly, topLevel, portlet.root)
Ejemplo n.º 11
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or \
                           navtree_properties.getProperty('bottomLevel', 0)

        currentFolderOnly = portlet.currentFolderOnly or \
            navtree_properties.getProperty('currentFolderOnlyInNavtree', False)

        topLevel = portlet.topLevel or navtree_properties.getProperty('topLevel', 0)
        self.rootPath = getRootPath(context, currentFolderOnly, topLevel, portlet.root)
Ejemplo n.º 12
0
    def update(self):
        self.query = self.request.get("q", None)
        self.tab = self.request.get("tab", None)
        b_size = int(self.request.get("b_size", 10))
        page = int(self.request.get("page", 1))
        strategy = SitemapNavtreeStrategy(self.context)

        uids = None
        result = self.search(self.query, uids=uids, page=page, b_size=b_size)
        self.has_next = result.has_next
        self.nextpage = result.nextpage
        result = [strategy.decoratorFactory({"item": node}) for node in result]
        self.level = 1
        self.children = result
Ejemplo n.º 13
0
    def update(self):
        self.query = self.request.get('q', None)
        self.tab = self.request.get('tab', None)
        b_size = int(self.request.get('b_size', 10))
        page = int(self.request.get('page', 0))
        strategy = SitemapNavtreeStrategy(self.context)

        uids = None
        result = self.search(self.query, uids=uids, page=page, b_size=b_size)
        self.has_next = result.next is not None
        self.nextpage = result.pagenumber
        result = [strategy.decoratorFactory({'item': node}) for node in result]
        self.level = 1
        self.children = result
Ejemplo n.º 14
0
    def setup(self):
        self.query = self.request.get('q', None)
        self.tab = self.request.get('tab', None)
        page = int(self.request.get('page', 1))
        strategy = SitemapNavtreeStrategy(self.context)

        uuids = None
        result = self.search(self.query, uuids=uuids, page=page)
        self.has_next = result.next is not None
        self.nextpage = result.pagenumber + 1
        children = [
            strategy.decoratorFactory({'item': node}) for node in result
        ]
        self.level = 1
        self.children = children
Ejemplo n.º 15
0
 def subtreeFilter(self, node):
     sitemapDecision = SitemapNavtreeStrategy.subtreeFilter(self, node)
     if not sitemapDecision:
         return False
     depth = node.get('depth', 0)
     return not (depth > 0 and self.bottomLevel > 0
                 and depth >= self.bottomLevel)
Ejemplo n.º 16
0
    def update(self):
        self.query = self.request.get('q', None)
        self.tab = self.request.get('tab', None)
        page = int(self.request.get('page', 1))
        strategy = SitemapNavtreeStrategy(self.context)

        uids = None
        result = self.search(
            self.query, uids=uids,
            page=page
        )
        self.has_next = result.next is not None
        self.nextpage = result.pagenumber + 1
        children = [strategy.decoratorFactory({'item': node}) for node in result]
        self.level = 1
        self.children = children
    def __init__(self, context, tile):
        SitemapNavtreeStrategy.__init__(self, context, tile)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = tile.data.get('bottomLevel') or \
                           navtree_properties.getProperty('bottomLevel', 0)

        currentFolderOnly = tile.data.get('currentFolderOnly') or \
                            navtree_properties.getProperty(
                                    'currentFolderOnlyInNavtree', False)
        topLevel = tile.data.get('topLevel') or \
                   navtree_properties.getProperty('topLevel', 0)
        tileRoot = uuidToFolderishPath(context, tile.data.get('root'))
        self.rootPath = getRootPath(context, currentFolderOnly,
                                    topLevel, tileRoot)
Ejemplo n.º 18
0
 def subtreeFilter(self, node):
     sitemapDecision = SitemapNavtreeStrategy.subtreeFilter(self, node)
     if not sitemapDecision:
         return False
     depth = node.get('depth', 0)
     return not (
         depth > 0 and self.bottomLevel > 0 and depth >= self.bottomLevel
     )
Ejemplo n.º 19
0
    def __init__(self, context, tile):
        SitemapNavtreeStrategy.__init__(self, context, tile)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = (tile.data.get('bottomLevel')
                            or navtree_properties.getProperty(
                                'bottomLevel', 0))
        currentFolderOnly = (tile.data.get('currentFolderOnly')
                             or navtree_properties.getProperty(
                                 'currentFolderOnlyInNavtree', False))
        topLevel = (tile.data.get('topLevel')
                    or navtree_properties.getProperty('topLevel', 0))
        tileRoot = uuidToFolderishPath(context, tile.data.get('root'))
        self.rootPath = getRootPath(context, currentFolderOnly, topLevel,
                                    tileRoot)
Ejemplo n.º 20
0
 def subtreeFilter(self, node):
     sitemapDecision = SitemapNavtreeStrategy.subtreeFilter(self, node)
     if sitemapDecision == False:
         return False
     depth = node.get('depth', 0)
     if depth > 0 and self.bottomLevel > 0 and depth >= self.bottomLevel:
         return False
     else:
         return True
 def subtreeFilter(self, node):
     sitemapDecision = SitemapNavtreeStrategy.subtreeFilter(self, node)
     if sitemapDecision == False:
         return False
     depth = node.get('depth', 0)
     if depth > 0 and self.bottomLevel > 0 and depth >= self.bottomLevel:
         return False
     else:
         return True
Ejemplo n.º 22
0
    def __init__(self, context, portlet):
        
        SitemapNavtreeStrategy.__init__(self, context, portlet)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or navtree_properties.getProperty('bottomLevel', 0)

        currentFolderOnly = portlet.currentFolderOnly or navtree_properties.getProperty('currentFolderOnlyInNavtree', False)
        topLevel = portlet.topLevel or navtree_properties.getProperty('topLevel', 0)
        #custom implementation starts here
        currentObject = self.context
        parentList = currentObject.aq_chain
        parentspace = None
        found = 0

        try:
            for type in parentList:
                if type.portal_type == 'Space' and type.meta_type == 'Space':
                    parentspace = type
                    found = 1
                if found == 1:
                    break
        except AttributeError:
                pass

        rootObject = self.context.portal_url.getPortalObject()

        objNavtree = 1

        isMemberFolder = False
        members = rootObject.Members
        if parentspace is None:
            if members in parentList:
                isMemberFolder = True
        
        if parentspace <> None:
            self.rootPath = '/'.join(parentspace.getPhysicalPath())                
        else:
            topLevel = portlet.topLevel or navtree_properties.getProperty('topLevel', 0)
            self.rootPath = getRootPath(context, currentFolderOnly, topLevel, portlet.root)
Ejemplo n.º 23
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')
        portal_languages = getToolByName(context, 'portal_languages')

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or navtree_properties.getProperty('bottomLevel', 0)

        currentFolderOnly = portlet.currentFolderOnly or navtree_properties.getProperty('currentFolderOnlyInNavtree', False)
        topLevel = portlet.topLevel or navtree_properties.getProperty('topLevel', 0)
        #self.rootPath = getRootPath(context, currentFolderOnly, topLevel, portlet.root)
        #self.rootPath = "%s/%s" % ( getRootPath(context, currentFolderOnly, topLevel, portlet.root), portal_languages.getPreferredLanguage())
        portal_url = getToolByName(context, 'portal_url')
        portal_root = portal_url.getPortalPath()

        self.rootPath = "%s/%s" % ( portal_root, portal_languages.getPreferredLanguage())
        if "//" in self.rootPath:
            self.rootPath = self.rootPath.replace("//","/")
        self.showAllParents = False
Ejemplo n.º 24
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or 0

        root_uid = portlet.root_uid
        topLevel = portlet.topLevel

        if not root_uid:
            override_topLevel = getNavigationTopLevelObject(
                self.context, getSite())
            if override_topLevel:
                topLevel = override_topLevel.portlet_nav_topLevel
            root = getNavigationFolderObject(self.context, getSite())
            if root:
                root_uid = root.UID()

        self.rootPath = navigation.getRootPath(context,
                                               portlet.currentFolderOnly,
                                               topLevel, root_uid)
Ejemplo n.º 25
0
 def subtreeFilter(self, node):
     sitemapDecision = SitemapNavtreeStrategy.subtreeFilter(self, node)
     if sitemapDecision == False:
         return False
     if getattr(self.context.aq_base, 'hide_subnavigation', False):
         if "/".join(self.context.getPhysicalPath()) == node['path']:
             return False
     depth = node.get('depth', 0)
     if depth > 0 and self.bottomLevel > 0 and depth >= self.bottomLevel:
         return False
     else:
         return True
Ejemplo n.º 26
0
    def __init__(self, context, portlet):
        SitemapNavtreeStrategy.__init__(self, context, portlet)
        portal_properties = getToolByName(context, 'portal_properties')
        navtree_properties = getattr(portal_properties, 'navtree_properties')
        portal_languages = getToolByName(context, 'portal_languages')

        # XXX: We can't do this with a 'depth' query to EPI...
        self.bottomLevel = portlet.bottomLevel or navtree_properties.getProperty(
            'bottomLevel', 0)

        currentFolderOnly = portlet.currentFolderOnly or navtree_properties.getProperty(
            'currentFolderOnlyInNavtree', False)
        topLevel = portlet.topLevel or navtree_properties.getProperty(
            'topLevel', 0)
        #self.rootPath = getRootPath(context, currentFolderOnly, topLevel, portlet.root)
        #self.rootPath = "%s/%s" % ( getRootPath(context, currentFolderOnly, topLevel, portlet.root), portal_languages.getPreferredLanguage())
        portal_url = getToolByName(context, 'portal_url')
        portal_root = portal_url.getPortalPath()

        self.rootPath = "%s/%s" % (portal_root,
                                   portal_languages.getPreferredLanguage())
        if "//" in self.rootPath:
            self.rootPath = self.rootPath.replace("//", "/")
        self.showAllParents = False
Ejemplo n.º 27
0
 def __init__(self, context, view=None):
     SitemapNavtreeStrategy.__init__(self, context, view)
     self.rootPath = '/'.join(context.getPhysicalPath())
Ejemplo n.º 28
0
 def decoratorFactory(self, node):
     new_node = SitemapNavtreeStrategy.decoratorFactory(self, node)
     if getattr(new_node["item"], "nav_title", False):
         new_node["nav_title"] = new_node["item"].nav_title
     return new_node
Ejemplo n.º 29
0
 def __init__(self, context):
     SitemapNavtreeStrategy.__init__(self, context, None)
     self.context = context
     self.bottomLevel = 0
     self.rootPath = self.getRootPath()
 def __init__(self, context, view=None):
     SitemapNavtreeStrategy.__init__(self, context, view)
     self.rootPath = '/'.join(context.getPhysicalPath())
     self.bottomLevel = 65535