/** Datei: plugins/pwas/library/ARUNOX/Generator/PWA/Manifest.php **/ * @copyright 2024 Sparky@ARUNOX * @version 1.0.0 * @since 1.0.0 File is created */ namespace ARUNOX\Generator\PWA; class Manifest { /* ### VARIABLES ################################################ # */ protected static array $ORIENTATION = [ "any" => [ "A" ], "natural" => [ "N" ], "landscape" => [ "L" ], "landscape-primary" => [ "L!", "L1" ], "landscape-secondary" => [ "L2" ], "portrait" => [ "P" ], "portrait-primary" => [ "P!", "P1" ], "portrait-secondary" => [ "P2" ], ]; protected static array $DISPLAY = [ "fullscreen" => [ "F" ], "standalone" => [ "S" ], "minimal-ui" => [ "U" ], "browser" => [ "B" ], ]; /* ### PUBLIC FUNCTIONS ######################################### # */ public static function orientation( $config = NULL ) { if( key_exists( $config, static::$ORIENTATION ) ) return $config; foreach( static::$ORIENTATION as $key => $shorts ) { if( in_array( $config, $shorts ) ) return $key; } return "any"; } public static function display( $config = NULL ) { if( key_exists( $config, static::$DISPLAY ) ) return $config; foreach( static::$DISPLAY as $key => $shorts ) { if( in_array( $config, $shorts ) ) return $key; } return "browser"; } public static function manifest( $config ) { foreach( $config["display_override"] as &$display ) { $display = static::display( $display ); } return array_filter([ "name" => $config["name"], "short_name" => $config["short"] ?? $config["name"], "description" => $config["description"] ?? NULL, "id" => $config["url"], // "start_url" => $config["url"], "start_url" => extend_url_query( $config["url"], [ "version" => $config["version"] ?? "0" ] ), // "scope" => $config["scope"] ?? "/", "orientation" => static::orientation( $config["orientation"] ), "display" => static::display( $config["display"] ), "display_override" => $config["display_override"], "icons" => (array)( $config["icons"] ?? [] ), "shortcuts" => (array)( $config["shortcuts"] ?? [] ), "screenshots" => (array)( $config["screenshots"] ?? [] ), "protocol_handlers" => $config["protocol"] ?? NULL, "background_color" => $config["bg_color"] ?? "#000000", "theme_color" => $config["theme_color"] ?? "#33ABC9", ]); } /* ### PROTECTED FUNCTIONS ####################################### # */ /* ### PRIVATE FUNCTIONS ######################################## # */ /* ### MAGIC FUNCTIONS ########################################## # */ }