1 | <?php |
---|
2 | // ************************************************************************************************************************************************* |
---|
3 | // Aplicación WEB: ogAdmWebCon |
---|
4 | // Autor: José Manuel Alonso (E.T.S.I.I.) Universidad de Sevilla |
---|
5 | // Fecha Creación: Año 2009-2010 |
---|
6 | // Fecha Última modificación: Agosto-2010 |
---|
7 | // Nombre del fichero: gestor_imagenes.php |
---|
8 | // Descripción : |
---|
9 | // Gestiona el mantenimiento de la tabla de imagenes |
---|
10 | // ************************************************************************************************************************************************* |
---|
11 | include_once("../includes/ctrlacc.php"); |
---|
12 | include_once("../clases/AdoPhp.php"); |
---|
13 | include_once("../clases/XmlPhp.php"); |
---|
14 | include_once("../clases/ArbolVistaXML.php"); |
---|
15 | include_once("../includes/CreaComando.php"); |
---|
16 | include_once("../includes/constantes.php"); |
---|
17 | include_once("../includes/opciones.php"); |
---|
18 | include_once("./relaciones/imagenes_eliminacion.php"); |
---|
19 | //________________________________________________________________________________________________________ |
---|
20 | $opcion=0; // Inicializa parametros |
---|
21 | |
---|
22 | $idimagen=0; |
---|
23 | $nombreca=""; |
---|
24 | $ruta=""; |
---|
25 | $descripcion=""; |
---|
26 | $grupoid=0; |
---|
27 | $idperfilsoft=0; |
---|
28 | $comentarios=""; |
---|
29 | $inremotepc=false; |
---|
30 | $numpar=0; |
---|
31 | $codpar=0; |
---|
32 | $idrepositorio=0; |
---|
33 | $imagenid=0; |
---|
34 | $tipoimg=0; |
---|
35 | $litamb=""; |
---|
36 | |
---|
37 | if (isset($_POST["opcion"])) $opcion=$_POST["opcion"]; // Recoge parametros |
---|
38 | |
---|
39 | if (isset($_POST["idimagen"])) $idimagen=$_POST["idimagen"]; |
---|
40 | if (isset($_POST["nombreca"])) $nombreca=$_POST["nombreca"]; |
---|
41 | if (isset($_POST["ruta"])) $ruta=$_POST["ruta"]; |
---|
42 | if (isset($_POST["descripcion"])) $descripcion=$_POST["descripcion"]; |
---|
43 | if (isset($_POST["grupoid"])) $grupoid=$_POST["grupoid"]; |
---|
44 | if (isset($_POST["idperfilsoft"])) $idperfilsoft=$_POST["idperfilsoft"]; |
---|
45 | if (isset($_POST["comentarios"])) $comentarios=$_POST["comentarios"]; |
---|
46 | if (isset($_POST["inremotepc"])) $inremotepc=$_POST["inremotepc"]; |
---|
47 | if (isset($_POST["identificador"])) $idimagen=$_POST["identificador"]; |
---|
48 | if (isset($_POST["numpar"])) $numpar=$_POST["numpar"]; |
---|
49 | if (isset($_POST["codpar"])) $codpar=$_POST["codpar"]; |
---|
50 | if (isset($_POST["idrepositorio"])) $idrepositorio=$_POST["idrepositorio"]; |
---|
51 | if (isset($_POST["imagenid"])) $imagenid=$_POST["imagenid"]; |
---|
52 | if (isset($_POST["tipoimg"])) $tipoimg=$_POST["tipoimg"]; |
---|
53 | if (isset($_POST["litamb"])) $litamb=$_POST["litamb"]; |
---|
54 | |
---|
55 | $tablanodo=""; // Arbol para nodos insertados |
---|
56 | |
---|
57 | $cmd=CreaComando($cadenaconexion); // Crea objeto comando |
---|
58 | $resul=false; |
---|
59 | if ($cmd){ |
---|
60 | $resul=Gestiona(); |
---|
61 | $cmd->Conexion->Cerrar(); |
---|
62 | } |
---|
63 | if($opcion!=$op_movida){ |
---|
64 | echo '<HTML>'; |
---|
65 | echo '<HEAD>'; |
---|
66 | echo ' <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">'; |
---|
67 | echo '<BODY>'; |
---|
68 | echo '<P><SPAN style="visibility:hidden" id="arbol_nodo">'.$tablanodo.'</SPAN></P>'; |
---|
69 | echo ' <SCRIPT language="javascript" src="../jscripts/propiedades_imagenes.js"></SCRIPT>'; |
---|
70 | echo '<SCRIPT language="javascript">'.chr(13); |
---|
71 | if ($resul){ |
---|
72 | echo 'var oHTML'.chr(13); |
---|
73 | echo 'var cTBODY=document.getElementsByTagName("TBODY");'.chr(13); |
---|
74 | echo 'o=cTBODY.item(1);'.chr(13); |
---|
75 | } |
---|
76 | } |
---|
77 | $literal=""; |
---|
78 | switch($opcion){ |
---|
79 | case $op_alta : |
---|
80 | $literal="resultado_insertar_imagenes"; |
---|
81 | break; |
---|
82 | case $op_modificacion: |
---|
83 | $literal="resultado_modificar_imagenes"; |
---|
84 | break; |
---|
85 | case $op_eliminacion : |
---|
86 | $literal="resultado_eliminar_imagenes"; |
---|
87 | break; |
---|
88 | case $op_movida : |
---|
89 | $literal="resultado_mover"; |
---|
90 | break; |
---|
91 | default: |
---|
92 | break; |
---|
93 | } |
---|
94 | if ($resul){ |
---|
95 | if ($opcion==$op_alta ) |
---|
96 | echo $literal."(1,'".$cmd->DescripUltimoError()." ',".$idimagen.",o.innerHTML);".chr(13); |
---|
97 | else |
---|
98 | echo $literal."(1,'".$cmd->DescripUltimoError()." ','".$descripcion."');".chr(13); |
---|
99 | } |
---|
100 | else |
---|
101 | echo $literal."(0,'".$cmd->DescripUltimoError()."',".$idimagen.")"; |
---|
102 | |
---|
103 | if($opcion!=$op_movida){ |
---|
104 | echo ' </SCRIPT>'; |
---|
105 | echo '</BODY> '; |
---|
106 | echo '</HTML>'; |
---|
107 | } |
---|
108 | /********************************************************************************************************* |
---|
109 | Inserta, modifica o elimina datos en la tabla imagenes |
---|
110 | /*********************************************************************************************************/ |
---|
111 | function Gestiona(){ |
---|
112 | global $cmd; |
---|
113 | global $opcion; |
---|
114 | |
---|
115 | global $idcentro; |
---|
116 | global $idimagen; |
---|
117 | global $nombreca; |
---|
118 | global $ruta; |
---|
119 | global $descripcion; |
---|
120 | global $grupoid; |
---|
121 | global $comentarios; |
---|
122 | global $inremotepc; |
---|
123 | global $numpar; |
---|
124 | global $codpar; |
---|
125 | global $idrepositorio; |
---|
126 | global $imagenid; |
---|
127 | global $idperfilsoft; |
---|
128 | global $tipoimg; |
---|
129 | |
---|
130 | global $op_alta; |
---|
131 | global $op_modificacion; |
---|
132 | global $op_eliminacion; |
---|
133 | global $op_movida; |
---|
134 | |
---|
135 | global $tablanodo; |
---|
136 | |
---|
137 | $cmd->CreaParametro("@idcentro",$idcentro,1); |
---|
138 | |
---|
139 | $cmd->CreaParametro("@idimagen",$idimagen,1); |
---|
140 | $cmd->CreaParametro("@nombreca",$nombreca,0); |
---|
141 | $cmd->CreaParametro("@ruta",$ruta,0); |
---|
142 | $cmd->CreaParametro("@descripcion",$descripcion,0); |
---|
143 | $cmd->CreaParametro("@grupoid",$grupoid,1); |
---|
144 | $cmd->CreaParametro("@idperfilsoft",$idperfilsoft,1); |
---|
145 | $cmd->CreaParametro("@comentarios",$comentarios,0); |
---|
146 | $cmd->CreaParametro("@inremotepc",$inremotepc,1); |
---|
147 | $cmd->CreaParametro("@numpar",$numpar,1); |
---|
148 | $cmd->CreaParametro("@codpar",$codpar,1); |
---|
149 | $cmd->CreaParametro("@idrepositorio",$idrepositorio,1); |
---|
150 | $cmd->CreaParametro("@imagenid",$imagenid,1); |
---|
151 | $cmd->CreaParametro("@tipo",$tipoimg,1); |
---|
152 | |
---|
153 | switch($opcion){ |
---|
154 | case $op_alta : |
---|
155 | $cmd->texto="INSERT INTO imagenes |
---|
156 | (nombreca, ruta, descripcion, idperfilsoft, |
---|
157 | comentarios, inremotepc, numpar, codpar, |
---|
158 | idrepositorio, imagenid, idcentro, grupoid, tipo) |
---|
159 | VALUES (@nombreca, @ruta, @descripcion, @idperfilsoft, |
---|
160 | @comentarios, @inremotepc, @numpar, @codpar, |
---|
161 | @idrepositorio, @imagenid, @idcentro, @grupoid, @tipo)"; |
---|
162 | $resul=$cmd->Ejecutar(); |
---|
163 | if ($resul){ // Crea una tabla nodo para devolver a la página que llamó ésta |
---|
164 | $idimagen=$cmd->Autonumerico(); |
---|
165 | $arbolXML=SubarbolXML_imagenes($idimagen,$descripcion); |
---|
166 | $baseurlimg="../images/signos"; // Url de las imagenes de signo |
---|
167 | $clasedefault="texto_arbol"; // Hoja de estilo (Clase por defecto) del árbol |
---|
168 | $arbol=new ArbolVistaXML($arbolXML,0,$baseurlimg,$clasedefault); |
---|
169 | $tablanodo=$arbol->CreaArbolVistaXML(); |
---|
170 | } |
---|
171 | break; |
---|
172 | case $op_modificacion: |
---|
173 | $cmd->texto="UPDATE imagenes SET |
---|
174 | nombreca=@nombreca, ruta=@ruta, descripcion=@descripcion, |
---|
175 | idperfilsoft=@idperfilsoft, comentarios=@comentarios, |
---|
176 | inremotepc=@inremotepc, numpar=@numpar,codpar=@codpar, |
---|
177 | idrepositorio=@idrepositorio, imagenid=@imagenid |
---|
178 | WHERE idimagen=@idimagen"; |
---|
179 | $resul=$cmd->Ejecutar(); |
---|
180 | break; |
---|
181 | case $op_eliminacion : |
---|
182 | $resul=EliminaImagenes($cmd,$idimagen,"idimagen");// Eliminación en cascada |
---|
183 | break; |
---|
184 | case $op_movida : |
---|
185 | $cmd->texto="UPDATE imagenes SET grupoid=@grupoid WHERE idimagen=@idimagen"; |
---|
186 | $resul=$cmd->Ejecutar(); |
---|
187 | break; |
---|
188 | default: |
---|
189 | break; |
---|
190 | } |
---|
191 | return($resul); |
---|
192 | } |
---|
193 | /*________________________________________________________________________________________________________ |
---|
194 | Crea un arbol XML para el nuevo nodo insertado |
---|
195 | ________________________________________________________________________________________________________*/ |
---|
196 | function SubarbolXML_imagenes($idimagen,$descripcion) |
---|
197 | { |
---|
198 | global $litamb; |
---|
199 | |
---|
200 | $cadenaXML='<IMAGEN'; |
---|
201 | // Atributos |
---|
202 | $cadenaXML.=' imagenodo="../images/iconos/imagen.gif"'; |
---|
203 | $cadenaXML.=' infonodo="'.$descripcion.'"'; |
---|
204 | $cadenaXML.=' clickcontextualnodo="menu_contextual(this,' ."'flo_".$litamb."'" .')"'; |
---|
205 | $cadenaXML.=' nodoid='.$litamb.'-'.$idimagen; |
---|
206 | $cadenaXML.='>'; |
---|
207 | $cadenaXML.='</IMAGEN>'; |
---|
208 | return($cadenaXML); |
---|
209 | } |
---|
210 | |
---|