/
Logon.php
90 lines (86 loc) · 2.97 KB
/
Logon.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace App\Controller;
use App\Form\ListenerList as ListenerListForm;
use App\Repository\ListenerRepository;
use App\Utils\Rxx;
use Symfony\Component\Routing\Annotation\Route; // Required for annotations
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* Class ListenerList
* @package App\Controller
*/
class Logon extends BaseController {
/**
* @Route(
* "/{system}/logon",
* requirements={
* "system": "reu|rna|rww"
* },
* name="logon"
* )
*/
public function logonController(
$system,
Request $request,
ListenerListForm $form,
ListenerRepository $listenerRepository
) {
if (!$this->session->get('isAdmin', 0)) {
$this->session->set('isAdmin', 1);
return $this->redirectToRoute('logon', ['system' => $system]);
}
$options = [
'system' => $system
];
$form = $form->buildForm($this->createFormBuilder(), $options);
$form->handleRequest($request);
$args = [
'filter' => '',
'types' => [],
'country' => '',
'region' => '',
'sort' => 'name',
'order' => 'a'
];
if ($form->isSubmitted() && $form->isValid()) {
$args = $form->getData();
// print $this->rxx::y($args);
}
$total = $listenerRepository->getTotalListeners($system);
$showingAll = (
empty($args['filter']) &&
empty($args['country']) &&
empty($args['region'])
);
if (empty($args['types'])) {
$args['types'][] = 'type_NDB';
}
$filtered = $listenerRepository->getFilteredListeners($system, $args);
$matched =
($showingAll ?
"(Showing all $total listeners)"
:
"(Showing ".count($filtered)." of $total listeners)"
);
$parameters = [
'args' => $args,
'columns' => $listenerRepository->getColumns(),
'form' => $form->createView(),
'listeners' => $filtered,
'matched' => $matched,
'mode' => 'Listeners List',
'system' => $system,
'text' =>
"<ul>\n"
." <li>Log and station counts are updated each time new log data is added - "
."figures are for logs in the system at this time.</li>\n"
." <li>To see stats for different types of signals, check the boxes shown for 'Types' below.</li>\n"
." <li>This report prints best in Portrait.</li>\n"
."</ul>\n",
];
$parameters = array_merge($parameters, $this->parameters);
// return $this->rxx::debug($this->parameters);
return $this->render('listeners/index.html.twig', $parameters);
}
}