def header_upload(self):
        request = self.request
        try:
            session = request.get('SESSION', {})
            medialabel = session.get('mediaupload',
                                     request.get('mediaupload', 'files'))
        except SessionDataManagerErr:
            logger.debug('Error occurred getting session data. '
                         'Falling back to request.')
            medialabel = request.get('mediaupload', 'files')

        # to improve
        if '*.' in medialabel:
            medialabel = ''
        if not medialabel:
            return _('Files Quick Upload')
        elif medialabel == 'image':
            return _('Images Quick Upload')
        else:
            return _('label_media_quickupload',
                     default='${medialabel} Quick Upload',
                     mapping={
                         'medialabel':
                         translate(medialabel.capitalize(),
                                   domain='collective.quickupload',
                                   context=self.request)
                     })
    def header_upload(self):
        request = self.request
        try:
            session = request.get('SESSION', {})
            medialabel = session.get(
                'mediaupload',
                request.get('mediaupload', 'files')
            )
        except SessionDataManagerErr:
            logger.debug('Error occurred getting session data. '
                         'Falling back to request.')
            medialabel = request.get('mediaupload', 'files')

        # to improve
        if '*.' in medialabel:
            medialabel = ''
        if not medialabel:
            return _('Files Quick Upload')
        elif medialabel == 'image':
            return _('Images Quick Upload')
        else:
            return _('label_media_quickupload',
                     default='${medialabel} Quick Upload',
                     mapping={'medialabel': translate(
                         medialabel.capitalize(),
                         domain='collective.quickupload',
                         context=self.request)
                     })
    def ul_content_types_infos (self, mediaupload):
        """
        return some content types infos depending on mediaupload type
        mediaupload could be 'image', 'video', 'audio' or any
        extension like '*.doc'
        """
        ext = '*.*;'
        extlist = []
        msg = u'Choose files to upload'
        if mediaupload == 'image' :
            ext = '*.jpg;*.jpeg;*.gif;*.png;'
            msg = _(u'Choose images to upload')
        elif mediaupload == 'video' :
            ext = '*.flv;*.avi;*.wmv;*.mpg;'
            msg = _(u'Choose video files to upload')
        elif mediaupload == 'audio' :
            ext = '*.mp3;*.wav;*.ogg;*.mp4;*.wma;*.aif;'
            msg = _(u'Choose audio files to upload')
        elif mediaupload == 'flash' :
            ext = '*.swf;'
            msg = _(u'Choose flash files to upload')
        elif mediaupload :
            # you can also pass a list of extensions in mediaupload request var
            # with this syntax '*.aaa;*.bbb;'
            ext = mediaupload
            msg = _(u'Choose file for upload: ${ext}', mapping={'ext': ext})

        try :
            extlist = [f.split('.')[1].strip() for f in ext.split(';') if f.strip()]
        except :
            extlist = []
        if extlist==['*'] :
            extlist = []

        return ( ext, extlist, self._translate(msg))
    def ul_content_types_infos(self, mediaupload):
        """
        return some content types infos depending on mediaupload type
        mediaupload could be 'image', 'video', 'audio' or any
        extension like '*.doc'
        """
        ext = "*.*;"
        extlist = []
        msg = u"Choose files to upload"
        if mediaupload == "image":
            ext = "*.jpg;*.jpeg;*.gif;*.png;"
            msg = _(u"Choose images to upload")
        elif mediaupload == "video":
            ext = "*.flv;*.avi;*.wmv;*.mpg;"
            msg = _(u"Choose video files to upload")
        elif mediaupload == "audio":
            ext = "*.mp3;*.wav;*.ogg;*.mp4;*.wma;*.aif;"
            msg = _(u"Choose audio files to upload")
        elif mediaupload == "flash":
            ext = "*.swf;"
            msg = _(u"Choose flash files to upload")
        elif mediaupload:
            # you can also pass a list of extensions in mediaupload request var
            # with this syntax '*.aaa;*.bbb;'
            ext = mediaupload
            msg = _(u"Choose file for upload: ${ext}", mapping={"ext": ext})

        try:
            extlist = [f.split(".")[1].strip() for f in ext.split(";") if f.strip()]
        except:
            extlist = []
        if extlist == ["*"]:
            extlist = []

        return (ext, extlist, self._translate(msg))
