/** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs; use ARUNOX\API\PHP; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "pwas" )] #[PHP\Attributes\Database\Definitions\HashID( "pwa" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Logs\Rules\Create()] #[PHP\Attributes\Logs\Rules\Update( "name" )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/API/v1/Routes.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs\API\v1; use ARUNOX\Plugins; use ARUNOX\Database; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); /* ### MENU ROUTES ############################## # */ Hooks::add('router::get->api.v1.rest.routes', function( $routes ) { $routes[] = [ "path" => Controller::getRoute(), "label" => Controller::getLabelGroup(), "icon" => Controller::getIcon(), "menu" => "administration", ]; return $routes; }); } public static function installer( $result, $route, $data ) { $pwa = Plugins\PWAs\Model::get([ "status" => Database\Attribute\Status::Active, "system_id" => SYSTEM->id, ]); if( $pwa ) { $fileoOject = $pwa->createManifest(); Plugins\REST\Response::addLink( $fileoOject->versioned, "manifest" ); } return $result; } } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs\API\v1; use ARUNOX\HTTP; use ARUNOX\Plugins; use ARUNOX\API\PHP; use ARUNOX\Core\Hooks; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; use ARUNOX\Plugins\REST\Generator\Base\BaseGenerator; #[PHP\Attributes\Controller\Label( "PWA", "PWAs" )] #[PHP\Attributes\Controller\Icon( Plugins\REST\Generator\Config\Icon::Phone )] #[PHP\Attributes\Controller\Route( "pwas" )] #[PHP\Attributes\Database\Definitions\Model( Plugins\PWAs\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /pwas * @route.description Listet alle Logeinträge */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /pwas/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /pwas/{hashid} * @route.description Speichert Änderungen an einem bestehenden Termin */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.path /pwas * @route.description Erstellt einen neuen Kalender */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /pwas/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /pwas/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method POST * * @route.path /pwas * @route.description REST-Antwort nach dem Erstellen eines Kalenders */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { Plugins\REST\Response::closeModals(); Plugins\REST\Response::redirect( "/pwas/{$result->getBody("data", "hashid")}" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /pwas/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { Plugins\REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { Plugins\REST\Response::redirect( "/pwas" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /pwas/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /pwas * @route.description REST-Konfiguration für Logbuch-Tabelle */ public static function restConfigOverview() : BaseGenerator { return Plugins\REST\Response::addWrapper( "overview", static::getPlural() ) ->replaceContent( static::restConfigTable() ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "pwas" )) ) ; } /** * @internal rest * @method GET * * @route.path /pwas/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restConfigDetails( string $hashid ) : BaseGenerator { return Plugins\REST\Response::addWrapper( "details", static::getSingular( "%t bearbeiten" ) ) ->setBacklink( static::getRoute() ) ->get() ->setApi( static::getRoute( $hashid ) ) ->setAction( static::getRoute( $hashid ), "PUT" ) ->addTab( static::getSingular() )->get() ->setIcon( static::getIcon() ) ->addHeadline( static::getSingular(), 2 ) ->addCallable( [ static::class, "restConfigInputs" ], $hashid ) ->parent() ->addCallable( [ Plugins\PWAs\Images\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addCallable( [ Plugins\Logs\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addTab( "Speichern" )->get() ->setColor( Plugins\REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ) ; } /** * @internal rest * @method GET * * @route.path /pwas/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreatePrepared() : BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /pwas/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : BaseGenerator { return parent::restConfigDeletePrepared( $hashid ); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTable( null|string $hashid = NULL ) : BaseGenerator { $rest = Plugins\REST\Generator\Data\Table::create() ->setApi( static::getRoute() ) ->setAction( static::getRoute( "{hashid}" ) ) ->setOrder( "title", "asc" ) ->setSearch( TRUE ) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [], "status", [], "pwas", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "name", TRUE, TRUE, TRUE, "pwas" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "system.domain", TRUE, TRUE, TRUE, "pwas" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "description", TRUE, TRUE, TRUE, "pwas" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_edit", TRUE, FALSE, TRUE, "pwas" )) ; return $rest; } public static function restConfigInputs( BaseGenerator $rest ) : BaseGenerator { return $rest ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Plugins\Systems\Model::getAsOptions( "domain" ), ], "system_id", TRUE, TRUE, "pwas" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "name", TRUE, "pwas" )) ->addField(...Hooks::filter( "rest.generator::control.type->textarea", [], "description", FALSE, "pwas" )) ; } } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Entity.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs; use ARUNOX\API; use ARUNOX\Plugins; use ARUNOX\Database\BaseEntity; use ARUNOX\Generator\PWA\Manifest; #[API\PHP\Attributes\Database\Attributes( "status" )] #[API\PHP\Attributes\Database\Attributes( "date_edit" )] #[API\PHP\Attributes\Database\Attributes( "date_create" )] #[API\PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getSystem() : null|false|Plugins\Systems\Entity { if( $this->system_id ) { return Plugins\Systems\Model::get( $this->system_id ); } return NULL; } public function getImages() : array { return Images\Model::getByOrigin( $this->id ); } public function createManifest() : API\Filesystem\File { $images = $this->images; $root = realpath( UPLOADS_DIR ); $filename = "{$root}/manifests/{$this->getHashID()}.json"; $manifest = Manifest::manifest([ "name" => $this->name, "short" => $this->shortname, "url" => "https://{$this->system->domain}/startAsPWA", "version" => 1, "orientation" => "any", "display_override" => [ "fullscreen", "minimal-ui" ], "display" => "standalone", "description" => $this->description, "bg_color" => $this->color_bg ?? "#000000", "theme_color" => $this->color_theme ?? "#33ABC9", "screenshots" => [], "icons" => [] ]); foreach( $images as $image ) { $item = [ "src" => $image->source->url, "sizes" => $image->dimension, "type" => $image->mimetype->label, ]; if( $image->type->value == Images\Type::SCREEN ) { $type = "screenshots"; $item["form_factor"] = strtolower( $image->form_factor->label ); $item["label"] = $image->label; } if( $image->type->value == Images\Type::ICON ) { $type = "icons"; } $manifest[ $type ][] = $item; } return API\Filesystem::putFile( $filename, $manifest ); } } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Images/Model.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs\Images; use ARUNOX\Plugins; use ARUNOX\API\PHP; use ARUNOX\Database\BaseModel; #[PHP\Attributes\Database\Definitions\Table( "pwas_images" )] #[PHP\Attributes\Database\Definitions\HashID( "pimg" )] #[PHP\Attributes\Database\Definitions\Entity( Entity::class )] #[PHP\Attributes\Logs\Rules\Create()] #[PHP\Attributes\Logs\Rules\Update( "status", "Status wurde auf '%4\$t' gesetzt", Status::class )] #[PHP\Attributes\Logs\Rules\Update( "type", "Typ wurde auf '%4\$t' gesetzt", Type::class )] #[PHP\Attributes\Logs\Rules\Update( "name" )] class Model extends BaseModel { /* ### VARIABLES ################################################ # */ /* ### PUBLIC STATIC FUNCTIONS ################################## # */ public static function getByOrigin( int|string|array $origin, null|string $column = NULL ) { $origin = Plugins\PWAs\Model::getValue( $origin ); if( $column ) return Model::getAllValue([ "origin_id" => $origin ], $column ); return Model::getAll([ "origin_id" => $origin ] ); } /* ### PUBLIC STATIC LOG FUNCTIONS ############################## # */ } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Images/FormFactor.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs\Images\API\v1; use ARUNOX\Plugins; use ARUNOX\Database; use ARUNOX\Core\Hooks; use ARUNOX\Core\Router; class Routes { public static function register() : void { /* ### MAIN ROUTES ############################## # */ Router::addAll( Controller::class ); } } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Images/API/v1/Controller.php **/ * @copyright 2025 ARUNOX * @version 1.1.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs\Images\API\v1; use ARUNOX\API; use ARUNOX\HTTP; use ARUNOX\Plugins; use ARUNOX\Core\Hooks; use ARUNOX\API\BaseController; use ARUNOX\Database\BaseEntity; use ARUNOX\Plugins\REST\Generator\Base\BaseGenerator; #[API\PHP\Attributes\Controller\Label( "Bild", "Bilder" )] #[API\PHP\Attributes\Controller\Icon( Plugins\REST\Generator\Config\Icon::Images )] #[API\PHP\Attributes\Controller\Route( "images", Plugins\PWAs\API\v1\Controller::class )] #[API\PHP\Attributes\Database\Definitions\Model( Plugins\PWAs\Images\Model::class )] class Controller extends BaseController { /* ### PUBLIC GET FUNCTIONS ##################################### # */ /** * @api * @method GET * * @route.path /pwas/images * @route.description Listet alle Logeinträge */ public static function getAllPrepared() : array { return parent::getAllPrepared(); } /** * @api * @method GET * * @route.path /pwas/{origin}/images * @route.description Listet alle Logeinträge */ public static function getByOriginPrepared( string $origin ) : array { return parent::getByOriginPrepared( $origin ); } /** * @api * @method GET * * @route.path /pwas/images/{hashid} * @route.description Gibt einen einzelnen Logeintrag anhand der ID zurück */ public static function getPrepared( string $hashid ) : BaseEntity | HTTP\Response { return parent::getPrepared( $hashid ); } /* ### PUBLIC SAVE FUNCTIONS #################################### # */ /** * @api * @method PUT * * @route.path /pwas/images/{hashid} * @route.description Speichert Änderungen an einem bestehenden Termin */ public static function savePrepared( string $hashid, array $data ) : HTTP\Response { return parent::savePrepared( $hashid, $data ); } /** * @api * @method POST * * @route.path /pwas/images * @route.description Erstellt einen neuen Kalender */ public static function createPrepared( array $data ) : HTTP\Response { return parent::createPrepared( $data ); } /** * @api * @method DELETE * * @route.path /pwas/images/{hashid} * @route.description Löscht ein Logeintrag anhand der ID */ public static function deletePrepared( string $hashid ) : HTTP\Response { return parent::deletePrepared( $hashid ); } /** * @api * @method PATCH * * @route.path /pwas/images/{hashid}/status * @route.description Wechselt den Status (aktiv/inaktiv) eines Kalenders */ public static function toggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::toggleStatusPrepared( $hashid ); } /* ### PUBLIC VALIDATE FUNCTIONS ################################ # */ /* ### PUBLIC REST RESPONSE FUNCTIONS ########################### # */ /** * @internal rest * @method PUT * * @route.path /pwas/images/{hashid} * @route.description REST-Antwort nach dem Speichern eines Termins */ public static function restResponseSavePrepared( string $hashid, array $data ) : HTTP\Response { return parent::restResponseSavePrepared( $hashid, $data ); } /** * @internal rest * @method POST * * @route.path /pwas/images * @route.description REST-Antwort nach dem Erstellen eines Kalenders */ public static function restResponseCreate( array $data ) : HTTP\Response { $result = static::createPrepared( $data ); if( $result->isStatus( 200 ) ) { Plugins\REST\Response::closeModals(); Plugins\REST\Response::redirect( "/pwas/images/{$result->getBody("data", "hashid")}" ); } return static::restResponse( $result ); } /** * @internal rest * @method DELETE * * @route.path /pwas/images/{hashid} * @route.description REST-Antwort nach dem Löschen eines Logeintrag */ public static function restResponseDelete( string $hashid ) : HTTP\Response { Plugins\REST\Response::closeModals(); $result = static::deletePrepared( $hashid ); if( $result->isStatus( 200 ) ) { Plugins\REST\Response::redirect( "/pwas/images" ); } return static::restResponse( $result ); } /** * @internal rest * @method PATCH * * @route.path /pwas/images/{hashid}/status * @route.description REST-Antwort zur Status-Umschaltung eines Kalenders */ public static function restResponseToggleStatusPrepared( string $hashid ) : HTTP\Response { return parent::restResponseToggleStatusPrepared( $hashid ); } /* ### PUBLIC REST CONFIG FUNCTIONS ############################# # */ /** * @internal rest * @method GET * * @route.path /pwas/images * @route.description REST-Konfiguration für Logbuch-Tabelle */ public static function restConfigOverview() : BaseGenerator { return Plugins\REST\Response::addWrapper( "overview", static::getPlural() ) ->replaceContent( static::restConfigTable() ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], "pwas\images" )) ) ; } /** * @internal rest * @method GET * * @route.path /pwas/images/{hashid} * @route.description REST-Konfiguration für Detailansicht eines Logeintrags */ public static function restConfigDetails( string $hashid ) : BaseGenerator { return Plugins\REST\Response::addModal( "details", static::getSingular( "%t bearbeiten" ) ) ->setSize( "equal" ) ->get() ->setApi( static::getRoute( $hashid ) ) ->setAction( static::getRoute( $hashid ), "PUT" ) ->addTab( static::getSingular() )->get() ->setIcon( static::getIcon() ) ->addHeadline( static::getSingular(), 2 ) ->addCallable( [ static::class, "restConfigInputs" ], $hashid ) ->parent() ->addCallable( [ Plugins\Logs\API\v1\Controller::class, "restConfigTab" ], $hashid ) ->addTab( "Speichern" )->get() ->setColor( Plugins\REST\Generator\Config\Color::Primary ) ->setIcon( "bi bi-save" ) ->setType( "submit" ); } /** * @internal rest * @method GET * * @route.path /pwas/images/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreatePrepared() : BaseGenerator { return parent::restConfigCreatePrepared(); } /** * @internal rest * @method GET * * @route.path /pwas/{origin}/images/create * @route.description REST-Konfiguration für das Erstellen eines Kalenders (Formular) */ public static function restConfigCreateByOriginPrepared( bool | string $origin = FALSE ) : BaseGenerator { return parent::restConfigCreateByOriginPrepared( $origin ); } /** * @internal rest * @method GET * * @route.path /pwas/images/{hashid}/delete * @route.description REST-Konfiguration für die Lösch-Bestätigung eines Logeintrags */ public static function restConfigDeletePrepared( string $hashid ) : BaseGenerator { return parent::restConfigDeletePrepared( $hashid ); } /* ### PUBLIC REST EXTENSION FUNCTIONS ########################## # */ public static function restConfigTab( BaseGenerator $rest, null|string $hashid = NULL ) : void { $rest->addTab( static::getLabelGroup(), static::getPlural() )->get() ->setIcon( static::getIcon() ) ->addContent( static::restConfigTable( $hashid ) ) ; } public static function restConfigTable( null|string $hashid = NULL ) : BaseGenerator { $root = static::getRoute( "1:{$hashid}" ); $rest = Plugins\REST\Generator\Data\Table::create() ->setApi( $root ) ->setAction( static::getRoute( "{hashid}" ) ) ->setOrder( "label", "asc" ) ->setSearch( TRUE ) ->addButton(...Hooks::filter( "rest.generator::button.name->create", [], $root )) ->addColumn(...Hooks::filter( "rest.generator::column.type->status", [ "label" => Plugins\PWAs\Images\Status::getSingular(), "icon" => Plugins\PWAs\Images\Status::getIcon(), "options" => Plugins\PWAs\Images\Status::getAll(), ], "status", [], "pwas\images", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Plugins\PWAs\Images\Type::getSingular(), "icon" => Plugins\PWAs\Images\Type::getIcon(), "options" => Plugins\PWAs\Images\Type::getAll(), ], "type", [], "pwas\images", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Plugins\PWAs\Images\Mimetype::getSingular(), "icon" => Plugins\PWAs\Images\Mimetype::getIcon(), "options" => Plugins\PWAs\Images\Mimetype::getAll(), ], "mimetype", [], "pwas\images", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->icon", [ "label" => Plugins\PWAs\Images\FormFactor::getSingular(), "icon" => Plugins\PWAs\Images\FormFactor::getIcon(), "options" => Plugins\PWAs\Images\FormFactor::getAll(), ], "form_factor", [], "pwas\images", "hashid" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "dimension", TRUE, TRUE, TRUE, "pwas\images" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "source", TRUE, TRUE, TRUE, "pwas\images" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->text", [], "label", TRUE, TRUE, TRUE, "pwas\images" )) ->addColumn(...Hooks::filter( "rest.generator::column.type->datetime", [], "date_edit", TRUE, FALSE, TRUE, "pwas\images" )) ; return $rest; } public static function restConfigOrigin( BaseGenerator $rest, bool|string $hashid ) : BaseGenerator { if( $hashid === FALSE ) { return $rest->addField(...Hooks::filter( "rest.generator::control.type->select", [ "options" => Plugins\PWAs\Model::getAsOptions( "title" ), ], "origin_id", TRUE, FALSE, "pwas\images" )); } $origin = Plugins\PWAs\Model::getValue( $hashid, "id" ); return $rest->addField(...Hooks::filter( "rest.generator::control.type->hidden", [], "origin_id", $origin ?? $hashid, "pwas\images" )); } public static function restConfigInputs( BaseGenerator $rest ) : BaseGenerator { return $rest ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "label" => Plugins\PWAs\Images\Status::getSingular(), "options" => Plugins\PWAs\Images\Status::getAll(), ], "status", TRUE, FALSE, "pwas\images" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "label" => Plugins\PWAs\Images\Type::getSingular(), "options" => Plugins\PWAs\Images\Type::getAll(), ], "type", TRUE, FALSE, "pwas\images" )) ->addField(...Hooks::filter( "rest.generator::control.type->select", [ "label" => Plugins\PWAs\Images\FormFactor::getSingular(), "options" => Plugins\PWAs\Images\FormFactor::getAll(), ], "form_factor", TRUE, FALSE, "pwas\images" )) ->addField(...Hooks::filter( "rest.generator::control.type->file", [], "source", TRUE, "pwas\images" )) ->addField(...Hooks::filter( "rest.generator::control.type->text", [], "label", FALSE, "pwas\images" )) ; } } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Images/Type.php **/ * @copyright 2025 ARUNOX * @version 1.0.0 * * @since 1.0.0 File is created */ namespace ARUNOX\Plugins\PWAs\Images; use ARUNOX\Plugins; use ARUNOX\API\PHP; use ARUNOX\Database; #[PHP\Attributes\Database\Attributes( "type", Type::class )] #[PHP\Attributes\Database\Attributes( "status", Status::class )] #[PHP\Attributes\Database\Attributes( "form_factor", FormFactor::class )] #[PHP\Attributes\Database\Attributes( "mimetype", "mimetype" )] #[PHP\Attributes\Database\Attributes( "dimension", "dimension" )] #[PHP\Attributes\Database\Attributes( "source", Database\Attribute\File::class )] #[PHP\Attributes\Database\Attributes( "date_edit" )] #[PHP\Attributes\Database\Attributes( "date_create" )] #[PHP\Attributes\Database\Definitions\Model( Model::class )] class Entity extends Database\BaseEntity { /* ### VARIABLES ################################################ # */ /* ### PUBLIC FUNCTIONS ######################################### # */ public function getOrigin() { return Plugins\PWAs\Model::get( $this->origin_id ); } public function getMimetype() : Mimetype { if( !$this->source?->mime ?? FALSE ) return new Mimetype( 0, $this ); $mimetypes = Mimetype::getAll(); $mimetypes = array_column( $mimetypes, "value", "label" ); $minetype = $mimetypes[ $this->source->mime ]; return new Mimetype( $minetype, $this ); } public function getDimension() : null|string { if( $sizes = $this->source?->sizes ?? FALSE ) { return implode( "x", $sizes ); } return NULL; } } /** Datei: plugins/pwas/library/ARUNOX/Plugins/PWAs/Images/Status.php **/