removed pagination from Pages API request, added API request for tags

pull/84/head
Ro 3 years ago
parent 65def75433
commit 8417e692d7

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

@ -5,7 +5,7 @@ use function _\remove;
class Settings class Settings
{ {
private $folks; private $folks;
private $tags; private static $tags;
private $themes = []; private $themes = [];
private static $settings; private static $settings;
@ -13,7 +13,7 @@ class Settings
{ {
//gets all settings files and converts to php objects //gets all settings files and converts to php objects
$this->folks = json_decode(file_get_contents("../config/folks.json"), true); $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( self::$settings = json_decode(
file_get_contents("../config/settings.json"), file_get_contents("../config/settings.json"),
true true
@ -123,6 +123,11 @@ class Settings
return self::$settings; return self::$settings;
} }
public static function getTags()
{
return self::$tags;
}
public static function updateGlobalData($key, $data) public static function updateGlobalData($key, $data)
{ {
$settings = self::$settings; $settings = self::$settings;

Loading…
Cancel
Save