示例#5
0
    def title(self):
        """portlet title
        """
        if self.header:
            return PMF(self.header)

        media = self.upload_media_type
        if not media or '*.' in media:
            return _(u'Files Quick Upload')
        elif media == 'image':
            return _(u'Images Quick Upload')
        else:
            return _(u'label_media_quickupload',
                     default='${medialabel} Quick Upload',
                     mapping={'medialabel': media.capitalize()})
示例#6
0
    def __call__(self, obj, filename, title, description, content_type, data):
        result = {}
        result['success'] = None

        # consolidation because it's different upon Plone versions
        if title:
            obj.setTitle(title)

        if description:
            obj.setDescription(description)

        error = IQuickUploadFileSetter(obj).set(data, filename, content_type)
        # notify edited instead of modified whereas version history is not
        # saved
        notify(ObjectEditedEvent(obj))
        obj.reindexObject()

        result['error'] = error
        if not error:
            result['success'] = obj
            IStatusMessage(obj.REQUEST).addStatusMessage(
                _('msg_file_replaced',
                  default=u"${filename} file has been replaced",
                  mapping={'filename': filename}), type)

        return result
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        items = [SimpleTerm('auto', 'auto', context.translate(_('label_default_portaltype_configuration',
                                                      default=u'Default configuration (Content Type Registry).')))]
        archetype_tool = getToolByName(context, 'archetype_tool', None)
        if archetype_tool:
            flt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent)]
            ilt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent)]
            items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
                      for t in flt])
            file_types = [t['portal_type'] for t in flt]
            items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
                      for t in ilt if t['portal_type'] not in file_types])

        for fti in portal.portal_types.objectValues():
            if HAS_DEXTERITY and IDexterityFTI.providedBy(fti):
                try:
                    schema = fti.lookupSchema()
                except ImportError:
                    # this dexterity type was changed/removed in an improper way
                    # no need to punish, just fail gracefully
                    continue
                fields = getFieldsInOrder(schema)
                for fieldname, field in fields:
                    if INamedFileField.providedBy(field) or INamedImageField.providedBy(field):
                        items.append(SimpleTerm(fti.getId(), fti.getId(), fti.Title()))
                        break

        return SimpleVocabulary(items)
