mirror of
https://koodu.h-i.works/projects/thebadspace
synced 2025-06-25 16:04:37 -05:00
CSS Reshuffle, Added Page Renderer
Reorganized the CSS structure to there is some seperation between front facing style and the backend den. Also add the Render class so auth status is included in every template rendering event so login status and select member data is available if needed. will expand if needed.
This commit is contained in:
@ -10,30 +10,18 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
//use App\Utils\PageRender;
|
||||
use App\Service\Auth;
|
||||
use App\Service\Render;
|
||||
|
||||
class Index extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/den", name="back-index")
|
||||
*/
|
||||
public function enterTheDen(Request $request, Auth $auth, RequestStack $requestStack): Response
|
||||
public function enterTheDen(Request $request, Auth $auth, RequestStack $requestStack, Render $render): Response
|
||||
{
|
||||
if ($request->getMethod() == "GET") {
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
$session = $requestStack->getSession();
|
||||
$member = $session->get("member");
|
||||
return $this->render("back/start.twig", [
|
||||
"title" => "Welcome Back",
|
||||
"handle" => $member->getHandle()
|
||||
]);
|
||||
} else {
|
||||
return $this->render("back/index.twig", [
|
||||
"title" => "Close the door behind you",
|
||||
]);
|
||||
}
|
||||
return $render->page([], "This is the Den", "back/index.twig");
|
||||
} else {
|
||||
//handles login
|
||||
$handle = $request->request->get("handle");
|
||||
|
@ -13,10 +13,9 @@ use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use App\Service\HandleLocations;
|
||||
use Doctrine\DBAL\Connection;
|
||||
//use App\Utils\PageRender;
|
||||
//use App\Utils\StringTools;
|
||||
use App\Service\Auth;
|
||||
use App\Service\FileUploader;
|
||||
use App\Service\Render;
|
||||
|
||||
class Locations extends AbstractController
|
||||
{
|
||||
@ -39,6 +38,7 @@ class Locations extends AbstractController
|
||||
HandleLocations $locations,
|
||||
ManagerRegistry $doctrine,
|
||||
Connection $connection,
|
||||
Render $render,
|
||||
string $pageNum
|
||||
): Response {
|
||||
$result = $auth->status();
|
||||
@ -48,15 +48,7 @@ class Locations extends AbstractController
|
||||
$list = $locations->getLocationsPage($pageNum);
|
||||
|
||||
//$search = $connection->fetchAllAssociative("SELECT * FROM searchlocations('agenda')");
|
||||
|
||||
//var_dump($search[0]["name"]);
|
||||
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations",
|
||||
"handle" => $member->getHandle(),
|
||||
"list" => $list,
|
||||
"mode" => "index"
|
||||
]);
|
||||
return $render->page(["list" => $list, "mode" => "index"], "Bad Space | Locations", "back/locations.twig");
|
||||
} else {
|
||||
return $this->render("back/index.twig", [
|
||||
"title" => "Close the door behind you",
|
||||
@ -65,27 +57,41 @@ class Locations extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/den/locations/add", name="location-add")
|
||||
* @Route("/den/locations/modify/{action}/{uuid}", name="location-modify")
|
||||
*/
|
||||
public function addLocation(
|
||||
public function modifyLocation(
|
||||
Request $request,
|
||||
Auth $auth,
|
||||
HandleLocations $locations,
|
||||
ManagerRegistry $doctrine,
|
||||
FileUploader $uploader
|
||||
FileUploader $uploader,
|
||||
Render $render,
|
||||
string $action = "add",
|
||||
string $uuid = "001"
|
||||
): Response {
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
if ($request->getMethod() == "GET") {
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"mode" => "add"
|
||||
]);
|
||||
$options = [];
|
||||
if ($action == 'add') {
|
||||
return $render->page(
|
||||
["mode" => $action],
|
||||
"Bad Space | Locations | Add",
|
||||
"back/locations.twig"
|
||||
);
|
||||
} else {
|
||||
$location = $locations->getLocationbyUUID($uuid);
|
||||
return $render->page(
|
||||
["mode" => $action, "location" => $location[0]],
|
||||
"Bad Space | Locations | Edit",
|
||||
"back/locations.twig"
|
||||
);
|
||||
}
|
||||
} else {
|
||||
//add new member
|
||||
$token = $request->get("token");
|
||||
$notice = "";
|
||||
$entityManager = $doctrine->getManager();
|
||||
$token = $request->get("token");
|
||||
$notice = "";
|
||||
$mode = $request->get("mode");
|
||||
|
||||
//token check
|
||||
if (!$this->isCsrfTokenValid("upload", $token)) {
|
||||
@ -100,16 +106,6 @@ class Locations extends AbstractController
|
||||
);
|
||||
}
|
||||
|
||||
$examples = [];
|
||||
$files = $request->files->get("loc_examples");
|
||||
if (!empty($files)) {
|
||||
for ($i = 0; $i < count($files); $i++) {
|
||||
$path = $files[$i]->getClientOriginalName();
|
||||
array_push($examples, ["image_index" => $i, "path" => urlencode($path)]);
|
||||
$uploader->uploadExamples("../public/assets/images/examples", $files[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
$request->request->get("loc_name") == "" ||
|
||||
$request->request->get("loc_url") == "" ||
|
||||
@ -124,20 +120,40 @@ class Locations extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
//check clear, call add method
|
||||
$response = $locations->addLocation($request, $result["id"]);
|
||||
//once everything clears, upload images and process request
|
||||
$examples = [];
|
||||
$files = $request->files->get("loc_examples");
|
||||
if (!empty($files)) {
|
||||
for ($i = 0; $i < count($files); $i++) {
|
||||
$path = $files[$i]->getClientOriginalName();
|
||||
array_push($examples, ["image_index" => $i, "path" => urlencode($path)]);
|
||||
$uploader->uploadExamples("../public/assets/images/examples", $files[$i]);
|
||||
}
|
||||
}
|
||||
$response = $locations->modifyLocation($request, $result["id"], $mode, $request->request->get("uuid"));
|
||||
if ($response["status"]) {
|
||||
$notice = "New location added! Take a break.";
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"notice" => $notice,
|
||||
"mode" => "add"
|
||||
]);
|
||||
$options = [];
|
||||
if ($mode == 'add') {
|
||||
$options = [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"notice" => $response["message"],
|
||||
"mode" => $mode
|
||||
];
|
||||
} else {
|
||||
$location = $locations->getLocationbyUUID($request->request->get("uuid"));
|
||||
$options = [
|
||||
"title" => "Bad Space | Locations | Edit",
|
||||
"mode" => $mode,
|
||||
"notice" => $response["message"],
|
||||
"location" => $location[0]
|
||||
];
|
||||
}
|
||||
return $this->render("back/locations.twig", $options);
|
||||
} else {
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Add",
|
||||
"title" => "Bad Space | Locations | Error",
|
||||
"notice" => $response["message"],
|
||||
"mode" => "add"
|
||||
"mode" => $mode
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -156,15 +172,17 @@ class Locations extends AbstractController
|
||||
Auth $auth,
|
||||
HandleLocations $locations,
|
||||
ManagerRegistry $doctrine,
|
||||
FileUploader $uploader
|
||||
FileUploader $uploader,
|
||||
Render $render
|
||||
): Response {
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
if ($request->getMethod() == "GET") {
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Bulk Add",
|
||||
"mode" => "bulk-add"
|
||||
]);
|
||||
return $render->page(
|
||||
["mode" => "bulk-add"],
|
||||
"Bad Space | Locations | Bulk Add",
|
||||
"back/locations.twig"
|
||||
);
|
||||
} else {
|
||||
// do posting stuff
|
||||
$token = $request->get("token");
|
||||
@ -227,29 +245,4 @@ class Locations extends AbstractController
|
||||
return new Response("<html><body>LOGGED IN</body></html>");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/den/locations/edit/{uuid}", name="location-edit")
|
||||
*/
|
||||
public function editLocation(
|
||||
Request $request,
|
||||
Auth $auth,
|
||||
HandleLocations $locations,
|
||||
ManagerRegistry $doctrine,
|
||||
FileUploader $uploader,
|
||||
string $uuid = "1"
|
||||
): Response {
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
$location = $locations->getLocationbyUUID($uuid);
|
||||
return $this->render("back/locations.twig", [
|
||||
"title" => "Bad Space | Locations | Edit",
|
||||
"mode" => "edit",
|
||||
"location" => $location[0]
|
||||
]);
|
||||
} else {
|
||||
header("Location:/den");
|
||||
return new Response("<html><body>LOGGED IN</body></html>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,37 +9,19 @@ use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
//use App\Utils\PageRender;
|
||||
//use App\Data\Auth;
|
||||
use App\Service\Auth;
|
||||
use App\Service\Render;
|
||||
|
||||
class Index extends AbstractController
|
||||
{
|
||||
/**
|
||||
* @Route("/", name="index")
|
||||
*/
|
||||
public function showIndex(Request $request): Response
|
||||
public function showIndex(Request $request, Auth $auth, Render $render): Response
|
||||
{
|
||||
return $this->render("front/index.twig", [
|
||||
"title" => "This is The Bad Space",
|
||||
]);
|
||||
/*
|
||||
$result = $auth->status();
|
||||
if ($result["status"]) {
|
||||
return $render->renderPage(
|
||||
[
|
||||
"bgImage" => "/images/base/tweed-flowers.png",
|
||||
"role" => $result["role"],
|
||||
],
|
||||
"The Nile List | Welcome Back",
|
||||
"front/index.html.twig"
|
||||
);
|
||||
} else {
|
||||
//back to index to login
|
||||
header("Location:/login");
|
||||
return new Response("<html><body>LOGGED IN</body></html>");
|
||||
}
|
||||
*/
|
||||
$check = $auth->status();
|
||||
|
||||
return $render->page([], "This is The Bad Space", "front/index.twig");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user