Ver Mensaje Individual
  #4 (permalink)  
Antiguo 14/02/2008, 17:19
tico74
 
Fecha de Ingreso: diciembre-2002
Mensajes: 473
Antigüedad: 21 años, 5 meses
Puntos: 0
Re: Sajax y SAfari

Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Newsroom Administration</title>
<link href="layout.css" rel="stylesheet" type="text/css"><script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/plugins/filemanager/jscripts/mcfilemanager.js"></script>
<script language="javascript" type="text/javascript" src="tinymce/jscripts/tiny_mce/plugins/filemanager/jscripts/mcfilemanager.js">
</script>

<script language="JavaScript" src="js/tigra_calendar/calendar2.js"></script>
<script>
    <?
    sajax_show_javascript
();
    
?>

    function gestora(respuesta) {
    //es la gestora, carga el valor en la capa o objeto destino
    alert(respuesta)
        if (respuesta == 'Deletion complete (Multimedia File)'){
            document.getElementById("control1").value = "1";
            document.getElementById('DivPdfCargada1').innerHTML= respuesta;
        }
        if (respuesta == 'Deletion complete (Thumbnail)'){
            document.getElementById("control2").value = "1";
            document.getElementById('DivPdfCargada2').innerHTML= respuesta;
        }
    
    }
    
    function Borro(valor) {
        // get the folder name
        var x, y;
        combo = document.getElementById("cid").value;
        mediaType = document.getElementById("mediaType").value;
                
        if (valor=="1"){
        x = document.getElementById("Ajaxupload").value;        
        }
    
        if (valor=="2"){
        x = document.getElementById("Ajaximage").value;
        }
        
        y = document.getElementById("elid").value;
        //alert("Combo"+combo+"Valor es"+valor+"Ajax file es "+x+" y el id es:"+ y);
        x_veophp(x, y, valor, combo, mediaType, gestora);
    }

</script>
<SCRIPT>
function testform(){
      var image, control;
       estado = document.getElementById("estado").value;
       mediaType = document.getElementById("mediaType").value;
      
      //upload 
      upload = document.getElementById("upload").value;
      Ajaxupload = document.getElementById("Ajaxupload").value;      
      control1 = document.getElementById("control1").value;

      //thumbnail
      thumbnail = document.getElementById("thumbnail").value;
      Ajaximage = document.getElementById("Ajaximage").value;      
      control2 = document.getElementById("control2").value;
      
      //si controles cero es que no hubo borrado de imagenes
      //si encima notamos que imagen no esta vacio es porque el usuario 
      //quiere cargar nueva imagen sin haber borrado la anterior.


      //consulto si elegio un archivo multimedia y no tiene elegido el combo
      if (mediaType == "0" && upload != "") 
      {
         alert("You must click in a media type first");
         return false;             
      }

      
      //consulto si hay uno elegido y  ya existe un archivo en la BD
      if (estado == "edit" && control1 == "0" &&  upload != "" && Ajaxupload != "") 
      {
         alert("You must delete current multimedia first");
         return false;             
      }
      else if (estado == "edit" && control2 == "0" &&  thumbnail != "" && Ajaximage != "") 
      {
                 alert("You must delete current thumbnail first");
                 return false;
      }
      else
      {
             document.getElementById("myform").submit()
      }
      
      
    

  
}
</SCRIPT>
</head>

<body>
<?

 
if (($_GET['id']!= "") || ($_GET['state'] != "")){
         
//Recibo variables por GET///
                 
$estado trim($_GET['state']);  
                 
$elidtrim($_GET['id']); 
}
                                
if (
$estado != "new"){
            
$cadena_edit "SELECT * FROM multimedia WHERE id=".$elid;                                
            
$result_edit=mysql_db_query($database,$cadena_edit);
            while(
$fila_edit mysql_fetch_array($result_edit)) {
                
$cid $fila_edit["cid"];
                
$mediaType $fila_edit["mediaType"];
                
$title $fila_edit["title"];
                
$multimediaDate $fila_edit["multimediaDate"];
                
$upload $fila_edit["upload"];
                
$thumbnail $fila_edit["thumbnail"];
                
$active $fila_edit["active"];                            
            }
 }
 
 switch (
$estado){
 case 
"new":
 
$accion "Add ";
 
$accion2 "adding";
 break;
 case 
"delete":
 
$accion "Delete ";
 
$accion2 "deleting";
 break;
 case 
"edit":
 
$accion "Edit ";
 
$accion2 "editing";
 break;
 case 
"clone":
 
$accion "Clone ";
 
$accion2 "cloning";
 break;
 }
?>


