-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetGalleryImages.php
More file actions
53 lines (38 loc) · 1.22 KB
/
Copy pathgetGalleryImages.php
File metadata and controls
53 lines (38 loc) · 1.22 KB
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
<?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);
$database_data = [];
/*
* The below must be used in order for the json to be decoded properly.
*/
try {
$database_data = json_decode(file_get_contents('php://input'), true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
}
/*
* Grab the data from the CMS class method *static*
* and put the data into an array variable.
*/
$send = $gallery->page((int)$database_data['per_page'], (int)$database_data['offset'], 'gallery', $database_data['category']);
//$cms = CMS::getImages('blog', $database_data['category']);
// add a carriage return to the text
$send['content'] = str_replace("\n", "<br>", $send['content']);
output($send);
function output($output): void
{
http_response_code(200);
try {
echo json_encode($output, JSON_THROW_ON_ERROR);
} catch (JsonException) {
}
}