/** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Generator/Layouts/Tabs/Tabs.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Generator\Layouts; use ARUNOX\Plugins\REST\Generator; use ARUNOX\Plugins\REST\Generator\Config; use ARUNOX\Plugins\REST\Generator\Layouts\Tabs\Tab; use ARUNOX\Plugins\REST\Generator\Base\BaseGenerator; class Tabs extends BaseGenerator { /* ### VARIABLES ################################################ # */ protected ?string $GENERATOR = "tabs"; protected string $CHILDREN_NAME = "tabs"; protected array $ALLOWED_CONTENT = []; protected array $ALLOWED_CONFIG = [ "tabs" => [ "generator" => Tab::class, "args" => [ Config\Type::String, ], ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ public function addTab( ...$args ) { if( isset( $args["type"] ) ) { $class = "ARUNOX\\Plugins\\REST\\Generator\\Layout\\Tabs\\Tab\\" . $args["type"]->name; if( class_exists( $class ) ) { $field = Generator::create( $class, ...$args ); $this->add( "tabs", $field ); return $this; } } $this->add( "tabs", ...$args ); return $this; } public function getTab( ?string $name = NULL, ...$args ) { if( $name ) { foreach( $this->config["tabs"] as $tab ) { if( $tab->getKey() == $name ) { return $tab; } } } else return end( $this->config["tabs"] ); } public function getTabs() { return $this->config["tabs"] ?? []; } public function addTabs( ...$args ) { foreach( $args as $arg ) { $this->addTab( ...$arg ); } } public function removeTab( string $name ) { $tab = $this->getTab( $name ); return $tab->removeTabs(); } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( ...$args ) { parent::__construct(); $this->addTab( ...$args ); // $this->add( "tab", ...$args ); } } /** Datei: plugins/rest/library/ARUNOX/Plugins/REST/Generator/Layouts/Tabs/Tab.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\REST\Generator\Layouts\Tabs; use ARUNOX\Plugins\REST\Generator\Config; use ARUNOX\Plugins\REST\Generator\Base\BaseWrapper; use ARUNOX\Plugins\REST\Generator\Data\Form\Control; use ARUNOX\Plugins\REST\Generator\Components\Headline; use ARUNOX\Plugins\REST\Generator\Components\Paragraph; use ARUNOX\Plugins\REST\Generator\Helpers\ActionHelpers; use ARUNOX\Plugins\REST\Generator\Components\Button; use ARUNOX\Plugins\REST\Generator\Data\Form\Helpers\GroupHelpers; use ARUNOX\Plugins\REST\Generator\Data\Table\Helpers\TableHelpers; use ARUNOX\Plugins\REST\Generator\Data\Form\Helpers\ControlHelpers; class Tab extends BaseWrapper { /* ### TRAITS ################################################### # */ use ActionHelpers, ControlHelpers, GroupHelpers, TableHelpers; /* ### VARIABLES ################################################ # */ protected ?string $GENERATOR = NULL; protected static ?string $PRIMARYKEY = "label"; protected array $ALLOWED_CONTENT = [ "headline" => [ "generator" => Headline::class, "args" => [ Config\Type::String ], ], "text" => [ "generator" => Paragraph::class, "args" => [ Config\Type::String ], ], ]; protected array $ALLOWED_CONFIG = [ "id" => Config\Type::String, "label" => Config\Type::String, "title" => Config\Type::String, "icon" => Config\Type::String, "emoji" => Config\Type::String, "active" => Config\Type::Bool, "type" => Button\Type::class, "color" => Config\Color::class, ]; /* ### PUBLIC FUNCTIONS ######################################### # */ public function setId( string $id ) { $id = strtolower( $id ); $id = iconv("UTF-8", "ASCII//TRANSLIT", $id ); $id = filter_var( $id, FILTER_SANITIZE_EMAIL ); $this->config["id"] = $id; return $this; } /* ### MAGIC FUNCTIONS ########################################## # */ public function __construct( string $label, ?string $id = NULL ) { parent::__construct(); $this->setLabel( __( $label ) ); $this->setId( strtolower( $id ?? $label ) ); } }