Code

Added initial message handling
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 18 Sep 2007 14:00:56 +0000 (14:00 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 18 Sep 2007 14:00:56 +0000 (14:00 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@7316 594d385d-05f5-0310-b6e9-bd551577e9d8

html/main.php
ihtml/themes/default/framework.tpl
ihtml/themes/default/msg_dialog.tpl [new file with mode: 0644]
include/class_msg_dialog.inc [new file with mode: 0644]

index b99ea8ba1be9d07f444450bf02d38e584ec0b406..1481915cc44dd099f1e3168ab897ad27046d59da 100644 (file)
@@ -359,7 +359,12 @@ if (is_file("$plugin_dir/main.inc")){
 
 
 /* Print_out last ErrorMessage repeated string. */
+#msg_dialog::display("Error"   ,"Kann datei nicht schreiben, bla",ERROR_DIALOG);
+#msg_dialog::display("Warning" ,"Kann datei nicht schreiben, bla",WARNING_DIALOG);
+#msg_dialog::display("Info"    ,"Kann datei nicht schreiben, bla",INFO_DIALOG);
+#msg_dialog::display("Confirm" ,"Kann datei nicht schreiben, bla",CONFIRM_DIALOG);
 
+$smarty->assign("msg_dialogs", msg_dialog::get_dialogs());
 $smarty->assign("contents", $display);
 
 /* Assign erros to smarty */
index 89be08a551f7f1fa0f2bd4f3ab0525c925499403..fd2baefc50f67eff9bd1261fc53f7ac6f05f6932 100644 (file)
@@ -45,6 +45,7 @@
       <table style="vertical-align:top; text-align:justify; background-color: white; border:1px solid #AAA; margin-top:0px; margin-left:7px; margin-right:7px; width:99%" summary="">
        <tr>
         <td>
+       {$msg_dialogs}
         {$contents}
        </td>
       </tr>
diff --git a/ihtml/themes/default/msg_dialog.tpl b/ihtml/themes/default/msg_dialog.tpl
new file mode 100644 (file)
index 0000000..2a24061
--- /dev/null
@@ -0,0 +1,160 @@
+{if $IE}
+       <iframe id='e_layer3{$i_ID}'
+               style="
+                       position:absolute;
+                       width:100%;
+                       height:100%;
+                       top:0px;
+                       left:0px;
+                       border:none;
+                       border-style:none;
+                       border-width:0pt;
+                       display:block;
+                       allowtransparency='true';
+                       background-color: #FFFFFF;
+                       filter:chroma(color=#FFFFFF);
+                       z-index:0; ">
+       </iframe>
+       <div  id='e_layer2{$i_ID}'
+               style="
+                       position: absolute;
+                       left: 0px;
+                       top: 0px;
+                       right:0px;
+                       bottom:0px;
+                       z-index:0;
+                       width:100%;
+                       height:100%;
+                       filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='images/opacity_black.png'); ">
+{else}
+       <div  id='e_layer2{$i_ID}'>
+<!--           style="
+                       position: absolute;
+                       left: 0px;
+                       top: 0px;
+                       right:0px;
+                       bottom:0px;
+                       z-index:0;
+                       background-image: url(images/opacity_black.png);">
+-->
+{/if}
+
+{if $i_Type == ERROR_DIALOG}
+       <div id='e_layer{$i_ID}'
+                       style='left:20%;
+                               right:20%;
+                               top:30%;
+                               background-color:white;
+                               padding:5px;
+                               border:5px solid red;
+                               z-index:150;
+                               position:absolute;'>
+               <table style='width:100%' summary='' border=0>
+                       <tr>
+                               <td style='vertical-align:top;padding:10px'>
+                                       <img src='images/error.png' alt='{t}Error{/t}'>
+                               <img alt='' src=''>
+                               </td>
+                               <td style='width:100%'>
+                                       <h1>{$s_Title}</h1>
+                                       <b>{$s_Message}</b>
+                                       <br>
+                                       <br>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td colspan='2' align='center'>
+                                       <button type='button' name='MSG_OK{$i_ID}' onClick='hide("e_layer{$i_ID}");hide("e_layer2{$i_ID}");'>{t}Ok{/t}</button>
+                               </td>
+                       </tr>
+               </table>
+       </div>
+</div>
+{elseif $i_Type == WARNING_DIALOG}
+       <div id='e_layer{$i_ID}'
+                       style='left:20%;
+                               right:20%;
+                               top:30%;
+                               background-color:white;
+                               padding:5px;
+                               border:5px solid yellow;
+                               z-index:150;
+                               position:absolute;'>
+               <table style='width:100%' summary='' border=0>
+                       <tr>
+                               <td style='vertical-align:top;padding:10px'>
+                                       <img src='images/warning.png'  alt='{t}Warning{/t}'>
+                               </td>
+                               <td style='width:100%'>
+                                       <h1>{$s_Title}</h1>
+                                       <b>{$s_Message}</b>
+                                       <br>
+                                       <br>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td colspan='2' align='center'>
+                                       <button type='button' name='MSG_OK{$i_ID}' onClick='hide("e_layer{$i_ID}");hide("e_layer2{$i_ID}");'>{t}Ok{/t}</button>
+                               </td>
+                       </tr>
+               </table>
+       </div>
+</div>
+{elseif $i_Type == INFO_DIALOG}
+       <div id='e_layer{$i_ID}'
+                       style='left:20%;
+                               right:20%;
+                               top:30%;
+                               background-color:white;
+                               padding:5px;
+                               border:5px solid green;
+                               z-index:150;
+                               position:absolute;'>
+               <table style='width:100%' summary='' border=0>
+                       <tr>
+                               <td style='vertical-align:top;padding:10px'>
+                                       <img src='images/info.png' alt='{t}Information{/t}'>
+                               </td>
+                               <td style='width:100%'>
+                                       <h1>{$s_Title}</h1>
+                                       <b>{$s_Message}</b>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td colspan='2' align='center'>
+                                               <button type='button' name='MSG_OK{$i_ID}' onClick='hide("e_layer{$i_ID}");hide("e_layer2{$i_ID}");'>{t}Ok{/t}</button>
+                               </td>
+                       </tr>
+               </table>
+       </div>
+</div>
+{elseif $i_Type == CONFIRM_DIALOG}
+       <div id='e_layer{$i_ID}'
+                       style='left:20%;
+                               right:20%;
+                               top:30%;
+                               background-color:white;
+                               padding:5px;
+                               border:5px solid green;
+                               z-index:150;
+                               position:absolute;'>
+               <table style='width:100%' summary='' border=0>
+                       <tr>
+                               <td style='vertical-align:top;padding:10px'>
+                                       <img src='images/info.png' alt='{t}Information{/t}'>
+                               </td>
+                               <td style='width:100%'>
+                                       <h1>{$s_Title}</h1>
+                                       <b>{$s_Message}</b>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td colspan='2' align='center'>
+                                       <button type='submit' name='MSG_OK{$i_ID}'      onClick='hide("e_layer{$i_ID}");hide("e_layer2{$i_ID}");'>{t}Ok{/t}</button>
+                                       <button type='button' name='MSG_CANCEL{$i_ID}' onClick='hide("e_layer{$i_ID}");hide("e_layer2{$i_ID}");'>{t}Cancel{/t}</button>
+                               </td>
+                       </tr>
+               </table>
+       </div>
+</div>
+{/if}
diff --git a/include/class_msg_dialog.inc b/include/class_msg_dialog.inc
new file mode 100644 (file)
index 0000000..5e3a7cd
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+
+define("INFO_DIALOG"   , 10001);
+define("WARNING_DIALOG"        , 10002);
+define("ERROR_DIALOG"  , 10003);
+define("CONFIRM_DIALOG"        , 10004);
+
+class msg_dialog
+{
+       private $s_Title        = "Undefined";
+       private $s_Message      = "Undefined";
+       private $i_Type         = INFO_DIALOG ;
+       private $i_ID           = 0;
+
+       public function __construct($s_title,$s_message,$i_type)
+       {
+               $this->i_ID      = preg_replace("/[^0-9]*/","",microtime()); 
+               $this->s_Title   = $s_title;
+               $this->s_Message = $s_message;
+               $this->i_Type    = $i_type;
+               if(!isset($_SESSION['msg_dialogs'])){
+                       $_SESSION['msg_dialogs'] = array();
+               }
+               $_SESSION['msg_dialogs'][] = $this;
+       }
+
+       public static function display($s_title,$s_message,$i_type = INFO_DIALOG)
+       {
+               $box = new msg_dialog($s_title,$s_message,$i_type);     
+       }
+
+       public function is_confirmed()
+       {
+               if($this->i_Type == CONFIRM_DIALOG && isset($_POST['MSG_OK'])){
+                       return(TRUE);
+               }
+       }
+
+       public function execute()
+       {
+               $smarty = get_smarty();
+               $smarty->assign("i_Type",$this->i_Type);
+               $smarty->assign("s_Message",$this->s_Message);
+               $smarty->assign("s_Title",$this->s_Title);
+               $smarty->assign("i_ID",$this->i_ID);
+               $smarty->assign("IE",preg_match("/MSIE/", $_SERVER['HTTP_USER_AGENT']));
+               return($smarty->fetch(get_template_path('msg_dialog.tpl')));
+       }
+       
+
+       public static function get_dialogs()
+       {
+               $return  ="";
+               if(isset($_SESSION['msg_dialogs']) && is_array($_SESSION['msg_dialogs'])){
+                       foreach($_SESSION['msg_dialogs'] as $key => $dialog){
+                               $return.= $dialog->execute();
+                       }
+               }
+               unset($_SESSION['msg_dialogs']);
+               return($return);
+       }
+}
+?>