résolution anomalies widget fichier (ref #239)
This commit is contained in:
parent
49e2527337
commit
81f4614680
|
@ -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]);
|
||||
$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]);
|
||||
$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,7 +211,7 @@ 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',[
|
||||
|
@ -286,13 +313,16 @@ class FileController extends Controller
|
|||
}
|
||||
else {
|
||||
$fs->rename($urlsource,$urldestination,true);
|
||||
$fs->touch($urldestination);
|
||||
|
||||
$urlsource= $fulldirectory."/thumb/".$oldname;
|
||||
$urldestination = $fulldirectory."/thumb/".$data["subdirectory"];
|
||||
if($fs->exists($urlsource))
|
||||
$fs->rename($urlsource,$urldestination,true);
|
||||
|
||||
$urlsource= $fulldirectory."/thumbmini/".$oldname;
|
||||
$urldestination = $fulldirectory."/thumbmini/".$data["subdirectory"];
|
||||
if($fs->exists($urlsource))
|
||||
$fs->rename($urlsource,$urldestination,true);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,20 +74,47 @@
|
|||
{% endif %}
|
||||
</a>
|
||||
|
||||
{% 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 %}
|
||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'subdirectory':subdirectory,'sort':action }) }}" type="button" class="btn btn-primary">
|
||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'subdirectory':subdirectory,'sort':'name', 'order':action }) }}" type="button" class="btn btn-primary {{active}}">
|
||||
{% else %}
|
||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'sort':action }) }}" type="button" class="btn btn-primary">
|
||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'sort':'name', 'order':action }) }}" type="button" class="btn btn-primary {{active}}">
|
||||
{% endif %}
|
||||
{% if sort=="name" %}
|
||||
{% if order=="SORT_ASC" %}
|
||||
<i class="fas fa-long-arrow-alt-down"></i> Nom
|
||||
{% else %}
|
||||
<i class="fas fa-long-arrow-alt-up"></i> Nom
|
||||
{% endif %}
|
||||
</a>
|
||||
|
||||
{% 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 %}
|
||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'subdirectory':subdirectory,'sort':'date', 'order':action }) }}" type="button" class="btn btn-primary {{active}}">
|
||||
{% else %}
|
||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'sort':'date', 'order':action }) }}" type="button" class="btn btn-primary {{active}}">
|
||||
{% endif %}
|
||||
{% if order=="SORT_ASC" %}
|
||||
<i class="fas fa-long-arrow-alt-down"></i> Date
|
||||
{% else %}
|
||||
<i class="fas fa-long-arrow-alt-up"></i> Date
|
||||
{% endif %}
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue