<?php
namespace App\Controller\ING;
use App\Controller\BaseController;
use Empire\Core\Core;
use Empire\Core\Document;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
/**
* Class PagesController
* @package App\Controller\ING
* @Route("/p")
*
* Controller for miscellaneous pages, that cannot be created through the content editor.
*/
class PagesController extends BaseController
{
/**
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Exception
* @Route("/relations")
*/
public function relations() {
$stances = [];
foreach(\Empire\Core\Stance::loadAll() as $stance ) {
$stances[] = [
'id' =>$stance->id,
'name' => $stance->getName(),
'status' => $stance->status,
'status.sort' => $stance->statusNumber,
'status.style' => 'color: ' . $stance->statusColor . '; text-align: center;',
'date' => $stance->date->cgtDateString,
'date.sort' => $stance->date->realtime,
];
}
$columns = [
'name' => 'Faction',
'status' => 'Status',
'date' => 'Last Change',
];
return $this->render('pages/relations.twig', [
'gejs' => ['ajax'],
'data' => $stances,
'columns' => $columns,
'title' => "Diplomatic Relations",
'text' => "<p>Across the thousands of worlds of the galaxy there exists countless governments, corporations, religions, mercenary bands, and other organisations. In the course of governing its vast swathes of territory, the Galactic Empire maintains diplomatic dealings with hundreds of major organisations such as governments, influential corporations, and powerful issue-motivated groups. Due to associated prohibitions on trade with enemies, configuring Identify Friend or Foe (IFF) systems, and clear expression of relations with organisations, the Empire publishes a list of its major Diplomatic Stances.</p>
<p>This list identifies the Empire’s allied, friendly, and adversarial relationships. If an organisation is not found on this list, then the Empire’s stance is to be considered officially neutral.</p>"
]);
}
/**
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Exception
* @Route("/awards")
*/
public function awards() {
return $this->render('pages/awards.twig', [
'gejs' => ['ajax', 'award'],
'awards' => \Empire\Core\Award::loadAll(),
]);
}
/**
* @return mixed
* @throws \Exception
* @Route("/warrants")
*/
public function warrants() {
return $this->render('pages/warrants.twig', [
'gejs' => ['ajax'],
'warrants' => \Empire\Core\Warrant::loadAll()
]) ;
}
/**
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Exception
* @Route("/blacklist")
*/
public function blacklist() {
$blacklist = [];
foreach(\Empire\Core\Blacklisted::loadAll() as $bl) {
$blacklist[] = [
'id' => $bl->id,
'name' => $bl->name,
'type' => $bl->type == 1 ? "<i class='fa fa-user' title='Indivdual'></i>" : "<i class='fa fa-users' title='Faction'></i>",
'type.sort' => $bl->type,
'type.style' => 'text-align: center;',
'date' => $bl->date->cgtDateString,
'date.sort' => $bl->date->realtime,
];
}
$columns = [
'name' => "Entity Name",
'type' => "Entity Type",
'date' => "Last Update",
];
return $this->render('pages/relations.twig', [
'gejs' => ['ajax'],
'data' => $blacklist,
'columns' => $columns,
'title' => 'Trading Blacklist',
'text' => ""
]);
}
/**
* @return \Symfony\Component\HttpFoundation\Response
* @throws \Exception
* @Route("/library")
*/
public function library() {
$userclearance = !is_null(Core::user()) ? Core::user()->getClearance()->order : 0;
$blacklist = [];
foreach(\Empire\Core\Document::loadAll() as $doc) {
if($userclearance >= $doc->clearance->order)
if($doc->branch->id == cint_BRANCH_THRONE){
$documents_emp[] = [
'id' => $doc->id,
'ref' => $doc->ref,
'name' => "<a href='/p/library/$doc->ref'>" . $doc->name . "</a>",
'name.sort' => $doc->name,
'date' => $doc->date->cgtDateStringShort,
'date.sort' => $doc->date->realtime,
'clearance' => $doc->clearance->name,
'clearance.sort' => $doc->clearance->order,
'status' => $doc->printDocStatus(),
'status.sort' => $doc->status,
'branch' => $doc->branch->name
];
}
else {
$documents[] = [
'id' => $doc->id,
'ref' => $doc->ref,
'name' => "<a href='/p/library/$doc->ref'>" . $doc->name . "</a>",
'name.sort' => $doc->name,
'date' => $doc->date->cgtDateStringShort,
'date.sort' => $doc->date->realtime,
'clearance' => $doc->clearance->name,
'clearance.sort' => $doc->clearance->order,
'status' => $doc->printDocStatus(),
'status.sort' => $doc->status,
'branch' => $doc->branch->name
];
}
}
$columns = [
'ref' => "REF#",
'name' => "Document Name",
'date' => "Release",
'clearance' => "Security Clearance",
'status' => "Status",
'branch' => "Branch",
];
$columns_emp = [
'ref' => "REF#",
'name' => "Document Name",
'date' => "Release",
'clearance' => "Security Clearance",
'status' => "Status",
];
return $this->render('pages/doclib.twig', [
'gejs' => ['ajax'],
'data' => $documents,
'data_emp' => $documents_emp,
'columns' => $columns,
'columns_emp' => $columns_emp,
'title' => 'Document Library',
'text' => Core::user() == null ? "Please log in to see documents up to your Clearance Level." : "You may see Documents up to and including a Security Clearance of <b>". Core::user()->getClearance()->name . "</b>."
]);
}
/**
* @return Response
* @Route("/library/{ref}")
*/
public function library_document($ref) {
$clearance = Core::user() !== null ? Core::user()->getClearance()->order : 0;
if($ref !== null) {
$fileinfo = Document::loadByRef($ref);
if(!is_object($fileinfo)) {
$this->addFlash('error', 'Reference Number <b>'. $ref. '</b> not found!');
return $this->redirect('/p/library');
}
if($clearance >= $fileinfo->clearance->order) {
return new BinaryFileResponse(EMPIRE_APPLICATION . "/var/docs/" . $fileinfo->link);
} else {
$this->addFlash('error', 'Missing security clearance to view this file.');
return $this->redirect('/login');
}
} else {
$this->addFlash('error', 'Missing Reference Number');
return $this->redirect('/p/library');
}
}
}