|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
<?php
|
|
|
|
|
use function _\filter;
|
|
|
|
|
|
|
|
|
|
class PagesAPI
|
|
|
|
|
{
|
|
|
|
@ -9,16 +10,24 @@ class PagesAPI
|
|
|
|
|
public static function getPageContent($request, $args)
|
|
|
|
|
{
|
|
|
|
|
$task = $args["fourth"];
|
|
|
|
|
|
|
|
|
|
$content = (new Book("../content/pages"))->getContents();
|
|
|
|
|
switch ($task) {
|
|
|
|
|
case "published":
|
|
|
|
|
$pageNum = $args["fifth"];
|
|
|
|
|
$result = (new Book("../content/pages"))->getPages($pageNum, 4, $task);
|
|
|
|
|
//$pageNum = $args["fifth"]; not not needed but gonna keep remnant in case it becomes useful/needed
|
|
|
|
|
$published = filter($content, function ($item) {
|
|
|
|
|
return $item["published"] == true && $item["deleted"] == false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$result = ["pages" => $published, "totalPages" => count($published)];
|
|
|
|
|
//$result = (new Book("../content/pages"))->getPages($pageNum, 4, $task);
|
|
|
|
|
break;
|
|
|
|
|
case "single":
|
|
|
|
|
$uuid = $args["fifth"];
|
|
|
|
|
$result = (new Book("../content/pages"))->findPageById($uuid);
|
|
|
|
|
break;
|
|
|
|
|
case "tags":
|
|
|
|
|
$result = Settings::getTags();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
$result = [
|
|
|
|
|
"message" => "Hm, no task. That's unfortunate",
|
|
|
|
|