<?php

class button
{
    public static function confirm(array $_array = NULL)
    {
        $config = array(
            "value" => "Valider",
            "title" => "Confirmation",
            "text" => "Vous êtes certain de vouloir poursuivre ?",
            "confirm" => "Continuer",
            "cancel" => "Annuler",
            "type" => "submit",
            "class" => "btn btn-primary btn-lg",
            "style" => "width: 100%",
            "add" => ""
        );

        if($_array != NULL){
            (!empty($_array["value"])) ? $config["value"] = $_array["value"] : NULL;
            (!empty($_array["text"])) ? $config["text"] = $_array["text"] : NULL;
            (!empty($_array["title"])) ? $config["title"] = $_array["title"] : NULL;
            (!empty($_array["confirm"])) ? $config["confirm"] = $_array["confirm"] : NULL;
            (!empty($_array["cancel"])) ? $config["cancel"] = $_array["cancel"] : NULL;
            (!empty($_array["type"])) ? $config["type"] = $_array["type"] : NULL;
            (!empty($_array["class"])) ? $config["class"] = $_array["class"] : NULL;
            (!empty($_array["style"])) ? $config["style"] = $_array["style"] : NULL;
            (!empty($_array["id"])) ? $config["id"] = $_array["id"] : NULL;
            (!empty($_array["add"])) ? $config["add"] = $_array["add"] : NULL;
        }
        
        $print = "<input ";
        $print .= 'class="' . $config["class"] .'" ';
        $print .= 'style="' . $config["style"] .'" ';
        $print .= 'type="' . $config["type"] .'" ';
        $print .= 'value="' . $config["value"] .'" ';
        $print .= 'data-confirm="' . $config["text"] .'" ';
        $print .= 'data-confirm-title="' . $config["title"] .'" ';
        $print .= 'data-confirm-button-confirm="' . $config["confirm"] .'" ';
        $print .= 'data-confirm-button-cancel="' . $config["cancel"] .'" ';
        if(!empty($_array["id"])) { $print .= 'id="' . $config["id"] .'" '; }
        $print .= ' ' . $config["add"] .'>';

        echo $print;
    }

}