示例#8
0
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        items = [
            SimpleTerm(
                'auto', 'auto',
                context.translate(
                    _('label_default_portaltype_configuration',
                      default=u'Default configuration (Content Type Registry).'
                      )))
        ]

        flt = [
            _infoDictForType(portal, tipe)
            for tipe in _listTypesForInterface(portal, 'file')
        ]
        ilt = [
            _infoDictForType(portal, tipe)
            for tipe in _listTypesForInterface(portal, 'image')
        ]
        items.extend([
            SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
            for t in flt
        ])
        file_types = [t['portal_type'] for t in flt]
        items.extend([
            SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
            for t in ilt if t['portal_type'] not in file_types
        ])

        return SimpleVocabulary(items)
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        items = [
            SimpleTerm(
                'auto', 'auto', context.translate(_(
                    'label_default_portaltype_configuration',
                    default=u'Default configuration (Content Type Registry).'))
            )
        ]

        flt = [
            _infoDictForType(portal, tipe) for tipe in
            _listTypesForInterface(portal, 'file')
        ]
        ilt = [
            _infoDictForType(portal, tipe) for tipe in
            _listTypesForInterface(portal, 'image')
        ]
        items.extend([
            SimpleTerm(
                t['portal_type'], t['portal_type'], t['type_ui_info']
            )
            for t in flt
        ])
        file_types = [t['portal_type'] for t in flt]
        items.extend([
            SimpleTerm(
                t['portal_type'], t['portal_type'], t['type_ui_info']
            )
            for t in ilt if t['portal_type'] not in file_types
        ])

        return SimpleVocabulary(items)
    def __call__(self, obj, filename, title, description, content_type, data):
        result = {}
        result['success'] = None

        # consolidation because it's different upon Plone versions
        if title:
            obj.setTitle(title)

        if description:
            obj.setDescription(description)

        error = IQuickUploadFileSetter(obj).set(data, filename, content_type)
        # notify edited instead of modified whereas version history is not
        # saved
        notify(ObjectEditedEvent(obj))
        obj.reindexObject()

        result['error'] = error
        if not error:
            result['success'] = obj
            IStatusMessage(obj.REQUEST).addStatusMessage(
                _('msg_file_replaced',
                  default=u"${filename} file has been replaced",
                  mapping={'filename': filename}),
                type)

        return result
    def header_upload(self):
        request = self.request
        try:
            session = request.get("SESSION", {})
            medialabel = session.get("mediaupload", request.get("mediaupload", "files"))
        except SessionDataManagerErr:
            logger.debug("Error occurred getting session data. " "Falling back to request.")
            medialabel = request.get("mediaupload", "files")

        # to improve
        if "*." in medialabel:
            medialabel = ""
        if not medialabel:
            return _("Files Quick Upload")
        elif medialabel == "image":
            return _("Images Quick Upload")
        else:
            return _(
                "label_media_quickupload",
                default="${medialabel} Quick Upload",
                mapping={"medialabel": medialabel.capitalize()},
            )
