def getTitleFromValue(self, value):
     reference_tool = getToolByName(self.base, 'reference_catalog')
     pm = getToolByName(self.base, 'portal_membership')
     # the value could be
     # uid or uid/image_thumb or uid/view or uid/download ....
     uid = value.split('/')[0]
     obj = reference_tool.lookupObject(uid)
     if obj is not None:
         if pm.checkPermission('View', obj):
             return obj.pretty_title_or_id()
         return '%s : %s ' %(_(u"You don't have permission to access this object"),uid)
     else:
         return '%s : %s ' %(_(u"Object not found with uid"),uid)
예제 #2
0
    def getThumbSizes(self):
        """Return an ordered list of thumb sizes taken from portal properties
        imaging properties when exists list of tuples [(label, width, height,
        thumb_label, thumb_extension), ...]
        FIXME: This is too much associated with standard ATImage. We should proceed
        with views/adapters
        """
        context = aq_inner(self.context)
        pprops = getToolByName(context, "portal_properties")
        if hasattr(pprops, "imaging_properties"):
            imaging_properties = pprops.imaging_properties
            thumb_sizes_props = imaging_properties.getProperty("allowed_sizes")
            thumb_sizes = []
            for prop in thumb_sizes_props:
                propInfo = prop.split(" ")
                thumb_name = propInfo[0]
                thumb_width = int(propInfo[1].split(":")[0])
                thumb_height = int(propInfo[1].split(":")[1])
                thumb_label = "%s : %ipx*%ipx" % (_(thumb_name.capitalize()), thumb_width, thumb_height)
                thumb_extension = "/@@images/image/%s" % thumb_name
                thumb_sizes.append((thumb_name, thumb_width, thumb_height, thumb_label, thumb_extension))
            thumb_sizes.sort(key=lambda ts: ts[1])
            return thumb_sizes

        return [
            ("listing", 16, 16, "%s : 16px*16px" % _("Listing"), "/@@images/image/listing"),
            ("icon", 32, 32, "%s : 32px*32px" % _("Icon"), "/@@images/image/icon"),
            ("tile", 64, 64, "%s : 64px*64px" % _("Tile"), "/@@images/image/tile"),
            ("thumb", 128, 128, "%s : 128px*128px" % _("Thumb"), "/@@images/image/thumb"),
            ("mini", 200, 200, "%s : 200px*200px" % _("Mini"), "/@@images/image/mini"),
            ("preview", 400, 400, "%s : 400px*400px" % _("Preview"), "/@@images/image/preview"),
            ("large", 768, 768, "%s : 768px*768px" % _("Large"), "/@@images/image/large"),
        ]
 def getTitleFromValue(self, value):
     reference_tool = getToolByName(self.base, 'reference_catalog')
     pm = getToolByName(self.base, 'portal_membership')
     # the value could be
     # uid or uid/image_thumb or uid/view or uid/download ....
     uid = value.split('/')[0]
     obj = reference_tool.lookupObject(uid)
     if obj is not None:
         if pm.checkPermission('View', obj):
             return obj.pretty_title_or_id()
         return '%s : %s ' % (
             _(u"You don't have permission to access this object"), uid)
     else:
         return '%s : %s ' % (_(u"Object not found with uid"), uid)
예제 #4
0
    def getThumbSizes(self):
        """Return an ordered list of thumb sizes taken from portal properties
        imaging properties when exists list of tuples [(label, width, height,
        thumb_label, thumb_extension), ...]
        FIXME: This is too much associated with standard ATImage. We should proceed
        with views/adapters
        """
        context = aq_inner(self.context)
        pprops = getToolByName(context, 'portal_properties')
        if hasattr(pprops, 'imaging_properties'):
            imaging_properties = pprops.imaging_properties
            thumb_sizes_props = imaging_properties.getProperty('allowed_sizes')
            thumb_sizes = []
            for prop in thumb_sizes_props:
                propInfo = prop.split(' ')
                thumb_name = propInfo[0]
                thumb_width = int(propInfo[1].split(':')[0])
                thumb_height = int(propInfo[1].split(':')[1])
                thumb_label = "%s : %ipx*%ipx" % (_(thumb_name.capitalize()), thumb_width,
                                                  thumb_height)
                thumb_extension = "/image_%s" % thumb_name
                thumb_sizes.append((thumb_name, thumb_width, thumb_height, thumb_label,
                                    thumb_extension))
            thumb_sizes.sort(key=lambda ts: ts[1])
            return thumb_sizes

        return [
            ('listing', 16, 16, '%s : 16px*16px' % _('Listing'), '/image_listing'),
            ('icon', 32, 32, '%s : 32px*32px' % _('Icon'), '/image_icon'),
            ('tile', 64, 64, '%s : 64px*64px' % _('Tile'), '/image_tile'),
            ('thumb', 128, 128, '%s : 128px*128px' % _('Thumb'), '/image_thumb'),
            ('mini', 200, 200, '%s : 200px*200px' % _('Mini'), '/image_mini'),
            ('preview', 400, 400, '%s : 400px*400px' % _('Preview'), '/image_preview'),
            ('large', 768, 768, '%s : 768px*768px' % _('Large'), '/image_large')
            ]
