add dns-editor in twig/tablelisting/formfield

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-03-14 11:13:21 +01:00
parent 237476b30d
commit 05cc08c376
6 changed files with 240 additions and 49 deletions

View File

@@ -0,0 +1,27 @@
<?php
namespace Froxlor\UI\Callbacks;
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Froxlor\UI\Callbacks
*
*/
class Dns
{
public static function prio(array $attributes): string
{
return ($attributes['fields']['prio'] <= 0
&& $attributes['fields']['type'] != 'MX'
&& $attributes['fields']['type'] != 'SRV') ? '' : $attributes['data'];
}
}

View File

@@ -60,4 +60,9 @@ class Text
{
return substr($attributes['data'], 0, 20) . '...';
}
public static function wordwrap(array $attributes): string
{
return wordwrap($attributes['data'], 100, '<br>', true);
}
}

View File

@@ -0,0 +1,69 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Formfields
*
*/
return array(
'dns_add' => array(
'title' => 'DNS Editor',
'image' => 'fa-solid fa-globe',
'sections' => array(
'section_a' => array(
'fields' => array(
'dns_record' => array(
'label' => 'Record',
'type' => 'text',
'value' => $record,
'mandatory' => true
),
'dns_type' => array(
'label' => 'Type',
'type' => 'select',
'select_var' => [
'A' => 'A',
'AAAA' => 'AAAA',
'CAA' => 'CAA',
'CNAME' => 'CNAME',
'DNAME' => 'DNAME',
'LOC' => 'LOC',
'MX' => 'MX',
'NS' => 'NS',
'RP' => 'RP',
'SRV' => 'SRV',
'SSHFP' => 'SSHFP',
'TXT' => 'TXT'
],
'selected' => $type
),
'dns_mxp' => array(
'label' => 'Priority',
'type' => 'number',
'value' => $prio
),
'dns_content' => array(
'label' => 'Content',
'type' => 'text',
'value' => $content
),
'dns_ttl' => array(
'label' => 'TTL',
'type' => 'number',
'min' => 30,
'value' => $ttl
)
)
)
)
)
);

View File

@@ -0,0 +1,72 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package Tabellisting
*
*/
use Froxlor\UI\Callbacks\Dns;
use Froxlor\UI\Callbacks\Text;
use Froxlor\UI\Listing;
return [
'dns_list' => [
'title' => 'DNS Entries',
'icon' => 'fa-solid fa-globe',
'columns' => [
'record' => [
'label' => 'Record',
'field' => 'record'
],
'type' => [
'label' => 'Type',
'field' => 'type'
],
'prio' => [
'label' => 'Priority',
'field' => 'prio',
'callback' => [Dns::class, 'prio'],
],
'content' => [
'label' => 'Content',
'field' => 'content',
'callback' => [Text::class, 'wordwrap'],
],
'ttl' => [
'label' => 'TTL',
'field' => 'ttl'
]
],
'visible_columns' => Listing::getVisibleColumnsForListing('dns_list', [
'record',
'type',
'prio',
'content',
'ttl'
]),
'actions' => [
'delete' => [
'icon' => 'fa fa-trash',
'title' => $lng['panel']['delete'],
'class' => 'text-danger',
'href' => [
'section' => 'domains',
'page' => 'domaindnseditor',
'action' => 'delete',
'domain_id' => $domain_id,
'id' => ':id'
],
],
]
]
];