Commit cd532333 authored by Théo GUILLON's avatar Théo GUILLON
Browse files

Correction : récupération dans l'ordre de dépot des fichiers

parent 9bc39f2f
......@@ -122,9 +122,12 @@ class FichesController extends AppController
if (in_array($mime, $accepted) === true) {
move_uploaded_file($tmpFile, $path);
$allTmpFiles = $files = $this->scan_dir($dir);
$last_key_file = key(array_slice( $allTmpFiles, -1, 1, true ));
$selectType = '';
if (!empty($typages)) {
$selectType = '<div class="form-group"><label for="typage_'.$key.'" class="col-md-4 control-label"></label><div class="col-md-8"><select name="data[Fichier][typage_'.$key.']" id="typage_'.$key.'" class="form-control">'
$selectType = '<div class="form-group"><label for="typage_'.$last_key_file.'" class="col-md-4 control-label"></label><div class="col-md-8"><select name="data[Fichier][typage_'.$last_key_file.']" id="typage_'.$last_key_file.'" class="form-control">'
. '<option value="">Séléctionnez un type pour le fichier</option>';
foreach ($typages as $val => $typage) {
$selectType = $selectType . '<option value="' . $val . '">' . $typage . '</option>';
......@@ -212,6 +215,22 @@ class FichesController extends AppController
}
}
private function scan_dir($dir) {
$ignored = ['.', '..', '.svn', '.htaccess'];
$files = [];
foreach (scandir($dir) as $file) {
if (in_array($file, $ignored)) continue;
$files[$file] = filemtime($dir . '/' . $file);
}
// ksort($files);
asort($files);
$files = array_keys($files);
return ($files) ? $files : [];
}
/**
* Gère l'ajout de fiches
*
......@@ -232,7 +251,9 @@ class FichesController extends AppController
}
if (empty($this->Session->read($this->Session->read('Auth.User.uuid')))) {
$files = array_diff(scandir(CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid')), array('..', '.'));
$dir = CHEMIN_PIECE_JOINT_TMP . $this->Session->read('Auth.User.id') . DS . $this->Session->read('Auth.User.uuid');
$files = $this->scan_dir($dir);
$this->set('files', $files);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment