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 ecc88a6b..8a515970 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Controller/FileController.php @@ -26,6 +26,7 @@ class FileController extends Controller $clear=$request->get("clear"); $view=$request->get("view"); $sort=$request->get("sort"); + $order=$request->get("order"); $defaultview=$request->get("defaultview"); // Récupérer les préférences utilisateur @@ -68,7 +69,7 @@ class FileController extends Controller $preference["widgetviewdirectory"][$directory]=$view; } - // Prérence trie + // Préférence trie if(!array_key_exists("widgetsortdirectory",$preference)) { $toupdate=true; $preference["widgetsortdirectory"]=[]; @@ -82,6 +83,21 @@ class FileController extends Controller $preference["widgetsortdirectory"][$directory]=$sort; } + // Préférence order + if(!array_key_exists("widgetorderdirectory",$preference)) { + $toupdate=true; + $preference["widgetorderdirectory"]=[]; + } + if((!array_key_exists($directory,$preference["widgetorderdirectory"]))) { + $toupdate=true; + $preference["widgetorderdirectory"][$directory]="SORT_ASC"; + } + if($sort&&$preference["widgetorderdirectory"][$directory]!=$order) { + $toupdate=true; + $preference["widgetorderdirectory"][$directory]=$order; + } + + // Mise à jour des préferences if($toupdate) { $em = $this->getDoctrine()->getManager(); @@ -115,17 +131,21 @@ class FileController extends Controller if(is_dir($file)) { $tmp=[]; $tmp["name"]=$file->getRelativePathname(); + $tmp["namesort"]=strtolower($tmp["name"]); $tmp["date"]=date ("d/m/Y H:i", filemtime($file)); + $tmp["datesort"] = date ("YmdHi", filemtime($file)); array_push($dirs,$tmp); } else { $tmp=[]; $tmp["name"]=$file->getRelativePathname(); + $tmp["namesort"]=strtolower($tmp["name"]); $tmp["extension"]=strtolower($file->getExtension()); $fileinfo = new file($file->getPathname()); $tmp["minetype"]=$fileinfo->getMimeType(); $tmp["minefamily"]=explode("/",$tmp["minetype"])[0]; $tmp["date"] = date ("d/m/Y H:i", filemtime($file)); + $tmp["datesort"] = date ("YmdHi", filemtime($file)); $tmp["thumb"]=""; if($tmp["extension"]=="pdf") { @@ -153,11 +173,17 @@ class FileController extends Controller if(stripos($subdirectory,"_trash")==1) $fgtrash=true; // Trie du tableu - $sort = array_column($files, $preference["widgetsortdirectory"][$directory]); - array_multisort($sort, SORT_ASC, $files); + $sort = array_column($files, $preference["widgetsortdirectory"][$directory]."sort"); + if($preference["widgetorderdirectory"][$directory]=="SORT_ASC") + array_multisort($sort, SORT_ASC, $files); + else + array_multisort($sort, SORT_DESC, $files); - $sort = array_column($dirs, $preference["widgetsortdirectory"][$directory]); - array_multisort($sort, SORT_ASC, $dirs); + $sort = array_column($dirs, $preference["widgetsortdirectory"][$directory]."sort"); + if($preference["widgetorderdirectory"][$directory]=="SORT_ASC") + array_multisort($sort, SORT_ASC, $dirs); + else + array_multisort($sort, SORT_DESC, $dirs); return $this->render('CadolesCoreBundle:File:list.html.twig',[ 'useheader' => false, @@ -175,6 +201,7 @@ class FileController extends Controller 'canadd' => $canupdate, 'view' => $preference["widgetviewdirectory"][$directory], 'sort' => $preference["widgetsortdirectory"][$directory], + 'order' => $preference["widgetorderdirectory"][$directory], 'fgtrash' => $fgtrash, ]); } @@ -184,9 +211,9 @@ class FileController extends Controller $canupdate =$this->getPermission($access,$id); if(!$canupdate) throw $this->createNotFoundException('Permission denied'); - $subdirectory=$request->get("subdirectory"); + $subdirectory=urldecode($request->get("subdirectory")); $forcereload=(is_null($request->get("forcereload"))?true:$request->get("forcereload")); - + return $this->render('CadolesCoreBundle:File:upload.html.twig',[ 'useheader' => false, 'usemenu' => false, @@ -286,14 +313,17 @@ class FileController extends Controller } else { $fs->rename($urlsource,$urldestination,true); + $fs->touch($urldestination); $urlsource= $fulldirectory."/thumb/".$oldname; $urldestination = $fulldirectory."/thumb/".$data["subdirectory"]; - $fs->rename($urlsource,$urldestination,true); + if($fs->exists($urlsource)) + $fs->rename($urlsource,$urldestination,true); $urlsource= $fulldirectory."/thumbmini/".$oldname; $urldestination = $fulldirectory."/thumbmini/".$data["subdirectory"]; - $fs->rename($urlsource,$urldestination,true); + if($fs->exists($urlsource)) + $fs->rename($urlsource,$urldestination,true); } $toclose=true; 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 index dfdfa354..dbfa22bb 100644 --- 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 @@ -74,20 +74,47 @@ {% endif %} + {% set active="" %} {% if sort=="name" %} - {%set action="date" %} + {% set active="active" %} + {%endif%} + + {% if order=="SORT_ASC" %} + {%set action="SORT_DESC" %} {% else %} - {%set action="name" %} + {%set action="SORT_ASC" %} {% endif %} {% if not subdirectory is empty %} - + {% else %} - + {% endif %} - {% if sort=="name" %} + {% if order=="SORT_ASC" %} Nom {% else %} + Nom + {% endif %} + + + {% set active="" %} + {% if sort=="date" %} + {% set active="active" %} + {%endif%} + + {% if order=="SORT_ASC" %} + {%set action="SORT_DESC" %} + {% else %} + {%set action="SORT_ASC" %} + {% endif %} + {% if not subdirectory is empty %} + + {% else %} + + {% endif %} + {% if order=="SORT_ASC" %} Date + {% else %} + Date {% endif %} diff --git a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/upload.html.twig b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/upload.html.twig index 3878b1d6..3a8c052f 100644 --- a/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/upload.html.twig +++ b/src/ninegate-1.0/src/Cadoles/CoreBundle/Resources/views/File/upload.html.twig @@ -23,7 +23,7 @@ init: function() { this.on("sending", function(file, xhr, formData) { formData.append("directory", "{{ id }}"); - formData.append("subdirectory", "{{ subdirectory }}"); + formData.append("subdirectory", "{{ subdirectory|raw }}"); }); var totalFiles = 0;