class FinderSelectFileWidget(FinderSelectWidget):
    """A widget with a plone_finder link for a Sequence field (tuple or list)
    that could reference and upload files
    """
    finderlabel = _(u'Browse for files')
    types = ['File']
    allowupload = 1
    allowaddfolder = 1
class FinderImageWidget(TextWidget):
    """A base widget with a plone_finder link for a Sequence field (tuple or
    list) that could reference any kind of value from browsed objects By defaut
    uid is used as value
    """
    template = ViewPageTemplateFile('finderimage.pt')
    finderlabel = _(u'Browse for image')
    types = ['Image']
    typeview = 'image'
    imagestypes = ('Image', )
    query = None
    selectiontype = 'uid'
    allowupload = True
    allowaddfolder = False
    allowimagesizeselection = True
    forcecloseoninsert = True
    base = None

    def __call__(self):
        self.value = self._getFormValue()
        if self.value is None or self.value == self.context.missing_value:
            self.value = ''
        return self.template()

    def _getBaseUrl(self):
        base = getSite()
        return base.absolute_url()

    def htmlid(self):
        return self.name.replace('.', '_')

    def portal_url(self):
        content = self.context.context
        portal_state = content.restrictedTraverse('@@plone_portal_state')
        portal_url = portal_state.portal_url()
        return portal_url

    def image_url(self):
        return absolute_image_url(self.context.context, self.value)

    def finder_url(self):
        """JS link that opens the finder
        """
        base_url = self._getBaseUrl()
        # TODO: put all these queryString pairs in session (see finder.py)
        values = {
            'fieldid': self.htmlid(),
            'fieldname': self.htmlid(),
            'typeview': self.typeview,
            'selectiontype': self.selectiontype,
            'allowupload': int(self.allowupload),
            'allowaddfolder': int(self.allowaddfolder),
            'allowimagesizeselection': int(self.allowimagesizeselection),
            'forcecloseoninsert': int(self.forcecloseoninsert),
            'types': list(self.types),
            'imagestypes': list(self.imagestypes)
        }
        return '%s/@@plone_finder?%s' % (base_url, make_query(values))
class FinderSelectImageWidget(FinderSelectWidget):
    """A widget with a plone_finder link for a Sequence field (tuple or list)
    that could reference and upload images values are stored as uid/image_size
    """
    finderlabel = _(u'Browse for images')
    types = ['Image', 'News Item']
    typeview = 'image'
    allowupload = 1
    allowaddfolder = 1
    allowimagesizeselection = 1
