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

namespace Kufer\Web\KuferTools\Basis\DozentenInfo\SammelEMail;

abstract class SammelEMailPresenter extends \Kufer\Web\KuferTools\Basis\Presenter\MitRahmenPresenter
{
  protected function getViewModel()
  {
    $viewModel = new SammelEMailViewModel();
    $viewModel->toolId = $this->useCaseResponse->toolId;
    $viewModel->errorMessage = $this->useCaseResponse->errorMessage;

    $viewModel->backLink = $this->useCaseResponse->backLink;
    $viewModel->backButtonLabel = $this->useCaseResponse->backButtonLabel;
    $viewModel->dozenten = $this->useCaseResponse->dozenten;
    $viewModel->showEMail = $this->useCaseResponse->showEMail ?? false;

    return $viewModel;
  }

  protected function getJSDeclarations(): string
  {
    $result = parent::getJSDeclarations();

    $tool0Settings = \ToolSettingsAPI::getToolSettings(0);
    if ($tool0Settings->dokuUploadAllowByExclude) {
      
      $fileExtStr = $tool0Settings->uploadBlacklist4Ext;
      $useBlacklist = true;
    } else {
      
      $fileExtStr = $tool0Settings->uploadWhitelist4Ext;
      $useBlacklist = false;
    }
    $statusMessageStr4FileExt = \DokuUploadUserAPI::getStatusMessagePart4FileExt($tool0Settings);

    $result .= \JsOperations::getDeclarationBoolean('KuferTools.Kontakt.AllowUploadByExclude', $useBlacklist);
    $result .= \JsOperations::getDeclarationString('KuferTools.Kontakt.FileExtStr', $fileExtStr);
    $result .= \JsOperations::getDeclarationString('KuferTools.Kontakt.FileExtMessagePart', $statusMessageStr4FileExt);
    $result .= \JsOperations::getDeclarationBoolean('KuferTools.Kontakt.UseAllowedExt4Attach', $tool0Settings->useAllowedExt4Attach);
    $result .= \JsOperations::getDeclarationInt('KuferTools.Kontakt.MaxGroesseProUploadDateien', \ConstantOperations::getMaxFileSize4Upload(($tool0Settings->uploadmaxsize)));
    $result .= \JsOperations::getDeclarationInt('KuferTools.Kontakt.MaxGesamtGroesseAllerUploadDateien', \ConstantOperations::getMaxFileSize4Upload(5 * ($tool0Settings->uploadmaxsize)));

    return $result;
  }

  protected function getJsFilesSrcAryWeitere(): array
  {
    return array(
      $this->getJsFileFromOldTools('Formulare/kontakte.js'),
      $this->getJsFileFromSys('kontaktformular.js')
    );
  }
}