<?php

use CodeIgniter\Router\RouteCollection;

/* Entry routes */
$routes->get("/entries/(:alphanum)", "EntryController::GetEntries/$1");
$routes->post("/entry/(:num)", "EntryController::PostEntry/$1");
$routes->delete("/entry/(:num)", "EntryController::DeleteEntry/$1");
$routes->get("/entry/find", "EntryController::SearchFunction");
$routes->get("/entry", "EntryController::GetEntry");

/* User routes */
$routes->post("/user", "UserController::CreateUser");
$routes->post("/user/login", "UserController::LogInUser");
$routes->get("/user/session", "UserController::CheckSession");
$routes->post("/user/logout", "UserController::EndSession");
$routes->get("/user/permissions", "UserController::CheckUserPermissions");

/* Topic routes */
$routes->get("/topics", "TopicController::GetPublicTopics");
$routes->post("/topic", "TopicController::CreateTopic");
$routes->get("/topic/permissions", "TopicController::GetTopicPermissions");
$routes->get("/topic/(:alphanum)", "TopicController::GetTopic/$1");
$routes->get("/title/(:alphanum)", "TopicController::GetTitle/$1");
$routes->post("/topic/(:alphanum)", "TopicController::UpdateTopic/$1");

/* Permission routes */
$routes->get("/permissions/topic", "PermissionController::GetTopicPerms");
$routes->put("/permissions/topic", "PermissionController::UpdateTopicPerms");
$routes->get("/permissions/users", "PermissionController::GetUsers");
$routes->post("/permissions/user", "PermissionController::PostUser");
$routes->put("/permissions/user/(:num)", "PermissionController::PutUser/$1");
$routes->delete("/permissions/user/(:num)", "PermissionController::DeleteUser/$1");

/* File routes */
$routes->get("/(:alphanum)/load/(:segment)", "FilesController::LoadFile/$1/$2");
$routes->get("/files/(:alphanum)", "FilesController::GetTopicFiles/$1");
$routes->get("/file/(:segment)", "FilesController::GetFile/$1");
$routes->post("/file/(:num)", "FilesController::PostFile/$1");
$routes->delete("/file/(:num)", "FilesController::DeleteFile/$1");

/* Error routes */
$routes->get("/error", "TransferController::ErrorPage");

/* Transfer routes */
$routes->get("/", "TransferController::Index");
$routes->get("/create_account", "TransferController::ViewCreateAccountPage");
$routes->get("/log_in", "TransferController::ViewLogInPage");
$routes->get("/topic_form", "TransferController::ViewTopicFormPage");
$routes->get("/user", "TransferController::ViewUserPage");
$routes->get("/(:alphanum)/Page:Main", "TransferController::ViewTopic/$1");
$routes->get("/(:alphanum)/Page:Search", "TransferController::SearchPage/$1");
$routes->get("/(:alphanum)/Page:Admin", "TransferController::AdminPanel/$1");
$routes->get("/(:alphanum)/Page:Entries", "TransferController::EntriesPage/$1");
$routes->get("/(:alphanum)/Page:Files", "TransferController::FilesPage/$1");
$routes->get("/(:alphanum)/Page:Create", "TransferController::CreateEntryPage/$1");
$routes->get("/(:alphanum)/File:Upload", "TransferController::FileUploadPage/$1");
$routes->get("/(:alphanum)/File:(:segment)", "TransferController::ViewFile/$1");
$routes->get("/(:alphanum)/(:segment)", "TransferController::ViewEntry/$1");

$routes->set404Override(function() {
    return view("errors/error404.html");
});