示例#12
0
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        flt = [
            _infoDictForType(portal, tipe)
            for tipe in _listTypesForInterface(portal, IFileContent)
        ]
        ilt = [
            _infoDictForType(portal, tipe)
            for tipe in _listTypesForInterface(portal, IImageContent)
        ]
        items = [
            SimpleTerm(
                'auto', 'auto',
                context.translate(
                    _('label_default_portaltype_configuration',
                      default=u'Default configuration (Content Type Registry).'
                      )))
        ]
        items.extend([
            SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
            for t in flt
        ])
        file_types = [t['portal_type'] for t in flt]
        items.extend([
            SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
            for t in ilt if t['portal_type'] not in file_types
        ])

        for fti in portal.portal_types.objectValues():
            if HAS_DEXTERITY and IDexterityFTI.providedBy(fti):
                fields = getFieldsInOrder(fti.lookupSchema())
                for fieldname, field in fields:
                    if INamedFileField.providedBy(
                            field) or INamedImageField.providedBy(field):
                        items.append(
                            SimpleTerm(fti.getId(), fti.getId(), fti.Title()))
                        break

        return SimpleVocabulary(items)
    def __call__(self, obj, filename, title, description, content_type, data):
        error = ''
        result = {}
        result['success'] = None

        # consolidation because it's different upon Plone versions
        if title:
            obj.setTitle(title)

        if description:
            obj.setDescription(description)

        error = IQuickUploadFileSetter(obj).set(data, filename, content_type)

        result['error'] = error
        if not error :
            result['success'] = obj
            IStatusMessage(obj.REQUEST).addStatusMessage(_('msg_file_replaced',
                        default=u"${filename} file has been replaced",
                        mapping={'filename': filename}), type)

        return result
    def __call__(self, context):
        context = getattr(context, 'context', context)
        portal = getToolByName(context, 'portal_url').getPortalObject()
        flt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IFileContent)]
        ilt = [_infoDictForType(portal, tipe) for tipe in _listTypesForInterface(portal, IImageContent)]
        items = [SimpleTerm('auto', 'auto', context.translate(_('label_default_portaltype_configuration',
                                                      default=u'Default configuration (Content Type Registry).')))]
        items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
                  for t in flt])
        file_types = [t['portal_type'] for t in flt]
        items.extend([SimpleTerm(t['portal_type'], t['portal_type'], t['type_ui_info'])
                  for t in ilt if t['portal_type'] not in file_types])

        for fti in portal.portal_types.objectValues():
            if HAS_DEXTERITY and IDexterityFTI.providedBy(fti):
                fields = getFieldsInOrder(fti.lookupSchema())
                for fieldname, field in fields:
                    if INamedFileField.providedBy(field) or INamedImageField.providedBy(field):
                        items.append(SimpleTerm(fti.getId(), fti.getId(), fti.Title()))
                        break

        return SimpleVocabulary(items)
    def upload_settings(self):
        context = aq_inner(self.context)
        request = self.request
        try:
            session = request.get('SESSION', {})
            mediaupload = session.get(
                'mediaupload', request.get('mediaupload', ''))
            typeupload = session.get(
                'typeupload', request.get('typeupload', ''))
        except SessionDataManagerErr:
            logger.debug(
                'Error occurred getting session data. Falling back to request.'
            )
            mediaupload = request.get('mediaupload', '')
            typeupload = request.get('typeupload', '')
        portal_url = getToolByName(context, 'portal_url')()
        # use a ticket for authentication (used for flashupload only)
        ticket = context.restrictedTraverse('@@quickupload_ticket')()

        settings = dict(
            ticket                 = ticket,
            portal_url             = portal_url,
            typeupload             = '',
            context_url            = context.absolute_url(),
            physical_path          = "/".join(context.getPhysicalPath()),
            ul_id                  = self.uploader_id,
            ul_fill_titles         = self.qup_prefs.fill_titles and 'true' or 'false',
            ul_fill_descriptions   = self.qup_prefs.fill_descriptions and 'true' or 'false',
            ul_auto_upload         = self.qup_prefs.auto_upload and 'true' or 'false',
            ul_size_limit          = self.qup_prefs.size_limit and str(self.qup_prefs.size_limit*1024) or '',
            ul_xhr_size_limit      = self.qup_prefs.size_limit and str(self.qup_prefs.size_limit*1024) or '0',
            ul_sim_upload_limit    = str(self.qup_prefs.sim_upload_limit),
            ul_object_override     = self.qup_prefs.object_override and 'true' or 'false',
            ul_button_text         = self._translate(_(u'Browse')),
            ul_draganddrop_text    = self._translate(_(u'Drag and drop files to upload')),
            ul_msg_all_sucess      = self._translate(_(u'All files uploaded with success.')),
            ul_msg_some_sucess     = self._translate(_(u' files uploaded with success, ')),
            ul_msg_some_errors     = self._translate(_(u" uploads return an error.")),
            ul_msg_failed          = self._translate(_(u"Failed")),
            ul_error_try_again_wo  = self._translate(_(u"please select files again without it.")),
            ul_error_try_again     = self._translate(_(u"please try again.")),
            ul_error_empty_file    = self._translate(_(u"Selected elements contain an empty file or a folder:")),
            ul_error_empty_extension = self._translate(_(u"This file has no extension:")),
            ul_error_file_large    = self._translate(_(u"This file is too large:")),
            ul_error_maxsize_is    = self._translate(_(u"maximum file size is:")),
            ul_error_bad_ext       = self._translate(_(u"This file has invalid extension:")),
            ul_error_onlyallowed   = self._translate(_(u"Only allowed:")),
            ul_error_no_permission = self._translate(_(u"You don't have permission to add this content in this place.")),
            ul_error_disallowed_type = self._translate(_(u"This type of element is not allowed in this folder.",)),
            ul_error_already_exists = self._translate(_(u"This file already exists with the same name on server:")),
            ul_error_zodb_conflict = self._translate(_(u"A data base conflict error happened when uploading this file:")),
            ul_error_server        = self._translate(_(u"Server error, please contact support and/or try again.")),
        )

        settings['typeupload'] = typeupload
        if typeupload:
            imageTypes = _listTypesForInterface(context, 'image')
            if typeupload in imageTypes:
                ul_content_types_infos = self.ul_content_types_infos('image')
            else:
                ul_content_types_infos = self.ul_content_types_infos(
                    mediaupload
                )
        else:
            ul_content_types_infos = self.ul_content_types_infos(mediaupload)

        settings['ul_file_extensions'] = ul_content_types_infos[0]
        settings['ul_file_extensions_list'] = str(ul_content_types_infos[1])
        settings['ul_file_description'] = ul_content_types_infos[2]

        return settings
