def images(self):
     provider = IImages(self.context)
     manageable = interfaces.IManageable(self.context)
     mship = getToolByName(self.context, 'portal_membership')
     if interfaces.IArticleEditView.providedBy(self.view) and mship.checkPermission(MANAGE_PERMISSION, self.context):
         items = provider.getImages()
     else:
         items = provider.getImages(component=self.component)
     items = manageable.getList(items, self.component)
     for item in items:
         img = IImage(item['obj'])
         item.update({'caption': img.getCaption(),
                      'img': img.getImage(self.thumb_size),
                      'url': img.getImageURL(self.img_size),
                      'class': item.has_key('show') and item['show'] and 'hidden' or ''})
     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 images(self):
        provider = IImages(self.context)
        manageable = interfaces.IManageable(self.context)
        mship = getToolByName(self.context, 'portal_membership')
        canManage = interfaces.IArticleEditView.providedBy(self.view) and mship.checkPermission(MANAGE_PERMISSION, self.context)
        if canManage:
            items = provider.getImages()
        else:
            items = provider.getImages(component=self.component)

        items = manageable.getList(items, self.component)
        i = 0
        l = len(items)
        relAttribute = self._getProperty('gallery_rel_attribute','lightbox')

        for item in items:
            img = IImage(item['obj'])
            item.update({'caption': img.getCaption(),
                         'class': self._class(item['brain'], i, l),
                         'img': img.getImage(self.thumb_size),
                         'description': item['brain'].Description,
                         'rel': None,
                         'url': None,
                         'viewUrl': None})
            if item.has_key('show') and item['show']:
                item['class'] += ' hidden'
            if (self.maxItems and i>=self.maxItems) and not canManage:
                item['class'] += ' invisible'
            w, h = item['obj'].getSize()
            tw, th = img.getSize(self.thumb_size)
            if (tw < w and tw > 0) or (th < h and th > 0):
                item['rel'] = '%s[%s]' % (relAttribute, self.css_class)
                item['url'] = img.getImageURL(size="popup")
                item['viewUrl'] = item['obj'].absolute_url()+ '/view'
            i += 1
        return items