You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
<?php
|
|
|
|
|
|
|
|
class PagesAPI
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getPageContent($request, $args)
|
|
|
|
{
|
|
|
|
$task = $args["fourth"];
|
|
|
|
|
|
|
|
switch ($task) {
|
|
|
|
case "published":
|
|
|
|
$pageNum = $args["fifth"];
|
|
|
|
$result = (new Book("../content/pages"))->getPages($pageNum, 4, $task);
|
|
|
|
break;
|
|
|
|
case "single":
|
|
|
|
$uuid = $args["fifth"];
|
|
|
|
$result = (new Book("../content/pages"))->findPageById($uuid);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$result = [
|
|
|
|
"message" => "Hm, no task. That's unfortunate",
|
|
|
|
"type" => "TASK_NONE",
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function handlePageTask($request, $args)
|
|
|
|
{
|
|
|
|
$task = $args["fourth"];
|
|
|
|
switch ($task) {
|
|
|
|
case "delete":
|
|
|
|
case "create":
|
|
|
|
case "write":
|
|
|
|
$result = (new Book("../content/pages"))->editPage($task, $request);
|
|
|
|
break;
|
|
|
|
case "add-entry-image":
|
|
|
|
$result = ImagesAPI::uploadImage($request);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$result = [
|
|
|
|
"message" => "Hm, no task. That's unfortunate",
|
|
|
|
"type" => "TASK_NONE",
|
|
|
|
];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
}
|