예제 #8
0
    def getThumbSizes(self):
        """Return an ordered list of thumb sizes taken from portal properties
        imaging properties when exists list of tuples [(label, width, height,
        thumb_label, thumb_extension), ...]
        FIXME: This is too much associated with standard ATImage. We should proceed
        with views/adapters
        """
        context = aq_inner(self.context)
        pprops = getToolByName(context, 'portal_properties')
        if hasattr(pprops, 'imaging_properties'):
            imaging_properties = pprops.imaging_properties
            thumb_sizes_props = imaging_properties.getProperty('allowed_sizes')
            thumb_sizes = []
            for prop in thumb_sizes_props:
                propInfo = prop.split(' ')
                thumb_name = propInfo[0]
                thumb_width = int(propInfo[1].split(':')[0])
                thumb_height = int(propInfo[1].split(':')[1])
                thumb_label = "%s : %ipx*%ipx" % (_(
                    thumb_name.capitalize()), thumb_width, thumb_height)
                thumb_extension = "/@@images/image/%s" % thumb_name
                thumb_sizes.append((thumb_name, thumb_width, thumb_height,
                                    thumb_label, thumb_extension))
            thumb_sizes.sort(key=lambda ts: ts[1])
            return thumb_sizes

        return [('listing', 16, 16, '%s : 16px*16px' % _('Listing'),
                 '/@@images/image/listing'),
                ('icon', 32, 32, '%s : 32px*32px' % _('Icon'),
                 '/@@images/image/icon'),
                ('tile', 64, 64, '%s : 64px*64px' % _('Tile'),
                 '/@@images/image/tile'),
                ('thumb', 128, 128, '%s : 128px*128px' % _('Thumb'),
                 '/@@images/image/thumb'),
                ('mini', 200, 200, '%s : 200px*200px' % _('Mini'),
                 '/@@images/image/mini'),
                ('preview', 400, 400, '%s : 400px*400px' % _('Preview'),
                 '/@@images/image/preview'),
                ('large', 768, 768, '%s : 768px*768px' % _('Large'),
                 '/@@images/image/large')]
예제 #9
0
    def finderResults(self):
        """Return results to select
        """
        cat = self.data["catalog"]
        scope = self.data["scope"]
        if IATTopic.providedBy(scope):
            supQuery = self.finderQuery()
            if supQuery.has_key("path"):
                del supQuery["path"]
            brains = finderTopicsQueryCatalog(scope, cat, **supQuery)
        else:
            query = self.finderQuery()
            brains = cat(**query)
        results = []
        for b in brains:
            title_or_id = b.pretty_title_or_id()
            r = {
                "uid": b.UID,
                "url": b.getURL(),
                "path": b.getPath(),
                "title": title_or_id,
                "jstitle": title_or_id.replace("\x27", "\x5C\x27"),
                "description": b.Description,
                "state_class": "state-%s" % b.review_state,
                "is_folderish": b.is_folderish or False,
                "size": b.getObjSize,
                "type": b.portal_type,
                "blacklisted": False,
                "created": b.created,
                "actions_menu": {},
            }
            if r["type"] in self.imagestypes:
                o = b.getObject()
                imageInfos = self.getImageInfos(o)
                orientation = imageInfos[0]
                width = imageInfos[1]
                height = imageInfos[2]
                if width and height:
                    # FIXME: This should go in config.py
                    min, max = 70, 100
                    if orientation == "portrait":
                        ratio = float(width) / float(height)
                        if height > max:
                            width = int(ratio * max)
                            height = max
                        if width > min:
                            width = min
                            height = int(min / ratio)
                    else:
                        ratio = float(height) / float(width)
                        if width > max:
                            height = int(ratio * max)
                            width = max
                        if height > min:
                            height = min
                            width = int(min / ratio)
                    thumb_sizes = self.getThumbSizes()
                    # define thumb icon and preview urls for display
                    thumb = icon = "%s/@@images/image" % r["url"]
                    preview = "%s/@@images/image?isImage=1" % r["url"]
                    for ts in thumb_sizes:
                        if ts[1] >= width and ts[2] >= height:
                            thumb = "%s/@@images/image/%s" % (r["url"], ts[0])
                            break
                    for ts in thumb_sizes:
                        if ts[1] >= 16 and ts[2] >= 16:
                            icon = "%s/@@images/image/%s" % (r["url"], ts[0])
                            break
                    for ts in thumb_sizes:
                        if ts[1] >= 400 and ts[2] >= 400:
                            preview = "%s/@@images/image/%s?isImage=1" % (r["url"], ts[0])
                            break
                    # images sizes actions menu
                    thumb_sizes.extend([("full", width, height, _("Full size"), "/image")])
                    if self.allowimagesizeselection:
                        r["actions_menu"]["choose_image_size"] = {
                            "label": _(u"Choose image size"),
                            "actions": thumb_sizes,
                        }
                    r.update(
                        {
                            "is_image": True,
                            "preview_url": preview,
                            "url": "%s/@@images/image" % r["url"],
                            "container_class": "imageContainer",
                            "style": "width: %ipx; height: %ipx" % (width, height),
                        }
                    )
                else:
                    orientation = "small"
                    thumb = icon = None
                    r.update(
                        {
                            "iconclass": ("contenttype-%s divicon" % b.portal_type.lower().replace(" ", "-")),
                            "is_image": False,
                            "container_class": "fileContainer",
                            "style": "",
                        }
                    )
            else:
                # Not an image type
                orientation = "small"
                r["style"] = ""
                if b.portal_type in self.filestypes:
                    o = b.getObject()
                    icon_base = o.getIcon()
                    if icon_base:
                        r["style"] = "background-image: url(./%s)" % icon_base
                r["iconclass"] = "contenttype-%s divicon" % b.portal_type.lower().replace(" ", "-")
                thumb = icon = None
                r["is_image"] = False
                r["container_class"] = "fileContainer"
            if self.typeview == "image":
                r["orientation_class"] = orientation
                r["thumb"] = thumb
            else:
                r["orientation_class"] = "%s_icon" % orientation
                r["thumb"] = icon

            if r["size"]:
                r["real_size"] = float(r["size"].split(" ")[0])
            else:
                r["real_size"] = 0

            results.append(r)

        return results
