trie sur widget fichier
This commit is contained in:
parent
9947b7db23
commit
ea2af3b861
|
@ -25,6 +25,7 @@ class FileController extends Controller
|
||||||
$subdirectory=$request->get("subdirectory");
|
$subdirectory=$request->get("subdirectory");
|
||||||
$clear=$request->get("clear");
|
$clear=$request->get("clear");
|
||||||
$view=$request->get("view");
|
$view=$request->get("view");
|
||||||
|
$sort=$request->get("sort");
|
||||||
$defaultview=$request->get("defaultview");
|
$defaultview=$request->get("defaultview");
|
||||||
|
|
||||||
// Récupérer en session le dernier subdirectory visité
|
// Récupérer en session le dernier subdirectory visité
|
||||||
|
@ -53,6 +54,14 @@ class FileController extends Controller
|
||||||
$sessionviewdirectory[$directory] = $view;
|
$sessionviewdirectory[$directory] = $view;
|
||||||
$this->get('session')->set('sessionviewdirectory',$sessionviewdirectory);
|
$this->get('session')->set('sessionviewdirectory',$sessionviewdirectory);
|
||||||
|
|
||||||
|
// Récupérer en session le trie
|
||||||
|
$sessionviewsort = $this->get('session')->get('sessionviewsort');
|
||||||
|
if(!is_array($sessionviewsort)) $sessionviewsort=[$sort=>"name"];
|
||||||
|
if(!array_key_exists($directory,$sessionviewsort)) $sessionviewsort[$directory]="name";
|
||||||
|
if($sort)
|
||||||
|
$sessionviewsort[$directory] = $sort;
|
||||||
|
$this->get('session')->set('sessionviewsort',$sessionviewsort);
|
||||||
|
|
||||||
|
|
||||||
// Construire le chemin réel
|
// Construire le chemin réel
|
||||||
$iddirectory=explode("-",$directory)[1];
|
$iddirectory=explode("-",$directory)[1];
|
||||||
|
@ -79,6 +88,7 @@ class FileController extends Controller
|
||||||
if(is_dir($file)) {
|
if(is_dir($file)) {
|
||||||
$tmp=[];
|
$tmp=[];
|
||||||
$tmp["name"]=$file->getRelativePathname();
|
$tmp["name"]=$file->getRelativePathname();
|
||||||
|
$tmp["date"]=date ("d/m/Y H:i", filemtime($file));
|
||||||
array_push($dirs,$tmp);
|
array_push($dirs,$tmp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -88,6 +98,7 @@ class FileController extends Controller
|
||||||
$fileinfo = new file($file->getPathname());
|
$fileinfo = new file($file->getPathname());
|
||||||
$tmp["minetype"]=$fileinfo->getMimeType();
|
$tmp["minetype"]=$fileinfo->getMimeType();
|
||||||
$tmp["minefamily"]=explode("/",$tmp["minetype"])[0];
|
$tmp["minefamily"]=explode("/",$tmp["minetype"])[0];
|
||||||
|
$tmp["date"] = date ("d/m/Y H:i", filemtime($file));
|
||||||
|
|
||||||
$tmp["thumb"]="";
|
$tmp["thumb"]="";
|
||||||
if($tmp["extension"]=="pdf") {
|
if($tmp["extension"]=="pdf") {
|
||||||
|
@ -110,6 +121,13 @@ class FileController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Trie du tableu
|
||||||
|
$sort = array_column($files, $sessionviewsort[$directory]);
|
||||||
|
array_multisort($sort, SORT_ASC, $files);
|
||||||
|
|
||||||
|
$sort = array_column($dirs, $sessionviewsort[$directory]);
|
||||||
|
array_multisort($sort, SORT_ASC, $dirs);
|
||||||
|
|
||||||
return $this->render('CadolesCoreBundle:File:list.html.twig',[
|
return $this->render('CadolesCoreBundle:File:list.html.twig',[
|
||||||
'useheader' => false,
|
'useheader' => false,
|
||||||
'usemenu' => false,
|
'usemenu' => false,
|
||||||
|
@ -125,6 +143,7 @@ class FileController extends Controller
|
||||||
'canupdate' => $canupdate,
|
'canupdate' => $canupdate,
|
||||||
'canadd' => $canupdate,
|
'canadd' => $canupdate,
|
||||||
'view' => $sessionviewdirectory[$directory],
|
'view' => $sessionviewdirectory[$directory],
|
||||||
|
'sort' => $sessionviewsort[$directory],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,14 +11,21 @@
|
||||||
|
|
||||||
.grid .grid-list .grid-item-title h2 {
|
.grid .grid-list .grid-item-title h2 {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 22px;
|
line-height: 18px;
|
||||||
height: 22px;
|
height: 18px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.grid .grid-list .grid-item-title {
|
||||||
|
padding:0px 0px 0px 5px;
|
||||||
|
line-height: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.grid-item-title h2 {
|
.grid-item-title h2 {
|
||||||
text-transform: initial !important;
|
text-transform: initial !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block pagewrapper %}
|
{% block pagewrapper %}
|
||||||
|
@ -43,19 +50,34 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
{%set action="small" %}
|
{%set action="small" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if not subdirectory is empty %}
|
{% if not subdirectory is empty %}
|
||||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'subdirectory':subdirectory,'view':action }) }}" type="button" class="btn btn-primary">
|
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'subdirectory':subdirectory,'view':action }) }}" type="button" class="btn btn-primary">
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'view':action }) }}" type="button" class="btn btn-primary">
|
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'view':action }) }}" type="button" class="btn btn-primary">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if view=="small" %}
|
{% if view=="small" %}
|
||||||
<i class="fas fa-list"></i>
|
<i class="fas fa-list"></i>
|
||||||
{% else %}
|
{% else %}
|
||||||
<i class="fas fa-th"></i>
|
<i class="fas fa-th"></i>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
|
{% if sort=="name" %}
|
||||||
|
{%set action="date" %}
|
||||||
|
{% else %}
|
||||||
|
{%set action="name" %}
|
||||||
|
{% 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">
|
||||||
|
{% else %}
|
||||||
|
<a href="{{ path('cadoles_core_'~access~'_file_list',{'directory':directory,'clear':true,'sort':action }) }}" type="button" class="btn btn-primary">
|
||||||
|
{% endif %}
|
||||||
|
{% if sort=="name" %}
|
||||||
|
<i class="fas fa-sort-alpha-down"></i>
|
||||||
|
{% else %}
|
||||||
|
<i class="fas fa-sort-numeric-down"></i>
|
||||||
|
{% endif %}
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -87,7 +109,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% for dir in dirs|sort %}
|
{% for dir in dirs %}
|
||||||
<div class="grid-item grid-{{view}}">
|
<div class="grid-item grid-{{view}}">
|
||||||
<div class="grid-item-content">
|
<div class="grid-item-content">
|
||||||
{% if canadd %}
|
{% if canadd %}
|
||||||
|
@ -108,7 +130,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid-item-title">
|
<div class="grid-item-title">
|
||||||
<h2>{{ dir.name }}</h2>
|
<h2>{{ dir.name }}</h2>{% if view=="list" %}<small>le {{ dir.date }}</small>{%endif%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
@ -116,7 +138,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for file in files|sort %}
|
{% for file in files %}
|
||||||
<div class="grid-item grid-{{view}}">
|
<div class="grid-item grid-{{view}}">
|
||||||
<div class="grid-item-content">
|
<div class="grid-item-content">
|
||||||
{% if canadd %}
|
{% if canadd %}
|
||||||
|
@ -140,7 +162,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="grid-item-title">
|
<div class="grid-item-title">
|
||||||
<h2>{{ file.name }}</h2>
|
<h2>{{ file.name }}</h2>{% if view=="list" %}<small>le {{ file.date }}</small>{%endif%}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
|
|
Loading…
Reference in New Issue