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


class PageKontakt extends PageBaseWT
{
  
  protected $_ueberschrift;
  
  protected $_betreff;
  
  protected $_inhaltLabel;
  
  protected $_inhalt;
  
  protected $_isMultipartFormdata = false;

  
  protected $acceptcharset;

  
  protected $textAreaName;

  protected $zeigeBetreff;

  
  protected $textAreaClass;

  
  protected $maxLength;

  
  protected $initJSFileExtSettings;

  
  protected function setInitJSFileExtSettings()
  {
    $this->initJSFileExtSettings = false;
  }

  public function getSpecialCSS()
  {
    $result = parent::getSpecialCss();
    array_push($result, './css/kontakte.css');

    return $result;
  }

  public function getSpecialJS()
  {
    $fileAry = parent::getSpecialJS();
    array_push($fileAry, 'js/Formulare/kontakte.js');

    return $fileAry;
  }

  
  public function getJSDeclarations()
  {
    $result = parent::getJSDeclarations();
    
    
    if ($this->initJSFileExtSettings) {
      
      $tool0Settings = ToolSettingsAPI::getToolSettings(0);
      if ($tool0Settings->dokuUploadAllowByExclude) {
        
        $fileExtStr = $tool0Settings->uploadBlacklist4Ext;
        $allowByExclude = true;
      } else {
        
        $fileExtStr = $tool0Settings->uploadWhitelist4Ext;
        $allowByExclude = false;
      }
      $result .= JsOperations::getDeclarationBoolean('KuferTools.Kontakt.AllowUploadByExclude', $allowByExclude);
      $result .= JsOperations::getDeclarationString('KuferTools.Kontakt.FileExtStr', $fileExtStr);
      $statusMessageStr4FileExt = DokuUploadUserAPI::getStatusMessagePart4FileExt($tool0Settings);
      $result .= JsOperations::getDeclarationString('KuferTools.Kontakt.FileExtMessagePart', $statusMessageStr4FileExt);

      
      $result .= JsOperations::getDeclarationBoolean('KuferTools.Kontakt.UseAllowedExt4Attach', $tool0Settings->useAllowedExt4Attach);
    } 

    return $result;
  }

  

  
  public function __construct(
    $pPageTitle,
    $pPageId,
    $pTool,
    $pUeberschrift,
    $pBetreff = '',
    $pInhaltLabel = 'Ihre Nachricht:',
    $pInhalt = '',
    $pZeigeBetreff = true,
    $acceptcharset = '',
    $textAreaName = 'info',
    $pTextAreaClass = '',
    $pTextAreaMaxLength = ''
  ) {
    parent::__construct($pPageTitle, $pPageId, $pTool);
    $this->_ueberschrift = $pUeberschrift;
    $this->_inhaltLabel = $pInhaltLabel;
    $this->_betreff = $pBetreff;
    $this->_inhalt = $pInhalt;
    $this->zeigeBetreff = $pZeigeBetreff;
    $this->acceptcharset = $acceptcharset;
    $this->textAreaName = $textAreaName;
    $this->textAreaClass = $pTextAreaClass;
    $this->maxLength = $pTextAreaMaxLength;
    
    $this->setInitJSFileExtSettings();
  }

  public function getContentHeader()
  {
    return $this->_ueberschrift;
  }

  public function getContent()
  {
    $action = isset($this->links['action']) ? $this->links['action'] : '';
    $result = '<form action="' . CleanOperations::cleanStringForHtml($action) . '" method="post" class="kontaktformular"'
                 . ($this->_isMultipartFormdata ? ' enctype="multipart/form-data"' : '') . ($this->acceptcharset == '' ? '' : ' accept-charset="' . CleanOperations::cleanStringForHtml($this->acceptcharset) . '"') . '>';
    $result .= '<div id="formular">';
    $result .= $this->_getSonstigenFormularinhalt();
    $result .= $this->_getInfoOrBetreff();

    $result .= '<br /><br /><h3>' . $this->_inhaltLabel . '</h3>';
    $result .= $this->_getHinweis();
    $result .= '<label class="zeichenanz"></label>';
    $class = $this->textAreaClass == '' ? '' : ' class="' . CleanOperations::cleanStringForHtml($this->textAreaClass) . '"';
    $maxLength = $this->maxLength == '' ? '' : ' maxlength="' . CleanOperations::cleanStringForHtml($this->maxLength) . '"';
    $result .= '<textarea name="' . CleanOperations::cleanStringForHtml($this->textAreaName) . '"' . $class . '' . $maxLength . '>' . CleanOperations::cleanStringForHtml($this->_inhalt) . '</textarea>' . BR_WT;
    $result .= $this->_getAttachments();
    $result .= $this->_getButtons();
    $result .= '</div>';
    $result .= '</form>';

    return $result;
  }

  
  protected function _getAttachments()
  {
    return '';
  }

  
  protected function _getSonstigenFormularinhalt()
  {
    return '';
  }

  
  protected function _getHinweis()
  {
    return '';
  }

  
  protected function _getButtons()
  {
    $buttons = $this->_getSendButton();

    
    $anchor = '';
    if (GetOperations::isDefined('tab')) {
      $anchor = '#' . GetOperations::getVarValue('tab');
    }

    $buttons .= HTMLOperations::CreateBackButton($this->links['back'] . $anchor);

    return $buttons;
  }

  
  protected function _getSendButton()
  {
    return '<input type="image" name="Absenden" src="layout/button_send.gif" title="Absenden">';
  }

  
  protected function _getInfoOrBetreff()
  {
    $result = '';
    if ($this->zeigeBetreff) {
      $result .= '<br /><h3>Betreff:</h3>';
      $result .= '<input class="betreff" name="betreff"  type="text"  value="' . CleanOperations::cleanStringForHtml($this->_betreff) . '">';
    }

    return $result;
  }

  
}