예제 #10
0
    def finderResults(self):
        """Return results to select
        """
        cat = self.data['catalog']
        scope = self.data['scope']
        if IATTopic.providedBy(scope):
            supQuery = self.finderQuery()
            if supQuery.has_key('path'):
                del supQuery['path']
            brains = finderTopicsQueryCatalog(scope, cat, **supQuery)
        else:
            query = self.finderQuery()
            brains = cat(**query)
        results = []
        for b in brains:
            title_or_id = b.pretty_title_or_id()
            r = {
                'uid': b.UID,
                'url': b.getURL(),
                'path': b.getPath(),
                'title': title_or_id,
                'jstitle': title_or_id.replace("\x27", "\x5C\x27"),
                'description':b.Description,
                'state_class': 'state-%s' % b.review_state,
                'is_folderish': b.is_folderish or False,
                'size': b.getObjSize,
                'type': b.portal_type,
                'blacklisted': False,
                'created': b.created,
                'actions_menu': {}
                }
            if r['type'] in self.imagestypes:
                o = b.getObject()
                imageInfos = self.getImageInfos(o)
                orientation = imageInfos[0]
                width = imageInfos[1]
                height = imageInfos[2]
                if width and height:
                    # FIXME: This should go in config.py
                    min, max = 70, 100
                    if orientation == 'portrait':
                        ratio = float(width)/float(height)
                        if height > max:
                            width = int(ratio *max)
                            height = max
                        if width > min:
                            width = min
                            height = int(min/ratio)
                    else:
                        ratio = float(height)/float(width)
                        if width > max:
                            height = int(ratio *max)
                            width = max
                        if height > min:
                            height = min
                            width = int(min/ratio)
                    thumb_sizes = self.getThumbSizes()
                    # define thumb icon and preview urls for display
                    thumb = icon = '%s/image' % r['url']
                    preview = '%s/image?isImage=1' % r['url']
                    for ts in thumb_sizes:
                        if ts[1] >= width and ts[2] >= height:
                            thumb = '%s/image_%s' % (r['url'], ts[0])
                            break
                    for ts in thumb_sizes:
                        if ts[1] >= 16 and ts[2] >= 16:
                            icon = '%s/image_%s' % (r['url'], ts[0])
                            break
                    for ts in thumb_sizes:
                        if ts[1] >= 400 and ts[2] >= 400:
                            preview = '%s/image_%s?isImage=1' % (r['url'], ts[0])
                            break
                    # images sizes actions menu
                    thumb_sizes.extend([('full',width ,height ,_('Full size'), '/image')])
                    if self.allowimagesizeselection:
                        r['actions_menu']['choose_image_size'] = {
                            'label': _(u'Choose image size'),
                            'actions': thumb_sizes
                            }
                    r.update({
                        'is_image': True,
                        'preview_url': preview,
                        'url': '%s/image' % r['url'],
                        'container_class': 'imageContainer',
                        'style': 'width: %ipx; height: %ipx' % (width, height)
                        })
                else:
                    orientation = 'small'
                    thumb = icon = None
                    r.update({
                        'iconclass': ('contenttype-%s divicon' %
                                      b.portal_type.lower().replace(' ','-')),
                        'is_image': False,
                        'container_class': 'fileContainer',
                        'style': ''
                        })
            else:
                # Not an image type
                orientation = 'small'
                r['style'] = ''
                if b.portal_type in self.filestypes:
                    o = b.getObject()
                    icon_base = o.getIcon()
                    if icon_base:
                        r['style'] = 'background-image: url(./%s)' % icon_base
                r['iconclass'] = 'contenttype-%s divicon' % b.portal_type.lower().replace(' ','-')
                thumb = icon = None
                r['is_image'] = False
                r['container_class'] = 'fileContainer'
            if self.typeview == 'image':
                r['orientation_class'] = orientation
                r['thumb'] = thumb
            else:
                r['orientation_class'] = '%s_icon' % orientation
                r['thumb'] = icon

            if r['size']:
                r['real_size'] = float(r['size'].split(' ')[0])
            else:
                r['real_size'] = 0

            results.append(r)

        return results
