<?php
namespace ThurData\Servers\KerioEmail\App\UI\Client\Setting\Forms;

use ThurData\Servers\KerioEmail\core\UI\Traits\Alerts;
use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
use ThurData\Servers\KerioEmail\Core\UI\Traits\FormDataProvider;
use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Forms\SortedFieldForm;
use ThurData\Servers\KerioEmail\App\UI\Client\Setting\Providers\InfoSettingDataProvider;
use ThurData\Servers\KerioEmail\Core\UI\Interfaces\ClientArea;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Hidden;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\FormConstants;
use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\BaseForm;
use function ThurData\Servers\KerioEmail\Core\Helper\di;


class InfoForm extends BaseForm implements ClientArea
{
    use FormExtendedTrait;
    use FormDataProvider;

    public function initContent()
    {
        $this->initIds('infoForm');
        $this->setFormType('info');
        $this->setProvider(new InfoSettingDataProvider());
        $this->initFields();
        $this->loadDataToForm();
    }

    public function getAllowedActions()
    {
        return ['info'];
    }

    private function initFields()
    {
//        $message = di('lang')->absoluteT('dnsinfomessage');
        $message = 'dnsinfomessage';
        $this->setConfirmMessage("DNS Information");
        $this->addInternalAlert($message, null, 100);
        $this->addField(new Hidden("id"));
        $this->addField(new Hidden("selfdns"));
        $this->addField(new Hidden("selfdomain"));
        $fieldl = new Text("mxthurdata");
        $fieldl->setRawTitle('MX Eintrag ThurData Vorgabe')->addHtmlAttribute('readonly','true');
        $fieldr = new Text("mxactive");
        $fieldr->setRawTitle('Aktueller MX Eintrag')->addHtmlAttribute('readonly','true');
        $this->generateDoubleSection([$fieldl,$fieldr]);
        $fieldl = new Text("spfthurdata");
        $fieldl->setRawTitle('SPF ThurData Vorgabe')->addHtmlAttribute('readonly','true');
        $fieldr = new Text("spf");
        $fieldr->setRawTitle('Aktueller SPF Eintrag:')->addHtmlAttribute('readonly','true');
        $this->generateDoubleSection([$fieldl,$fieldr]);
        $fieldl = new Text("dmarcthurdata");
        $fieldl->setRawTitle('DMACR ThurData Vorgabe')->addHtmlAttribute('readonly','true');
        $fieldr = new Text("dmarc");
        $fieldr->setRawTitle('Aktueller DMARC Eintrag')->addHtmlAttribute('readonly','true');
        $this->generateDoubleSection([$fieldl,$fieldr]);
        $fieldl = new Text("dkimthurdata");
        $fieldl->setRawTitle('DKIM ThurData Vorgabe')->addHtmlAttribute('readonly','true');
        $fieldr = new Text("dkim");
        $fieldr->setRawTitle('Aktueller DKIM Eintrag')->addHtmlAttribute('readonly','true');
        $this->generateDoubleSection([$fieldl,$fieldr]);
    }
}