|
|
|
<?php
|
|
|
|
use function _\find;
|
|
|
|
class Settings
|
|
|
|
{
|
|
|
|
private $folks;
|
|
|
|
private $tags;
|
|
|
|
private static $settings;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
//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::$settings = json_decode(
|
|
|
|
file_get_contents("../config/settings.json"),
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getFolks($key = null)
|
|
|
|
{
|
|
|
|
if (isset($key)) {
|
|
|
|
$member = Session::get("member");
|
|
|
|
$found = find($this->folks, ["handle" => $member["handle"]]);
|
|
|
|
return $found[$key];
|
|
|
|
} else {
|
|
|
|
return $this->folks;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getCurrentIndex()
|
|
|
|
{
|
|
|
|
$settings = self::$settings;
|
|
|
|
return $settings["library_stats"]["current_index"];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function updateIndex()
|
|
|
|
{
|
|
|
|
$settings = self::$settings;
|
|
|
|
$index = $settings["library_stats"]["current_index"];
|
|
|
|
$settings["library_stats"]["current_index"] = $index + 1;
|
|
|
|
|
|
|
|
DocTools::writeSettings("../config/settings.json", $settings);
|
|
|
|
}
|
|
|
|
}
|