示例#16
0
class IQuickUploadPortlet(IPortletDataProvider):
    """Quickupload portlet schema
    """

    header = schema.TextLine(
        title=_(u"Box title"),
        default=u"",
        description=_(u"If title is empty, the portlet title will be the "
                      u"Media Choice + ' Quick Upload'."),
        required=False)

    upload_portal_type = schema.Choice(
        title=_(u"Content type"),
        description=_(u"Choose the portal type used for file upload. "
                      u"Let the default configuration for an automatic portal "
                      u"type, depending on settings defined in "
                      u"content_type_registry."),
        required=True,
        default='auto',
        vocabulary="collective.quickupload.fileTypeVocabulary")

    upload_media_type = schema.Choice(
        title=_(u"Media type"),
        description=_(u"Choose the media type used for file upload. "
                      u"image, audio, video ..."),
        required=False,
        default='',
        vocabulary=SimpleVocabulary(
            [SimpleTerm('', '', _(u"All")),
             SimpleTerm('image', 'image', _(u"Images")),
             SimpleTerm('video', 'video', _(u"Video files")),
             SimpleTerm('audio', 'audio', _(u"Audio files")),
             SimpleTerm('flash', 'flash', _(u"Flash files"))]
        ),
    )
    def upload_settings(self):
        context = aq_inner(self.context)
        request = self.request
        try:
            session = request.get('SESSION', {})
            mediaupload = session.get('mediaupload',
                    request.get('mediaupload', ''))
            typeupload = session.get('typeupload',
                    request.get('typeupload', ''))
        except SessionDataManagerErr:
            logger.debug('Error occurred getting session data. Falling back to '
                    'request.')
            mediaupload = request.get('mediaupload', '')
            typeupload = request.get('typeupload', '')
        portal_url = getToolByName(context, 'portal_url')()
        # use a ticket for authentication (used for flashupload only)
        ticket = context.restrictedTraverse('@@quickupload_ticket')()

        settings = dict(
            ticket                 = ticket,
            portal_url             = portal_url,
            typeupload             = '',
            context_url            = context.absolute_url(),
            physical_path          = "/".join(context.getPhysicalPath()),
            ul_id                  = self.uploader_id,
            ul_fill_titles         = self.qup_prefs.fill_titles and 'true' or 'false',
            ul_fill_descriptions   = self.qup_prefs.fill_descriptions and 'true' or 'false',
            ul_auto_upload         = self.qup_prefs.auto_upload and 'true' or 'false',
            ul_size_limit          = self.qup_prefs.size_limit and str(self.qup_prefs.size_limit*1024) or '',
            ul_xhr_size_limit      = self.qup_prefs.size_limit and str(self.qup_prefs.size_limit*1024) or '0',
            ul_sim_upload_limit    = str(self.qup_prefs.sim_upload_limit),
            ul_button_text         = self._translate(_(u'Browse')),
            ul_draganddrop_text    = self._translate(_(u'Drag and drop files to upload')),
            ul_msg_all_sucess      = self._translate(_(u'All files uploaded with success.')),
            ul_msg_some_sucess     = self._translate(_(u' files uploaded with success, ')),
            ul_msg_some_errors     = self._translate(_(u" uploads return an error.")),
            ul_msg_failed          = self._translate(_(u"Failed")),
            ul_error_try_again_wo  = self._translate(_(u"please select files again without it.")),
            ul_error_try_again     = self._translate(_(u"please try again.")),
            ul_error_empty_file    = self._translate(_(u"Selected elements contain an empty file or a folder:")),
            ul_error_empty_extension = self._translate(_(u"This file has no extension:")),
            ul_error_file_large    = self._translate(_(u"This file is too large:")),
            ul_error_maxsize_is    = self._translate(_(u"maximum file size is:")),
            ul_error_bad_ext       = self._translate(_(u"This file has invalid extension:")),
            ul_error_onlyallowed   = self._translate(_(u"Only allowed:")),
            ul_error_no_permission = self._translate(_(u"You don't have permission to add this content in this place.")),
            ul_error_disallowed_type = self._translate(_(u"This type of element is not allowed in this folder.",)),
            ul_error_already_exists = self._translate(_(u"This file already exists with the same name on server:")),
            ul_error_zodb_conflict = self._translate(_(u"A data base conflict error happened when uploading this file:")),
            ul_error_server        = self._translate(_(u"Server error, please contact support and/or try again.")),
        )

        settings['typeupload'] = typeupload
        if typeupload :
            imageTypes = _listTypesForInterface(context, IImageContent)
            if typeupload in imageTypes :
                ul_content_types_infos = self.ul_content_types_infos('image')
            else :
                ul_content_types_infos = self.ul_content_types_infos(mediaupload)
        else :
            ul_content_types_infos = self.ul_content_types_infos(mediaupload)

        settings['ul_file_extensions'] = ul_content_types_infos[0]
        settings['ul_file_extensions_list'] = str(ul_content_types_infos[1])
        settings['ul_file_description'] = ul_content_types_infos[2]

        return settings