class FinderSelectWidget(OrderedMultiSelectWidget):
    """A base widget with a plone_finder link for a Sequence field (tuple or
    list) that could reference any kind of value from browsed objects By defaut
    uid is used as value
    """
    template = ViewPageTemplateFile('finderbase.pt')
    finderlabel = _(u'Browse for contents')
    moveuplabel = _(u'Move up')
    movedownlabel = _(u'Move down')
    deleteentrylabel = _(u'Remove item')
    types = ()
    typeview = 'file'
    imagestypes = ('Image', 'News Item')
    query = None
    selectiontype = 'uid'
    allowupload = False
    allowaddfolder = False
    allowimagesizeselection = False
    forcecloseoninsert = False
    base = None

    def __init__(self, field, request):
        """TODO: set some plone_finder attributes in session for a smaller
        querystring. The most important improvement can be the plone_finder
        blacklist stored in session to remove selected objects from plone_finder
        results
        """
        if field.value_type != None:
            voc = field.value_type.vocabulary
        else:
            voc = None
        if self.base is None:
            self.base = getSite()
        super(FinderSelectWidget, self).__init__(field, voc, request)

    def _getBaseUrl(self):
        return self.base.absolute_url()

    def getTitleFromValue(self, value):
        reference_tool = getToolByName(self.base, 'reference_catalog')
        pm = getToolByName(self.base, 'portal_membership')
        # the value could be
        # uid or uid/image_thumb or uid/view or uid/download ....
        uid = value.split('/')[0]
        obj = reference_tool.lookupObject(uid)
        if obj is not None:
            if pm.checkPermission('View', obj):
                return obj.pretty_title_or_id()
            return '%s : %s ' % (
                _(u"You don't have permission to access this object"), uid)
        else:
            return '%s : %s ' % (_(u"Object not found with uid"), uid)

    def finderlink(self):
        """JS link that opens the finder
        """
        base_url = self._getBaseUrl()
        # TODO: put all these queryString pairs in session (see finder.py)
        values = {
            'fieldid': self.name,
            'fieldname': self.name,
            'typeview': self.typeview,
            'selectiontype': self.selectiontype,
            'allowupload': int(self.allowupload),
            'allowaddfolder': int(self.allowaddfolder),
            'allowimagesizeselection': int(self.allowimagesizeselection),
            'forcecloseoninsert': int(self.forcecloseoninsert),
            'types': list(self.types),
            'imagestypes': list(self.imagestypes)
        }
        return "openFinder('%s/@@plone_finder?%s')" % (base_url,
                                                       make_query(values))

    def convertTokensToValues(self, tokens):
        """Convert term tokens to the terms themselves.
        if vocabulary is None just append token in values list
        """
        values = []
        for token in tokens:
            if self.vocabulary is not None:
                try:
                    term = self.vocabulary.getTermByToken(token)
                except LookupError:
                    raise InvalidValue("token %r not found in vocabulary" %
                                       token)
                else:
                    values.append(term.value)
            else:
                values.append(token)
        return values

    def selected(self):
        """Return a list of tuples (text, value) that are selected
           when vocabulary is not None
           otherwise return list of tuples (value, value)."""

        # Get form values
        values = self._getFormValue()
        # Not all content objects must necessarily support the attributes
        if hasattr(self.context.context, self.context.__name__):
            # merge in values from content
            for value in self.context.get(self.context.context):
                if value not in values:
                    values.append(value)

        if self.vocabulary is not None:
            terms = [self.vocabulary.getTerm(value) for value in values]
            return [{
                'text': self.textForValue(term),
                'value': term.token
            } for term in terms]
        elif self.selectiontype == 'uid':
            return [{
                'text': self.getTitleFromValue(value),
                'value': value
            } for value in values]
        else:
            return [{'text': value, 'value': value} for value in values]
