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

namespace Kufer\KuferTools\Veranstalter\KursUebersicht\KursDetails\Feedback;

class FeedbackPresenter extends \Kufer\KuferTools\Basis\Presenter\MitRahmenPresenter
{
  protected function getView()
  {
    return new FeedbackView($this->getViewModel());
  }
  
  protected function getViewModel()
  {
    $viewModel = new FeedbackViewModel();
    $viewModel->kurs = $this->useCaseResponse->kurs;
    $viewModel->kurs->user_vorname = $this->useCaseResponse->user->vorname;
    $viewModel->kurs->user_name = $this->useCaseResponse->user->name;
    $viewModel->kurs->maxGroesseProDatei = isset($this->useCaseResponse->maxGroesseProDatei) ? $this->useCaseResponse->maxGroesseProDatei : '';
    $viewModel->kurs->maxGroesseAllerDateien = isset($this->useCaseResponse->maxGroesseAllerDateien) ? $this->useCaseResponse->maxGroesseAllerDateien : '';
    return $viewModel;
  }
  
  protected function getJSDeclarations()
  {
    $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::getMaxGesamtGroesseAllerUploadDateien(5 * ($tool0Settings->uploadmaxsize)));
    return $result;
  }
  
  protected function getJsFilesSrcAryWeitere() {
    return array (
      $this->getJsFileFromSys('kontaktformular.js'),
      $this->getJsFileFromOldTools('Formulare/kontakte.js')
    );
  }
}