diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php index c1af414c..ee6d9317 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php @@ -16,6 +16,83 @@ use Symfony\Component\HttpFoundation\File\File; class FileController extends Controller { + + public function listAction($directory,Request $request,$access="config") { + $canupdate= $this->getPermission($access,$directory); + $subdirectory=$request->get("subdirectory"); + + $iddirectory=explode("-",$directory)[1]; + $fulldirectory=$this->get('kernel')->getRootDir()."/../uploads/file/".$directory."/".$subdirectory; + + $parents=null; + $dirname="Home"; + if($subdirectory) { + $parents=explode("/",$subdirectory); + $dirname=end($parents); + array_pop($parents); + } + + $files=[]; + $dirs=[]; + $fs = new Filesystem(); + + if($fs->exists($fulldirectory)) { + $finder = new Finder(); + $finder->depth('== 0')->sortByName()->in($fulldirectory)->exclude('thumb')->exclude('thumbmini'); + + foreach ($finder as $file) { + if(is_dir($file)) { + $tmp=[]; + $tmp["name"]=$file->getRelativePathname(); + array_push($dirs,$tmp); + } + else { + $tmp=[]; + $tmp["name"]=$file->getRelativePathname(); + $tmp["extension"]=strtolower($file->getExtension()); + $fileinfo = new file($file->getPathname()); + $tmp["minetype"]=$fileinfo->getMimeType(); + $tmp["minefamily"]=explode("/",$tmp["minetype"])[0]; + + $tmp["thumb"]=""; + if($tmp["extension"]=="pdf") { + $tmp["thumb"]="/".$this->getParameter('alias')."/bundles/cadolescore/images/files/".$tmp["extension"].".png"; + } + elseif($fs->exists($fulldirectory."/thumbmini/".$tmp["name"])) { + $data = file_get_contents($fulldirectory."/thumbmini/".$tmp["name"]); + $tmp["thumb"]="data:image/" . $tmp["extension"] . ";base64," . base64_encode($data); + } + elseif($fs->exists($fulldirectory."/thumb/".$tmp["name"])) { + $data = file_get_contents($fulldirectory."/thumb/".$tmp["name"]); + $tmp["thumb"]="data:image/" . $tmp["extension"] . ";base64," . base64_encode($data); + } + elseif($fs->exists($this->get('kernel')->getRootDir()."/../web/bundles/cadolescore/images/files/".$tmp["extension"].".png")) { + $tmp["thumb"]="/".$this->getParameter('alias')."/bundles/cadolescore/images/files/".$tmp["extension"].".png"; + } + + array_push($files,$tmp); + } + } + } + + return $this->render('CadolesCoreBundle:File:list.html.twig',[ + 'useheader' => true, + 'usemenu' => false, + 'usesidebar' => false, + 'access' => $access, + 'iddirectory' => $iddirectory, + 'directory' => $directory, + 'parents' => $parents, + 'subdirectory' => $subdirectory, + 'dirname' => $dirname, + 'dirs' => $dirs, + 'files' => $files, + 'canupdate' => $canupdate, + 'canadd' => $canupdate, + 'colorbodyfont' => "000000", + ]); + } + public function uploadAction($id,$type,$access="config") { return $this->render('CadolesCoreBundle:File:upload.html.twig',[ @@ -194,5 +271,8 @@ class FileController extends Controller break; } } + else $canupdate=true; + + return $canupdate; } } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml index f5fc4b9a..7242080f 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/config/routing.yml @@ -57,6 +57,10 @@ cadoles_core_crop02: #== File ================================================================================================================= #-- Access config +cadoles_core_config_file_list: + path: /config/file/list/{directory} + defaults: { _controller: CadolesCoreBundle:File:list, access: config } + cadoles_core_config_file_upload: path: /config/file/upload/{id}/{type} defaults: { _controller: CadolesCoreBundle:File:upload, access: config } @@ -78,6 +82,10 @@ cadoles_core_config_file_download: defaults: { _controller: CadolesCoreBundle:File:download, access: config } #-- Access user +cadoles_core_user_file_list: + path: /user/file/list/{directory} + defaults: { _controller: CadolesCoreBundle:File:list, access: user } + cadoles_core_user_file_upload: path: /user/file/upload/{id}/{type} defaults: { _controller: CadolesCoreBundle:File:upload, access: user } @@ -87,15 +95,15 @@ cadoles_core_user_file_delete: defaults: { _controller: CadolesCoreBundle:File:delete, access: user } cadoles_core_user_file_view: - path: file/view/{directory}/{filename} + path: /user/file/view/{directory}/{filename} defaults: { _controller: CadolesCoreBundle:File:view, access: user } cadoles_core_user_file_download: - path: file/download/{directory}/{filename} + path: /user/file/download/{directory}/{filename} defaults: { _controller: CadolesCoreBundle:File:download, access: user } cadoles_core_user_file_show: - path: file/show/{directory}/{filename} + path: /user/file/show/{directory}/{filename} defaults: { _controller: CadolesCoreBundle:File:show, access: user } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css index 1ac0964a..3c1583bd 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/css/style.css @@ -291,7 +291,9 @@ span.item-drag { position: relative; display: block; } - +.grid-sizer { + display: none !important; +} .grid-item .grid-item-content { /*height: 100%;*/ } diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/images/files/dir.png b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/images/files/dir.png new file mode 100644 index 00000000..9f7319f4 Binary files /dev/null and b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/images/files/dir.png differ diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/list.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/list.html.twig new file mode 100644 index 00000000..4dcbe91d --- /dev/null +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/list.html.twig @@ -0,0 +1,162 @@ +{% extends '@CadolesCore/base.html.twig' %} + +{% block pagewrapper %} + +
+ + + + + +
+
+
+ + + + {% for dir in dirs|sort %} +
+
+ {% if canadd %} + + + + {% endif %} + + {% if subdirectory is empty %} + {% set link = dir.name %} + {% else %} + {% set link = subdirectory~"/"~dir.name %} + {% endif %} + + + +
+
+ {% endfor %} + + {% for file in files|sort %} +
+
+ {% if canadd %} + + + + {% endif %} + + {% if file.minefamily=="text" or file.minefamily=="image" or file.minetype == "application/pdf" %} + + {% else %} + + {% endif %} + + +
+
+ {% endfor %} +
+
+{% endblock %} + + +{% block localjavascript %} + var optiongrid={columnWidth: '.grid-sizer',itemSelector: '.grid-item', gutter: '.grid-gutter-sizer'}; + + // Création des grilles d'items + $('body').imagesLoaded(function() { + var grid = $('.grid').masonry(optiongrid); + }); + + // Supprimer un fichier + function delFile(directory,filename) { + var r = confirm("Confirmez-vous la suppression de ce fichier ?"); + if (r == true) { + $.ajax({ + method: "POST", + url: "{{ path('cadoles_core_'~access~'_file_delete') }}", + data: { + directory:directory, + filename:filename + }, + success: function() { + location.reload(); + } + }); + } + } + + // Affichage des frames associés aux items de bureau + function showFrameitem(id,url,forcereload) { + $("#explorer").hide(); + $("body").css("overflow-y","hidden"); + + if($("#frameitem-"+id).length) { + if(forcereload) { + $("#frameitem-"+id).attr("src",url); + } + $("#frameitem-"+id).show(); + } + else { + $("#explorer").before(""); + } + } +{% endblock %} + + +