/**
  * Shows api content
  *
  * @param \phpOMS\Message\RequestAbstract  $request  Request
  * @param \phpOMS\Message\ResponseAbstract $response Response
  *
  * @since  1.0.0
  * @author Dennis Eichhorn <*****@*****.**>
  */
 private function apiShow($request, $response)
 {
     if ($request->getPath(3) === 'download') {
         // TODO: check permissions + load data from database + if request = virtual directory -> zip all files and download + cache zip
         $file = $_GET["file"] . ".pdf";
         $response->setHeader('Content-Disposition', 'Content-Disposition: attachment; filename=' . urlencode($file));
         $response->setHeader('Content-Type', 'Content-Type: application/octet-stream');
         $response->setHeader('Content-Description', 'Content-Description: File Transfer');
         $response->setHeader('Content-Length', 'Content-Length: ' . filesize($file));
         $fp = fopen($file, "r");
         while (!feof($fp)) {
             echo fread($fp, 65536);
             flush();
         }
         fclose($fp);
     } else {
         // TODO: check permissions + load data from database
         switch ($extension) {
             case 'jpeg':
             case 'png':
             case 'bmp':
             case 'tiff':
             case 'gif':
                 $response->setHeader('Content-Type', 'Content-Type: image/' . $extension);
                 break;
             case 'jpg':
                 $response->setHeader('Content-Type', 'Content-Type: image/jpeg');
                 break;
             case 'svg':
                 $response->setHeader('Content-Type', 'Content-Type: image/svg+xml');
                 break;
             case 'pdf':
                 $response->setHeader('Content-Type', 'Content-Type: application/pdf');
                 break;
             case 'txt':
             case 'csv':
             case 'css':
             case 'xml':
             case 'html':
                 $response->setHeader('Content-Type', 'Content-Type: text/' . $extension);
                 break;
             case 'htm':
                 $response->setHeader('Content-Type', 'Content-Type: text/html');
                 break;
             case 'md':
                 $response->setHeader('Content-Type', 'Content-Type: text/markdown');
                 break;
             case 'json':
                 $response->setHeader('Content-Type', 'Content-Type: application/json');
                 break;
             case 'js':
                 $response->setHeader('Content-Type', 'Content-Type: application/javascript');
                 break;
             case 'avi':
             case 'mpeg':
             case 'mp4':
             case 'ogg':
                 $response->setHeader('Content-Type', 'Content-Type: video/' . $extension);
                 break;
             case 'mp3':
                 $response->setHeader('Content-Type', 'Content-Type: audio/' . $extension);
                 break;
             default:
                 $response->setHeader('HTTP', 'HTTP/1.0 406 Not acceptable');
                 $response->setHeader('Status', 'Status:406 Not acceptable');
                 return;
         }
         $response->setHeader('Content-Length', 'Content-Length: ' . filesize($file));
     }
 }
 /**
  * Shows module content
  *
  * @param \phpOMS\Message\RequestAbstract  $request  Request
  * @param \phpOMS\Message\ResponseAbstract $response Response
  *
  * @since  1.0.0
  * @author Dennis Eichhorn <*****@*****.**>
  */
 public function showBackendAccount($request, $response)
 {
     switch ($request->getPath(4)) {
         case 'list':
             /** @noinspection PhpUnusedLocalVariableInspection */
             $accountList = new \Modules\Accounting\Models\AccountList($this->app->dbPool);
             /** @noinspection PhpIncludeInspection */
             include __DIR__ . '/Theme/Backend/account-list.tpl.php';
             break;
         case 'postings':
             /** @noinspection PhpIncludeInspection */
             include __DIR__ . '/Theme/Backend/account-postings.tpl.php';
             break;
         case 'balance':
             /** @noinspection PhpIncludeInspection */
             include __DIR__ . '/Theme/Backend/account-balance.tpl.php';
             break;
         case 'single':
             /** @noinspection PhpIncludeInspection */
             include __DIR__ . '/Theme/Backend/account-single.tpl.php';
             break;
         case 'create':
             /** @noinspection PhpIncludeInspection */
             include __DIR__ . '/Theme/Backend/account-create.tpl.php';
             break;
         default:
             $response->setHeader('HTTP', 'HTTP/1.0 404 Not Found');
             $response->setHeader('Status', 'Status: 404 Not Found');
             include __DIR__ . '/../../Web/Backend/404.tpl.php';
             return;
     }
 }
 /**
  * Shows module content
  *
  * @param \phpOMS\Message\RequestAbstract  $request  Request
  * @param \phpOMS\Message\ResponseAbstract $response Response
  *
  * @since  1.0.0
  * @author Dennis Eichhorn <*****@*****.**>
  */
 public function showAPI($request, $response)
 {
     switch ($request->getRequestDestination()) {
         case \phpOMS\Message\RequestMethod::POST:
             $newsOBJ = new \Modules\News\Models\NewsArticle($this->app->dbPool);
             $newsOBJ->setAuthor($request->getRequest()['author']);
             $newsOBJ->setCreated(new \DateTime('now'));
             $newsOBJ->setPublish(new \DateTime($request->getRequest()['publish']));
             $newsOBJ->setTitle($request->getRequest()['title']);
             $newsOBJ->setContent($request->getRequest()['content']);
             $newsOBJ->setLang($request->getRequest()['language']);
             $newsOBJ->setType($request->getRequest()['type']);
             $created = $newsOBJ->create();
             $response->get('GLOBAL')->add($request->__toString(), $created);
             break;
         default:
             $response->setHeader('HTTP', 'HTTP/1.0 406 Not acceptable');
             $response->setHeader('Status', 'Status:406 Not acceptable');
             return;
     }
 }
 /**
  * Shows api content
  *
  * @param \phpOMS\Message\RequestAbstract  $request  Request
  * @param \phpOMS\Message\ResponseAbstract $response Response
  *
  * @since  1.0.0
  * @author Dennis Eichhorn <*****@*****.**>
  */
 private function apiModule($request, $response)
 {
     switch ($request->getRequestDestination()) {
         case \phpOMS\Message\RequestMethod::POST:
             $this->app->moduleManager->install($request->getData('module'));
             break;
         default:
             $response->setHeader('HTTP', 'HTTP/1.0 406 Not acceptable');
             $response->setHeader('Status', 'Status:406 Not acceptable');
             return;
     }
 }
 /**
  * Shows api content
  *
  * @param \phpOMS\Message\RequestAbstract  $request  Request
  * @param \phpOMS\Message\ResponseAbstract $response Response
  *
  * @since  1.0.0
  * @author Dennis Eichhorn <*****@*****.**>
  */
 public function showAPI($request, $response)
 {
     switch ($request->getPath(3)) {
         case 'export':
             switch ($request->getData('type')) {
                 case 'pdf':
                     $response->setHeader('Content-Type', \phpOMS\System\MimeType::M_PDF, true);
                     break;
                 case 'csv':
                     $response->setHeader('Content-Type', \phpOMS\System\MimeType::M_CONF, true);
                     break;
                 case 'xlsx':
                     $response->setHeader('Content-Type', \phpOMS\System\MimeType::M_XLSX, true);
                     break;
                 case 'json':
                     $response->setHeader('Content-Type', \phpOMS\System\MimeType::M_JSON, true);
                     break;
                 default:
                     // TODO handle bad request
             }
             if ($request->getData('download') !== null) {
                 $response->setHeader('Content-Type', \phpOMS\System\MimeType::M_BIN, true);
                 $response->setHeader('Content-Transfer-Encoding', 'Binary', true);
                 $response->setHeader('Content-disposition', 'attachment; filename="' . $request->getData('id') . '.' . $request->getData('type') . '"', true);
             }
             /** @var array $reportLanguage */
             /** @noinspection PhpIncludeInspection */
             include_once __DIR__ . '/Templates/' . $request->getData('id') . '/' . $request->getData('id') . '.lang.php';
             $pdfView = new \phpOMS\Views\View($this->app, $request, $response);
             $pdfView->addData('lang', $reportLanguage[$this->app->accountManager->get($request->getAccount())->getL11n()->getLanguage()]);
             $pdfView->setTemplate('/Modules/Reporter/Templates/' . $request->getData('id') . '/' . $request->getData('id') . '.' . $request->getData('type'));
             $response->set('GLOBAL', $pdfView->render());
             break;
     }
 }