checcoux/fm-elfinder-bundle

原始fm-elfinder-bundle的分支,包含aws s3连接器的acl规则

安装: 6

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 127

类型:symfony-bundle

10.1 2021-01-29 14:07 UTC

README

原始fm-elfinder-bundle的分支,包含aws s3连接器的acl规则

FMElfinderBundle

ElFinder 在 Symfony 中的集成

代码质量保证

elFinder 是一个基于JavaScript和jQuery UI的Web开源文件管理器。其设计灵感来源于Mac OS X操作系统中使用的Finder程序,注重简洁和便捷。

推荐使用的包

目录

安装

步骤 1:安装

对于Symfony Flex安装,您需要启用社区食谱

  composer config extra.symfony.allow-contrib true

安装

  composer require helios-ag/fm-elfinder-bundle

将elfinder资源复制到公共文件夹

  bin/console elfinder:install

步骤 2:启用包(可选)

在kernel中启用包(使用symfony flex时不需要)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new FM\ElfinderBundle\FMElfinderBundle(),
    );
}

步骤 3:导入 FMElfinderBundle 路由文件

# app/config/routing.yaml
elfinder:
     resource: "@FMElfinderBundle/Resources/config/routing.yaml"

步骤 4:配置您的应用程序的 security.yaml

使用 access_control 保护 ElFinder

# app/config/security.yaml
security:

    //....
    access_control:
        - { path: ^/efconnect, role: ROLE_USER }
        - { path: ^/elfinder, role: ROLE_USER }

基本配置

将配置选项添加到您的 config.yaml

fm_elfinder:
    #assets_path: / # default is /assets, this is where css/js elfinder files are
    instances:
        default:
            locale: '%locale%' # defaults to current request locale
            editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
            relative_path: false #default true, will produce absolute urls to specified file(s)
            #editor_template: custom template for your editor # default null
            #path_prefix: / # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/
            #fullscreen: true|false # default is true, applies to simple and ckeditor editors
            #theme: smoothness # jquery theme, default is 'smoothness'
            #visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all
            connector:
                #debug: true|false # defaults to false
                roots:       # at least one root must be defined, defines root filemanager directories
                    uploads:
                        #show_hidden: true|false # defaults to false, hides dotfiles
                        driver: LocalFileSystem
                        path: uploads
                        upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
                        upload_deny: ['all']
                        upload_max_size: 2M # also file upload sizes restricted in php.ini
                        #attributes: example of setting attributes permission
                        #    - { pattern: '/(.*?)/', read: true, write: false, locked: true }
  • default - elfinder 的实例,可以用来定义多个 ElFinder 配置,允许为项目中不同类型的 WYSIWYG 编辑器同时进行配置
  • path - 定义 web/ 目录内文件的根目录,默认为 "uploads"。请确保为此目录设置适当的读写和所有权权限。
  • url - 前缀到显示时图像路径的 URL,可以是 absoluterelative。如果是绝对路径,可以使用 {homeFolder} 字符串作为占位符,它将自动替换。如果是相对路径,它将与应用程序的基本 URL 前缀。如果为空,则 URL 将是基本 URL,并附加 'path' 参数的值
  • driver - 可以是 LocalFileSystem、FTP 或 MySQL、Flysystem、S3 等,请参阅 FM\ElfinderBundle\DependencyInjection\Configuration 类
  • locale - 区域设置确定 ElFinder 将使用哪种语言来翻译用户界面,默认是当前请求的区域设置
  • cors_support - 允许跨域响应处理(默认为 false)
  • editor - 确定要渲染的模板,以与 WYSIWYG 网页编辑器兼容,目前支持以下选项:"ckeditor"(与 FOSCKEditorBundle 或 TrsteelCkeditorBundle 一起使用),"fm_tinymce"(与 FMTinyMCEBundle 一起使用 tinymce4),"form"(表单类型),"simple"(独立)和 "custom"(自定义模板)。如何配置 CKEDitor 和 TinyMCE 以与该包一起使用,将在本文件的后续部分中解释。
  • editor_template - 当编辑器设置为 "custom" 时,定义要渲染的模板。
  • connector - 定义 elfinder 根目录选项的根节点。
  • roots - 定义 "虚拟目录",它反映了项目中的目录。
  • path_prefix - 启用相对路径的路径前缀,默认为斜杠 ('/')
  • show_hidden - 显示以点 (.) 开头的文件和文件夹
  • driver - 驱动类型,LocalFileSystem、Dropbox、FTP
  • volume_id - (可选)在挂载卷时可以用来强制设置卷ID(默认自动递增)。如果提供,它必须是一个大于0的整数。
  • alias - 目录别名
  • path - 包含文件的目录
  • upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
  • upload_deny: ['all']
  • upload_max_size: 2M

您可以在此处查看完整的根选项列表。要使用它们,请将驼峰式命名的选项名称转换为下划线命名。

通过实例使用多个上传文件夹

您可以通过实例配置设置多个上传根文件夹。

如果您已将实例配置为 /uploads 路径,当访问实例URL时,可以提供一个额外的文件夹作为主文件夹(例如,对于多用户应用程序)

/elfinder/{instance}/{homeFolder}/efconnect/{instance}/{homeFolder}

例如,访问 /elfinder/acmeInstance/bob URL 将打开elfinder,以 /uploads/bob 作为根目录,其中只包含Bob的文件。

然后,访问 /elfinder/acmeInstance/alice URL 将重用您的实例,但将以 /uploads/alice 文件夹作为根目录打开elfinder,其中只包含Alice的文件。

要使用此功能,您必须在URL中提供实例名称,并且当然要确保设置主文件夹的适当读写权限。

注意:此功能仅适用于 LocalFileSystem 驱动。

我想设置更多一个主文件夹是否可能?

是的,您可以在fm_elfinder.yaml中的此配置中这样做

where_is_multi: {connector}: {连接器的索引} multi_home_folder: true folder_separator: {与/不同的一个字符}

示例

fm_elfinder:
    instances:
        default:
            locale: fr # defaults to current request locale
            editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce, form, simple, custom
            #editor_template: custom template for your editor # default null
            #path_prefix: https:/// # for setting custom assets path prefix, useful for non vhost configurations, i.e. http://127.0.0.1/mysite/
            fullscreen: false # default is true, applies to simple and ckeditor editors
            where_is_multi:
                roots: 0
            multi_home_folder: true
            folder_separator: "|"
            #theme: smoothness # jquery theme, default is 'smoothness'
            #visible_mime_types: ['image/png', 'image/jpg', 'image/jpeg'] # only show these mime types, defaults to show all
            connector:
                #debug: true|false # defaults to false
                roots:       # at least one root must be defined, defines root filemanager directories
                    uploads:
                        #show_hidden: true|false # defaults to false, hides dotfiles
                        driver: LocalFileSystem
                        path: "/var"
                        alias: Bibliothèque générale
                        upload_allow: ['all']
                        #upload_deny: ['all']
                        upload_max_size: 500M # also file upload sizes restricted in php.ini
                        attributes:
                            - {pattern: '..', read: true, write: true, locked: false}
                        #attributes: example of setting attributes permission
                        #    - { pattern: '/(.*?)/', read: true, write: false, locked: true }