2018-04-04 23:46:36 +02:00
|
|
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
|
2018-04-13 23:32:29 +02:00
|
|
|
// $_POST
|
2018-04-09 22:56:12 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2018-04-13 23:32:29 +02:00
|
|
|
// (integer) $_POST['pageNumber'] > 0
|
2018-10-06 19:39:34 +02:00
|
|
|
$pageNumber = empty($_POST['pageNumber']) ? 1 : (int)$_POST['pageNumber'];
|
2018-04-04 23:46:36 +02:00
|
|
|
$pageNumber = $pageNumber - 1;
|
|
|
|
|
2018-04-13 23:32:29 +02:00
|
|
|
// (string) $_POST['path']
|
2018-10-06 19:39:34 +02:00
|
|
|
$path = empty($_POST['path']) ? false : $_POST['path'];
|
|
|
|
|
|
|
|
// (string) $_POST['uuid']
|
|
|
|
$uuid = empty($_POST['uuid']) ? false : $_POST['uuid'];
|
2018-04-09 22:56:12 +02:00
|
|
|
// ----------------------------------------------------------------------------
|
2018-10-06 19:39:34 +02:00
|
|
|
|
|
|
|
// Set the path to get the file list
|
2018-08-10 15:41:23 +02:00
|
|
|
if ($path=='thumbnails') {
|
2018-10-06 19:39:34 +02:00
|
|
|
if ($uuid && IMAGE_RESTRICT) {
|
|
|
|
$path = PATH_UPLOADS_PAGES.$uuid.DS.'thumbnails'.DS;
|
|
|
|
} else {
|
|
|
|
$path = PATH_UPLOADS_THUMBNAILS;
|
|
|
|
}
|
2018-08-10 15:41:23 +02:00
|
|
|
} else {
|
2019-01-30 23:15:36 +01:00
|
|
|
ajaxResponse(1, 'Invalid path.');
|
2018-04-13 23:32:29 +02:00
|
|
|
}
|
|
|
|
|
2018-04-09 22:56:12 +02:00
|
|
|
// Get all files from the directory $path, also split the array by numberOfItems
|
2018-10-06 19:39:34 +02:00
|
|
|
// The function listFiles split in chunks
|
|
|
|
$listOfFilesByPage = Filesystem::listFiles($path, '*', '*', $GLOBALS['MEDIA_MANAGER_SORT_BY_DATE'], $GLOBALS['MEDIA_MANAGER_NUMBER_OF_FILES']);
|
2018-04-04 23:46:36 +02:00
|
|
|
|
|
|
|
// Check if the page number exists in the chunks
|
|
|
|
if (isset($listOfFilesByPage[$pageNumber])) {
|
|
|
|
|
2018-04-09 22:56:12 +02:00
|
|
|
// Get only the filename from the chunk
|
2018-10-06 19:39:34 +02:00
|
|
|
$files = array();
|
2018-04-04 23:46:36 +02:00
|
|
|
foreach ($listOfFilesByPage[$pageNumber] as $file) {
|
2018-10-06 19:39:34 +02:00
|
|
|
$filename = basename($file);
|
|
|
|
array_push($files, $filename);
|
2018-04-04 23:46:36 +02:00
|
|
|
}
|
|
|
|
|
2018-08-06 21:46:58 +02:00
|
|
|
// Returns the number of chunks for the paginator
|
2018-04-09 22:56:12 +02:00
|
|
|
// Returns the files inside the chunk
|
2019-01-30 23:15:36 +01:00
|
|
|
ajaxResponse(0, 'List of files and number of chunks.', array(
|
2018-04-04 23:46:36 +02:00
|
|
|
'numberOfPages'=>count($listOfFilesByPage),
|
2018-10-06 19:39:34 +02:00
|
|
|
'files'=>$files
|
2019-01-30 23:15:36 +01:00
|
|
|
));
|
2018-04-04 23:46:36 +02:00
|
|
|
}
|
|
|
|
|
2019-01-30 23:15:36 +01:00
|
|
|
ajaxResponse(1, 'Chunks out of index');
|
2018-04-04 23:46:36 +02:00
|
|
|
|
|
|
|
?>
|