class IQuickUploadControlPanel(Interface):
    """
    fields for quick upload control panel
    """
    use_flashupload = Bool(title=_(u"title_use_flashupload", default=u"Use Flash Upload"),
                           description=_(u"description_use_flashupload", 
                                          default=u"By default, the upload script is a javascript only tool. "
                                          "Check this option to replace it with a Flash Upload based script. "
                                          "For modern browsers the javascript tool is more powerful. "
                                          "Flash Upload is just more user friendly under other browsers (MSIE 7, MSIE 8),  "
                                          "but has many problems : don't work in https, don't work behind HTTP Authentication ..."),
                           default=False,
                           required=False)    
    auto_upload = Bool(title=_(u"title_auto_upload", default=u"Automatic upload on select"),
                                 description=_(u"description_auto_upload", default=u"Check if you want to start the files upload on select, without submit the form. "
                                                "Note that you cannot choose file titles or descriptions "
                                                "with this option set to True."),
                                 default=False,
                                 required=False) 
    fill_titles = Bool(title=_(u"title_fill_titles", default=u"Fill title before upload"),
                                 description=_(u"description_fill_titles", default=u"If checked, you can fill the files titles "
                                                "before upload. Uncheck if you don't need titles."),
                                 default=True,
                                 required=False) 

    fill_descriptions = Bool(title=_(u"title_fill_descriptions", default=u"Fill description before upload"),
                                 description=_(u"description_fill_descriptions", default=u"If checked, you can fill the files descriptions "
                                                "before upload. Uncheck if you don't need descriptions."),
                                 default=False,
                                 required=False) 

    size_limit = Int( title=_(u"title_size_limit", default=u"Size limit"),
                      description=_(u"description_size_limit", default=u"Size limit for each file in KB, 0 = no limit"),
                      default=0,
                      required=True)

    sim_upload_limit = Int( title=_(u"title_sim_upload_limit", default=u"Simultaneous uploads limit"),
                            description=_(u"description_sim_upload_limit", default=u"Number of simultaneous files uploaded, over this number uploads are placed in a queue, 0 = no limit"),
                            default=2,
                            required=True)
