<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */

namespace Kufer\KuferTools\Firma\MitarbeiterUebersicht\MitarbeiterDokumente\Download;

class MitarbeiterDokumenteDownloadPresenter extends \Kufer\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;
  }
}