214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
* $listLength représente la longueur d'items de la pagination à génerer
*
* @param int $current
* @param int $total
* @param int $bypage
* @param int $listLength
* @param bool $showLast Toggle l'affichage du dernier élément de la pagination
* @return array
*/
public static function getGenericPagination($current, $total, $bypage, $listLength=11, $showLast = true)
{
if ($total <= $bypage)
return false;
$total = ceil($total / $bypage);
if ($total < $current)
return false;
$length = ($listLength / 2);
$begin = $current - ceil($length);
if ($begin < 1)
{
$begin = 1;
|
|
|
|
|
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
* $listLength représente la longueur d'items de la pagination à génerer
*
* @param int $current
* @param int $total
* @param int $bypage
* @param int $listLength
* @param bool $showLast Toggle l'affichage du dernier élément de la pagination
* @return array|null
*/
public static function getGenericPagination($current, $total, $bypage, $listLength=11, $showLast = true)
{
if ($total <= $bypage)
return null;
$total = ceil($total / $bypage);
if ($total < $current)
return null;
$length = ($listLength / 2);
$begin = $current - ceil($length);
if ($begin < 1)
{
$begin = 1;
|
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
static public function safe_unlink($path)
{
if (!@unlink($path))
{
return true;
}
if (!file_exists($path))
{
return true;
}
throw new \RuntimeException(sprintf('Impossible de supprimer le fichier %s: %s', $path, error_get_last()));
|
|
|
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
|
static public function safe_unlink($path)
{
if (!@unlink($path))
{
return true;
}
if (!file_exists($path))
{
return true;
}
throw new \RuntimeException(sprintf('Impossible de supprimer le fichier %s: %s', $path, error_get_last()));
|
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
return Security::getRandomPassphrase(ROOT . '/include/data/dictionary.fr');
}
static public function checkIBAN($value)
{
// Enlever les caractères indésirables (espaces, tirets),
$value = preg_replace('/[^A-Z0-9]/', '', strtoupper($value));
// Supprimer les 4 premiers caractères et les replacer à la fin du compte
$value = substr($value, 4) . substr($value, 0, 4);
// Remplacer les lettres par des chiffres au moyen d'une table de conversion (A=10, B=11, C=12 etc.)
$value = str_replace(range('A', 'Z'), range(10, 35), $value);
// Diviser le nombre ainsi obtenu par 97
|
|
|
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
return Security::getRandomPassphrase(ROOT . '/include/data/dictionary.fr');
}
static public function checkIBAN($value)
{
// Enlever les caractères indésirables (espaces, tirets),
$value = preg_replace('/[^A-Z0-9]/', '', strtoupper($value));
// Supprimer les 4 premiers caractères et les replacer à la fin du compte
$value = substr($value, 4) . substr($value, 0, 4);
// Remplacer les lettres par des chiffres au moyen d'une table de conversion (A=10, B=11, C=12 etc.)
$value = str_replace(range('A', 'Z'), range(10, 35), $value);
// Diviser le nombre ainsi obtenu par 97
|
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
|
case 'G': case 'g': return (int)$size_str * pow(1024, 3);
case 'M': case 'm': return (int)$size_str * pow(1024, 2);
case 'K': case 'k': return (int)$size_str * 1024;
default: return $size_str;
}
}
static public function format_bytes($size) {
if ($size > (1024 * 1024))
return str_replace('.', ',', round($size / 1024 / 1024, 2)) . ' Mo';
elseif ($size > 1024)
return str_replace('.', ',', round($size / 1024, 2)) . ' Ko';
else
return $size . ' o';
}
static public function deleteRecursive($path)
{
if (!file_exists($path))
|
|
>
|
|
|
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
case 'G': case 'g': return (int)$size_str * pow(1024, 3);
case 'M': case 'm': return (int)$size_str * pow(1024, 2);
case 'K': case 'k': return (int)$size_str * 1024;
default: return $size_str;
}
}
static public function format_bytes($size)
{
if ($size > (1024 * 1024))
return number_format(round($size / 1024 / 1024, 2), 2, ',', '') . ' Mo';
elseif ($size > 1024)
return round($size / 1024) . ' Ko';
else
return $size . ' o';
}
static public function deleteRecursive($path)
{
if (!file_exists($path))
|