<?php
/**
 * @copyright (c) Kufer Software GmbH, Oderstraße 7, D-84453 Mühldorf
 */

namespace Kufer\Web\KuferTools\Firma\KursUebersicht\Detailsreiter\Dokumente\DokumenteDownload;

class DokumenteDownloadPresenter extends \Kufer\Web\KuferTools\Basis\Presenter\Presenter
{
  public function present()
  {
    return base64_decode($this->useCaseResponse->file->ContentBase64);
  }

  public function setRequestHeader()
  {
    $contentType = \FSOperations::getContentTypeByFileName($this->useCaseResponse->file->DateiName);

    if ($contentType) {
      header('Content-Type: ' . $contentType);
    }
    $fileparts = \FSOperations::getFileParts($this->useCaseResponse->file->DateiName);
    header('Content-Disposition: attachment; filename="' . $fileparts['name'] . '.' . $fileparts['extension'] . '"');
  }

  public function getEncoding()
  {
    return UTF_8;
  }

  public function getExternalEncoding()
  {
    return $this->getEncoding();
  }

  protected function getView()
  {
    return null;
  }

  protected function getViewModel()
  {
    return null;
  }
}