-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetGalleryPagination.php
54 lines (33 loc) · 1.16 KB
/
getGalleryPagination.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
require_once 'assets/config/config.php';
require_once "vendor/autoload.php";
use PhotoTech\ErrorHandler;
use PhotoTech\Database;
use PhotoTech\ImageContentManager;
$errorHandler = new ErrorHandler();
// Register the exception handler method
set_exception_handler([$errorHandler, 'handleException']);
$database = new Database();
$pdo = $database->createPDO();
$args = [];
$gallery = new ImageContentManager($pdo, $args);
/**
* @throws JsonException
*/
function main(): array {
return json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR);
}
$database_data = []; // Set a default value for $database_data
$database_data = main(); // Call the function to execute your code and get the decoded JSON data
$per_page = (int) $database_data['per_page']; // Total number of records to be displayed:
/* Grab the offset (page) location from using the offset method */
$database_data['offset'] = $per_page * ((int) $database_data['current_page'] - 1);
output($database_data);
function output($output): void
{
http_response_code(200);
try {
echo json_encode($output, JSON_THROW_ON_ERROR);
} catch (JsonException) {
}
}