コード例 #1
0
 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
コード例 #2
0
 def getArticle(self, **kwargs):
     """ Returns a random article (catalog brain)
     """
     provider = IArticles(self.context)
     articles = provider.getArticles(**kwargs)
     if not len(articles):
         return None
     return articles[random.randint(0, len(articles)-1)]
コード例 #3
0
 def articles(self):
     provider = IArticles(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.getArticles()
     else:
         items = provider.getArticles(component=self.component)
     items = manageable.getList(items, self.component)
     i = 0
     l = len(items)
     for item in items:
         self._data(item, i, l)
         i += 1
     return items
コード例 #4
0
 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)
コード例 #5
0
 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
コード例 #6
0
 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
コード例 #7
0
 def articles(self):
     provider = IArticles(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.getArticles()
     else:
         items = provider.getArticles(component=self.component)
     items = manageable.getList(items, self.component)
     i = 0
     l = len(items)
     for item in items:
         classes = ['article', 'component',]
         styles = item['obj'].Schema().get('styles', None)
         if styles is not None:
             classes.extend(styles.get(item['obj']))
         item.update({'content': component.getMultiAdapter((item['obj'], self.request), name=u'allcontent')(item.has_key('show') and item['show']),
                      'class': self._class(item['brain'], i, l, classes)})
         if item.has_key('show') and item['show']:
             item['class'] += ' hidden'
         i += 1
     return items
コード例 #8
0
 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
コード例 #9
0
 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