def _data(self, item, i, l): item.update({'title': item['brain'].Title, 'description': item['brain'].Description, 'url': item['brain'].hasDetail and item['brain'].getURL() or None, 'class': self._class(item['brain'], i, l)}) if item.has_key('show') and item['show']: item['class'] += ' hidden' if REFERENCE: reference = IReference(item['obj']) url = reference.getReferenceURL() if url: item['url'] = url if TEASER and self.thumb_size: teaser = ITeaser(item['obj']) image = {'img': teaser.getTeaser(self.thumb_size), 'caption': teaser.getCaption(), 'url': None, 'rel': None} if image['img']: w, h = item['obj'].Schema()['image'].getSize(item['obj']) tw, th = teaser.getSize(self.thumb_size) if item['url']: image['url'] = item['url'] elif (tw < w and tw > 0) or (th < h and th > 0): image['rel'] = 'lightbox' image['url'] = teaser.getTeaserURL(size="popup") item['image'] = image if WYSIWYG and self.wysiwyg: item['wysiwyg'] = IWYSIWYG(item['obj']).getAdditionalText()
def url(self): provider = ITeaser(self.context) w, h = self.context.Schema()['image'].getSize(self.context) tw, th = provider.getSize(self.type) if (not tw or tw >= w) and (not th or th >= h): return None return provider.getTeaserURL(size="popup")
def articles(self): provider = IArticles(self.context) manageable = interfaces.IManageable(self.context) items = provider.getArticles(component=self.component) items = manageable.getList(items, self.component) i = 0 l = len(items) for item in items: item.update({'title': item['brain'].Title, 'description': self.description and item['brain'].Description or None, 'url': item['brain'].hasDetail and item['brain'].getURL() or None, 'class': item.has_key('show') and item['show'] and 'hidden' or ''}) if REFERENCE: reference = IReference(item['obj']) url = reference.getReferenceURL() if url: item['url'] = url if self.image: teaser = ITeaser(item['obj']) image = {'img': teaser.getTeaserURL(self.thumb_size), 'thumb': teaser.getTeaserURL(size="supersizedthumb"), 'caption': teaser.getCaption(), 'rel': 'supersized'} item['image'] = image i += 1 return items
def media(self): manageable = interfaces.IManageable(self.context) mship = getToolByName(self.context, 'portal_membership') catalog = getToolByName(self.context, 'portal_catalog') args = {} if not interfaces.IArticleEditView.providedBy(self.view) or not mship.checkPermission(MANAGE_PERMISSION, self.context): args['component'] = self.component types = [IATImage.__identifier__] if TEASER: types.append(interfaces.IArticle.__identifier__) if MEDIA: types.extend([IVideo.__identifier__, IVideoEmbed.__identifier__]) items = catalog(object_provides=types, path={'query': '/'.join(self.context.getPhysicalPath()), 'depth': 1}, sort_on='getObjPositionInParent', **args) items = manageable.getList(items, self.component) groups = [] main = None for item in items: if interfaces.IArticle.providedBy(item['obj']): item.update({'title': item['brain'].Title, 'description': item['brain'].Description, 'childs': []}) teaser = ITeaser(item['obj']) item['image'] = teaser.getTeaser(self.thumb_size + 'group') childs = catalog(object_provides=[IATImage.__identifier__, IVideo.__identifier__, IVideoEmbed.__identifier__], path={'query': '/'.join(item['obj'].getPhysicalPath()), 'depth': 1}, sort_on='getObjPositionInParent', **args) if not len(childs): continue childs = manageable.getList(childs, self.component) for child in childs: self._data(child) item['childs'].append(child) groups.append(item) else: self._data(item) if main is None: ptypes = getToolByName(self.context, 'portal_types') context = self.context while interfaces.IArticle.providedBy(context) and not context.Schema()['detail'].get(context): context = aq_parent(context) type = ptypes.getTypeInfo(context).Title() main = {'title': _(u'Media of this ${type}', mapping={'type': translate(type, context=self.request)}), 'description': None, 'childs': []} groups.append(main) main['childs'].append(item) return groups
def persons(self): for brain in self._data(): person = brain.getObject() teaser = ITeaser(person) image = teaser.getTeaser(self.thumb_size) yield dict( title=person.title, img=image, position=person.position, email=person.email, emailLink="mailto:%s" % person.email, phone=person.phone, )
def url(self): """return link to popup image, none if the popup is not bigger than the already displayed teaser image """ provider = ITeaser(self.context) w, h = self.context.Schema()['image'].getSize(self.context) tw, th = provider.getSize(self.type) if (not tw or tw >= w) and (not th or th >= h): #original image <= already displayed teaser -> no popup needed #extra check since this popup scale might "blow up" the original picture #XXX really needed? if we need a check, shouldn't we check org <= popup here? return None pw, ph = provider.getSize('popup') if (pw and pw <= tw) or (ph and ph <= th): #popup scale <= teaser -> no popup needed return None return provider.getTeaserURL(size='popup')
def items(self): provider = IArticles(self.context) raw_items = provider.getArticles(component=self.component) items = [] for item in raw_items: obj = item.getObject() img = ITeaser(obj) if img.getTeaserURL(self.thumb_size): v = {'title': item.Title, 'img': img.getTeaserURL(self.thumb_size), 'url': item.hasDetail and item.getURL() or ''} if REFERENCE: reference = IReference(obj) url = reference.getReferenceURL() if url: v['url'] = url items.append(self.item_template % v) return '\n'.join(items)
def articles(self): provider = IArticles(self.context) manageable = interfaces.IManageable(self.context) raw_items = manageable.getList(provider.getArticles(component=self.component), self.component) items = [] for item in raw_items: img = ITeaser(item['obj']) if img.getTeaserURL(self.img_size): item.update({'title': item['brain'].Title, 'description': item['brain'].Description, 'caption': img.getCaption(), 'img': img.getTeaser(self.thumb_size), 'img_url': img.getTeaserURL(self.img_size), 'url': item['brain'].hasDetail and item['brain'].getURL() or None}) if REFERENCE: reference = IReference(item['obj']) url = reference.getReferenceURL() if url: item['url'] = url items.append(item) return items
def articles(self): provider = IArticles(self.context) manageable = interfaces.IManageable(self.context) mship = getToolByName(self.context, 'portal_membership') if mship.checkPermission(MANAGE_PERMISSION, self.context): items = provider.getArticles() else: items = provider.getArticles(component=self.component) items = manageable.getList(items, self.component) i = 0 l = len(items) for item in items: item.update({'title': item['brain'].Title, 'description': item['brain'].Description, 'url': item['brain'].hasDetail and item['brain'].getURL() or None, 'class': self._class(item['brain'], i, l)}) if item.has_key('show') and item['show']: item['class'] += ' hidden' if REFERENCE: reference = IReference(item['obj']) url = reference.getReferenceURL() if url: item['url'] = url if TEASER: teaser = ITeaser(item['obj']) image = {'img': teaser.getTeaser(self.thumb_size), 'caption': teaser.getCaption(), 'url': None, 'rel': None} if image['img']: w, h = item['obj'].Schema()['image'].getSize(item['obj']) tw, th = teaser.getSize(self.thumb_size) if item['url']: image['url'] = item['url'] elif (tw < w and tw > 0) or (th < h and th > 0): image['rel'] = 'lightbox' image['url'] = teaser.getTeaserURL(size="popup") item['image'] = image i += 1 return items
def articles(self): provider = IArticles(self.context) manageable = interfaces.IManageable(self.context) items = provider.getArticles(component=self.component) items = manageable.getList(items, self.component) for item in items: item.update( { "title": item["brain"].Title, "description": item["brain"].Description, "url": item["brain"].hasDetail and item["brain"].getURL() or None, } ) if item.has_key("show") and item["show"]: item["class"] = "hidden" if REFERENCE: reference = IReference(item["obj"]) url = reference.getReferenceURL() if url: item["url"] = url teaser = ITeaser(item["obj"]) item["image"] = teaser.getTeaserURL() return items
def _data(self, item): item.update({'title': item['brain'].Title, 'description': item['brain'].Description, 'class': ''}) if item.has_key('show') and item['show']: item['class'] += ' hidden' if IATImage.providedBy(item['obj']): img = IImage(item['obj']) item['image'] = img.getImage(self.thumb_size) elif MEDIA and IVideoEmbed.providedBy(item['obj']): embedders = component.getAdapters((item['obj'],), IVideoEmbedder) item['embed'] = True item['url'] = item['brain'].getRemoteUrl for name, embedder in embedders: if embedder.matches(): item['code'] = embedder.getEmbedCode() item['provider'] = embedder.name elif MEDIA and IVideo.providedBy(item['obj']): view = component.queryMultiAdapter((item['obj'], self.request,), name='flowplayer') teaser = ITeaser(item['obj']) item['image'] = teaser.getTeaser(self.thumb_size) item['embed'] = False item['url'] = view is None and item['brain'].getURL() or view.href()
def articles(self): provider = IArticles(self.context) manageable = interfaces.IManageable(self.context) items = provider.getArticles(component=self.component) items = manageable.getList(items, self.component) i = 0 l = len(items) for item in items: item.update({'title': item['brain'].Title, 'description': self.description and item['brain'].Description or None, 'url': item['brain'].hasDetail and item['brain'].getURL() or None, 'class': item.has_key('show') and item['show'] and 'hidden' or ''}) if REFERENCE: reference = IReference(item['obj']) url = reference.getReferenceURL() if url: item['url'] = url if self.image: teaser = ITeaser(item['obj']) image = {'img': teaser.getTeaser(self.thumb_size), 'caption': teaser.getCaption(), 'url': None, 'rel': None} if image['img']: w, h = item['obj'].Schema()['image'].getSize(item['obj']) tw, th = teaser.getSize(self.thumb_size) if item['url']: image['url'] = item['url'] elif (tw < w and tw > 0) or (th < h and th > 0): image['rel'] = 'lightbox' image['url'] = teaser.getTeaserURL(size="popup") item['image'] = image if self.wysiwyg: item['text'] = IWYSIWYG(item['obj']).getAdditionalText() i += 1 return items
def image(self): provider = ITeaser(self.context) return provider.getTeaser(size=self.type)
def caption_non_default(self): provider = ITeaser(self.context) return provider.getCaption(non_default=True)
def caption(self): provider = ITeaser(self.context) return provider.getCaption()