class IQuickUploadControlPanel(Interface):
    """
    fields for quick upload control panel
    """
    use_flashupload = Bool(
        title=_(u"title_use_flashupload", default=u"Use Flash Upload"),
        description=_(
            u"description_use_flashupload",
            default=u"By default, the upload script is a javascript only "
            u"tool. Check this option to replace it with a Flash "
            u"Upload based script. For modern browsers the javascript "
            u"tool is more powerful. Flash Upload is just more user "
            u"friendly under other browsers (MSIE 7, MSIE 8), but has "
            u"many problems : don't work in https, don't work behind "
            u"HTTP Authentication ..."),
        default=False,
        required=False)

    use_flash_as_fallback = Bool(
        title=_(u"title_use_flash_fallback",
                default=u"Use flash as fallback for IE"),
        description=_(
            u"description_use_flash_fallback",
            default=u"Check if you want to use flash upload as fallback for IE"
        ),
        default=False,
        required=False)

    auto_upload = Bool(
        title=_(u"title_auto_upload", default=u"Automatic upload on select"),
        description=_(
            u"description_auto_upload",
            default=u"Check if you want to start the files upload on select, "
            u"without submit the form. Note that you cannot choose "
            u"file titles or descriptions with this option set to "
            u"True."),
        default=False,
        required=False)

    show_upload_action = Bool(
        title=_('title_show_upload_action', default=u'Show "Upload" action'),
        description=_(
            'description_show_upload_action',
            default=u'Check if '
            'you want to have an "Upload" link in your edit bar. Clicking it '
            'will open a panel for uploading below the title of the current '
            'item. This panel is an alternative to the "Upload" portlet and '
            'does not offer any further configuration, such as filtering by '
            'content type. The panel will only be shown where the "Upload" '
            'portlet is not present.'),
        default=False,
        required=False,
    )

    fill_titles = Bool(
        title=_(u"title_fill_titles", default=u"Fill title before upload"),
        description=_(u"description_fill_titles",
                      default=u"If checked, you can fill the files titles "
                      u"before upload. Uncheck if you don't need titles."),
        default=True,
        required=False)

    fill_descriptions = Bool(
        title=_(u"title_fill_descriptions",
                default=u"Fill description before upload"),
        description=_(
            u"description_fill_descriptions",
            default=u"If checked, you can fill the files descriptions "
            u"before upload. Uncheck if you don't need descriptions."),
        default=False,
        required=False)

    size_limit = Int(
        title=_(u"title_size_limit", default=u"Size limit"),
        description=_(u"description_size_limit",
                      default=u"Size limit for each file in KB, 0 = no limit"),
        default=0,
        required=True)

    sim_upload_limit = Int(
        title=_(u"title_sim_upload_limit",
                default=u"Simultaneous uploads limit"),
        description=_(
            u"description_sim_upload_limit",
            default=u"Number of simultaneous files uploaded, over this number "
            u"uploads are placed in a queue, 0 = no limit"),
        default=2,
        required=True)

    object_unique_id = Bool(
        title=_(u"title_object_unique_id", default=u"Choose unique file id"),
        description=_(
            u"description_object_unique_id",
            default=u"Choose a unique id for each uploaded file."
            u"Checked: Your files will never be overridden and you'll "
            u"never get a 'file already exists' error message because "
            u"each file has its unique id."
            u"Non-Checked: The id will not be unique. "
            u"The 'Override by upload file' option is considered "
            u"when a conflict happens."),
        default=False,
        required=False)

    object_override = Bool(
        title=_(u"title_object_override", default=u"Override by upload file"),
        description=_(u"description_object_override",
                      default=u"If the folder already has same file name, "
                      u"Checked: Override, Non-Checked: raise upload error."),
        default=True,
        required=False)

    id_as_title = Bool(
        title=_(u"title_id_as_title", default=u"Use id as title"),
        description=_(u"description_id_as_title",
                      default=u"Reuse the file name for the title "
                      u"when no explicit title is given. "
                      u"Checked: use exact id including file extension, "
                      u"Non-Checked: use cleaned id, without extension "
                      u"and with spaces instead of dashes or underscores."),
        default=False,
        required=False)