예제 #12
0
    def finderResults(self):
        """Return results to select
        """
        cat = self.data['catalog']
        scope = self.data['scope']
        if IATTopic.providedBy(scope):
            supQuery = self.finderQuery()
            if supQuery.has_key('path'):
                del supQuery['path']
            brains = finderTopicsQueryCatalog(scope, cat, **supQuery)
        else:
            query = self.finderQuery()
            brains = cat(**query)
        results = []
        for b in brains:
            title_or_id = b.pretty_title_or_id()
            r = {
                'uid': b.UID,
                'url': b.getURL(),
                'path': b.getPath(),
                'title': title_or_id,
                'jstitle': title_or_id.replace("\x27", "\x5C\x27"),
                'description': b.Description,
                'state_class': 'state-%s' % b.review_state,
                'is_folderish': b.is_folderish or False,
                'size': b.getObjSize,
                'type': b.portal_type,
                'blacklisted': False,
                'created': b.created,
                'actions_menu': {}
            }
            if r['type'] in self.imagestypes:
                o = b.getObject()
                imageInfos = self.getImageInfos(o)
                orientation = imageInfos[0]
                width = imageInfos[1]
                height = imageInfos[2]
                if width and height:
                    # FIXME: This should go in config.py
                    min, max = 70, 100
                    if orientation == 'portrait':
                        ratio = float(width) / float(height)
                        if height > max:
                            width = int(ratio * max)
                            height = max
                        if width > min:
                            width = min
                            height = int(min / ratio)
                    else:
                        ratio = float(height) / float(width)
                        if width > max:
                            height = int(ratio * max)
                            width = max
                        if height > min:
                            height = min
                            width = int(min / ratio)
                    thumb_sizes = self.getThumbSizes()
                    # define thumb icon and preview urls for display
                    thumb = icon = '%s/image' % r['url']
                    preview = '%s/image?isImage=1' % r['url']
                    for ts in thumb_sizes:
                        if ts[1] >= width and ts[2] >= height:
                            thumb = '%s/@@images/image/%s' % (r['url'], ts[0])
                            break
                    for ts in thumb_sizes:
                        if ts[1] >= 16 and ts[2] >= 16:
                            icon = '%s/@@images/image/%s' % (r['url'], ts[0])
                            break
                    for ts in thumb_sizes:
                        if ts[1] >= 400 and ts[2] >= 400:
                            preview = '%s/@@images/image/%s?isImage=1' % (
                                r['url'], ts[0])
                            break
                    # images sizes actions menu
                    thumb_sizes.extend([('full', width, height, _('Full size'),
                                         '/@@images/image')])
                    if self.allowimagesizeselection:
                        r['actions_menu']['choose_image_size'] = {
                            'label': _(u'Choose image size'),
                            'actions': thumb_sizes
                        }
                    r.update({
                        'is_image':
                        True,
                        'preview_url':
                        preview,
                        'url':
                        '%s/image' % r['url'],
                        'container_class':
                        'imageContainer',
                        'style':
                        'width: %ipx; height: %ipx' % (width, height)
                    })
                else:
                    orientation = 'small'
                    thumb = icon = None
                    r.update({
                        'iconclass': ('contenttype-%s divicon' %
                                      b.portal_type.lower().replace(' ', '-')),
                        'is_image':
                        False,
                        'container_class':
                        'fileContainer',
                        'style':
                        ''
                    })
            else:
                # Not an image type
                orientation = 'small'
                r['style'] = ''
                if b.portal_type in self.filestypes:
                    o = b.getObject()
                    icon_base = o.getIcon()
                    if icon_base:
                        r['style'] = 'background-image: url(./%s)' % icon_base
                r['iconclass'] = 'contenttype-%s divicon' % b.portal_type.lower(
                ).replace(' ', '-')
                thumb = icon = None
                r['is_image'] = False
                r['container_class'] = 'fileContainer'
            if self.typeview == 'image':
                r['orientation_class'] = orientation
                r['thumb'] = thumb
            else:
                r['orientation_class'] = '%s_icon' % orientation
                r['thumb'] = icon

            if r['size']:
                r['real_size'] = float(r['size'].split(' ')[0])
            else:
                r['real_size'] = 0

            results.append(r)

        return results