startsevdenis/fm-elfinder-bundle

ElFinder组件,将ElFinder文件管理器添加到您的Symfony2项目中

安装: 156

依赖项: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 127

类型:symfony-bundle

6.0.2 2016-01-24 03:01 UTC

README

ElFinder 在Symfony2中的集成

代码质量保证

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

推荐搭配使用的组件

目录

安装

步骤1:安装

版本6(与Symfony 3兼容)

将FMElfinderBundle添加到您的composer.json中

{
    "require": {
        "helios-ag/fm-elfinder-bundle": "~6",
    }
}

版本5

将FMElfinderBundle添加到您的composer.json中

{
    "require": {
        "helios-ag/fm-elfinder-bundle": "~5",
    }
}

还需要在composer.json的config节点下添加component-dir

{
    "config": {
        "component-dir": "web/assets"
    }
}

版本4

此版本不使用 component

composer require helios-ag/fm-elfinder-bundle: "~4.0"

对于 Symfony =<2.3,请使用版本 ~2.3

composer require helios-ag/fm-elfinder-bundle: "~2.3"

现在运行以下命令让composer下载组件

composer update helios-ag/fm-elfinder-bundle

步骤2:启用组件

在内核中启用组件

<?php
// app/AppKernel.php

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

步骤3:导入FMElfinderBundle路由文件

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

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

使用access_control保护ElFinder

# app/config/security.yml
security:

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

步骤5:安装资源

通过symfony内置命令安装和导出资源

app/console assets:install web

基本配置

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

fm_elfinder:
    instances:
        default:
            locale: %locale% # defaults to current request locale
            editor: ckeditor # other options are tinymce, tinymce4, fm_tinymce,  form, simple, custom
            #editor_template: set 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 # defaults true, applies to simple and ckeditor editors
            #theme: smoothness # jquery theme, default is 'smoothness'
            include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
            #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
                    uploads:
                        #show_hidden: true|false # defaults to false, hide files that
                        driver: LocalFileSystem
                        path: uploads
                        upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
                        upload_deny: ['all']
                        upload_max_size: 2M
                        #attributes: example of setting attributes permission
                        #    - { pattern: '/(.*?)/', read: true, write: false, locked: true }
  • default - elfinder的实例,可以用于定义ElFinder的多个配置,允许为项目中的不同类型的WYSIWYG编辑器同时配置
  • path - 定义web/目录内部文件的根目录,默认为"uploads"。请确保设置正确的读写权限到这个目录。
  • url - 需要添加到图像路径的前缀URL,用于显示。可以是绝对或相对的。如果是相对的,它将以应用程序的基本URL为前缀。如果留空,则URL将是基本URL,附加'path'参数的值
  • driver - 可以是LocalFileSystem、FTP或MySQL2,目前只支持LocalFileSystem,默认是LocalFileSystem
  • locale - 决定ElFinder将使用哪种语言进行用户界面翻译,默认是当前请求的区域设置
  • cors_support - 允许处理跨域响应(默认false)
  • editor - 确定要渲染的模板,以与WYSIWYG Web编辑器兼容,目前支持以下选项:"ckeditor"(与IvoryCKEditorBundle或TrsteelCkeditorBundle一起使用)、"fm_tinymce"(与FMTinyMCEBundle一起使用)、"form"(表单类型)、"simple"(独立)和"custom"(自定义模板)。如何配置CKEDitor和TinyMCE以与此组件一起使用,将在本文档中进一步解释。
  • editor_template - 当编辑器设置为"custom"时,定义要渲染的模板。
  • connector - 定义elfinder根目录选项的根节点。
  • roots - 定义"虚拟目录",它反映项目中的目录。
  • path_prefix - 当启用relative_path时,路径前缀,默认为斜杠('/')
    • 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驱动程序。