Skip to content

Commit

Permalink
Merge pull request #182 from helios-ag/fm_tinymce
Browse files Browse the repository at this point in the history
fm_tinymce_bundle
  • Loading branch information
helios-ag committed Nov 15, 2015
2 parents 6dc8bdf + 449c551 commit 01545d6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Controller/ElFinderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath,
'pathPrefix' => $pathPrefix,
);

return $result;
case 'fm_tinymce':
$result['template'] = 'FMElfinderBundle:Elfinder:fm_tinymce.html.twig';
$result['params'] = array(
'locale' => $locale,
'includeAssets' => $includeAssets,
'instance' => $instance,
'homeFolder' => $homeFolder,
'relative_path' => $relativePath,
'prefix' => $assetsPath,
'theme' => $theme,
'pathPrefix' => $pathPrefix,
);

return $result;
case 'form':
$result['template'] = 'FMElfinderBundle:Elfinder:elfinder_type.html.twig';
Expand Down
40 changes: 40 additions & 0 deletions Resources/views/Elfinder/fm_tinymce.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!DOCTYPE html>
<html>
<head>
{% if includeAssets %}
{% include "FMElfinderBundle:Elfinder:helper/assets_css.html.twig" %}
{% endif %}
</head>
<body>
{% if includeAssets %}
{% include "FMElfinderBundle:Elfinder:helper/assets_js.html.twig" %}
{% endif %}
<script type="text/javascript" charset="utf-8">
var FileBrowserDialogue = {
mySubmit: function (file, elf) {
// pass selected file data to TinyMCE
parent.tinymce.activeEditor.windowManager.getParams().oninsert(file, elf);
// close popup window
parent.tinymce.activeEditor.windowManager.close();
}
};
$(document).ready(function() {
var elf = $('.elfinder').elfinder({
// set your elFinder options here
url: '{{ path('ef_connect', {'instance': instance, 'homeFolder': homeFolder }) }}', // connector URL
lang : '{{ locale }}',
getFileCallback: function(file) { // editor callback
{% if relative_path %}
file.url = '{{ pathPrefix }}' + file.url.replace("{{ app.request.schemeAndHttpHost }}/", "");
FileBrowserDialogue.mySubmit(file, elf); // pass selected file path to TinyMCE
{% else %}
FileBrowserDialogue.mySubmit(file, elf); // pass selected file path to TinyMCE
{% endif %}
}
}).elfinder('instance');
});
</script>
<div class="elfinder"></div>
</body>
</html>

0 comments on commit 01545d6

Please sign in to comment.