2022-11-15 12:57:14 -08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// src/Controller/DataImport.php
|
|
|
|
// Grab data from transfer app
|
|
|
|
|
|
|
|
namespace App\Controller\Routes\Front;
|
|
|
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
2023-01-08 14:28:25 -08:00
|
|
|
use App\Service\Auth;
|
|
|
|
use App\Service\Render;
|
2023-01-12 15:43:54 -08:00
|
|
|
use App\Service\HandleLocations;
|
2023-04-12 16:46:21 -07:00
|
|
|
use App\Service\HandleExports;
|
2022-11-15 12:57:14 -08:00
|
|
|
|
|
|
|
class Index extends AbstractController
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @Route("/", name="index")
|
|
|
|
*/
|
2023-01-12 15:43:54 -08:00
|
|
|
public function showIndex(Request $request, Auth $auth, Render $render, HandleLocations $locations): Response
|
2022-11-15 12:57:14 -08:00
|
|
|
{
|
2023-01-12 15:43:54 -08:00
|
|
|
$list = $locations->getActiveLocations();
|
2023-01-17 15:54:59 -08:00
|
|
|
if ($request->getMethod() == "GET") {
|
|
|
|
return $render->page(["count" => count($list)], "This is The Bad Space", "front/index.twig");
|
|
|
|
} else {
|
|
|
|
$results = $locations->searchLocations($request->request->get("index_search"));
|
|
|
|
return $render->page(
|
|
|
|
["count" => count($list),
|
2023-01-22 14:03:45 -08:00
|
|
|
"items" => $results['items'],
|
|
|
|
"terms" => $results["terms"]
|
2023-01-17 15:54:59 -08:00
|
|
|
],
|
|
|
|
"This is The Bad Space",
|
|
|
|
"front/index.twig"
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/location/{uuid}", name="front-location")
|
|
|
|
*/
|
|
|
|
public function showLocations(
|
|
|
|
Request $request,
|
|
|
|
Render $render,
|
|
|
|
HandleLocations $locations,
|
|
|
|
string $uuid = "none"
|
|
|
|
): Response {
|
|
|
|
$location = $locations->getLocationbyUUID($uuid);
|
|
|
|
return $render->page(
|
|
|
|
["location" => $location[0]],
|
|
|
|
"The Bad Space | " . $location[0]->getName(),
|
|
|
|
"front/location.twig"
|
|
|
|
);
|
2023-01-12 15:43:54 -08:00
|
|
|
}
|
2023-01-08 14:28:25 -08:00
|
|
|
|
2023-01-12 15:43:54 -08:00
|
|
|
/**
|
|
|
|
* @Route("/about", name="about")
|
|
|
|
*/
|
|
|
|
public function showAbout(
|
|
|
|
Request $request,
|
|
|
|
Auth $auth,
|
|
|
|
Render $render,
|
|
|
|
HandleLocations $locations
|
|
|
|
): Response {
|
|
|
|
return $render->page([], "About The Bad Space", "front/about.twig");
|
2022-11-15 12:57:14 -08:00
|
|
|
}
|
2022-12-12 17:42:40 -08:00
|
|
|
|
|
|
|
/**
|
2023-01-12 15:43:54 -08:00
|
|
|
* @Route("/listings/page/{pageNum}", name="listings")
|
2022-12-12 17:42:40 -08:00
|
|
|
*/
|
2023-01-12 15:43:54 -08:00
|
|
|
public function showListing(
|
|
|
|
Request $request,
|
|
|
|
Auth $auth,
|
|
|
|
Render $render,
|
|
|
|
HandleLocations $locations,
|
2023-01-23 19:59:51 -08:00
|
|
|
int $pageNum = 1
|
2023-01-12 15:43:54 -08:00
|
|
|
): Response {
|
|
|
|
$list = $locations->getLocationsPage($pageNum, "true");
|
2023-01-23 19:59:51 -08:00
|
|
|
|
|
|
|
$next = $pageNum + 1;
|
|
|
|
if ($next > $list["total"]) {
|
|
|
|
$next = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
$prev = $pageNum - 1;
|
|
|
|
|
|
|
|
if ($prev <= 0) {
|
|
|
|
$prev = $list["total"];
|
|
|
|
}
|
|
|
|
|
|
|
|
return $render->page([
|
|
|
|
"list" => $list,
|
|
|
|
"currentPage" => $pageNum,
|
|
|
|
"nextPage" => $next,
|
|
|
|
"prevPage" => $prev
|
|
|
|
], "About The Bad Space", "front/listing.twig");
|
2022-12-12 17:42:40 -08:00
|
|
|
}
|
2023-04-12 16:46:21 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Route("/exports/{type}", name="exports")
|
|
|
|
*/
|
|
|
|
public function showExports(
|
|
|
|
Request $request,
|
|
|
|
Auth $auth,
|
|
|
|
Render $render,
|
|
|
|
HandleLocations $locations,
|
|
|
|
HandleExports $exports,
|
|
|
|
string $type = "none"
|
|
|
|
): Response {
|
|
|
|
switch ($type) {
|
|
|
|
case 'none':
|
|
|
|
case '':
|
|
|
|
return $render->page([], "File Exports", "front/exports.twig");
|
|
|
|
break;
|
|
|
|
case 'mastodon':
|
|
|
|
return $exports->buildMastodonCSV();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-11-15 12:57:14 -08:00
|
|
|
}
|