forked from projects/fipamo
removed pagination from Pages API request, added API request for tags
This commit is contained in:
parent
65def75433
commit
8417e692d7
2 changed files with 19 additions and 5 deletions
|
@ -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",
|
||||
|
|
|
@ -5,7 +5,7 @@ use function _\remove;
|
|||
class Settings
|
||||
{
|
||||
private $folks;
|
||||
private $tags;
|
||||
private static $tags;
|
||||
private $themes = [];
|
||||
private static $settings;
|
||||
|
||||
|
@ -13,7 +13,7 @@ class Settings
|
|||
{
|
||||
//gets all settings files and converts to php objects
|
||||
$this->folks = json_decode(file_get_contents("../config/folks.json"), true);
|
||||
$this->tags = json_decode(file_get_contents("../config/tags.json"), true);
|
||||
self::$tags = json_decode(file_get_contents("../config/tags.json"), true);
|
||||
self::$settings = json_decode(
|
||||
file_get_contents("../config/settings.json"),
|
||||
true
|
||||
|
@ -123,6 +123,11 @@ class Settings
|
|||
return self::$settings;
|
||||
}
|
||||
|
||||
public static function getTags()
|
||||
{
|
||||
return self::$tags;
|
||||
}
|
||||
|
||||
public static function updateGlobalData($key, $data)
|
||||
{
|
||||
$settings = self::$settings;
|
||||
|
|
Loading…
Reference in a new issue