diff --git a/Controller/ElfinderController.php b/Controller/ElfinderController.php index 2637be2..c56606c 100644 --- a/Controller/ElfinderController.php +++ b/Controller/ElfinderController.php @@ -3,6 +3,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response; + /** * Loader service for Elfinder backend * displays Elfinder @@ -22,23 +23,36 @@ public function showAction() $editor = $parameters['editor']; $locale = $parameters['locale']; $fullscreen = $parameters['fullscreen']; + $includeAssets = $parameters['include_assets']; + $compression = $parameters['compression']; + $prefix = ($compression ? '/compressed' : ''); switch ($editor){ case 'ckeditor': - return $this->render('FMElfinderBundle:Elfinder:ckeditor.html.twig', array('locale' => $locale, 'fullscreen' => $fullscreen)); + return $this->render('FMElfinderBundle:Elfinder'.$prefix.':ckeditor.html.twig', array( + 'locale' => $locale, + 'fullscreen' => $fullscreen, + 'includeAssets' => $includeAssets + )); break; case 'tinymce': - return $this->render('FMElfinderBundle:Elfinder:tinymce.html.twig', array( + return $this->render('FMElfinderBundle:Elfinder'.$prefix.':tinymce.html.twig', array( 'locale' => $locale, - 'tinymce_popup_path' => $this->getAssetsUrl($parameters['tinymce_popup_path']) + 'tinymce_popup_path' => $this->getAssetsUrl($parameters['tinymce_popup_path']), + 'includeAssets' => $includeAssets, )); break; case 'tinymce4': - return $this->render('FMElfinderBundle:Elfinder:tinymce4.html.twig', array( + return $this->render('FMElfinderBundle:Elfinder'.$prefix.':tinymce4.html.twig', array( 'locale' => $locale, + 'includeAssets'=>$includeAssets )); break; default: - return $this->render('FMElfinderBundle:Elfinder:simple.html.twig', array('locale' => $locale, 'fullscreen' => $fullscreen)); + return $this->render('FMElfinderBundle:Elfinder'.$prefix.':simple.html.twig', array( + 'locale' => $locale, + 'fullscreen' => $fullscreen, + 'includeAssets' => $includeAssets, + )); } } diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 90be0cc..82dd550 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -30,7 +30,9 @@ public function getConfigTreeBuilder() ->scalarNode('locale')->defaultValue('en_US.UTF8')->end() ->booleanNode('showhidden')->defaultValue(false)->end() ->scalarNode('editor')->defaultValue('simple')->end() + ->booleanNode('compression')->defaultValue(false)->end() ->booleanNode('fullscreen')->defaultValue(true)->end() + ->booleanNode('include_assets')->defaultValue(true)->end() ->scalarNode('tinymce_popup_path')->defaultValue('')->end() ->end() ; @@ -38,6 +40,9 @@ public function getConfigTreeBuilder() return $treeBuilder; } + /** + * @param ArrayNodeDefinition $rootNode + */ private function addConnectorSection(ArrayNodeDefinition $rootNode) { $rootNode diff --git a/README.md b/README.md index f81aafb..f434442 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Creation is inspired by simplicity and convenience of Finder program used in Mac - [Step 1: Installation:](#step-1-installation-1) - [Step 2: Configure CKEditor setting via settings.yml or through form builder:](#step-2-configure-ckeditor-setting-via-settingsyml-or-through-form-builder) - [Using ElFinder with TinyMCE](#using-elfinder-with-tinymce) - - [Using ElfinderBundle with TinyMCEBundle](#using-elfinderbundle-with-tinymcebundle) + - [Using ElfinderBundle with TinyMCEBundle](#using-elfinderbundle-with-tinymcebundle) - [Integrating with TinyMCE 4.x](#integrating-with-tinymce-4x) ## Installation @@ -97,8 +97,11 @@ ROLE_USER is provided as example. ### Step 5: Configure assetic -Under assetic section of your config.yml, add FMElfinderBundle to bundles section, also enable yui compressor. +Under assetic section of your config.yml, add FMElfinderBundle to bundles section, also you can enable uglify js/css +compressor (also you need to enable option "compression: true" under bundle configuration). + Also set "use_controller: false". + ``` yaml assetic: debug: %kernel.debug% @@ -107,10 +110,11 @@ assetic: java: /usr/bin/java filters: cssrewrite: ~ - yui_css: - jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar - yui_js: - jar: %kernel.root_dir%/Resources/java/yuicompressor-2.4.7.jar + uglifyjs2: + # the path to the uglifyjs executable + bin: /usr/bin/uglifyjs + uglifycss: + bin: /usr/bin/uglifycss ``` ### Step 6: Install and dump assets @@ -216,7 +220,8 @@ ElFinder will be available under Insert Image dialog You can integrate TinyMCE byself or use Bundles that already add TinyMCE functionality to your Symfony project. Below instruction how to integrate [FMElfinderBundle](https://github.com/helios-ag/FMElfinderBundle) with [TinyMCEBundle](https://github.com/stfalcon/TinymceBundle) -## Using ElfinderBundle with [TinyMCEBundle](https://github.com/stfalcon/TinymceBundle) + +### Using ElfinderBundle with [TinyMCEBundle](https://github.com/stfalcon/TinymceBundle) Instruction for bundle version 0.2.1 (TinyMCE 3.x), instruction for TinyMCE 4.x, you can find at the end of this document. Download both bundles, configure, dump and install assets as written in installation steps @@ -277,3 +282,8 @@ Thats all, Elfinder is integrated into TinyMCE. Manual integration guide can be found [here](/INTEGRATION_GUIDE.md) + +##Changelog + +1.x +Switched from YUI compressor to Uglify diff --git a/Resources/views/Elfinder/ckeditor.html.twig b/Resources/views/Elfinder/ckeditor.html.twig index a492515..4cd305f 100644 --- a/Resources/views/Elfinder/ckeditor.html.twig +++ b/Resources/views/Elfinder/ckeditor.html.twig @@ -2,21 +2,14 @@
- {% stylesheets output='assetic/css/compiled/fmelfinder/main.css' - 'bundles/fmelfinder/css/*' filter='cssrewrite,?yui_css' %} - - {% endstylesheets %} + {% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_css.html.twig" %} + {% endif %} - {% javascripts output='assetic/js/compiled/fmelfinder/main.js' filter='?yui_js' - '@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' - '@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' - '@FMElfinderBundle/Resources/public/js/elfinder.min.js' - '@FMElfinderBundle/Resources/public/js/i18n/*' - %} - - {% endjavascripts %} - +{% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_js.html.twig" %} +{% endif %} \ No newline at end of file diff --git a/Resources/views/Elfinder/compressed/_tinymce4.html.twig b/Resources/views/Elfinder/compressed/_tinymce4.html.twig new file mode 100644 index 0000000..d6c56b1 --- /dev/null +++ b/Resources/views/Elfinder/compressed/_tinymce4.html.twig @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/Resources/views/Elfinder/compressed/ckeditor.html.twig b/Resources/views/Elfinder/compressed/ckeditor.html.twig new file mode 100644 index 0000000..a492515 --- /dev/null +++ b/Resources/views/Elfinder/compressed/ckeditor.html.twig @@ -0,0 +1,58 @@ + + + + + {% stylesheets output='assetic/css/compiled/fmelfinder/main.css' + 'bundles/fmelfinder/css/*' filter='cssrewrite,?yui_css' %} + + {% endstylesheets %} + + + {% javascripts output='assetic/js/compiled/fmelfinder/main.js' filter='?yui_js' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' + '@FMElfinderBundle/Resources/public/js/elfinder.min.js' + '@FMElfinderBundle/Resources/public/js/i18n/*' + %} + + {% endjavascripts %} + + + + + + + + diff --git a/Resources/views/Elfinder/compressed/simple.html.twig b/Resources/views/Elfinder/compressed/simple.html.twig new file mode 100644 index 0000000..b0d603d --- /dev/null +++ b/Resources/views/Elfinder/compressed/simple.html.twig @@ -0,0 +1,38 @@ + + + + {% stylesheets output='assetic/css/compiled/fmelfinder/main.css' + 'bundles/fmelfinder/css/*' filter='cssrewrite,?uglifycss' %} + + {% endstylesheets %} + + + {% javascripts output='bundles/fmelfinder/js/main.js' filter='?uglifyjs2' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' + '@FMElfinderBundle/Resources/public/js/elfinder.min.js' + '@FMElfinderBundle/Resources/public/js/i18n/*' + %} + + {% endjavascripts %} + + + + diff --git a/Resources/views/Elfinder/compressed/tinymce.html.twig b/Resources/views/Elfinder/compressed/tinymce.html.twig new file mode 100644 index 0000000..af4a420 --- /dev/null +++ b/Resources/views/Elfinder/compressed/tinymce.html.twig @@ -0,0 +1,70 @@ + + + + {% stylesheets output='assetic/css/compiled/fmelfinder/main.css' + 'bundles/fmelfinder/css/*' filter='cssrewrite,?uglifycss' %} + + {% endstylesheets %} + + + {% javascripts output='bundles/fmelfinder/js/main.js' filter='?uglifyjs2' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' + '@FMElfinderBundle/Resources/public/js/elfinder.min.js' + '@FMElfinderBundle/Resources/public/js/i18n/*' + %} + + {% endjavascripts %} + + + + + diff --git a/Resources/views/Elfinder/compressed/tinymce4.html.twig b/Resources/views/Elfinder/compressed/tinymce4.html.twig new file mode 100644 index 0000000..5123ad4 --- /dev/null +++ b/Resources/views/Elfinder/compressed/tinymce4.html.twig @@ -0,0 +1,46 @@ + + + + {% stylesheets output='assetic/css/compiled/fmelfinder/main.css' + 'bundles/fmelfinder/css/*' filter='cssrewrite,?uglifycss' %} + + {% endstylesheets %} + + +{% javascripts output='bundles/fmelfinder/js/main.js' filter='?uglifyjs2' +'@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' +'@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' +'@FMElfinderBundle/Resources/public/js/elfinder.min.js' +'@FMElfinderBundle/Resources/public/js/i18n/*' +%} + +{% endjavascripts %} + + + + \ No newline at end of file diff --git a/Resources/views/Elfinder/helper/_tinymce.html.twig b/Resources/views/Elfinder/helper/_tinymce.html.twig new file mode 100644 index 0000000..a7fa558 --- /dev/null +++ b/Resources/views/Elfinder/helper/_tinymce.html.twig @@ -0,0 +1,20 @@ + \ No newline at end of file diff --git a/Resources/views/Elfinder/helper/_tinymce4.html.twig b/Resources/views/Elfinder/helper/_tinymce4.html.twig new file mode 100644 index 0000000..d6c56b1 --- /dev/null +++ b/Resources/views/Elfinder/helper/_tinymce4.html.twig @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/Resources/views/Elfinder/helper/assets_css.html.twig b/Resources/views/Elfinder/helper/assets_css.html.twig new file mode 100644 index 0000000..56d22db --- /dev/null +++ b/Resources/views/Elfinder/helper/assets_css.html.twig @@ -0,0 +1,4 @@ +{% stylesheets output='assetic/css/compiled/fmelfinder/main.css' + 'bundles/fmelfinder/css/*' filter='cssrewrite' %} + +{% endstylesheets %} \ No newline at end of file diff --git a/Resources/views/Elfinder/helper/assets_js.html.twig b/Resources/views/Elfinder/helper/assets_js.html.twig new file mode 100644 index 0000000..ff998e2 --- /dev/null +++ b/Resources/views/Elfinder/helper/assets_js.html.twig @@ -0,0 +1,8 @@ +{% javascripts output='assetic/js/compiled/fmelfinder/main.js' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' + '@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' + '@FMElfinderBundle/Resources/public/js/elfinder.min.js' + '@FMElfinderBundle/Resources/public/js/i18n/*' +%} + +{% endjavascripts %} \ No newline at end of file diff --git a/Resources/views/Elfinder/simple.html.twig b/Resources/views/Elfinder/simple.html.twig index 64ddd07..6c5eb96 100644 --- a/Resources/views/Elfinder/simple.html.twig +++ b/Resources/views/Elfinder/simple.html.twig @@ -1,20 +1,14 @@ - {% stylesheets output='assetic/css/compiled/fmelfinder/main.css' - 'bundles/fmelfinder/css/*' filter='cssrewrite,?yui_css' %} - - {% endstylesheets %} + {% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_css.html.twig" %} + {% endif %} - {% javascripts output='bundles/fmelfinder/js/main.js' filter='?yui_js' - '@FMElfinderBundle/Resources/public/js/jquery/jquery-1.8.0.min.js' - '@FMElfinderBundle/Resources/public/js/jquery/jquery-ui-1.8.23.custom.min.js' - '@FMElfinderBundle/Resources/public/js/elfinder.min.js' - '@FMElfinderBundle/Resources/public/js/i18n/*' - %} - - {% endjavascripts %} +{% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_js.html.twig" %} +{% endif %} - {% endjavascripts %} +{% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_js.html.twig" %} +{% endif %} -{% endjavascripts %} +{% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_js.html.twig" %} +{% endif %}