From 80020683259d0556a4caab75ea504d1571eec5fa Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 03:08:06 +1000 Subject: [PATCH 01/14] summernote support --- Controller/ElFinderController.php | 14 ++++++++++ .../Elfinder/helper/_summernote.html.twig | 10 +++++++ Resources/views/Elfinder/summernote.html.twig | 27 +++++++++++++++++++ Twig/Extension/FMElfinderTinymceExtension.php | 19 ++++++++++++- 4 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 Resources/views/Elfinder/helper/_summernote.html.twig create mode 100644 Resources/views/Elfinder/summernote.html.twig diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index 207c944..ba4a96e 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -91,6 +91,20 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'pathPrefix' => $pathPrefix ); return $result; + case 'summernote': + $result['template'] = 'FMElfinderBundle:Elfinder:summernote.html.twig'; + $result['params'] = array( + 'locale' => $locale, + 'fullscreen' => $fullScreen, + 'includeAssets' => $includeAssets, + 'instance' => $instance, + 'homeFolder' => $homeFolder, + 'relative_path' => $relativePath, + 'prefix' => $assetsPath, + 'theme' => $theme, + 'pathPrefix' => $pathPrefix + ); + return $result; case 'tinymce': $result['template'] = 'FMElfinderBundle:Elfinder:tinymce.html.twig'; $result['params'] = array( diff --git a/Resources/views/Elfinder/helper/_summernote.html.twig b/Resources/views/Elfinder/helper/_summernote.html.twig new file mode 100644 index 0000000..abe8b3b --- /dev/null +++ b/Resources/views/Elfinder/helper/_summernote.html.twig @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/Resources/views/Elfinder/summernote.html.twig b/Resources/views/Elfinder/summernote.html.twig new file mode 100644 index 0000000..d573092 --- /dev/null +++ b/Resources/views/Elfinder/summernote.html.twig @@ -0,0 +1,27 @@ + + + + {% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_css.html.twig" %} + {% endif %} + + +{% if includeAssets %} + {% include "FMElfinderBundle:Elfinder:helper/assets_js.html.twig" %} +{% endif %} + +
+ + diff --git a/Twig/Extension/FMElfinderTinymceExtension.php b/Twig/Extension/FMElfinderTinymceExtension.php index 38eace2..12e9f2c 100644 --- a/Twig/Extension/FMElfinderTinymceExtension.php +++ b/Twig/Extension/FMElfinderTinymceExtension.php @@ -34,7 +34,8 @@ public function getFunctions() { return array( 'elfinder_tinymce_init' => new \Twig_Function_Method($this, 'tinymce', array('is_safe' => array('html'))), - 'elfinder_tinymce_init4' => new \Twig_Function_Method($this, 'tinymce4', array('is_safe' => array('html'))) + 'elfinder_tinymce_init4' => new \Twig_Function_Method($this, 'tinymce4', array('is_safe' => array('html'))), + 'elfinder_summernote_init' => new \Twig_Function_Method($this, 'summernote', array('is_safe' => array('html'))), ); } @@ -80,6 +81,22 @@ public function tinymce4($instance = 'default', $parameters = array('width' => 9 )); } + public function summernote($instance = 'default', $selector = '.summenote', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) + { + if (!is_string($instance)) { + throw new Twig_Error_Runtime('The function can be applied to strings only.'); + } + + return $this->twig->render('FMElfinderBundle:Elfinder/helper:_summernote.html.twig', + array( + 'instance' => $instance, + 'selector' => $selector, + 'width' => $parameters['width'], + 'height' => $parameters['height'], + 'title' => $parameters['title'] + )); + } + /** * (non-PHPdoc) * @see Twig_ExtensionInterface::getName() From a7ea5f5c79ec0a7a9d513484715b24c67e74f234 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 03:10:24 +1000 Subject: [PATCH 02/14] Edit suggestion section --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 261c667..685e32c 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,8 @@ "suggest": { "stfalcon/tinymce-bundle": "TinyMCE Bundle by Stfalcon", "egeloen/ckeditor-bundle": "CKEditor Bundle by Egeloen", - "trsteel/ckeditor-bundle": "CKEditor Bundle by trsteel" + "trsteel/ckeditor-bundle": "CKEditor Bundle by trsteel", + "helios-ag/fm-summernote-bundle": "Summernote Bundle by me" }, "autoload": { "psr-4": { "FM\\ElfinderBundle\\": "" } From dbbcb00595fe5d66dca9cd24fe0bf193de1010aa Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:20:26 +1000 Subject: [PATCH 03/14] made entity optional, modev to resources dir --- Entity/ElFinderFile.php | 318 ---------------------------------------- 1 file changed, 318 deletions(-) delete mode 100644 Entity/ElFinderFile.php diff --git a/Entity/ElFinderFile.php b/Entity/ElFinderFile.php deleted file mode 100644 index 73b0e78..0000000 --- a/Entity/ElFinderFile.php +++ /dev/null @@ -1,318 +0,0 @@ -content = $content; - } - - /** - * @return string - */ - public function getContent() - { - return $this->content; - } - - /** - * @param int $height - */ - public function setHeight($height) - { - $this->height = $height; - } - - /** - * @return int - */ - public function getHeight() - { - return $this->height; - } - - /** - * @param string $hidden - */ - public function setHidden($hidden) - { - $this->hidden = $hidden; - } - - /** - * @return string - */ - public function getHidden() - { - return $this->hidden; - } - - /** - * @param int $id - */ - public function setId($id) - { - $this->id = $id; - } - - /** - * @return int - */ - public function getId() - { - return $this->id; - } - - /** - * @param string $locked - */ - public function setLocked($locked) - { - $this->locked = $locked; - } - - /** - * @return string - */ - public function getLocked() - { - return $this->locked; - } - - /** - * @param string $mime - */ - public function setMime($mime) - { - $this->mime = $mime; - } - - /** - * @return string - */ - public function getMime() - { - return $this->mime; - } - - /** - * @param int $mtime - */ - public function setMtime($mtime) - { - $this->mtime = $mtime; - } - - /** - * @return int - */ - public function getMtime() - { - return $this->mtime; - } - - /** - * @param string $name - */ - public function setName($name) - { - $this->name = $name; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * @param int $parentId - */ - public function setParentId($parentId) - { - $this->parentId = $parentId; - } - - /** - * @return int - */ - public function getParentId() - { - return $this->parentId; - } - - /** - * @param string $read - */ - public function setRead($read) - { - $this->read = $read; - } - - /** - * @return string - */ - public function getRead() - { - return $this->read; - } - - /** - * @param int $size - */ - public function setSize($size) - { - $this->size = $size; - } - - /** - * @return int - */ - public function getSize() - { - return $this->size; - } - - /** - * @param int $width - */ - public function setWidth($width) - { - $this->width = $width; - } - - /** - * @return int - */ - public function getWidth() - { - return $this->width; - } - - /** - * @param string $write - */ - public function setWrite($write) - { - $this->write = $write; - } - - /** - * @return string - */ - public function getWrite() - { - return $this->write; - } - -} From f48020eb7f0eba40b242e80c36798be46fd64a0e Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:20:45 +1000 Subject: [PATCH 04/14] move entity file --- Resources/entity/ElFinderFile.php.dst | 318 ++++++++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 Resources/entity/ElFinderFile.php.dst diff --git a/Resources/entity/ElFinderFile.php.dst b/Resources/entity/ElFinderFile.php.dst new file mode 100644 index 0000000..73b0e78 --- /dev/null +++ b/Resources/entity/ElFinderFile.php.dst @@ -0,0 +1,318 @@ +content = $content; + } + + /** + * @return string + */ + public function getContent() + { + return $this->content; + } + + /** + * @param int $height + */ + public function setHeight($height) + { + $this->height = $height; + } + + /** + * @return int + */ + public function getHeight() + { + return $this->height; + } + + /** + * @param string $hidden + */ + public function setHidden($hidden) + { + $this->hidden = $hidden; + } + + /** + * @return string + */ + public function getHidden() + { + return $this->hidden; + } + + /** + * @param int $id + */ + public function setId($id) + { + $this->id = $id; + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param string $locked + */ + public function setLocked($locked) + { + $this->locked = $locked; + } + + /** + * @return string + */ + public function getLocked() + { + return $this->locked; + } + + /** + * @param string $mime + */ + public function setMime($mime) + { + $this->mime = $mime; + } + + /** + * @return string + */ + public function getMime() + { + return $this->mime; + } + + /** + * @param int $mtime + */ + public function setMtime($mtime) + { + $this->mtime = $mtime; + } + + /** + * @return int + */ + public function getMtime() + { + return $this->mtime; + } + + /** + * @param string $name + */ + public function setName($name) + { + $this->name = $name; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param int $parentId + */ + public function setParentId($parentId) + { + $this->parentId = $parentId; + } + + /** + * @return int + */ + public function getParentId() + { + return $this->parentId; + } + + /** + * @param string $read + */ + public function setRead($read) + { + $this->read = $read; + } + + /** + * @return string + */ + public function getRead() + { + return $this->read; + } + + /** + * @param int $size + */ + public function setSize($size) + { + $this->size = $size; + } + + /** + * @return int + */ + public function getSize() + { + return $this->size; + } + + /** + * @param int $width + */ + public function setWidth($width) + { + $this->width = $width; + } + + /** + * @return int + */ + public function getWidth() + { + return $this->width; + } + + /** + * @param string $write + */ + public function setWrite($write) + { + $this->write = $write; + } + + /** + * @return string + */ + public function getWrite() + { + return $this->write; + } + +} From abf18871bb067f9f5420e4cb534110fd543a197a Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:22:36 +1000 Subject: [PATCH 05/14] renamed twig extension, deprecated method removed --- Resources/config/elfinder.xml | 5 ++--- ...eExtensionTest.php => FMElfinderExtensionTest.php} | 11 +++++------ 2 files changed, 7 insertions(+), 9 deletions(-) rename Tests/Twig/Extension/{FMElfinderTinymceExtensionTest.php => FMElfinderExtensionTest.php} (89%) diff --git a/Resources/config/elfinder.xml b/Resources/config/elfinder.xml index b80dcd3..afc83e9 100644 --- a/Resources/config/elfinder.xml +++ b/Resources/config/elfinder.xml @@ -17,10 +17,9 @@ - + - + - diff --git a/Tests/Twig/Extension/FMElfinderTinymceExtensionTest.php b/Tests/Twig/Extension/FMElfinderExtensionTest.php similarity index 89% rename from Tests/Twig/Extension/FMElfinderTinymceExtensionTest.php rename to Tests/Twig/Extension/FMElfinderExtensionTest.php index df6c737..67cbe89 100644 --- a/Tests/Twig/Extension/FMElfinderTinymceExtensionTest.php +++ b/Tests/Twig/Extension/FMElfinderExtensionTest.php @@ -2,7 +2,7 @@ namespace FM\ElfinderBundle\Tests\Twig\Extension; -use FM\ElfinderBundle\Twig\Extension\FMElfinderTinymceExtension; +use FM\ElfinderBundle\Twig\Extension\FMElfinderExtension; use Symfony\Bridge\Twig\Extension\RoutingExtension; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -11,7 +11,7 @@ use Symfony\Component\Routing\RequestContext; use Symfony\Component\Routing\RouteCollection; -class FMElfinderTinymceExtensionTest extends \PHPUnit_Framework_TestCase +class FMElfinderExtensionTest extends \PHPUnit_Framework_TestCase { /** @var \Symfony\Component\DependencyInjection\ContainerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $containerMock; @@ -36,7 +36,7 @@ class FMElfinderTinymceExtensionTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array(__DIR__.'/../../../Resources/views/Elfinder/helper'))); - $this->extension = new FMElfinderTinymceExtension($this->twig); + $this->extension = new FMElfinderExtension($this->twig); $this->twig->addExtension($this->extension); $loader = new YamlFileLoader(new FileLocator(__DIR__ . '/../../../Resources/config')); $routes = new RouteCollection(); @@ -109,7 +109,7 @@ function elFinderBrowser (field_name, url, type, win) { */ public function testName() { - $this->assertEquals('fm_tinymce_init', $this->extension->getName()); + $this->assertEquals('fm_elfinder_init', $this->extension->getName()); } /** @@ -146,9 +146,8 @@ protected function normalizeOutput($output) */ public function testSubClassOfTwigExtension() { - $rc = new \ReflectionClass('FM\ElfinderBundle\Twig\Extension\FMElfinderTinymceExtension'); + $rc = new \ReflectionClass('FM\ElfinderBundle\Twig\Extension\FMElfinderExtension'); $this->assertTrue($rc->isSubclassOf('Twig_Extension')); } } - From 02aa73ec2e63b75c473331846f30f3e3ebf4b2a7 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:23:36 +1000 Subject: [PATCH 06/14] moved fixture file to resources dir --- .../fixtures/LoadRootElement.php.dst | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename DataFixtures/ORM/LoadRootElement.php => Resources/fixtures/LoadRootElement.php.dst (100%) diff --git a/DataFixtures/ORM/LoadRootElement.php b/Resources/fixtures/LoadRootElement.php.dst similarity index 100% rename from DataFixtures/ORM/LoadRootElement.php rename to Resources/fixtures/LoadRootElement.php.dst From cf5216ac368315d9886f7185f76addc254ae6498 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:24:31 +1000 Subject: [PATCH 07/14] renamed twig extension --- Twig/Extension/FMElfinderExtension.php | 113 +++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Twig/Extension/FMElfinderExtension.php diff --git a/Twig/Extension/FMElfinderExtension.php b/Twig/Extension/FMElfinderExtension.php new file mode 100644 index 0000000..d4a59b4 --- /dev/null +++ b/Twig/Extension/FMElfinderExtension.php @@ -0,0 +1,113 @@ +twig = $twig; + } + + /** + * {@inheritdoc} + * @return array + */ + public function getFunctions() + { + $options = array('is_safe'=>array('html')); + + return array( + new \Twig_SimpleFunction('elfinder_tinymce_init', array($this, 'tinymce'), $options), + new \Twig_SimpleFunction('elfinder_tinymce_init4', array($this, 'tinymce4'), $options), + new \Twig_SimpleFunction('elfinder_summernote_init', array($this, 'summernote'), $options) + ); + } + + /** + * @param string $instance + * @param array $parameters + * @throws \Twig_Error_Runtime + * @return mixed + */ + public function tinymce($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) + { + if (!is_string($instance)) { + throw new \Twig_Error_Runtime('The function can be applied to strings only.'); + } + + return $this->twig->render('FMElfinderBundle:Elfinder/helper:_tinymce.html.twig', + array( + 'instance' => $instance, + 'width' => $parameters['width'], + 'height' => $parameters['height'], + 'title' => $parameters['title'] + )); + } + + /** + * @param string $instance + * @param array $parameters + * @throws \Twig_Error_Runtime + * @return mixed + */ + public function tinymce4($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) + { + if (!is_string($instance)) { + throw new \Twig_Error_Runtime('The function can be applied to strings only.'); + } + + return $this->twig->render('FMElfinderBundle:Elfinder/helper:_tinymce4.html.twig', + array( + 'instance' => $instance, + 'width' => $parameters['width'], + 'height' => $parameters['height'], + 'title' => $parameters['title'] + )); + } + + /** + * @param string $instance + * @param array $parameters + * @throws \Twig_Error_Runtime + * @return mixed + */ + public function summernote($instance = 'default', $selector = '.summenote', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) + { + if (!is_string($instance)) { + throw new Twig_Error_Runtime('The function can be applied to strings only.'); + } + + return $this->twig->render('FMElfinderBundle:Elfinder/helper:_summernote.html.twig', + array( + 'instance' => $instance, + 'selector' => $selector, + 'width' => $parameters['width'], + 'height' => $parameters['height'], + 'title' => $parameters['title'] + )); + } + + /** + * (non-PHPdoc) + * @see Twig_ExtensionInterface::getName() + */ + public function getName() + { + return 'fm_elfinder_init'; + } + +} From 2b866380db3ceec7a80653a3e3c31152feaeae91 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:25:03 +1000 Subject: [PATCH 08/14] extension file renamed --- Twig/Extension/FMElfinderTinymceExtension.php | 110 ------------------ 1 file changed, 110 deletions(-) delete mode 100644 Twig/Extension/FMElfinderTinymceExtension.php diff --git a/Twig/Extension/FMElfinderTinymceExtension.php b/Twig/Extension/FMElfinderTinymceExtension.php deleted file mode 100644 index 12e9f2c..0000000 --- a/Twig/Extension/FMElfinderTinymceExtension.php +++ /dev/null @@ -1,110 +0,0 @@ -twig = $twig; - } - - /** - * (non-PHPdoc) - * @see Twig_Extension::getFilters() - * @return array - */ - public function getFunctions() - { - return array( - 'elfinder_tinymce_init' => new \Twig_Function_Method($this, 'tinymce', array('is_safe' => array('html'))), - 'elfinder_tinymce_init4' => new \Twig_Function_Method($this, 'tinymce4', array('is_safe' => array('html'))), - 'elfinder_summernote_init' => new \Twig_Function_Method($this, 'summernote', array('is_safe' => array('html'))), - ); - } - - /** - * @param string $instance - * @param array $parameters - * @throws \Twig_Error_Runtime - * @return mixed - */ - public function tinymce($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) - { - if (!is_string($instance)) { - throw new Twig_Error_Runtime('The filter can be applied to strings only.'); - } - - return $this->twig->render('FMElfinderBundle:Elfinder/helper:_tinymce.html.twig', - array( - 'instance' => $instance, - 'width' => $parameters['width'], - 'height' => $parameters['height'], - 'title' => $parameters['title'] - )); - } - - /** - * @param string $instance - * @param array $parameters - * @throws \Twig_Error_Runtime - * @return mixed - */ - public function tinymce4($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) - { - if (!is_string($instance)) { - throw new Twig_Error_Runtime('The filter can be applied to strings only.'); - } - - return $this->twig->render('FMElfinderBundle:Elfinder/helper:_tinymce4.html.twig', - array( - 'instance' => $instance, - 'width' => $parameters['width'], - 'height' => $parameters['height'], - 'title' => $parameters['title'] - )); - } - - public function summernote($instance = 'default', $selector = '.summenote', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) - { - if (!is_string($instance)) { - throw new Twig_Error_Runtime('The function can be applied to strings only.'); - } - - return $this->twig->render('FMElfinderBundle:Elfinder/helper:_summernote.html.twig', - array( - 'instance' => $instance, - 'selector' => $selector, - 'width' => $parameters['width'], - 'height' => $parameters['height'], - 'title' => $parameters['title'] - )); - } - - /** - * (non-PHPdoc) - * @see Twig_ExtensionInterface::getName() - */ - public function getName() - { - return 'fm_tinymce_init'; - } - -} - From 30685095cd7cda1b7c5bbc869c06c28900d7311e Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:25:26 +1000 Subject: [PATCH 09/14] fixed intendation --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 685e32c..827929b 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ "stfalcon/tinymce-bundle": "TinyMCE Bundle by Stfalcon", "egeloen/ckeditor-bundle": "CKEditor Bundle by Egeloen", "trsteel/ckeditor-bundle": "CKEditor Bundle by trsteel", - "helios-ag/fm-summernote-bundle": "Summernote Bundle by me" + "helios-ag/fm-summernote-bundle": "Summernote Bundle by me" }, "autoload": { "psr-4": { "FM\\ElfinderBundle\\": "" } From a5eb6336a5b3a192196e1bc98483b17ffd292616 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 12:48:18 +1000 Subject: [PATCH 10/14] test extension rename --- Tests/DependencyInjection/FMElfinderExtensionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/DependencyInjection/FMElfinderExtensionTest.php b/Tests/DependencyInjection/FMElfinderExtensionTest.php index 0207f17..9610ab9 100644 --- a/Tests/DependencyInjection/FMElfinderExtensionTest.php +++ b/Tests/DependencyInjection/FMElfinderExtensionTest.php @@ -22,7 +22,7 @@ public function testServices() $this->assertContainerBuilderHasAlias('fm_elfinder.configurator'); $this->assertContainerBuilderHasService('fm_elfinder.loader'); $this->assertContainerBuilderHasService('fm_elfinder.configurator.default'); - $this->assertContainerBuilderHasService('twig.extension.fm_tinymce_init'); + $this->assertContainerBuilderHasService('twig.extension.fm_elfinder_init'); } /** From e59f324f4159d3acb761c7a41b1762de63e08eee Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Thu, 24 Sep 2015 08:38:05 -0400 Subject: [PATCH 11/14] Applied fixes from StyleCI --- Bridge/ElFinderBridge.php | 3 +- Configuration/ElFinderConfigurationReader.php | 89 ++--- Controller/ElFinderController.php | 68 ++-- DependencyInjection/Compiler/TwigFormPass.php | 4 +- DependencyInjection/Configuration.php | 8 +- DependencyInjection/FMElfinderExtension.php | 2 +- Event/ElFinderEvents.php | 2 + Event/ElFinderPostExecutionEvent.php | 6 +- Event/ElFinderPreExecutionEvent.php | 17 +- FMElfinderBundle.php | 3 +- Form/Type/ElFinderType.php | 26 +- Loader/ElFinderLoader.php | 16 +- ...ElFinderConfigurationProviderInterface.php | 4 +- Model/ElFinderPermissionsInterface.php | 4 +- .../ElFinderConfigurationReaderTest.php | 28 +- Tests/Controller/ElFinderControllerTest.php | 11 +- .../ConfigurationLoadTest.php | 261 ++++++++------- .../DependencyInjection/ConfigurationTest.php | 54 ++-- .../FMElfinderExtensionTest.php | 7 +- .../Event/ElFinderPostExecutionEventTest.php | 4 +- Tests/Event/ElFinderPreExecutionEventTest.php | 14 +- Tests/Fixtures/config/config.php | 98 +++--- Tests/Loader/ElFinderLoaderTest.php | 71 ++-- .../Extension/FMElfinderExtensionTest.php | 304 +++++++++--------- Tests/bootstrap.php | 1 + Twig/Extension/FMElfinderExtension.php | 31 +- 26 files changed, 576 insertions(+), 560 deletions(-) diff --git a/Bridge/ElFinderBridge.php b/Bridge/ElFinderBridge.php index 33da06b..ae3bf31 100644 --- a/Bridge/ElFinderBridge.php +++ b/Bridge/ElFinderBridge.php @@ -6,10 +6,9 @@ use FM\ElFinderPHP\Driver\ElFinderVolumeDriver; /** - * Class ElFinderBridge + * Class ElFinderBridge. * * Use Symfony services as regular VolumeDrivers. - * */ class ElFinderBridge extends ElFinder { diff --git a/Configuration/ElFinderConfigurationReader.php b/Configuration/ElFinderConfigurationReader.php index 5638231..955c449 100644 --- a/Configuration/ElFinderConfigurationReader.php +++ b/Configuration/ElFinderConfigurationReader.php @@ -21,18 +21,17 @@ use Barracuda\Copy\API; /** - * Class ElFinderConfigurationReader - * @package FM\ElfinderBundle\Configuration + * Class ElFinderConfigurationReader. */ class ElFinderConfigurationReader implements ElFinderConfigurationProviderInterface { /** - * @var array $options + * @var array */ protected $options = array(); /** - * @var array $parameters + * @var array */ protected $parameters; @@ -49,7 +48,7 @@ class ElFinderConfigurationReader implements ElFinderConfigurationProviderInterf /** * @param $parameters * @param \Symfony\Component\HttpFoundation\RequestStack $requestStack - * @param ContainerInterface $container + * @param ContainerInterface $container */ public function __construct($parameters, RequestStack $requestStack, ContainerInterface $container) { @@ -60,29 +59,30 @@ public function __construct($parameters, RequestStack $requestStack, ContainerIn /** * @param $instance + * * @return array */ public function getConfiguration($instance) { - $request = $this->requestStack->getCurrentRequest(); - $efParameters = $this->parameters; - $parameters = $efParameters['instances'][$instance]; - $options = array(); + $request = $this->requestStack->getCurrentRequest(); + $efParameters = $this->parameters; + $parameters = $efParameters['instances'][$instance]; + $options = array(); $options['corsSupport'] = $parameters['cors_support']; - $options['debug'] = $parameters['connector']['debug']; - $options['bind'] = $parameters['connector']['binds']; - $options['plugins'] = $parameters['connector']['plugins']; - $options['roots'] = array(); + $options['debug'] = $parameters['connector']['debug']; + $options['bind'] = $parameters['connector']['binds']; + $options['plugins'] = $parameters['connector']['plugins']; + $options['roots'] = array(); foreach ($parameters['connector']['roots'] as $parameter) { - $path = $parameter['path']; + $path = $parameter['path']; $homeFolder = $request->attributes->get('homeFolder'); if ($homeFolder !== '') { $homeFolder = '/'.$homeFolder.'/'; } - if($parameter['flysystem']['enabled']) { - $adapter = $parameter['flysystem']['type']; // ftp ex. - $opt = $parameter['flysystem']['options']; + if ($parameter['flysystem']['enabled']) { + $adapter = $parameter['flysystem']['type']; // ftp ex. + $opt = $parameter['flysystem']['options']; $filesystem = $this->configureFlysystem($opt, $adapter); } $driver = $this->container->has($parameter['driver']) ? $this->container->get($parameter['driver']) : null; @@ -93,7 +93,7 @@ public function getConfiguration($instance) 'glideURL' => $parameter['glide_url'], 'glideKey' => $parameter['glide_key'], 'plugin' => $parameter['plugins'], - 'path' => $path . $homeFolder, //removed slash for Flysystem compatibility + 'path' => $path.$homeFolder, //removed slash for Flysystem compatibility 'startPath' => $parameter['start_path'], 'URL' => $this->getURL($parameter, $request, $homeFolder, $path), 'alias' => $parameter['alias'], @@ -123,18 +123,18 @@ public function getConfiguration($instance) 'separator' => $parameter['separator'], 'timeFormat' => $parameter['time_format'], 'archiveMimes' => $parameter['archive_mimes'], - 'archivers' => $parameter['archivers'] + 'archivers' => $parameter['archivers'], ); if ($parameter['volume_id'] > 0) { $driverOptions['id'] = $parameter['volume_id']; } - if(!$parameter['show_hidden']) { + if (!$parameter['show_hidden']) { $driverOptions['accessControl'] = array($this, 'access'); }; - if($parameter['driver'] == 'Flysystem') { + if ($parameter['driver'] == 'Flysystem') { $driverOptions['filesystem'] = $filesystem; } $options['roots'][] = array_merge($driverOptions, $this->configureDriver($parameter)); @@ -148,6 +148,7 @@ public function getConfiguration($instance) * @param $request * @param $homeFolder * @param $path + * * @return string */ private function getURL($parameter, $request, $homeFolder, $path) @@ -162,6 +163,7 @@ private function getURL($parameter, $request, $homeFolder, $path) /** * @param $opt * @param $adapter + * * @return Filesystem */ private function configureFlysystem($opt, $adapter) @@ -176,21 +178,21 @@ private function configureFlysystem($opt, $adapter) 'username' => $opt['ftp']['username'], 'password' => $opt['ftp']['password'], - /** optional config settings */ + /* optional config settings */ 'port' => $opt['ftp']['port'], 'root' => $opt['ftp']['root'], 'passive' => $opt['ftp']['passive'], 'ssl' => $opt['ftp']['ssl'], 'timeout' => $opt['ftp']['timeout'], - 'directoryPerm' => $opt['ftp']['directoryPerm'] + 'directoryPerm' => $opt['ftp']['directoryPerm'], ); - $filesystem = (!$opt['ftp']['sftp']) ? new Filesystem(new Ftp($settings)): new Filesystem(new SftpAdapter($settings)); + $filesystem = (!$opt['ftp']['sftp']) ? new Filesystem(new Ftp($settings)) : new Filesystem(new SftpAdapter($settings)); break; case 'aws_s3_v2': $client = S3Client::factory(array( 'key' => $opt['aws_s3_v2']['key'], 'secret' => $opt['aws_s3_v2']['secret'], - 'region' => $opt['aws_s3_v2']['region'] + 'region' => $opt['aws_s3_v2']['region'], )); $filesystem = new Filesystem(new AwsS3v2($client, $opt['aws_s3_v2']['bucket_name'], $opt['aws_s3_v2']['optional_prefix'])); break; @@ -199,7 +201,7 @@ private function configureFlysystem($opt, $adapter) 'key' => $opt['aws_s3_v3']['key'], 'secret' => $opt['aws_s3_v3']['secret'], 'region' => $opt['aws_s3_v3']['region'], - 'version' => $opt['aws_s3_v3']['version'] + 'version' => $opt['aws_s3_v3']['version'], )); $filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix'])); break; @@ -214,21 +216,23 @@ private function configureFlysystem($opt, $adapter) break; case 'gridfs': $mongoClient = new MongoClient(); - $gridFs = $mongoClient->selectDB($opt['gridfs']['db_name'])->getGridFS(); - $filesystem = new Filesystem(new GridFSAdapter($gridFs)); + $gridFs = $mongoClient->selectDB($opt['gridfs']['db_name'])->getGridFS(); + $filesystem = new Filesystem(new GridFSAdapter($gridFs)); break; case 'zip': $filesystem = new Filesystem(new ZipArchiveAdapter($opt['zip']['path'])); break; case 'dropbox': - $filesystem = new Filesystem(new DropboxAdapter(new Client($opt['dropbox']['token'],$opt['dropbox']['app']))); + $filesystem = new Filesystem(new DropboxAdapter(new Client($opt['dropbox']['token'], $opt['dropbox']['app']))); break; } + return $filesystem; } /** - * @param array $parameter + * @param array $parameter + * * @return array */ private function configureDriver(array $parameter) @@ -236,19 +240,19 @@ private function configureDriver(array $parameter) $settings = array(); switch (strtolower($parameter['driver'])) { - case "ftp": + case 'ftp': $settings['host'] = $parameter['ftp_settings']['host']; $settings['user'] = $parameter['ftp_settings']['user']; $settings['pass'] = $parameter['ftp_settings']['password']; $settings['path'] = $parameter['ftp_settings']['path']; break; - case "ftpiis": + case 'ftpiis': $settings['host'] = $parameter['ftp_settings']['host']; $settings['user'] = $parameter['ftp_settings']['user']; $settings['pass'] = $parameter['ftp_settings']['password']; $settings['path'] = $parameter['ftp_settings']['path']; break; - case "dropbox": + case 'dropbox': $settings['consumerKey'] = $parameter['dropbox_settings']['consumer_key']; $settings['consumerSecret'] = $parameter['dropbox_settings']['consumer_secret']; $settings['accessToken'] = $parameter['dropbox_settings']['access_token']; @@ -256,13 +260,13 @@ private function configureDriver(array $parameter) $settings['dropboxUid'] = $parameter['dropbox_settings']['dropbox_uid']; $settings['metaCachePath'] = $parameter['dropbox_settings']['meta_cache_path']; break; - case "s3": - $settings['accesskey'] = $parameter['s3_settings']['access_key']; - $settings['secretkey'] = $parameter['s3_settings']['secret_key']; - $settings['bucket'] = $parameter['s3_settings']['bucket']; - $settings['tmpPath'] = $parameter['s3_settings']['tmp_path']; + case 's3': + $settings['accesskey'] = $parameter['s3_settings']['access_key']; + $settings['secretkey'] = $parameter['s3_settings']['secret_key']; + $settings['bucket'] = $parameter['s3_settings']['bucket']; + $settings['tmpPath'] = $parameter['s3_settings']['tmp_path']; $settings['signature'] = $parameter['s3_settings']['signature']; - $settings['region'] = $parameter['s3_settings']['region']; + $settings['region'] = $parameter['s3_settings']['region']; break; default: break; @@ -273,12 +277,13 @@ private function configureDriver(array $parameter) /** * Simple function to demonstrate how to control file access using "accessControl" callback. - * This method will disable accessing files/folders starting from '.' (dot) + * This method will disable accessing files/folders starting from '.' (dot). * - * @param string $attr attribute name (read|write|locked|hidden) - * @param string $path file path relative to volume root directory started with directory separator + * @param string $attr attribute name (read|write|locked|hidden) + * @param string $path file path relative to volume root directory started with directory separator * @param $data * @param $volume + * * @return bool|null */ public function access($attr, $path, $data, $volume) diff --git a/Controller/ElFinderController.php b/Controller/ElFinderController.php index ba4a96e..4133789 100644 --- a/Controller/ElFinderController.php +++ b/Controller/ElFinderController.php @@ -13,38 +13,42 @@ /** * Loader service for Elfinder backend - * displays Elfinder + * displays Elfinder. + * * @author Al Ganiev * @copyright 2012-2015 Al Ganiev * @license http://www.opensource.org/licenses/mit-license.php MIT License */ class ElFinderController extends Controller { - /** - * Renders Elfinder + * Renders Elfinder. + * * @param Request $request - * @param string $instance - * @param string $homeFolder + * @param string $instance + * @param string $homeFolder + * * @return Response */ public function showAction(Request $request, $instance, $homeFolder) { $efParameters = $this->container->getParameter('fm_elfinder'); - $parameters = $efParameters['instances'][$instance]; - $assetsPath = $efParameters['assets_path']; - $result = $this->selectEditor($parameters, $instance, $homeFolder, $assetsPath, $request->get("id")); + $parameters = $efParameters['instances'][$instance]; + $assetsPath = $efParameters['assets_path']; + $result = $this->selectEditor($parameters, $instance, $homeFolder, $assetsPath, $request->get('id')); return $this->render($result['template'], $result['params']); } /** - * @param array $parameters + * @param array $parameters * @param string $instance * @param string $homeFolder * @param $assetsPath * @param null $formTypeId + * * @return array + * * @throws Exception */ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, $formTypeId = null) @@ -65,7 +69,7 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, } $result['template'] = $parameters['editor_template']; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'fullscreen' => $fullScreen, 'includeAssets' => $includeAssets, @@ -74,12 +78,13 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'relative_path' => $relativePath, 'prefix' => $assetsPath, 'theme' => $theme, - 'pathPrefix' => $pathPrefix + 'pathPrefix' => $pathPrefix, ); + return $result; case 'ckeditor': $result['template'] = 'FMElfinderBundle:Elfinder:ckeditor.html.twig'; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'fullscreen' => $fullScreen, 'includeAssets' => $includeAssets, @@ -88,12 +93,13 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'relative_path' => $relativePath, 'prefix' => $assetsPath, 'theme' => $theme, - 'pathPrefix' => $pathPrefix + 'pathPrefix' => $pathPrefix, ); + return $result; case 'summernote': $result['template'] = 'FMElfinderBundle:Elfinder:summernote.html.twig'; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'fullscreen' => $fullScreen, 'includeAssets' => $includeAssets, @@ -102,12 +108,13 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'relative_path' => $relativePath, 'prefix' => $assetsPath, 'theme' => $theme, - 'pathPrefix' => $pathPrefix + 'pathPrefix' => $pathPrefix, ); + return $result; case 'tinymce': $result['template'] = 'FMElfinderBundle:Elfinder:tinymce.html.twig'; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'tinymce_popup_path' => $this->getAssetsUrl($parameters['tinymce_popup_path']), 'includeAssets' => $includeAssets, @@ -115,12 +122,13 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'homeFolder' => $homeFolder, 'prefix' => $assetsPath, 'theme' => $theme, - 'pathPrefix' => $pathPrefix + 'pathPrefix' => $pathPrefix, ); + return $result; case 'tinymce4': $result['template'] = 'FMElfinderBundle:Elfinder:tinymce4.html.twig'; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'includeAssets' => $includeAssets, 'instance' => $instance, @@ -128,12 +136,13 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'relative_path' => $relativePath, 'prefix' => $assetsPath, 'theme' => $theme, - 'pathPrefix' => $pathPrefix + 'pathPrefix' => $pathPrefix, ); + return $result; case 'form': $result['template'] = 'FMElfinderBundle:Elfinder:elfinder_type.html.twig'; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'fullscreen' => $fullScreen, 'includeAssets' => $includeAssets, @@ -143,28 +152,32 @@ private function selectEditor($parameters, $instance, $homeFolder, $assetsPath, 'relative_path' => $relativePath, 'prefix' => $assetsPath, 'theme' => $theme, - 'pathPrefix' => $pathPrefix + 'pathPrefix' => $pathPrefix, ); + return $result; default: $result['template'] = 'FMElfinderBundle:Elfinder:simple.html.twig'; - $result['params'] = array( + $result['params'] = array( 'locale' => $locale, 'fullscreen' => $fullScreen, 'includeAssets' => $includeAssets, 'instance' => $instance, 'homeFolder' => $homeFolder, - 'prefix' => $assetsPath + 'prefix' => $assetsPath, ); + return $result; } } /** - * Loader service init + * Loader service init. + * * @param Request $request - * @param string $instance - * @param string $homeFolder + * @param string $instance + * @param string $homeFolder + * * @return JsonResponse/void */ public function loadAction(Request $request, $instance, $homeFolder) @@ -185,7 +198,7 @@ public function loadAction(Request $request, $instance, $homeFolder) } /** - * Get url from config string + * Get url from config string. * * @param string $inputUrl * @@ -204,5 +217,4 @@ protected function getAssetsUrl($inputUrl) return $inputUrl; } - } diff --git a/DependencyInjection/Compiler/TwigFormPass.php b/DependencyInjection/Compiler/TwigFormPass.php index 9438028..172bde6 100644 --- a/DependencyInjection/Compiler/TwigFormPass.php +++ b/DependencyInjection/Compiler/TwigFormPass.php @@ -6,8 +6,7 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; /** - * Class TwigFormPass - * @package FM\ElfinderBundle\DependencyInjection\Compiler + * Class TwigFormPass. */ class TwigFormPass implements CompilerPassInterface { @@ -23,4 +22,3 @@ public function process(ContainerBuilder $container) )); } } - diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 6d75414..a64b209 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -6,10 +6,11 @@ use Symfony\Component\Config\Definition\ConfigurationInterface; /** - * This class contains the configuration information for the bundle + * This class contains the configuration information for the bundle. * * This information is solely responsible for how the different configuration * sections are normalized, and merged. + * * @author Al Ganiev * @copyright 2012-2015 Al Ganiev * @license http://www.opensource.org/licenses/mit-license.php MIT License @@ -17,12 +18,12 @@ class Configuration implements ConfigurationInterface { /** - * {@inheritDoc} + * {@inheritdoc} */ public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); - $rootNode = $treeBuilder->root('fm_elfinder'); + $rootNode = $treeBuilder->root('fm_elfinder'); $rootNode ->fixXmlConfig('instance') @@ -347,4 +348,3 @@ private function createTreeBuilder() return new TreeBuilder(); } } - diff --git a/DependencyInjection/FMElfinderExtension.php b/DependencyInjection/FMElfinderExtension.php index 5ed6fe9..8c49a76 100644 --- a/DependencyInjection/FMElfinderExtension.php +++ b/DependencyInjection/FMElfinderExtension.php @@ -17,7 +17,7 @@ class FMElfinderExtension extends Extension { /** - * {@inheritDoc} + * {@inheritdoc} */ public function load(array $configs, ContainerBuilder $container) { diff --git a/Event/ElFinderEvents.php b/Event/ElFinderEvents.php index 7b18bd2..4f9a139 100644 --- a/Event/ElFinderEvents.php +++ b/Event/ElFinderEvents.php @@ -8,12 +8,14 @@ abstract class ElFinderEvents extends Event { /** * Event name to identify pre execution event. + * * @var string */ const PRE_EXECUTION = 'fm_elfinder.event.pre_execution'; /** * Event name to identify post execution event. + * * @var string */ const POST_EXECUTION = 'fm_elfinder.event.post_execution'; diff --git a/Event/ElFinderPostExecutionEvent.php b/Event/ElFinderPostExecutionEvent.php index 2f4e1ac..5fa6cae 100644 --- a/Event/ElFinderPostExecutionEvent.php +++ b/Event/ElFinderPostExecutionEvent.php @@ -9,13 +9,14 @@ class ElFinderPostExecutionEvent extends ElFinderPreExecutionEvent { /** * Command execution result. + * * @var array */ protected $result; - /** * Constructor. + * * @param Request $request * @param HttpKernelInterface $httpKernel * @param string $instance @@ -31,7 +32,8 @@ public function __construct(Request $request, HttpKernelInterface $httpKernel, $ /** * Tells if execution has encountered errors. - * @return boolean + * + * @return bool */ public function hasErrors() { diff --git a/Event/ElFinderPreExecutionEvent.php b/Event/ElFinderPreExecutionEvent.php index a5f7fe3..59016fa 100644 --- a/Event/ElFinderPreExecutionEvent.php +++ b/Event/ElFinderPreExecutionEvent.php @@ -9,31 +9,35 @@ class ElFinderPreExecutionEvent extends ElFinderEvents { /** * Request object containing ElFinder command and parameters. + * * @var Request */ protected $request; /** * Used to make sub requests. + * * @var HttpKernelInterface */ private $httpKernel; /** * ElFinder instance. + * * @var string */ protected $instance; /** * Home folder. + * * @var string */ protected $homeFolder; - /** * Constructor. + * * @param Request $request * @param HttpKernelInterface $httpKernel * @param string $instance @@ -41,9 +45,9 @@ class ElFinderPreExecutionEvent extends ElFinderEvents */ public function __construct(Request $request, HttpKernelInterface $httpKernel, $instance, $homeFolder) { - $this->request = $request; + $this->request = $request; $this->httpKernel = $httpKernel; - $this->instance = $instance; + $this->instance = $instance; $this->homeFolder = $homeFolder; } @@ -53,7 +57,7 @@ public function __construct(Request $request, HttpKernelInterface $httpKernel, $ * * @see https://github.com/symfony/symfony/blob/2.5/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php * - * @param array $path An array of path parameters + * @param array $path An array of path parameters * @param array $query An array of query parameters * * @return Symfony\Component\HttpFoundation\Response A Response instance @@ -61,13 +65,14 @@ public function __construct(Request $request, HttpKernelInterface $httpKernel, $ public function subRequest(array $path, array $query) { $path['_controller'] = 'FMElfinderBundle:ElFinder:load'; - $subRequest = $this->request->duplicate($query, null, $path); - + $subRequest = $this->request->duplicate($query, null, $path); + return $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST); } /** * Returns executed command. + * * @return string */ public function getCommand() diff --git a/FMElfinderBundle.php b/FMElfinderBundle.php index e65af4c..cd121cd 100644 --- a/FMElfinderBundle.php +++ b/FMElfinderBundle.php @@ -8,8 +8,7 @@ use Symfony\Component\HttpKernel\Bundle\Bundle; /** - * Class FMElfinderBundle - * @package FM\ElfinderBundle + * Class FMElfinderBundle. */ class FMElfinderBundle extends Bundle { diff --git a/Form/Type/ElFinderType.php b/Form/Type/ElFinderType.php index edf59c8..9f2a38a 100644 --- a/Form/Type/ElFinderType.php +++ b/Form/Type/ElFinderType.php @@ -9,39 +9,38 @@ use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** - * Class ElFinderType - * @package FM\ElfinderBundle\Form\Type + * Class ElFinderType. */ class ElFinderType extends AbstractType { - /** - * @inheritdoc + * {@inheritdoc} */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->setAttribute('enable', $options['enable']); - if($builder->getAttribute('enable')) + if ($builder->getAttribute('enable')) { $builder->setAttribute('instance', $options['instance']); - $builder->setAttribute('homeFolder', $options['homeFolder']); + } + $builder->setAttribute('homeFolder', $options['homeFolder']); } /** - * @inheritdoc + * {@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'); + if ($form->getConfig()->getAttribute('enable')) { + $view->vars['instance'] = $form->getConfig()->getAttribute('instance'); $view->vars['homeFolder'] = $form->getConfig()->getAttribute('homeFolder'); } } /** - * @inheritdoc + * {@inheritdoc} */ public function setDefaultOptions(OptionsResolverInterface $resolver) { @@ -57,19 +56,20 @@ public function setDefaultOptions(OptionsResolverInterface $resolver) 'homeFolder' => array('string', 'null'), )); } + /** - * @inheritdoc + * {@inheritdoc} */ public function getParent() { return 'text'; } + /** - * @inheritdoc + * {@inheritdoc} */ public function getName() { return 'elfinder'; } } - diff --git a/Loader/ElFinderLoader.php b/Loader/ElFinderLoader.php index d9d5558..dd4bac4 100644 --- a/Loader/ElFinderLoader.php +++ b/Loader/ElFinderLoader.php @@ -9,8 +9,7 @@ use Symfony\Component\HttpFoundation\Request; /** - * Class ElFinderLoader - * @package FM\ElfinderBundle\Loader + * Class ElFinderLoader. */ class ElFinderLoader { @@ -21,7 +20,7 @@ class ElFinderLoader /** * @var ElFinderConfigurationProviderInterface - * Configurator service name + * Configurator service name */ protected $configurator; @@ -35,13 +34,14 @@ public function __construct(ElFinderConfigurationProviderInterface $configurator /** * @throws \Exception + * * @return array */ public function configure() { $configurator = $this->configurator; if (!($configurator instanceof ElFinderConfigurationProviderInterface)) { - throw new Exception("Configurator class must implement ElFinderConfigurationProviderInterface"); + throw new Exception('Configurator class must implement ElFinderConfigurationProviderInterface'); } $parameters = $configurator->getConfiguration($this->instance); @@ -49,15 +49,15 @@ public function configure() } /** - * Starts ElFinder - * @var Request $request + * Starts ElFinder. + * + * @var Request * @var string $instance - * @return void/array */ public function load(Request $request, $instance) { $this->setInstance($instance); - $config = $this->configure(); + $config = $this->configure(); $connector = new ElFinderConnector(new ElFinderBridge($config)); if ($config['corsSupport']) { return $connector->execute($request->query->all()); diff --git a/Model/ElFinderConfigurationProviderInterface.php b/Model/ElFinderConfigurationProviderInterface.php index 7cf1336..1f77d56 100644 --- a/Model/ElFinderConfigurationProviderInterface.php +++ b/Model/ElFinderConfigurationProviderInterface.php @@ -3,13 +3,13 @@ namespace FM\ElfinderBundle\Model; /** - * Interface ElFinderConfigurationProviderInterface - * @package FM\ElfinderBundle\Model + * Interface ElFinderConfigurationProviderInterface. */ interface ElFinderConfigurationProviderInterface { /** * @param $instance + * * @return array */ public function getConfiguration($instance); diff --git a/Model/ElFinderPermissionsInterface.php b/Model/ElFinderPermissionsInterface.php index f1d725b..2a970e1 100644 --- a/Model/ElFinderPermissionsInterface.php +++ b/Model/ElFinderPermissionsInterface.php @@ -3,8 +3,7 @@ namespace FM\ElfinderBundle\Model; /** - * Interface ElFinderUserInterface - * @package FM\ElfinderBundle\Model + * Interface ElFinderUserInterface. */ interface ElFinderPermissionsInterface { @@ -24,5 +23,4 @@ public function getRootDirectoryName(); // * @return mixed // */ // public function setPermissions($permissions = array()); - } diff --git a/Tests/Configuration/ElFinderConfigurationReaderTest.php b/Tests/Configuration/ElFinderConfigurationReaderTest.php index dc04b43..39b2d79 100644 --- a/Tests/Configuration/ElFinderConfigurationReaderTest.php +++ b/Tests/Configuration/ElFinderConfigurationReaderTest.php @@ -1,15 +1,13 @@ -assertTrue($rc->isSubclassOf('FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface')); - } -} \ No newline at end of file +assertTrue($rc->isSubclassOf('FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface')); + } +} diff --git a/Tests/Controller/ElFinderControllerTest.php b/Tests/Controller/ElFinderControllerTest.php index f85e838..4c1efd1 100644 --- a/Tests/Controller/ElFinderControllerTest.php +++ b/Tests/Controller/ElFinderControllerTest.php @@ -18,18 +18,18 @@ public function setUp() public function testDispatchedPrePostExecutionEvents() { - $preExecCount = 0; + $preExecCount = 0; $postExecCount = 0; // storing the real event dispatcher $eventDispatcher = $this->container->get('event_dispatcher'); // creating a container with mocked services for this test $container = $this->getContainer($eventDispatcher); - // adding listeners + // adding listeners $eventDispatcher->addListener(ElFinderEvents::PRE_EXECUTION, $preExecListener = function (ElFinderEvents $e) use (&$preExecCount) { - $preExecCount++; + ++$preExecCount; }); $eventDispatcher->addListener(ElFinderEvents::POST_EXECUTION, $postExecListener = function (ElFinderEvents $e) use (&$postExecCount) { - $postExecCount++; + ++$postExecCount; }); $controller = new ElFinderController(); @@ -46,6 +46,7 @@ private function getContainer($eventDispatcher) $container->set('fm_elfinder.loader', $this->getElFinderLoaderMock()); $container->set('http_kernel', $this->getHttpKernelMock()); $container->set('event_dispatcher', $eventDispatcher); + return $container; } @@ -57,6 +58,7 @@ private function getElFinderLoaderMock() $stub->expects($this->once()) ->method('load') ->willReturn(array()); + return $stub; } @@ -65,6 +67,7 @@ private function getHttpKernelMock() $stub = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface') ->disableOriginalConstructor() ->getMock(); + return $stub; } } diff --git a/Tests/DependencyInjection/ConfigurationLoadTest.php b/Tests/DependencyInjection/ConfigurationLoadTest.php index 3930435..225da38 100644 --- a/Tests/DependencyInjection/ConfigurationLoadTest.php +++ b/Tests/DependencyInjection/ConfigurationLoadTest.php @@ -1,131 +1,130 @@ - 'app.configurator.custom', - 'assets_path' => '/assets', - 'loader' => 'fm_elfinder.loader.default', - 'instances' => array( - 'default' => array( - 'locale' => 'en', - 'editor' => 'tinymce', - 'theme' => 'smoothness', - 'editor_template' => 'Elfinder/editor.html.twig', - 'fullscreen' => false, - 'include_assets' => false, - 'cors_support' => false, - 'tinymce_popup_path' => '/pop-up', - 'relative_path' => false, - 'path_prefix' => '/', - 'connector' => array( - 'debug' => true, - 'binds' => array(), - 'plugins' => array(), - 'roots' => array( - 'uploads' => array( - 'driver' => 'LocalFileSystem', - 'volume_id' => 0, - 'disabled_commands' => array(), - 'plugins' => array(), - 'path' => 'uploads', - 'show_hidden' => true, - 'flysystem' => array( - 'enabled' => false, - 'type' => '' - ), - 'start_path' => '', - 'url' => '', - 'mime_detect' => 'auto', - 'mimefile' => '', - 'img_lib' => 'auto', - 'tmb_path' => '.tmb', - 'tmb_url' => '', - 'tmb_size' => 48, - 'tmb_crop' => true, - 'tmb_bg_color' => '#ffffff', - 'tmb_path_mode' => 511, - 'copy_overwrite' => true, - 'copy_join' => true, - 'copy_from' => true, - 'copy_to' => true, - 'upload_overwrite' => true, - 'attributes' => array( - 'some_pattern' => array( - 'pattern' => '/^some_pattern$/', - 'read' => true, - 'write' => true, - 'locked' => false, - 'hidden' => false, - ) - ), - 'accepted_name' => '/^\w[\w\s\.\%\-]*$/u', - 'check_subfolders' => true, - 'separator' => DIRECTORY_SEPARATOR, - 'date_format' => 'j M Y H:i', - 'time_format' => 'H:i', - 'archive_mimes' => array(), - 'archivers' => array(), - 'glide_url' => '', - 'glide_key' => '', - 'alias' => 'foo', - 'tree_deep' => 1, - 'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'), - 'upload_order' => array('deny', 'allow'), - 'defaults' => array('read' => true, 'write' => true), - 'upload_deny' => array('all'), - 'upload_max_size' => 0, - 'dropbox_settings' => array( - 'consumer_key' => 'some_consumer', - 'consumer_secret' => 'con$umer', - 'enabled' => true, - ), - 'ftp_settings' => array( - 'host' => '127.0.0.1', - 'user' => 'root', - 'enabled' => true, - ), - 's3_settings' => array( - 'enabled' => false, - ), - ), - ), - ), - ), - ), - ); - - - $this->assertProcessedConfigurationEquals($expectedConfiguration, array(__DIR__.'/../Fixtures/'.$path)); - } - - public function getSupportsAllConfigFormatsData() - { - return array( - 'yml' => array('config/config.yml'), - 'php' => array('config/config.php'), - 'xml' => array('config/config.xml') - ); - } -} + 'app.configurator.custom', + 'assets_path' => '/assets', + 'loader' => 'fm_elfinder.loader.default', + 'instances' => array( + 'default' => array( + 'locale' => 'en', + 'editor' => 'tinymce', + 'theme' => 'smoothness', + 'editor_template' => 'Elfinder/editor.html.twig', + 'fullscreen' => false, + 'include_assets' => false, + 'cors_support' => false, + 'tinymce_popup_path' => '/pop-up', + 'relative_path' => false, + 'path_prefix' => '/', + 'connector' => array( + 'debug' => true, + 'binds' => array(), + 'plugins' => array(), + 'roots' => array( + 'uploads' => array( + 'driver' => 'LocalFileSystem', + 'volume_id' => 0, + 'disabled_commands' => array(), + 'plugins' => array(), + 'path' => 'uploads', + 'show_hidden' => true, + 'flysystem' => array( + 'enabled' => false, + 'type' => '', + ), + 'start_path' => '', + 'url' => '', + 'mime_detect' => 'auto', + 'mimefile' => '', + 'img_lib' => 'auto', + 'tmb_path' => '.tmb', + 'tmb_url' => '', + 'tmb_size' => 48, + 'tmb_crop' => true, + 'tmb_bg_color' => '#ffffff', + 'tmb_path_mode' => 511, + 'copy_overwrite' => true, + 'copy_join' => true, + 'copy_from' => true, + 'copy_to' => true, + 'upload_overwrite' => true, + 'attributes' => array( + 'some_pattern' => array( + 'pattern' => '/^some_pattern$/', + 'read' => true, + 'write' => true, + 'locked' => false, + 'hidden' => false, + ), + ), + 'accepted_name' => '/^\w[\w\s\.\%\-]*$/u', + 'check_subfolders' => true, + 'separator' => DIRECTORY_SEPARATOR, + 'date_format' => 'j M Y H:i', + 'time_format' => 'H:i', + 'archive_mimes' => array(), + 'archivers' => array(), + 'glide_url' => '', + 'glide_key' => '', + 'alias' => 'foo', + 'tree_deep' => 1, + 'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'), + 'upload_order' => array('deny', 'allow'), + 'defaults' => array('read' => true, 'write' => true), + 'upload_deny' => array('all'), + 'upload_max_size' => 0, + 'dropbox_settings' => array( + 'consumer_key' => 'some_consumer', + 'consumer_secret' => 'con$umer', + 'enabled' => true, + ), + 'ftp_settings' => array( + 'host' => '127.0.0.1', + 'user' => 'root', + 'enabled' => true, + ), + 's3_settings' => array( + 'enabled' => false, + ), + ), + ), + ), + ), + ), + ); + + $this->assertProcessedConfigurationEquals($expectedConfiguration, array(__DIR__.'/../Fixtures/'.$path)); + } + + public function getSupportsAllConfigFormatsData() + { + return array( + 'yml' => array('config/config.yml'), + 'php' => array('config/config.php'), + 'xml' => array('config/config.xml'), + ); + } +} diff --git a/Tests/DependencyInjection/ConfigurationTest.php b/Tests/DependencyInjection/ConfigurationTest.php index 0387921..7743733 100644 --- a/Tests/DependencyInjection/ConfigurationTest.php +++ b/Tests/DependencyInjection/ConfigurationTest.php @@ -1,28 +1,26 @@ -assertConfigurationIsInvalid( - array( - array() - ) - ); - } - -} - +assertConfigurationIsInvalid( + array( + array(), + ) + ); + } +} diff --git a/Tests/DependencyInjection/FMElfinderExtensionTest.php b/Tests/DependencyInjection/FMElfinderExtensionTest.php index 9610ab9..2552723 100644 --- a/Tests/DependencyInjection/FMElfinderExtensionTest.php +++ b/Tests/DependencyInjection/FMElfinderExtensionTest.php @@ -12,7 +12,7 @@ class FMElfinderExtensionTest extends AbstractExtensionTestCase protected function getContainerExtensions() { return array( - new FMElfinderExtension() + new FMElfinderExtension(), ); } @@ -26,19 +26,17 @@ public function testServices() } /** - * @return void */ public function testMinimumConfiguration() { $this->container = new ContainerBuilder(); - $loader = new FMElfinderExtension(); + $loader = new FMElfinderExtension(); $loader->load(array($this->getMinimalConfiguration()), $this->container); $this->assertTrue($this->container instanceof ContainerBuilder); } protected function getMinimalConfiguration() { - $yaml = <<parse($yaml); } - } diff --git a/Tests/Event/ElFinderPostExecutionEventTest.php b/Tests/Event/ElFinderPostExecutionEventTest.php index 7db47f4..ea08d47 100644 --- a/Tests/Event/ElFinderPostExecutionEventTest.php +++ b/Tests/Event/ElFinderPostExecutionEventTest.php @@ -10,9 +10,9 @@ class ElFinderPostExecutionEventTest extends TestCase { public function testHasErrors() { - $request = new Request(); + $request = new Request(); $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $event = new ElFinderPostExecutionEvent($request, $httpKernel, 'testInstance', 'testHomeFolder', array()); + $event = new ElFinderPostExecutionEvent($request, $httpKernel, 'testInstance', 'testHomeFolder', array()); $this->assertEquals(false, $event->hasErrors()); $event = new ElFinderPostExecutionEvent($request, $httpKernel, 'testInstance', 'testHomeFolder', array('error' => true)); diff --git a/Tests/Event/ElFinderPreExecutionEventTest.php b/Tests/Event/ElFinderPreExecutionEventTest.php index dabd6e3..8471546 100644 --- a/Tests/Event/ElFinderPreExecutionEventTest.php +++ b/Tests/Event/ElFinderPreExecutionEventTest.php @@ -10,25 +10,25 @@ class ElFinderPreExecutionEventTest extends TestCase { public function testGetCommand() { - $command = 'rm'; - $request = new Request(array('cmd' => $command)); + $command = 'rm'; + $request = new Request(array('cmd' => $command)); $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); - $event = new ElFinderPreExecutionEvent($request, $httpKernel, 'testInstance', 'testHomeFolder'); + $event = new ElFinderPreExecutionEvent($request, $httpKernel, 'testInstance', 'testHomeFolder'); $this->assertEquals($command, $event->getCommand()); } public function testSubRequest() { - $request = new Request(array('cmd' => 'info')); + $request = new Request(array('cmd' => 'info')); $httpKernel = $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'); $httpKernel ->expects($this->once()) ->method('handle'); $event = new ElFinderPreExecutionEvent($request, $httpKernel, 'testInstance', 'testHomeFolder'); - + $jsonResponse = $event->subRequest(array( - 'instance' => $event->getInstance(), - 'homeFolder' => $event->getHomeFolder() + 'instance' => $event->getInstance(), + 'homeFolder' => $event->getHomeFolder(), ), $request->query->all()); } } diff --git a/Tests/Fixtures/config/config.php b/Tests/Fixtures/config/config.php index 64ff2b6..c581b57 100644 --- a/Tests/Fixtures/config/config.php +++ b/Tests/Fixtures/config/config.php @@ -1,49 +1,49 @@ -loadFromExtension('fm_elfinder', array( - 'configuration_provider' => 'app.configurator.custom', - 'instances' => array( - 'default' => array( - 'locale' => 'en', - 'cors_support' => false, - 'editor' => 'tinymce', - 'editor_template' => 'Elfinder/editor.html.twig', - 'fullscreen' => false, - 'include_assets' => false, - 'tinymce_popup_path' => '/pop-up', - 'relative_path' => false, - 'connector' => array( - 'debug' => true, - 'roots' => array( - 'uploads' => array( - 'driver' => 'LocalFileSystem', - 'path' => 'uploads', - 'show_hidden' => true, - 'alias' => 'foo', - 'tree_deep' => 1, - 'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'), - 'upload_deny' => array('all'), - 'upload_max_size' => 0, - 'dropbox_settings' => array( - 'consumer_key' => 'some_consumer', - 'consumer_secret' => 'con$umer', - ), - 'ftp_settings' => array( - 'host' => '127.0.0.1', - 'user' => 'root', - ), - 'attributes' => array( - 'some_pattern' => array( - 'pattern' => '/^some_pattern$/', - 'read' => true, - 'write' => true, - 'locked' => false, - 'hidden' => false, - ) - ), - ), - ), - ), - ), - ), -)); +loadFromExtension('fm_elfinder', array( + 'configuration_provider' => 'app.configurator.custom', + 'instances' => array( + 'default' => array( + 'locale' => 'en', + 'cors_support' => false, + 'editor' => 'tinymce', + 'editor_template' => 'Elfinder/editor.html.twig', + 'fullscreen' => false, + 'include_assets' => false, + 'tinymce_popup_path' => '/pop-up', + 'relative_path' => false, + 'connector' => array( + 'debug' => true, + 'roots' => array( + 'uploads' => array( + 'driver' => 'LocalFileSystem', + 'path' => 'uploads', + 'show_hidden' => true, + 'alias' => 'foo', + 'tree_deep' => 1, + 'upload_allow' => array('image/png', 'image/jpg', 'image/jpeg'), + 'upload_deny' => array('all'), + 'upload_max_size' => 0, + 'dropbox_settings' => array( + 'consumer_key' => 'some_consumer', + 'consumer_secret' => 'con$umer', + ), + 'ftp_settings' => array( + 'host' => '127.0.0.1', + 'user' => 'root', + ), + 'attributes' => array( + 'some_pattern' => array( + 'pattern' => '/^some_pattern$/', + 'read' => true, + 'write' => true, + 'locked' => false, + 'hidden' => false, + ), + ), + ), + ), + ), + ), + ), +)); diff --git a/Tests/Loader/ElFinderLoaderTest.php b/Tests/Loader/ElFinderLoaderTest.php index 71ae83c..b2b51c8 100644 --- a/Tests/Loader/ElFinderLoaderTest.php +++ b/Tests/Loader/ElFinderLoaderTest.php @@ -1,37 +1,34 @@ -configuratorMock = $this->getMock('FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface'); - $this->configuratorMock->expects($this->any()) - ->method('getConfiguration') - ->will($this->returnValue(array('parameters'=>array()))); - $this->loader = new ElFinderLoader($this->configuratorMock); - $this->loader->setInstance('minimal'); - } - - public function testConfigure() - { - $this->loader->configure(); - $this->assertEquals(array('parameters'=>array()), $this->configuratorMock->getConfiguration('minimal')); - } -} \ No newline at end of file +configuratorMock = $this->getMock('FM\ElfinderBundle\Model\ElFinderConfigurationProviderInterface'); + $this->configuratorMock->expects($this->any()) + ->method('getConfiguration') + ->will($this->returnValue(array('parameters' => array()))); + $this->loader = new ElFinderLoader($this->configuratorMock); + $this->loader->setInstance('minimal'); + } + + public function testConfigure() + { + $this->loader->configure(); + $this->assertEquals(array('parameters' => array()), $this->configuratorMock->getConfiguration('minimal')); + } +} diff --git a/Tests/Twig/Extension/FMElfinderExtensionTest.php b/Tests/Twig/Extension/FMElfinderExtensionTest.php index 67cbe89..009cbf3 100644 --- a/Tests/Twig/Extension/FMElfinderExtensionTest.php +++ b/Tests/Twig/Extension/FMElfinderExtensionTest.php @@ -1,153 +1,151 @@ -twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array(__DIR__.'/../../../Resources/views/Elfinder/helper'))); - $this->extension = new FMElfinderExtension($this->twig); - $this->twig->addExtension($this->extension); - $loader = new YamlFileLoader(new FileLocator(__DIR__ . '/../../../Resources/config')); - $routes = new RouteCollection(); - $collection = $loader->load('routing.yml'); - $routes->addCollection($collection); - $this->twig->addExtension(new RoutingExtension(new UrlGenerator($routes, new RequestContext()))); - } - - - public function testRenderTinyMCE3() - { - $this->template = $this->twig->loadTemplate('_tinymce.html.twig'); - $testData = $this->renderTemplate(array('instance' => 'minimal')); - - $expected = << - // - -EOF; - - $this->assertSame($this->normalizeOutput($expected), $this->normalizeOutput($testData)); - } - - public function testRenderTinyMCE4() - { - $this->template = $this->twig->loadTemplate('_tinymce4.html.twig'); - $testData = $this->renderTemplate(array('instance' => 'minimal')); - - $expected = << - function elFinderBrowser (field_name, url, type, win) { - tinymce.activeEditor.windowManager.open({ - file:"http://localhost/elfinder/minimal", - title:"", - width:, - height:, - resizable: 'yes' - }, { - setUrl: function (url) { - win.document.getElementById(field_name).value = url; - } - }); - return false; - } - -EOF; - - $this->assertSame($this->normalizeOutput($expected), $this->normalizeOutput($testData)); - } - - /** - * - */ - public function testName() - { - $this->assertEquals('fm_elfinder_init', $this->extension->getName()); - } - - /** - * {@inheritdoc} - */ - protected function tearDown() - { - unset($this->template); - unset($this->twig); - } - - /** - * {@inheritdoc} - */ - protected function renderTemplate(array $context = array()) - { - return $this->template->render($context); - } - - /** - * Normalizes the output by removing the heading whitespaces. - * - * @param string $output The output. - * - * @return string The normalized output. - */ - protected function normalizeOutput($output) - { - return preg_replace( "/\r|\n/", "", str_replace(PHP_EOL, '', str_replace(' ', '', $output))); - } - - /** - * - */ - public function testSubClassOfTwigExtension() - { - $rc = new \ReflectionClass('FM\ElfinderBundle\Twig\Extension\FMElfinderExtension'); - - $this->assertTrue($rc->isSubclassOf('Twig_Extension')); - } -} +twig = new \Twig_Environment(new \Twig_Loader_Filesystem(array(__DIR__.'/../../../Resources/views/Elfinder/helper'))); + $this->extension = new FMElfinderExtension($this->twig); + $this->twig->addExtension($this->extension); + $loader = new YamlFileLoader(new FileLocator(__DIR__.'/../../../Resources/config')); + $routes = new RouteCollection(); + $collection = $loader->load('routing.yml'); + $routes->addCollection($collection); + $this->twig->addExtension(new RoutingExtension(new UrlGenerator($routes, new RequestContext()))); + } + + public function testRenderTinyMCE3() + { + $this->template = $this->twig->loadTemplate('_tinymce.html.twig'); + $testData = $this->renderTemplate(array('instance' => 'minimal')); + + $expected = << + // + +EOF; + + $this->assertSame($this->normalizeOutput($expected), $this->normalizeOutput($testData)); + } + + public function testRenderTinyMCE4() + { + $this->template = $this->twig->loadTemplate('_tinymce4.html.twig'); + $testData = $this->renderTemplate(array('instance' => 'minimal')); + + $expected = << + function elFinderBrowser (field_name, url, type, win) { + tinymce.activeEditor.windowManager.open({ + file:"http://localhost/elfinder/minimal", + title:"", + width:, + height:, + resizable: 'yes' + }, { + setUrl: function (url) { + win.document.getElementById(field_name).value = url; + } + }); + return false; + } + +EOF; + + $this->assertSame($this->normalizeOutput($expected), $this->normalizeOutput($testData)); + } + + /** + * + */ + public function testName() + { + $this->assertEquals('fm_elfinder_init', $this->extension->getName()); + } + + /** + * {@inheritdoc} + */ + protected function tearDown() + { + unset($this->template); + unset($this->twig); + } + + /** + * {@inheritdoc} + */ + protected function renderTemplate(array $context = array()) + { + return $this->template->render($context); + } + + /** + * Normalizes the output by removing the heading whitespaces. + * + * @param string $output The output. + * + * @return string The normalized output. + */ + protected function normalizeOutput($output) + { + return preg_replace("/\r|\n/", '', str_replace(PHP_EOL, '', str_replace(' ', '', $output))); + } + + /** + * + */ + public function testSubClassOfTwigExtension() + { + $rc = new \ReflectionClass('FM\ElfinderBundle\Twig\Extension\FMElfinderExtension'); + + $this->assertTrue($rc->isSubclassOf('Twig_Extension')); + } +} diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 1209aaf..faa5eea 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -1,6 +1,7 @@ array('html')); + $options = array('is_safe' => array('html')); return array( new \Twig_SimpleFunction('elfinder_tinymce_init', array($this, 'tinymce'), $options), new \Twig_SimpleFunction('elfinder_tinymce_init4', array($this, 'tinymce4'), $options), - new \Twig_SimpleFunction('elfinder_summernote_init', array($this, 'summernote'), $options) + new \Twig_SimpleFunction('elfinder_summernote_init', array($this, 'summernote'), $options), ); } /** * @param string $instance - * @param array $parameters + * @param array $parameters + * * @throws \Twig_Error_Runtime + * * @return mixed */ public function tinymce($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) @@ -54,14 +55,16 @@ public function tinymce($instance = 'default', $parameters = array('width' => 90 'instance' => $instance, 'width' => $parameters['width'], 'height' => $parameters['height'], - 'title' => $parameters['title'] + 'title' => $parameters['title'], )); } /** * @param string $instance - * @param array $parameters + * @param array $parameters + * * @throws \Twig_Error_Runtime + * * @return mixed */ public function tinymce4($instance = 'default', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) @@ -75,14 +78,16 @@ public function tinymce4($instance = 'default', $parameters = array('width' => 9 'instance' => $instance, 'width' => $parameters['width'], 'height' => $parameters['height'], - 'title' => $parameters['title'] + 'title' => $parameters['title'], )); } /** * @param string $instance - * @param array $parameters + * @param array $parameters + * * @throws \Twig_Error_Runtime + * * @return mixed */ public function summernote($instance = 'default', $selector = '.summenote', $parameters = array('width' => 900, 'height' => 450, 'title' => 'elFinder 2.0')) @@ -97,17 +102,17 @@ public function summernote($instance = 'default', $selector = '.summenote', $par 'selector' => $selector, 'width' => $parameters['width'], 'height' => $parameters['height'], - 'title' => $parameters['title'] + 'title' => $parameters['title'], )); } /** - * (non-PHPdoc) + * (non-PHPdoc). + * * @see Twig_ExtensionInterface::getName() */ public function getName() { return 'fm_elfinder_init'; } - } From b9b50fbd3d3e9c22c7b573e6e90d4c2320e121a1 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Fri, 25 Sep 2015 01:19:32 +1000 Subject: [PATCH 12/14] removed unused interface --- Model/ElFinderPermissionsInterface.php | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 Model/ElFinderPermissionsInterface.php diff --git a/Model/ElFinderPermissionsInterface.php b/Model/ElFinderPermissionsInterface.php deleted file mode 100644 index 2a970e1..0000000 --- a/Model/ElFinderPermissionsInterface.php +++ /dev/null @@ -1,26 +0,0 @@ - Date: Fri, 25 Sep 2015 01:22:52 +1000 Subject: [PATCH 13/14] tests against 7.0 --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a93fc0c..1d00e86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,13 +4,14 @@ php: - 5.4 - 5.5 - 5.6 + - 7.0 - hhvm matrix: allow_failures: - php: - - 5.6 - hhvm + - 7.0 fast_finish: true install: From ebddc2cdff121e8d5d55153433b44cab09b83255 Mon Sep 17 00:00:00 2001 From: Al Ganiev Date: Fri, 25 Sep 2015 01:42:43 +1000 Subject: [PATCH 14/14] summenote section --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 7b91267..3145919 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Recommended bundles to use with: * [TinymceBundle](https://github.com/stfalcon/TinymceBundle/) * [IvoryCKEditorBundle](https://github.com/egeloen/IvoryCKEditorBundle/) * [TrsteelCkeditorBundle](https://github.com/trsteel88/TrsteelCkeditorBundle/) +* [FMSummernoteBundle](https://github.com/helios-ag/summernote-bundle/) @@ -50,6 +51,8 @@ Recommended bundles to use with: - [TinyMCE integration](#tinymce-integration) - [Integration with TinyMCE 3](#tinymce-3x) - [Integration with TinyMCE 4](#tinymce-4x) +- [Summernote integration](#summernote-integration) + - [Advanced configuration](#advanced-configuration) - [Custom configuration provider](#custom-configuration-provider) - [Custom loader](#custom-loader) @@ -522,6 +525,26 @@ as shown below instance_name is instance of elfinder configuration +## Summernote integration + +Update the editor property in your app/config.yml +Set Summernote editor type: + +```yaml +fm_elfinder: + editor: summernote +``` + +Edit template that contains summernote instance (the same way as for tinymce) + +```jinja + {{ elfinder_summernote_init('instance_name') }} + {{ summernote_init() }} +``` + +Don't forget to enable elfinder plugin in summernote configuration. + + # Advanced configuration ## Custom configuration provider