elendev / roxyfileman-bundle
为您的 Symfony2 项目提供 Roxyfileman 集成,主要用于 ckeditor 和 tinymce。
Requires
- php: >=5.3.3
- symfony/framework-bundle: ~2.3|~3.0|~4.0
Suggests
- egeloen/ckeditor-bundle: Allows to use Roxyfileman as a file selector for ckeditor
- twig/twig: Allows to use twig templates
This package is auto-updated.
Last update: 2024-09-09 14:09:06 UTC
README
此包为 Symfony2 提供 Roxyfileman 集成。它与 IvoryCKEditorBundle 配合良好。
文档
安装
在 composer.json 文件中要求此包
{ "require": { "elendev/roxyfileman-bundle": "~1.0" } }
注册包
// app/AppKernel.php public function registerBundles() { return array( new Elendev\RoxyFilemanBundle\ElendevRoxyFilemanBundle(), // ... ); }
更新 composer
$ composer update
将包的路由导入到您的路由配置文件中,例如 routing.yml
ElendevRoxyFilemanBundle:
resource: "@ElendevRoxyFilemanBundle/Resources/config/routing.yml"
prefix: /elendev-roxyfileman
前缀可以更改。您还可以将路径添加到防火墙,以便保护文件管理服务。
配置
RoxyFilemanBundle 提供简单的配置。
文件位置配置
如果您使用默认的 LocalFileSystem
(推荐),这是 必需的配置
elendev_roxy_fileman: local_file_system: base_path: /path/to/your/file base_url: /url/to/the/base/path
base_path
参数应该是绝对路径。base_url
参数附加到文件名/相对文件路径以创建其 URL。LocalFileSystem
用于访问本地文件系统中某个目录。如果您想从远程服务器或数据库中提供文件,请参阅 自定义文件系统服务 部分。
Roxyfileman 配置
每个配置选项均可在 Roxyfileman 配置页面 上找到。
elendev_roxy_fileman: conf: dirlist_route: elendev_roxyfileman_dir_list files_root: ...
参数必须为小写。 请注意:在 Roxyfileman 配置页面 上可用的每个 URL 参数都应在此处用作路由,并且参数必须后缀为 _route
。例如:参数 DIRLIST
变为 dirlist_route
。
多配置文件
上面展示了此包在单配置文件模式下的工作方式。偶尔,您可能需要不同的文件管理实例来管理不同的目录 - 假想一个具有“相册”和“博客”模块的 CMS,您不希望“相册”管理员触摸“博客”模块中的文件。通过告诉包在多配置文件模式下运行,这是可能的。以下是方法:
elendev_roxy_fileman: profiles: # Triggers multi-profile mode album: # Name of the profile local_file_system: base_path: /path/to/album/directory base_url: /web/album/directory conf: integration: tinymce4 blog: local_file_system: base_path: /path/to/blog/directory base_url: /web/blog/directory conf: integration: tinymce4
现在我们已定义了两个配置文件,每个配置文件都有自己的基本路径、URL 设置和配置选项。
当访问某些 URL 时,包需要知道它应该使用哪个配置文件。一种方法是将 profile
占位符添加到路由配置中
ElendevRoxyFilemanBundle: resource: "@ElendevRoxyFilemanBundle/Resources/config/routing.yml" prefix: /elendev-roxyfileman/{profile} requirements: profile: blog|album
注意:当 profiles
不为空时,包将在多配置文件模式下运行。在根配置中定义的 conf
、local_file_system
和 file_system_service_id
的值将被忽略。
与富文本编辑器(CKEditor)集成
原始索引路径 /fileman/index.html
由本包中的路由 elendev_roxyfileman_index
提供,这是您需要与富文本编辑器如 CKEditor 集成的部分。例如
<script>
$(function(){
CKEDITOR.replace( 'editor1', {
// Single profile mode
filebrowserBrowseUrl: '{{ path('elendev_roxyfileman_index') }}',
// To specify the profile name in multi-profile mode:
// filebrowserBrowseUrl: '{{ path('elendev_roxyfileman_index', { 'profile': 'blog' }) }}',
filebrowserImageBrowseUrl: '{{ path('elendev_roxyfileman_index') }}?type=image',
removeDialogTabs: 'link:upload;image:upload'
});
});
</script>
使用此包与 egeloen/IvoryCKEditorBundle
真的很简单,只需对 ivory_ck_editor
配置进行少量修改即可完成任务。
ivory_ck_editor:
default_config: default
configs:
default:
filebrowserBrowseRoute: elendev_roxyfileman_index
高级定制
自定义文件系统服务
《filesystem》服务代表Roxyfileman的文件系统。它能够提供文件、文件和目录树的服务,对目录和文件进行操作,... 您可以通过实现Elendev\RoxyFilemanBundle\FileSystem\FileSystemInterface
来创建自定义的文件系统服务,并将其作为服务提供给elendev_roxy_fileman
参数。
elendev_roxy_fileman: file_system_service_id: id_of_the_file_service
自定义 Roxyfileman 版本
该捆绑包自带Roxyfileman库的一个版本。如果您想使用自定义版本,可以将包含index.html
文件的目录路径指定给roxyfileman_lib_path
参数。
elendev_roxy_fileman: roxyfileman_lib_path: /path/to/the/library
库文件由Elendev\RoxyFilemanBundle\Controller\ResourcesController.php
控制器提供。它不需要公开访问。
许可证
Elendev RoxyFileman BUndle遵循MIT许可证。有关完整的版权和许可证信息,请阅读与源代码一起分发的LICENSE文件。
此捆绑包包含Roxyfileman库的部分副本。Roxyfileman库遵循GPLv3许可证。与源代码一起分发了GPLv3许可证的副本。