def update(self): super(Navigation, self).update() context = self.context # search configlet while not IConfiglet.providedBy(context): context = getattr(context, '__parent__', None) if context is None: break if context is not None: self.context = context else: self.isRoot = True self.isRoot = IRootConfiglet.providedBy(context) path = [] parent = context while IConfiglet.providedBy(parent): path.insert(0, parent) parent = parent.__parent__ self.root, path = path[0], path[1:] self.data = self._process(self.root)
def update(self): context = self.context request = self.request while context is not None and (not IPortletable.providedBy(context)): context = context.__parent__ self.headerContext = context self.hasTopBanner = queryMultiAdapter( (context, request, self), IContentProvider, name='banners.top') self.hasHeaderInfo = queryMultiAdapter( (context, request, self), IContentProvider, name='header.info') self.personalBar = not isinstance(self.view, RegistrationForm) \ and (IConfiglet.providedBy(self.context) or IPageletSubform.providedBy(self.view) or isinstance(self.context, Feeds))
def _process(self, context, level=1, parent=None): request = self.request data = [] for name, configlet in context.items(): if not IConfiglet.providedBy(configlet) or \ not configlet.isAvailable(): continue info = {'name': name, 'title': configlet.__title__, 'icon': queryMultiAdapter( (configlet, request), name='zmi_icon'), 'items': (), 'selected': False, 'hasSelected': False, 'isLink': bool(list(configlet.__schema__)) or \ IContentContainer.providedBy(configlet) or \ not ICategory.providedBy(configlet), 'parent': parent, 'configlet': configlet, 'level': level} if configlet.__id__ == self.context.__id__: info['selected'] = True info['hasSelected'] = True p = parent while p is not None: p['hasSelected'] = True if p['cssClass'].endswith(' closed'): p['cssClass'] = p['cssClass'][0:-7] p = p['parent'] info['cssClass'] = info['selected'] and 'selected' \ or '' info['items'] = self._process(configlet, level+1, info) if not info['hasSelected'] and info['items']: info['cssClass'] += ' closed' data.append((configlet.__title__, info)) data.sort() data = [info for t, info in data] return data
def process(self, context, request): data = [] for configlet in context.values(): if not IConfiglet.providedBy(configlet) or \ not configlet.isAvailable(): continue info = {'name': configlet.__name__, 'title': configlet.__title__, 'description': configlet.__description__, 'icon': queryMultiAdapter( (configlet, request), name='zmi_icon'), 'items': (), 'selected': False, 'configlet': configlet} data.append((configlet.__title__, info)) data.sort() return [info for t, info in data]
def update(self): context = self.context request = self.request maincontext = self.maincontext mainview = self.mainview ws = mainview view = mainview viewclass = mainview.__class__.__bases__[0] ct = IContentType(maincontext, None) self.portal_url = '%s/' % absoluteURL(context, request) self.context_title = getMultiAdapter( (maincontext, request), IBreadcrumb).name if not ISite.providedBy(maincontext): self.notRoot = True self.portal_title = getMultiAdapter( (getSite(), request), IBreadcrumb).name self.url = '%s/' % request.URL self.base_url = '%s/' % request.URL[-1] # body id while not IWorkspace.providedBy(ws): ws = ws.__parent__ if ws is None: break self.contentClass = 'aero' if ws is not None: self.contentClass += ' section-workspace-%s' % ws.__name__.replace( '.', '-') if IConfiglet.providedBy(maincontext): self.contentClass += ' section-controlpanel-%s' % maincontext.__name__.replace( '.', '-') # body class if ct is None: ctname = maincontext.__name__ else: ctname = ct.name if IConfiglet.providedBy(maincontext): ctname = maincontext.__name__ self.contentId = '-'.join( ('section', ctname, mainview.__name__)).replace('.', '-').replace('@', '') if IForm.providedBy(mainview): self.contentClass += ' ' + mainview.mode if not viewclass is BrowserPagelet: self.contentClass += ' %s.%s' % ( viewclass.__module__, viewclass.__name__) if mainview.template: self.contentClass += ' %s' % ( os.path.split(mainview.template.filename)[1]) self.contentClass = self.contentClass.replace('.', '-').lower() self.sitePath = getPath(getSite())[1:].replace('/', '-') self.contentPath = getPath(maincontext)[1:].replace('/', '-') while not IContentWizard.providedBy(view): view = view.__parent__ if view is None: break self.wizard = view is not None self.wizard = self.wizard or isinstance(maincontext, Feeds) if self.wizard: self.contentClass += ' wizard'