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