Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

dialog-james.class.php

Go to the documentation of this file.
00001 <?
00002 
00003 // Clase DialogJames
00004 
00005 /* Esta clase intenta ofrecer una forma para hacer páginas WEB con
00006   forma de ventana de diálogo de una manera sencilla. Esto puede
00007   resultar útil para casos como: enviar un mensaje al foro, crear un
00008   directorio en el repositorio, etc. En definitiva para aquellas 
00009   páginas que consistan en un formulario. 
00010   
00011   Las ventajas que puede aportar son:
00012    - Evitar tener que pensar el codigo HTML (no es muy dificil pero si
00013      una lata) cada vez que se quiere hacer.
00014    - Una forma de unificar todas las páginas del mismo estilo en james.
00015    
00016   Nota sobre el futuro de DialogJames: Ahora mismo esta hecho en HTML
00017   puro y duro, pero la idea es que sea una clase derivada de 
00018   TableJames y FormJames para su uso específico en este tipo de páginas,
00019   de esta forma, la migración sólo habrá que hacerla una vez en
00020   DialogJames, no una vez por página.
00021   
00022   Ejemplo de uso básico:
00023   
00024           $dialogo = new DialogJames("Titulo ventana" [, "tamaño_en_%_sin_%"]);
00025           
00026           $dialogo->PrintHeader();
00027           
00028           // Aqui viene todo el codigo especifico que quieras poner 
00029           
00030           $dialogo->PrintFoot();        // El foot incluye los botones
00031   
00032   
00033   Personalizacion de los botones (debe ir antes de PrintFoot):
00034   
00035           $dialogo->SetOK("Texto" [, "Nombre" [, "Tipo" [, "onClick"]]]);
00036           $dialogo->SetCancel("Texto" [, "Nombre" [, "Tipo" [, "onClick"]]]);
00037   
00038   Donde Tipo es button ó submit.
00039 */
00040 
00041 
00042 /* Definición de constantes para la clase */
00043 define ("DIALOG_DEFAULT_SIZE", 75);
00044 
00045 define ("DIALOG_DEFAULT_OK_TEXT", " Aceptar ");
00046 define ("DIALOG_DEFAULT_OK_NAME", "ok");
00047 define ("DIALOG_DEFAULT_OK_TYPE", "submit");
00048 define ("DIALOG_DEFAULT_OK_ONCLICK", "");
00049 
00050 define ("DIALOG_DEFAULT_CANCEL_TEXT", "Cancelar");
00051 define ("DIALOG_DEFAULT_CANCEL_NAME", "cancel");
00052 define ("DIALOG_DEFAULT_CANCEL_TYPE", "submit");
00053 define ("DIALOG_DEFAULT_CANCEL_ONCLICK", "");
00054 
00055 class DialogJames
00056 {
00057 
00058         // Título del Diálogo
00059         var $title;
00060         
00061         // Tamaño del Diálogo
00062         var $size;
00063         
00064         // Botones del Diálogo
00065         var $okButton;
00066         var $cancelButton;
00067         
00068         
00069         // DialogJames($title [, $size])
00070         function DialogJames($title)
00071         {
00072                 $this->title = $title;
00073                 
00074                 /* Si especificamos el tamaño */
00075                 if (func_num_args() == 2)
00076                         $this->size = func_get_arg(1);
00077                 else
00078                         $this->size = DIALOG_DEFAULT_SIZE;
00079                         
00080                 /* Fijamos los valores por defecto para los botones */
00081                 $this->okButton["show"] = false;
00082                 $this->cancelButton["show"] = false;
00083         }
00084         
00085         
00086         // SetOK("Texto" [, "Nombre" [, "Tipo" [, "onClick"]]])
00087         function SetOK($text)
00088         {
00089                 $this->okButton["show"] = true; 
00090                 $this->okButton["text"] = $text;
00091 
00092                 /* Fijamos valores por defecto para el botón */
00093                 $this->okButton["name"] = DIALOG_DEFAULT_OK_NAME;
00094                 $this->okButton["type"] = DIALOG_DEFAULT_OK_TYPE;
00095                 $this->okButton["onClick"] = DIALOG_DEFAULT_OK_ONCLICK;
00096                 
00097                 switch(func_num_args())
00098                 {
00099                         case 4:
00100                                 $this->okButton["onClick"] = func_get_arg(3);
00101                         case 3:
00102                                 $this->okButton["type"] = func_get_arg(2);
00103                         case 2:
00104                                 $this->okButton["name"] = func_get_arg(1);
00105                 }
00106         }
00107         
00108 
00109         // SetCancel("Texto" [, "Nombre" [, "Tipo" [, "onClick"]]])
00110         function SetCancel($text)
00111         {
00112                 $this->cancelButton["show"] = true;
00113                 $this->cancelButton["text"] = $text;
00114                 
00115                 /* Fijamos valores por defecto para el botón */
00116                 $this->cancelButton["name"] = DIALOG_DEFAULT_CANCEL_NAME;
00117                 $this->cancelButton["type"] = DIALOG_DEFAULT_CANCEL_TYPE;
00118                 $this->cancelButton["onClick"] = DIALOG_DEFAULT_CANCEL_ONCLICK;
00119                 
00120                 switch(func_num_args())
00121                 {
00122                         case 4:
00123                                 $this->cancelButton["onClick"] = func_get_arg(3);
00124                         case 3:
00125                                 $this->cancelButton["type"] = func_get_arg(2);
00126                         case 2:
00127                                 $this->cancelButton["name"] = func_get_arg(1);
00128                 }
00129         }
00130         
00131         
00132         // PrintHeader(["Texto"]) // hace q ignore el valor dado al crearlo
00133         function PrintHeader()
00134         {               
00135                 if (func_num_args() == 1)
00136                         $this->title = func_get_arg(0);
00137                 ?>      
00138                 <table class="dialog" cellpadding="3" align="center" cellspacing="3" width="<?echo $this->size;?>%">
00139                 <tr class="dialog-header"> 
00140                         <td class="dialog-header"><? echo $this->title; ?></td>
00141                 </tr>
00142                 <tr> 
00143                         <td>&nbsp;</td>
00144                 </tr>
00145                 <tr>
00146                         <td> 
00147                 <?
00148         }
00149         
00150         
00151         function PrintFoot()
00152         {
00153                 /* Obtenemos las lineas de cada uno de los botones */
00154                 if ($this->okButton["show"])
00155                 {
00156                         $okLine  = " type='".$this->okButton["type"]."' ";
00157                         $okLine .= " name='".$this->okButton["name"]."' ";
00158                         $okLine .= " value='".$this->okButton["text"]."' ";
00159                         $okLine .= " onClick='".$this->okButton["onClick"]."' ";
00160                 }
00161 
00162                 if ($this->cancelButton["show"])                
00163                 {
00164                         $cancelLine  = " type='".$this->cancelButton["type"]."' ";
00165                         $cancelLine .= " name='".$this->cancelButton["name"]."' ";
00166                         $cancelLine .= " value='".$this->cancelButton["text"]."' ";
00167                         $cancelLine .= " onClick='".$this->cancelButton["onClick"]."' ";
00168                 }
00169                 
00170 
00171                 /* Imprimimos el pie del dialogo */
00172                 ?>
00173                 
00174                         </td>
00175                 </tr>
00176                 <tr> 
00177                         <td align="center"> 
00178                                 <?
00179                                         if ($this->okButton["show"])
00180                                                 echo "<input class='Button' ".$okLine." >";
00181                                         
00182                                         if ($this->cancelButton["show"])
00183                                         {
00184                                                 echo "&nbsp;&nbsp;&nbsp;";
00185                                                 echo "<input class='Button' ".$cancelLine." >";
00186                                         }
00187                                         echo "</td>\n";
00188                                 ?>
00189                         </td>
00190                 </tr>
00191                 <tr> 
00192                         <td>&nbsp;</td>
00193                 </tr>
00194                 </table>
00195                 <?
00196         }
00197 
00198         /*      echo "\t\t\t</td>\n";
00199                 echo "\t\t</tr>\n";
00200                 echo "\t\t<tr>\n";
00201                 echo "\t\t\t<td align='center'>\n";
00202                 
00203                 echo "\t\t\t\t<input class='actionButton'".$okLine.">\n";
00204                 echo "\t\t\t\t&nbsp;&nbsp;&nbsp;\n";
00205                 echo "\t\t\t\t<input class='actionButton'".$cancelLine.">\n";
00206                 
00207                 echo "\t\t\t</td>\n";
00208                 echo "\t\t</tr>\n";
00209                 echo "\t\t<tr>\n";
00210                 echo "\t\t\t<td>&nbsp;</td>\n";
00211                 echo "\t\t</tr>\n";
00212             echo "\t</table>\n";
00213         */
00214 }
00215                 
00216 
00217                 
00218   
00219   

Generated on Wed Nov 19 20:29:34 2003 for James by doxygen 1.3.4