class QuickUploadControlPanel(ControlPanelForm):

    label = _("Quick Upload settings")
    description = _("""Control how the quick upload tool is used.""")
    form_name = _("Quick Upload settings")
    form_fields = FormFields(IQuickUploadControlPanel)
示例#21
0
class IQuickUploadControlPanel(Interface):
    """
    fields for quick upload control panel
    """
    use_flashupload = Bool(
        title=_(u"title_use_flashupload", default=u"Use Flash Upload"),
        description=
        _(u"description_use_flashupload",
          default=u"By default, the upload script is a javascript only tool. "
          "Check this option to replace it with a Flash Upload based script. "
          "For modern browsers the javascript tool is more powerful. "
          "Flash Upload is just more user friendly under other browsers (MSIE 7, MSIE 8),  "
          "but has many problems : don't work in https, don't work behind HTTP Authentication ..."
          ),
        default=False,
        required=False)
    use_flash_as_fallback = Bool(title=_(u"title_use_flash_fallback",
                                         default=u"Use flash as fallback for "
                                         "IE"),
                                 description=_(
                                     u"description_use_flash_fallback",
                                     default=u"Check if you want to use flash "
                                     "upload as fallback for IE"),
                                 default=False,
                                 required=False)
    auto_upload = Bool(
        title=_(u"title_auto_upload", default=u"Automatic upload on select"),
        description=_(
            u"description_auto_upload",
            default=
            u"Check if you want to start the files upload on select, without submit the form. "
            "Note that you cannot choose file titles or descriptions "
            "with this option set to True."),
        default=False,
        required=False)
    show_upload_action = Bool(
        title=_('title_show_upload_action', default=u'Show "Upload" action'),
        description=_(
            'description_show_upload_action',
            default=u'Check if '
            'you want to have an "Upload" link in your edit bar. Clicking it '
            'will open a panel for uploading below the title of the current '
            'item. This panel is an alternative to the "Upload" portlet and '
            'does not offer any further configuration, such as filtering by '
            'content type. The panel will only be shown where the "Upload" '
            'portlet is not present.'),
        default=False,
        required=False,
    )
    fill_titles = Bool(
        title=_(u"title_fill_titles", default=u"Fill title before upload"),
        description=_(u"description_fill_titles",
                      default=u"If checked, you can fill the files titles "
                      "before upload. Uncheck if you don't need titles."),
        default=True,
        required=False)

    fill_descriptions = Bool(
        title=_(u"title_fill_descriptions",
                default=u"Fill description before upload"),
        description=_(
            u"description_fill_descriptions",
            default=u"If checked, you can fill the files descriptions "
            "before upload. Uncheck if you don't need descriptions."),
        default=False,
        required=False)

    size_limit = Int(
        title=_(u"title_size_limit", default=u"Size limit"),
        description=_(u"description_size_limit",
                      default=u"Size limit for each file in KB, 0 = no limit"),
        default=0,
        required=True)

    sim_upload_limit = Int(
        title=_(u"title_sim_upload_limit",
                default=u"Simultaneous uploads limit"),
        description=_(
            u"description_sim_upload_limit",
            default=
            u"Number of simultaneous files uploaded, over this number uploads are placed in a queue, 0 = no limit"
        ),
        default=2,
        required=True)

    object_override = Bool(
        title=_(u"title_object_override", default=u"Override by upload file"),
        description=_(u"description_object_override",
                      default=u"If the folder already has same file name, "
                      "Checked: Override, Non-Checked: raise upload error."),
        default=True,
        required=False)