src/Controller/ING/PagesController.php line 74

Open in your IDE?
  1. <?php
  2. namespace App\Controller\ING;
  3. use App\Controller\BaseController;
  4. use Empire\Core\Core;
  5. use Empire\Core\Document;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpFoundation\BinaryFileResponse;
  8. /**
  9.  * Class PagesController
  10.  * @package App\Controller\ING
  11.  * @Route("/p")
  12.  *
  13.  * Controller for miscellaneous pages, that cannot be created through the content editor.
  14.  */
  15. class PagesController extends BaseController
  16. {
  17.     /**
  18.      * @return \Symfony\Component\HttpFoundation\Response
  19.      * @throws \Exception
  20.      * @Route("/relations")
  21.      */
  22.     public function relations() {
  23.         $stances = [];
  24.         foreach(\Empire\Core\Stance::loadAll() as $stance ) {
  25.             $stances[] = [
  26.                 'id' =>$stance->id,
  27.                 'name' => $stance->getName(),
  28.                 'status' => $stance->status,
  29.                 'status.sort' => $stance->statusNumber,
  30.                 'status.style' => 'color: ' $stance->statusColor '; text-align: center;',
  31.                 'date' => $stance->date->cgtDateString,
  32.                 'date.sort' => $stance->date->realtime,
  33.             ];
  34.         }
  35.         $columns = [
  36.             'name' => 'Faction',
  37.             'status' => 'Status',
  38.             'date' => 'Last Change',
  39.         ];
  40.         return $this->render('pages/relations.twig', [
  41.             'gejs' => ['ajax'],
  42.             'data' => $stances,
  43.             'columns' => $columns,
  44.             'title' => "Diplomatic Relations",
  45.             '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>
  46.     <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>"
  47.         ]);
  48.     }
  49.     /**
  50.      * @return \Symfony\Component\HttpFoundation\Response
  51.      * @throws \Exception
  52.      * @Route("/awards")
  53.      */
  54.     public function awards() {
  55.         return $this->render('pages/awards.twig', [
  56.             'gejs' => ['ajax''award'],
  57.             'awards' => \Empire\Core\Award::loadAll(),
  58.         ]);
  59.     }
  60.     /**
  61.      * @return mixed
  62.      * @throws \Exception
  63.      * @Route("/warrants")
  64.      */
  65.     public function warrants() {
  66.         return $this->render('pages/warrants.twig', [
  67.             'gejs' => ['ajax'],
  68.             'warrants' => \Empire\Core\Warrant::loadAll()
  69.         ]) ;
  70.     }
  71.     /**
  72.      * @return \Symfony\Component\HttpFoundation\Response
  73.      * @throws \Exception
  74.      * @Route("/blacklist")
  75.      */
  76.     public function blacklist() {
  77.         $blacklist = [];
  78.         foreach(\Empire\Core\Blacklisted::loadAll() as $bl) {
  79.             $blacklist[] = [
  80.                 'id' => $bl->id,
  81.                 'name' => $bl->name,
  82.                 'type' => $bl->type == "<i class='fa fa-user' title='Indivdual'></i>" "<i class='fa fa-users' title='Faction'></i>",
  83.                 'type.sort' => $bl->type,
  84.                 'type.style' => 'text-align: center;',
  85.                 'date' => $bl->date->cgtDateString,
  86.                 'date.sort' => $bl->date->realtime,
  87.             ];
  88.         }
  89.         $columns = [
  90.             'name' => "Entity Name",
  91.             'type' => "Entity Type",
  92.             'date' => "Last Update",
  93.         ];
  94.         return $this->render('pages/relations.twig', [
  95.             'gejs' => ['ajax'],
  96.             'data' => $blacklist,
  97.             'columns' => $columns,
  98.             'title' => 'Trading Blacklist',
  99.             'text' => ""
  100.         ]);
  101.     }
  102.         /**
  103.      * @return \Symfony\Component\HttpFoundation\Response
  104.      * @throws \Exception
  105.      * @Route("/library")
  106.      */
  107.     public function library() {
  108.         $userclearance = !is_null(Core::user()) ? Core::user()->getClearance()->order 0;
  109.         $blacklist = [];
  110.         foreach(\Empire\Core\Document::loadAll() as $doc) {
  111.             if($userclearance >= $doc->clearance->order)
  112.                 if($doc->branch->id == cint_BRANCH_THRONE){
  113.                     $documents_emp[] = [
  114.                         'id' => $doc->id,
  115.                         'ref' => $doc->ref,
  116.                         'name' => "<a href='/p/library/$doc->ref'>" $doc->name "</a>",
  117.                         'name.sort' => $doc->name,
  118.                         'date' => $doc->date->cgtDateStringShort,
  119.                         'date.sort' => $doc->date->realtime,
  120.                         'clearance' => $doc->clearance->name,
  121.                         'clearance.sort' => $doc->clearance->order,
  122.                         'status' => $doc->printDocStatus(),
  123.                         'status.sort' => $doc->status,
  124.                         'branch' => $doc->branch->name
  125.                     ];
  126.                 }
  127.                 else {
  128.                     $documents[] = [
  129.                         'id' => $doc->id,
  130.                         'ref' => $doc->ref,
  131.                         'name' => "<a href='/p/library/$doc->ref'>" $doc->name "</a>",
  132.                         'name.sort' => $doc->name,
  133.                         'date' => $doc->date->cgtDateStringShort,
  134.                         'date.sort' => $doc->date->realtime,
  135.                         'clearance' => $doc->clearance->name,
  136.                         'clearance.sort' => $doc->clearance->order,
  137.                         'status' => $doc->printDocStatus(),
  138.                         'status.sort' => $doc->status,
  139.                         'branch' => $doc->branch->name
  140.                     ];
  141.                 }
  142.         }
  143.         $columns = [
  144.             'ref' => "REF#",
  145.             'name' => "Document Name",
  146.             'date' => "Release",
  147.             'clearance' => "Security Clearance",
  148.             'status' => "Status",
  149.             'branch' => "Branch",
  150.         ];
  151.         $columns_emp = [
  152.             'ref' => "REF#",
  153.             'name' => "Document Name",
  154.             'date' => "Release",
  155.             'clearance' => "Security Clearance",
  156.             'status' => "Status",
  157.         ];
  158.         return $this->render('pages/doclib.twig', [
  159.             'gejs' => ['ajax'],
  160.             'data' => $documents,
  161.             'data_emp' => $documents_emp,
  162.             'columns' => $columns,
  163.             'columns_emp' => $columns_emp,
  164.             'title' => 'Document Library',
  165.             '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>."
  166.         ]);
  167.     }
  168.     /**
  169.      *  @return Response
  170.      *  @Route("/library/{ref}")
  171.      */
  172.     public function library_document($ref) {
  173.         $clearance =  Core::user() !== null Core::user()->getClearance()->order 0;
  174.         if($ref !== null) {
  175.             $fileinfo Document::loadByRef($ref);
  176.             if(!is_object($fileinfo)) {
  177.                 $this->addFlash('error''Reference Number <b>'$ref'</b> not found!');
  178.                 return $this->redirect('/p/library');
  179.             }
  180.             if($clearance >= $fileinfo->clearance->order) {
  181.                 return new BinaryFileResponse(EMPIRE_APPLICATION "/var/docs/" $fileinfo->link);
  182.             } else {
  183.                 $this->addFlash('error''Missing security clearance to view this file.');
  184.                 return $this->redirect('/login');
  185.             }
  186.         } else {
  187.             $this->addFlash('error''Missing Reference Number');
  188.             return $this->redirect('/p/library');
  189.         }
  190.     }
  191. }