-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
233 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace FM\ElfinderBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
|
||
/** | ||
* Class TwigFormPass | ||
* @package FM\ElfinderBundle\DependencyInjection\Compiler | ||
*/ | ||
class TwigFormPass implements CompilerPassInterface | ||
{ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if (!$container->hasParameter('twig.form.resources')) { | ||
return; | ||
} | ||
|
||
$container->setParameter('twig.form.resources', array_merge( | ||
array('FMElfinderBundle:Form:elfinder_widget.html.twig'), | ||
$container->getParameter('twig.form.resources') | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace FM\ElfinderBundle\Form\Type; | ||
|
||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\FormView; | ||
use Symfony\Component\Form\FormInterface; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\OptionsResolver\OptionsResolverInterface; | ||
|
||
/** | ||
* Class ElFinderType | ||
* @package FM\ElfinderBundle\Form\Type | ||
*/ | ||
class ElFinderType extends AbstractType | ||
{ | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options) | ||
{ | ||
$builder->setAttribute('enable', $options['enable']); | ||
|
||
if($builder->getAttribute('enable')) | ||
$builder->setAttribute('instance', $options['instance']); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function buildView(FormView $view, FormInterface $form, array $options) | ||
{ | ||
$view->vars['enable'] = $form->getConfig()->getAttribute('enable'); | ||
|
||
if($form->getConfig()->getAttribute('enable')) { | ||
$view->vars['instance'] = $form->getConfig()->getAttribute('instance'); | ||
} | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function setDefaultOptions(OptionsResolverInterface $resolver) | ||
{ | ||
$resolver | ||
->setDefaults(array( | ||
'enable' => true, | ||
'instance' => '' | ||
)) | ||
->addAllowedTypes(array( | ||
'enable' => 'bool', | ||
'instance' => array('string', 'null') | ||
)); | ||
} | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getParent() | ||
{ | ||
return 'text'; | ||
} | ||
/** | ||
* @inheritdoc | ||
*/ | ||
public function getName() | ||
{ | ||
return 'elfinder'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" ?> | ||
|
||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" | ||
> | ||
<parameters> | ||
<parameter key="elfinder.form.type.class">FM\ElfinderBundle\Form\Type\ElFinderType</parameter> | ||
</parameters> | ||
<services> | ||
<service id="fm_elfinder.form.type" class="%elfinder.form.type.class%"> | ||
<tag name="form.type" alias="elfinder" /> | ||
</service> | ||
</services> | ||
</container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<!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"> | ||
$().ready(function() { | ||
var $f = $('.elfinder').elfinder({ | ||
url : '{{path('ef_connect', { 'instance': instance } )}}', | ||
lang : '{{locale}}', | ||
getFileCallback: function(file) { | ||
window.opener.setValue(file.path); | ||
window.close(); | ||
} | ||
}); | ||
{% if fullscreen %} | ||
var $window = $(window); | ||
$window.resize(function(){ | ||
var $win_height = $window.height(); | ||
if( $f.height() != $win_height ){ | ||
$f.height($win_height).resize(); | ||
} | ||
}); | ||
{% endif %} | ||
}); | ||
</script> | ||
<div class="elfinder"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{% block elfinder_widget %} | ||
<input type="text" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %} data-type="elfinder-input-field" /> | ||
{{instance}} | ||
{% if enable and instance is defined %} | ||
<script type="text/javascript" charset="utf-8"> | ||
$('[data-type="elfinder-input-field"]').on("click",function() { | ||
var childWin = window.open("{{path('elfinder', {'instance': instance })}}", "popupWindow", "height=450, width=900"); | ||
}); | ||
function setValue(value) { | ||
$('[data-type="elfinder-input-field"]').val(value); | ||
} | ||
</script> | ||
{% endif %} | ||
{% endblock %} |