def __iter__(self): """ Returns an iterator enumerating the resources of this type. """ pvc = getToolByName(getSite(), 'portal_view_customizations') layer_precedence = self.layer_precedence() by_layer_precedence_and_ttwness = lambda x: (layer_precedence.index(x.required[1]), int(not ITTWViewTemplate.providedBy(x.factory))) regs = sorted(self.iter_view_registrations(), key=by_layer_precedence_and_ttwness) for info in templateViewRegistrationInfos(regs, mangle=False): required = info['required'].split(',') res = ViewResourceRegistration() res.name = info['viewname'] res.context = context = required[0] if context == 'zope.interface.Interface': context = '*' res.description = translate(_('View for X', default = u'View for ${context}', mapping = {u'context': context})) res.layer = required[1] res.actions = [] res.tags = ['template'] res.path = None if info['customized']: res.tags.append('customized') obj = getattr(pvc, info['customized']) res.path = '/'.join(obj.getPhysicalPath()) res.text = obj._text res.info = translate(_('In the database', default = u'In the database: ${path}', mapping = {'path': res.path})) res.actions.append(('Edit', obj.absolute_url() + '/manage_main')) remove_url = pvc.absolute_url() + '/manage_delObjects?ids=' + info['customized'] res.actions.append(('Remove', remove_url)) else: res.path = info['zptfile'] res.info = translate(_(u"On the filesystem", default=u"On the filesystem: ${path}", mapping={u"path" : res.path})) view_url = pvc.absolute_url() + '/@@customizezpt.html?required=%s&view_name=%s' % (info['required'], info['viewname']) res.actions.append(('View', view_url)) name = info['viewname'].lower() if name.endswith('.css'): res.tags.append('stylesheet') elif name.endswith('.js'): res.tags.append('javascript') elif name.endswith('.kss'): res.tags.append('kss') elif name.endswith('.jpg') or name.endswith('.gif') or name.endswith('.png'): res.tags.append('image') yield res
def __iter__(self): """ Returns an iterator enumerating the resources of this type. """ pvc = getToolByName(getSite(), 'portal_view_customizations') layer_precedence = self.layer_precedence() by_layer_precedence_and_ttwness = lambda x: (layer_precedence.index(x.required[1]), int(not ITTWViewTemplate.providedBy(x.factory))) regs = sorted(self.iter_portlet_registrations(), key=by_layer_precedence_and_ttwness) for info in templateViewRegistrationInfos(regs, mangle=False): required = info['required'].split(',') res = PortletResourceRegistration() res.name = info['viewname'] res.context = required[0], required[3] context = required[0] if context == 'zope.interface.Interface': context = '*' res.description = translate(_('portlet for X in the manager Y', default = u'Portlet for ${context} in the ${manager} manager', mapping = {'context': context, 'manager': required[3]})) res.layer = required[1] res.actions = [] res.tags = ['portlet'] res.path = None if info['customized']: res.tags.append('customized') obj = getattr(pvc, info['customized']) path = '/'.join(obj.getPhysicalPath()) res.text = obj._text res.info = translate(_(u"In the database", default=u"In the database: ${path}", mapping={u"path" : path})) res.actions.append((PMF(u'Edit'), obj.absolute_url() + '/manage_main')) remove_url = pvc.absolute_url() + '/manage_delObjects?ids=' + info['customized'] res.actions.append((PMF(u'Remove'), remove_url)) else: res.path = info['zptfile'] res.info = translate(_(u"On the filesystem", default=u"On the filesystem: ${path}", mapping={u"path" : res.path})) view_url = pvc.absolute_url() + '/@@customizezpt.html?required=%s&view_name=%s' % (info['required'], info['viewname']) res.actions.append((PMF(u'View'), view_url)) yield res
def __iter__(self): if self.skins_tool is None: self.skins_tool = getToolByName(getSite(), "portal_skins") if self.skin is None: self.skin = self.skins_tool.getDefaultSkin() skin_path = self.skins_tool.getSkinPath(self.skin) if skin_path is None: return for layer_path in skin_path.split(","): try: layer_folder = self.skins_tool.unrestrictedTraverse(layer_path) except KeyError: # Sometimes the active theme declares nonexistent folders # this is not themeeditors fault, so we skip the error continue for name, obj in layer_folder.items(): res = CMFResourceRegistration() res.base_skin = self.skin res.name = name res.layer = layer_path res.actions = [] res.icon = obj.icon res.tags = [] res.path = None if isinstance(obj, FSObject): res.info = _( "On the filesystem", default=u"On the filesystem: ${path}", mapping={"path": obj._filepath} ) res.path = obj._filepath res.actions.append((PMF(u"View"), obj.absolute_url() + "/manage_main")) elif isinstance(obj, Persistent) and not isinstance(obj, DirectoryViewSurrogate): res.tags.append("customized") res.path = "/".join(obj.getPhysicalPath()) # res.info = 'In the database: ' + res.path res.info = _(u"In the database", default=u"In the database: ${path}", mapping={u"path": res.path}) res.actions.append((PMF(u"Edit"), obj.absolute_url() + "/manage_main")) res.actions.append( (PMF(u"Remove"), obj.aq_parent.absolute_url() + "/manage_delObjects?ids=" + obj.getId()) ) elif isinstance(obj, Persistent): res.path = "/".join(obj.getPhysicalPath()) res.info = "In the database: " + res.path res.info = _(u"In the database", default=u"In the database: ${path}", mapping={u"path": res.path}) if IPageTemplate.providedBy(obj): res.tags.append("template") if isinstance(obj, Image) or isinstance(obj, FSImage): res.tags.append("image") elif isinstance(obj, FSPythonScript) or isinstance(obj, CustomizedPythonScript): res.tags.append("python-script") elif isinstance(obj, FSControllerValidator) or isinstance(obj, FSControllerPythonScript): res.tags.append("controller-page-template") elif isinstance(obj, FSDTMLMethod): res.tags.append("dtml") id = obj.getId().lower() if id.endswith(".css"): res.tags.append("stylesheet") elif id.endswith(".js"): res.tags.append("javascript") elif id.endswith(".kss"): res.tags.append("kss") yield res