<?php

/* 
 * Copyright (C) 2022 Echedey López Romero <elr@disroot.org>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

$DefaultConfig = [
    'url' => '',
    'token' => '',
    'path' => '/Blog',
    'title' => 'My Blog',
    'users_path' => '/users',
    'comments_path' => '/comments',
    'posts_path' => '/posts'
];

$Config = json_decode(file_get_contents('./data/config.json'), true);

$URL = isset($Config['url']) ? $Config['url'] : $DefaultConfig['url'];
$Token = isset($Config['token']) ? $Config['token'] : $DefaultConfig['token'];
$Path = isset($Config['path']) ? $Config['path'] : $DefaultConfig['path'];
$Title = isset($Config['title']) ? $Config['title'] : $DefaultConfig['title'];
$UsersPath = isset($Config['users_path']) ? $Config['users_path'] : $DefaultConfig['users_path'];
$CommentsPath = isset($Config['comments_path']) ? $Config['comments_path'] : $DefaultConfig['comments_path'];
$PostsPath = isset($Config['posts_path']) ? $Config['posts_path'] : $DefaultConfig['posts_path'];

$Connection = FirebaseCon::GetInstance($URL, $Token, $Path);

$ManageUsers = ManageUsers::GetInstance($Connection, $UsersPath);
$ManageComments = ManageComments::GetInstance($Connection, $CommentsPath);
$ManagePosts = ManagePosts::GetInstance($Connection, $PostsPath);

$ManageBlog = ManageBlog::GetInstance($Title, $ManageUsers, $ManageComments, $ManagePosts);

$Page = 'No content here';
