Symfony2 Elfinder不会加载Tinymce

时间:2016-02-17 11:50:18

标签: javascript symfony tinymce elfinder

从周日开始,我已经关注了CMF Media Bundle(here)的symfony2文档以下载图片并能够利用它们,我选择了不同的包:

 #composer.json
    "php": ">=5.5.9",
    "symfony/symfony": "2.8.*",
    #...
    "components/jquery": "^2.2",
    "stfalcon/tinymce-bundle": "^0.4.0",
    "symfony-cmf/media-bundle": "^1.2",
    "liip/imagine-bundle": "^1.4",
    "helios-ag/fm-elfinder-bundle": "~4",
    "jackalope/jackalope-doctrine-dbal": "1.2.*",
    "doctrine/phpcr-odm": "1.2.*",
    "doctrine/phpcr-bundle": "1.2.*"

(我用symfony 3.0开始了这个项目,只是在没有任何正确安装的情况下降级到2.8,但只是由作曲家更新给出了。)

以下是文档中给出的配置,只有很少的修改:

# app/config/config.yml
# Cmf Media
cmf_media:
    persistence:
        phpcr:
            enabled:         true
            manager_name:    ~
            media_basepath:  /cms/media
            media_class:     Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Media
            file_class:      Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\File
            directory_class: Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Directory
            image_class:     Symfony\Cmf\Bundle\MediaBundle\Doctrine\Phpcr\Image
            event_listeners:
                stream_rewind:    true
                image_dimensions: true
                imagine_cache:    auto

# Liip imagine
liip_imagine:
    filter_sets:
        image_upload_thumbnail:
            data_loader: cmf_media_doctrine_phpcr
            filters:
                thumbnail: { size: [100, 100], mode: outbound }
        elfinder_thumbnail:
            data_loader: cmf_media_doctrine_phpcr
            quality: 85
            filters:
                thumbnail: { size: [48, 48], mode: inset }

# Elfinder
fm_elfinder:
    instances:
        default:
            locale: %locale% # defaults to current request locale
            editor: tinymce4 # ckeditor, other options are tinymce, tinymce4, fm_tinymce,  form, simple, custom
            tinymce_popup_path: "asset[bundles/stfalcontinymce/vendor/tinymce/tinymce.min.js]"
            fullscreen: false # defaults true, applies to simple and ckeditor editors
            include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
           connector:
                debug: false # defaults to false
                roots:
                    uploads:
                        show_hidden: false # defaults to false, hide files that
                        driver: LocalFileSystem
                        path: uploads
                        upload_allow: ['image/gif', 'image/png', 'image/jpg', 'image/jpeg', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']
                        upload_deny: ['all']
                        upload_max_size: 2M
        form:
            locale: %locale% # defaults to current request locale
            editor: form # other choices are tinymce or simple, and form
            fullscreen: false # defaults true, applies to simple and ckeditor editors
            include_assets: true # disable if you want to handle loading of the javascript and css assets yourself
            connector:
                debug: false # defaults to false
                roots:       # at least one root must be defined
                    uploads:
                        driver: LocalFileSystem
                        path: uploads
                        upload_allow: ['image/png', 'image/jpg', 'image/jpeg']
                        upload_deny: ['all']
                        upload_max_size: 2M

# doctrine phpcr
doctrine_phpcr:
    odm:
        auto_mapping: true
    session:
        backend:
            type: doctrinedbal
            logging: true
            profiling: true
        workspace: default
        username: ******
        password: ******

# tinymce
stfalcon_tinymce:
    include_jquery: false
    tinymce_jquery: true
    selector: ".tinymce"
    base_url: %base_url%
    tinymce_buttons:
        stfalcon: # Id of the first button
            title: "Stfalcon"
            image: "http://stfalcon.com/favicon.ico"
    theme:
        simple: ~
        advanced:
            entity_encoding: "raw"
            file_browser_callback : elFinderBrowser
            plugins:
                - "advlist autolink lists link image charmap print preview hr anchor pagebreak"
                - "searchreplace wordcount visualblocks visualchars code fullscreen"
                - "insertdatetime media nonbreaking save table contextmenu directionality"
                - "emoticons template paste textcolor"
            file_browser_callback : elFinderBrowser
            toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media | forecolor backcolor emoticons | example"
            image_advtab: true
            templates:
                - {title: 'Test template 1', content: 'Test 1'}
                - {title: 'Test template 2', content: 'Test 2'}
        # BBCode tag compatible theme (see http://www.bbcode.org/reference.php)
        bbcode:
            plugins: ["bbcode, code, link, preview"]
            menubar: false
            toolbar1: "bold,italic,underline,undo,redo,link,unlink,removeformat,cleanup,code,preview"

这是html.twig文件中使用的javascript:

{% javascripts
    '@jquery'
    '@file_browser' %}
    <script src="{{ asset_url }}"></script>
{% endjavascripts %}
{{ tinymce_init() }}

和设置:

assets:
    jquery:
        inputs:
            - '%kernel.root_dir%/../vendor/components/jquery/jquery.min.js'
    file_browser:
        inputs:
            - '%kernel.root_dir%/../web/bundles/fmelfinder/js/elfinder.min.js'
            - '%kernel.root_dir%/../web/bundles/fmelfinder/js/tinymce.js'
            - '%kernel.root_dir%/../web/bundles/stfalcontinymce/js/init.jquery.js'

我得到了这个结果:enter image description here

当我期待类似的东西时(从http://localhost/app-dev.php/elfinder获取,这是测试和使用elfinder包的默认网址):

enter image description here

我在哪里配置elfinder和tinymce的参数失败了? 我应该正确安装2.8版本的symfony2吗?

编辑1: 这是路由文件:

...
cmf_media_file:
    resource: "@CmfMediaBundle/Resources/config/routing/file.xml"

cmf_media_image:
    resource: "@CmfMediaBundle/Resources/config/routing/image.xml"

_liip_imagine:
    resource: "@LiipImagineBundle/Resources/config/routing.xml"

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

1 个答案:

答案 0 :(得分:0)

我有一个类似的问题,使用Symfony3与Elfinder捆绑和TinyMCE4(虽然我没有使用Symfony CMF)。它归结为我的原因是ELFinder窗口没有加载创建finder窗口的javascript资源。如果您调试或查看窗口中创建的html的源代码,您将看到需要加载以创建窗口的几个javascript文件。我发现的最大问题是我的composer.json配置节点中没有component-dir指令。为了使其正常工作,我不得不:

将component-dir指令添加到我的composer.json文件中:

//composer.json
{
    ...
    "config": {
        "component-dir": "web/assets"
    },
    ...
}

在网络根目录中创建资产目录

  

mkdir web / assets

安装资产

  

php bin / console assets:install

或如果符号化资产

  

php bin / console assets:install --symlink

清除缓存并继续操作。希望这也适合你。欢呼声。