def __iter__(self): if self.contenttype is None: raise StopIteration context = self.context request = self.request actions = [] for ct in self.contenttype.listContainedTypes(): action = AddContent(context, request, ct, 9999) actions.append((action.title, action)) for context in self.context.values(): if IWorkspace.providedBy(context): contenttype = IContentType(context, None) if contenttype is not None: for ct in contenttype.listContainedTypes(): action = AddContent(context, request, ct, 9999) actions.append((action.title, action)) actions.sort() weight = 999 for _t, action in actions: weight = weight + 1 action.weight = weight yield action
def update(self): context = self.context request = self.request self.url = '%s/'%request.getURL() self.portal_url = '%s/'%absoluteURL(getSite(), request) try: self.base_url = '%s/'%request.URL[-1] except KeyError: self.base_url = self.portal_url # body id ws = self.maincontext while not IWorkspace.providedBy(ws): ws = ws.__parent__ if ws is None: break if ws is not None: self.contentId = 'workspace-%s'%ws.__name__.replace('.', '-') # body class ct = IContentType(self.maincontext, None) if ct is not None: self.contentClass = 'section-%s'%ct.name.replace('.', '-') viewclass = self.mainview.__class__.__bases__[0] if not viewclass is BrowserPagelet: self.contentClass += ' %s.%s'%(viewclass.__module__, viewclass.__name__) if self.mainview.template: self.contentClass += ' %s'%(os.path.split(self.mainview.template.filename)[1]) self.contentClass = self.contentClass.replace('.', '-').lower()
def __init__(self, context, request, view, manager=None): maincontext = context site = getSite() if not IRootSpace.providedBy(site) or \ IContentSpaceLayout.providedBy(site) and not site.showTabs: self.available = False super(PortalTabs, self).__init__(context, request, view, manager) return wsname = u'' ws = None if ILayout.providedBy(view.view): context = view.view.mainview elif ILayout.providedBy(view): context = view.mainview while not IRootSpace.providedBy(context) \ or IDraftedContent.providedBy(context): if IWorkspace.providedBy(context): ws = context wsname = context.__name__ context = context.__parent__ if context is None: break self.wsname = wsname self.workspace = ws super(PortalTabs, self).__init__(site, request, view, manager)
def update(self): super(WorkspaceLayout, self).update() wsname = u'' ws = self.mainview while not ISpace.providedBy(ws): if IWorkspace.providedBy(ws) and \ not IOverviewWorkspace.providedBy(ws): break ws = ws.__parent__ self.workspace = ws view = self.mainview while not IContentWizard.providedBy(view): view = view.__parent__ if view is None: break self.wizard = view is not None
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'
def update(self): super(SpaceLayout, self).update() wsname = u'' ws = self.mainview while not ISpace.providedBy(ws): if IWorkspace.providedBy(ws): wsname = ws.__name__ break ws = ws.__parent__ if not wsname: wsname = self.mainview.__name__ self.workspace = ws context = self.context request = self.request if IContentSpaceLayout.providedBy(context): self.showHeader = context.showHeader self.title = context.title else: self.title = getMultiAdapter((context, request), IBreadcrumb).name if IContentSpaceLayout.providedBy(context) and not context.showTabs: return wfactories = [] management = IWorkspacesManagement(context, None) if IWorkspacesManagement.providedBy(management): if management.enabledWorkspaces: for name in management.enabledWorkspaces: factory = queryAdapter(context, IWorkspaceFactory, name) if factory is not None \ and context.isEnabled(factory) \ and checkPermission('zope.View', factory.get()): wfactories.append((name, factory)) if not wfactories: for name, factory in getAdapters((context,), IWorkspaceFactory): if not IInactiveWorkspaceFactory.providedBy(factory) and \ not context.isEnabled(factory) or \ not checkPermission('zope.View', factory.get()): continue wfactories.append(( factory.weight, factory.title, name, factory)) wfactories.sort() wfactories = [(n, f) for _w, _t, n, f in wfactories] workspaces = [] for name, factory in wfactories: workspaces.append( {'name': name, 'title': factory.title, 'description': factory.description, 'selected': name == wsname, 'icon': queryMultiAdapter((factory,request), name='zmi_icon'), }) self.workspaces = workspaces