<DIV id=container>
<DIV id=header></DIV>
<? include("menu.php"?>
<DIV id=content>
<DIV id=main>
<DIV id=main-left>
<DIV class=lb>
<H2><?=$accion ?> a Multimedia Item </H2>
<p>You are <?=$accion2 ?> a multimedia item.</p>
<form id="myform" class="cssform" action="modMultimediaProcess.php" onSubmit="return testform()" method="post" enctype="multipart/form-data">
<input name="elid" id="elid" type="hidden" value="<? echo($elid?>" />
<input name="estado" id="estado"  type="hidden" value="<? echo($estado?>" />
<input name="control1" id="control1" type="hidden" value="0" />
<input name="control2" id="control2" type="hidden" value="0" />
<input name="Ajaxupload" id="Ajaxupload" type="hidden" value="<? echo($upload?>" />
<input name="Ajaximage" id="Ajaximage" type="hidden" value="<? echo($thumbnail?>" />
<? //si es edit o new muestro form
    
if (($estado=="new") || ($estado=="edit") || ($estado=="clone")) { 
        
//si es mas de 1 compañia
        
if ($_SESSION['OneCompany'] != 1) {
?>
        <p>
        <label for="cid">Company:</label>
        <?
              $cadena_comp 
"SELECT * FROM companies WHERE cid=".$cid;
                                          
              
$result_comp=mysql_db_query($database,$cadena_comp);
              while(
$fila_comp mysql_fetch_array($result_comp)) {                
                
$cidname $fila_comp["companyName"];
                
              }
              
                  echo(
$cidname);         
         
?>
         <input name="cid" type="hidden" value="<? echo($cid?>" />
        </p>
        <?
        
}else{
        
?>
         <input name="cid" type="hidden" value="1" />
        <?
        
}
        
?>
<p>
<label for="mediaType">Media Type:</label>
<select name="mediaType" id="mediaType" style='font-family:verdana;font-size:8pt;color:#000000' >
<option value="0">Select</option>
<option value="1" <? comparo($mediaType"1"?>>Logo</option>
<option value="2" <? comparo($mediaType"2"?>>Image</option>
<option value="3" <? comparo($mediaType"3"?>>Video</option>
<option value="4" <? comparo($mediaType"4"?>>Audio</option>
</select>
</p>

<p>
<label for="title">Title:</label>
<input name="title" type="text" id="title" style='font-family:verdana;font-size:8pt;color:#000000;width:360px' value="<? echo(htmlspecialchars($title)); ?>" />
</p>
<?
function CleanDateSmall($value){
//clean the =="0000-00-00 00:00:00" stuff
    
if ($value == "0000-00-00"){
     
$value"";
     return 
$value;
    }else{
     return 
$value;
    }
}
?>
<p>
<label for="date">Date:</label>
<input name="multimediaDate" type="text" id="multimediaDate" style='font-family:verdana;font-size:8pt;color:#000000;width:260px' value="<? echo(CleanDateSmall($multimediaDate)); ?>" /><a href="javascript:calendario1.popup();"><img src="js/tigra_calendar/img/cal.gif" alt="Click Here to Pick up the date" width="16" height="16" hspace="4" border="0"></a></p>

<p>
<label for="upload">Multimedia Upload:</label>
<input name="upload" type="file" id="upload" value="<? echo($upload); ?>" style='font-family:verdana;font-size:8pt;color:#000000;width:260px' />
<br><img  src="images/spacer.gif" height="2" width="1" /><br>
<? if ($estado != "new"){ ?>
<div id="DivPdfCargada1">
<strong>Current multimedia File:</strong> <? echo(htmlspecialchars($upload)); ?>
<br>
<img src="images/spacer.gif" height="2" width="1" />
<br>
<? if ($upload != ""): ?>
<img id="imagenCargada1" src="images/spacer.gif" height="2" width="1" >
<a href="#" onClick="Borro('1');return false;">Delete</a>
<? endif; ?>
</div>
<? ?>
</p>

<p>
<label for="thumbnail">Thumbnail: (optional):</label>
<input name="thumbnail" type="file" id="thumbnail" value="<? echo($thumbnail); ?>" style='font-family:verdana;font-size:8pt;color:#000000;width:260px' />72px x 72px
<br><img  src="images/spacer.gif" height="2" width="1" /><br>
<? if ($estado != "new"){ ?>
<div id="DivPdfCargada2">
<strong>Current File:</strong> <? echo(htmlspecialchars($thumbnail)); ?>
<br>
<img src="images/spacer.gif" height="2" width="1" />
<br>
<? if ($thumbnail != ""): ?>
<img src="../uploads/<? echo($cid); ?>/thumbnails/multimedia/<? echo($thumbnail); ?>" >
<a href="#" onClick="Borro('2');return false;">Delete</a>
<? endif; ?>
</div>
<? ?>



</p>

<div style="margin-left: 186px;">
<input type="image" value="Submit" src="images/submit1.gif" />
</div>

<?       
 
}else{                                              
        
//pregunto si hay delete 
        
if($estado == "delete"){        
?>
<p>
<div id="notation">Are you sure you want to delete this multimedia item?</div>
</p>

<div style="margin-left: 186px;">
<input name="Submit" type="submit"  value="Yes" />
<input name="Submit3" type="button" value="No" onclick="javascript:history.back()" />
</div>
<?       // id delete                      
    
//cierro if principal        
?>
</form>
            <script language="JavaScript">
            
                var calendario1 = new calendar2(document.forms['myform'].elements['multimediaDate']);
                calendario1.year_scroll = false;
                calendario1.time_comp = false;

            
            </script>
</DIV>
</DIV>
<div></div>
<DIV><img src="images/spacer.gif" width="1" height="10" /></DIV>
<BR style="CLEAR: both">
</DIV>
<? include("footer.php"?>
</DIV></DIV>
</body>
</html>[/QUOTE]