def getImageUrl(resource): if ((IRTVideo.providedBy(resource) and \ resource.hasSplashScreenImage()) or \ (not IRTVideo.providedBy(resource) and \ resource.hasSplashScreenImage)): if not IRTVideo.providedBy(resource): return resource.getURL()+'/image_thumb' return resource.absolute_url()+'/image_thumb' portal = getToolByName(resource, 'portal_url').getPortalObject() return portal.absolute_url() +\ "/++resource++collective.flowplayer.css/play.png"
def getImageUrl(resource): if ((IRTVideo.providedBy(resource) and \ resource.hasSplashScreenImage()) or \ (not IRTVideo.providedBy(resource) and \ resource.hasSplashScreenImage)): if not IRTVideo.providedBy(resource): return resource.getURL() + '/image_thumb' return resource.absolute_url() + '/image_thumb' portal = getToolByName(resource, 'portal_url').getPortalObject() return portal.absolute_url() +\ "/++resource++collective.flowplayer.css/play.png"
def enabled(self): if IFeatureImageViewletDisabled.providedBy(self.context): return False if IATNewsItem.providedBy(self.context): return False if IATFolder.providedBy(self.context): return False if IRTVideo.providedBy(self.context): return False if IFeaturable.providedBy(self.context): if self.get_feature_image(): return True return False
def videos(self): target = self.target() limit = self.data.limit if target is None: return [] if IRTVideo.providedBy(target): return [ dict(title=target.Title(), description=target.Description(), url=target.absolute_url(), path='/'.join(target.getPhysicalPath()), year=target.getYear(), duration=target.getDuration(), image_url=getImageUrl(target)), ] if IATFolder.providedBy(target): values = [] videos = target.getFolderContents( contentFilter={'object_provides': IRTVideo.__identifier__}) for v in videos: values.append( dict( title=v.Title, description=v.Description, url=v.getURL(), path=v.getPath(), year=v.getYear, duration=v.getDuration, image_url=getImageUrl(v), )) return (limit and values[:limit]) or values if IATTopic.providedBy(target): values = [] videos = target.queryCatalog( contentFilter={'object_provides': IRTVideo.__identifier__}) for v in videos: values.append( dict( title=v.Title, description=v.Description, url=v.getURL(), path=v.getPath(), year=v.getYear, duration=v.getDuration, image_url=getImageUrl(v), )) return (limit and values[:limit]) or values return []
def videos(self): target = self.target() limit = self.data.limit if target is None: return [] if IRTVideo.providedBy(target): return [dict(title=target.Title(), description=target.Description(), url=target.absolute_url(), path='/'.join(target.getPhysicalPath()), year=target.getYear(), duration=target.getDuration(), image_url=getImageUrl(target)), ] if IATFolder.providedBy(target): values = [] videos = target.getFolderContents( contentFilter={'object_provides': IRTVideo.__identifier__}) for v in videos: values.append(dict(title = v.Title, description = v.Description, url = v.getURL(), path=v.getPath(), year = v.getYear, duration = v.getDuration, image_url = getImageUrl(v), )) return (limit and values[:limit]) or values if IATTopic.providedBy(target): values = [] videos = target.queryCatalog( contentFilter={'object_provides': IRTVideo.__identifier__}) for v in videos: values.append(dict(title=v.Title, description=v.Description, url=v.getURL(), path=v.getPath(), year=v.getYear, duration=v.getDuration, image_url=getImageUrl(v), )) return (limit and values[:limit]) or values return []
def fields(self): image_field = [ # add your extension fields here ExtensionBlobImageField('image', required = 0, languageIndependent = True, storage = atapi.AttributeStorage(), widget=ExtensionBlobImageField._properties['widget']( label=_('Image'), ) ), ] image_caption_field = [ ExtensionStringField('imageCaption', required = 0, languageIndependent = False, storage = atapi.AttributeStorage(), widget=atapi.StringField._properties['widget']( label=_('Image Caption') ) ), ] fields = [ ExtensionStringField('imageCopyright', required = 0, languageIndependent = False, storage = atapi.AttributeStorage(), widget=atapi.StringField._properties['widget']( label=_('Image Copyright') ) ), ExtensionBooleanField('is_featured', schemata='settings', languageIndependent = 1, widget=atapi.BooleanField._properties['widget']( label=_('Is Featured'), description=_(u'Feature this item') ) ), ExtensionBooleanField('feature_hide_image', schemata='settings', languageIndependent = 1, widget=atapi.BooleanField._properties['widget']( label=_('Hide image from displaying in feature listings'), ) ) ] if IATNewsItem.providedBy(self.context): return fields if IRTVideo.providedBy(self.context): return image_caption_field + fields return image_field + image_caption_field + fields