"Errori","icon"=>"fa fa-exclamation-triangle","color-class"=>"danger"]; $types["warning"] = ["label"=>"Avvisi","icon"=>"fa fa-exclamation-circle","color-class"=>"warning"]; $types["success"] = ["label"=>"Completo","icon"=>"fa fa-check","color-class"=>"success"]; $this->types = $types; $this->id = $id; $this->alerts = []; $this->modal = false; if (!empty($this->id)) { $_SESSION["alertsManager"][$this->id] = &$this; } } public function printAlertModalButton() { include(__DIR__."/button.php"); } public function printList() { $this->modal = false; return $this->includeView(); } public function printModal() { $this->modal = true; return $this->includeView(); } private function includeView() { $view = __DIR__."/list.php"; if (file_exists($view)) { include($view); return true; } return false; } public function addAlert($type,$msg,$href="") { if (isset($this->types[$type])) { $alert = []; $alert["text"] = $msg; $alert["href"] = $href; $this->alerts[$type][] = $alert; } else { return false; } } public function addDangerAlert($msg,$href = "") { $this->addAlert("danger",$msg,$href); } public function addWarningAlert($msg,$href = "") { $this->addAlert("warning",$msg,$href); } public function addSuccessAlert($msg,$href = "") { $this->addAlert("success",$msg,$href); } public static function printAlertBox(string $titolo,$msg = null) { include (__DIR__."/views/alert.php"); } public static function printWarningBox(string $titolo,$msg = null) { include (__DIR__."/views/warning.php"); } public static function printSuccessBox(string $titolo,$msg = null) { include (__DIR__."/views/success.php"); } public static function printInfoBox(string $titolo,$msg = null) { include (__DIR__."/views/info.php"); } public static function printAlertCompact(string $titolo,$msg = null) { include (__DIR__."/views/alert-compact.php"); } public static function printWarningCompact(string $titolo,$msg = null) { include (__DIR__."/views/warning-compact.php"); } public static function printSuccessCompact(string $titolo,$msg = null) { include (__DIR__."/views/success-compact.php"); } public static function printInfoCompact(string $titolo,$msg = null) { include (__DIR__."/views/info-compact.php"); } public static function printCliAlert(string $msg) { $msg = "[" . date("Y-m-d H:i:s") . "] - " . $msg; echo "\033[91m{$msg}\033[39m" . PHP_EOL; } public static function printCliException(\Exception $e) { $msg = "[" . date("Y-m-d H:i:s") . "] - " . $e->getMessage(); echo "\033[91m{$msg}\033[39m" . PHP_EOL; echo $e->getTraceAsString(); } public static function printCliWarning(string $msg) { $msg = "[" . date("Y-m-d H:i:s") . "] - " . $msg; echo "\033[93m{$msg}\033[39m" . PHP_EOL; } public static function printCliSuccess(string $msg) { $msg = "[" . date("Y-m-d H:i:s") . "] - " . $msg; echo "\033[92m{$msg}\033[39m" . PHP_EOL; } public static function printCliInfo(string $msg) { $msg = "[" . date("Y-m-d H:i:s") . "] - " . $msg; echo "\033[96m{$msg}\033[39m" . PHP_EOL; } } ?>