b72e61b4e1f85f029540d67b10bec9e5ac9d2b55
1 <?php
3 define("INFO_DIALOG" , 10001);
4 define("WARNING_DIALOG" , 10002);
5 define("ERROR_DIALOG" , 10003);
6 define("CONFIRM_DIALOG" , 10004);
8 class msg_dialog
9 {
10 private $s_Title = "Undefined";
11 private $s_Message = "Undefined";
12 private $i_Type = INFO_DIALOG ;
13 private $i_ID = 0;
14 private $a_Trace = array();
16 public function __construct($s_title,$s_message,$i_type)
17 {
18 if(!in_array($i_type,array(INFO_DIALOG,WARNING_DIALOG,ERROR_DIALOG,CONFIRM_DIALOG))){
19 trigger_error("Invalid msg_dialog type.");
20 $i_type = INFO_DIALOG;
21 }
23 $this->i_ID = preg_replace("/[^0-9]*/","",microtime());
24 $this->s_Title = $s_title;
25 $this->s_Message = $s_message;
26 $this->i_Type = $i_type;
27 $this->a_Trace = debug_backtrace();
28 if(!isset($_SESSION['msg_dialogs'])){
29 $_SESSION['msg_dialogs'] = array();
30 }
31 $_SESSION['msg_dialogs'][] = $this;
32 }
34 public static function display($s_title,$s_message,$i_type = INFO_DIALOG)
35 {
36 new msg_dialog($s_title,$s_message,$i_type);
37 }
39 public function get_ID()
40 {
41 return($this->i_ID);
42 }
44 public function execute()
45 {
46 $smarty = get_smarty();
47 $smarty->assign("s_Trace",print_a($this->a_Trace,TRUE));
48 $smarty->assign("i_Type",$this->i_Type);
49 $smarty->assign("s_Message",$this->s_Message);
50 $smarty->assign("s_Title",$this->s_Title);
51 $smarty->assign("i_ID",$this->i_ID);
52 $smarty->assign("frame",false);
53 $smarty->assign("IE",preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']));
54 return($smarty->fetch(get_template_path('msg_dialog.tpl')));
55 }
58 public function is_confirmed()
59 {
60 if(isset($_POST['MSG_OK'.$this->i_ID])){
61 return(TRUE);
62 }else{
63 return(FALSE);
64 }
65 }
68 public static function get_dialogs()
69 {
70 $return ="";
71 $dialog_ids= "";
73 $seen = "";
74 if(isset($_POST['closed_msg_dialogs'])){
75 # $seen = $_POST['closed_msg_dialogs'];
76 }
78 if(isset($_SESSION['msg_dialogs']) && is_array($_SESSION['msg_dialogs'])){
80 /* Get frame one */
81 $smarty = get_smarty();
82 $smarty->assign("frame", true);
83 $smarty->assign("IE",preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']));
84 $return = $smarty->fetch(get_template_path('msg_dialog.tpl'));
86 foreach($_SESSION['msg_dialogs'] as $key => $dialog){
88 if(preg_match("/".$dialog->get_ID()."/",$seen)){
89 unset($_SESSION['msg_dialogs'][$key]);
90 }else{
91 $return.= $dialog->execute();
92 $dialog_ids= $dialog->get_ID().",".$dialog_ids;
93 }
94 unset($_SESSION['msg_dialogs'][$key]);
95 }
96 $dialog_ids = preg_replace("/,$/","",$dialog_ids);
98 $return .= "</div>";
99 $return .="<input type='hidden' style='width:400px;' name='pending_msg_dialogs' id='pending_msg_dialogs' value='".$dialog_ids."'>";
100 $return .="<input type='hidden' style='width:400px;' name='closed_msg_dialogs' id='closed_msg_dialogs' value=''>";
101 $return .="<input type='hidden' style='width:400px;' name='current_msg_dialogs' id='current_msg_dialogs' value=''>";
102 $return .="<input type='hidden' style='width:700px;' name='js_debug' id='js_debug'>";
103 }
104 return($return);
105 }
106 }
107 ?>