From 4f9ce5fba79aeb8a3efc39379697ef8e56d66b68 Mon Sep 17 00:00:00 2001 From: afornerot Date: Fri, 11 Sep 2020 17:02:46 +0200 Subject: [PATCH] debut explore de fichier --- .../CoreBundle/Controller/FileController.php | 80 +++++++++ .../CoreBundle/Resources/config/routing.yml | 14 +- .../CoreBundle/Resources/public/css/style.css | 4 +- .../Resources/public/images/files/dir.png | Bin 0 -> 4587 bytes .../Resources/views/File/list.html.twig | 162 ++++++++++++++++++ 5 files changed, 256 insertions(+), 4 deletions(-) create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/public/images/files/dir.png create mode 100644 src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/list.html.twig 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 0000000000000000000000000000000000000000..9f7319f4dc8e1a55dce88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2a}C!PQauVtfN>T?K(5rw$``?}*F zM!K#~@peY8A5&gL(V_1KguLRn9FtOn8MBNgye7J?9IKhk#NLCtcZ^Jmslbehv8`1T z7gZYeu0C7eBWnK)q;UQ5k6P3huRK6G4f$2x>b=mwBR*KaZy;WxB6OF{`NBl`$!_jD zRx+|;%#pKWWZmVk! zGKOGyMNp3Hcwmo*^ZFtjzb`K3gnxg%5jWm2Fy9uKxsqN~LT?+Tu<|r@1j5pzA%RHq zRV}`Dey`wx=`+Ov|2fk$>ZZNtjz5lUvYFR;IV?3sj;L>N%Fb`80vP#Z?~P{e&KmZt zoo60+SI#)kKzX0J$shv>0x^ALbJJT_g8$drsAt66693bkJI|is7xB_BtbA4ZsMZJd z9>GnKm(T_24ce>XSwXulIgCPv5~79oJ7ca*lQR4wzN_vzPP(qS{od?un)#vkrbV{8 z?VD?(+l7sopZ&kMZ@E*77msQ``1Nh50lnVO1oqRe3~cV!`c#gQ??&ZXB+UIWn#rTr zbQ1{fB;Q3#LV>9X(C4Aalf1V}{yKFvkVfk7&CwOdy|PEr)>=CGZ56z{)JG@;PpLZY zyzued3x21(rd_LCKak4C&2H3VEQx;~QOTYi(Mz^;>!RSko$ny0$=rSol6x($9#c&t zMwTOdvK=%a@y*O$!&td1BpPIOEBu*uy$5L<{PQHgtJAO<<6km?bO#B;MNTTM2V(d*uMZB!cQ9j literal 0 HcmV?d00001 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 %} + + +