Viewing file: ci_videos.php (4.66 KB) -rwxrwxr-x Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php //ini_set('upload_max_filesize', '20M'); //ini_set('post_max_size', '20M');
class ci_videos extends led_ci { protected $s__datos_filtro; protected $s__id_video;
//---- Filtro -----------------------------------------------------------------------
function conf__filtro(toba_ei_formulario $filtro) { if (isset($this->s__datos_filtro)) { $filtro->set_datos($this->s__datos_filtro); } }
function evt__filtro__filtrar($datos) { $this->s__datos_filtro = $datos; }
function evt__filtro__cancelar() { unset($this->s__datos_filtro); }
//---- Cuadro -----------------------------------------------------------------------
function conf__cuadro(toba_ei_cuadro $cuadro) { if (isset($this->s__datos_filtro)) { $cuadro->set_datos($this->dep('datos')->tabla('video')->get_listado($this->s__datos_filtro)); } else { $cuadro->set_datos($this->dep('datos')->tabla('video')->get_listado()); } }
function evt__cuadro__eliminar($datos) { /*$this->dep('datos')->resetear(); $this->dep('datos')->cargar($datos); $this->dep('datos')->eliminar_todo(); $this->dep('datos')->resetear();*/
if($this->dep('datos')->tabla('video')->eliminar($datos['id_video'])){ toba::notificacion()->agregar("Video ".$seleccion['id_video']." eliminado.", "info"); } }
function evt__cuadro__seleccion($datos) { $this->s__id_video = $datos['id_video'];
$this->dep('datos')->cargar($datos); $this->set_pantalla('pant_edicion'); }
//---- Formulario -------------------------------------------------------------------
function conf__formulario(toba_ei_formulario $form) { if ($this->dep('datos')->esta_cargada()) { $form->set_datos($this->dep('datos')->tabla('video')->get()); } else { $this->pantalla()->eliminar_evento('eliminar'); } }
function evt__formulario__modificacion($datos) { $folder_path = "../www/video/";
if ($this->dep('datos')->esta_cargada()) {
//archivo ---------------------------------------------------------- if (isset($datos['archivo']) and !empty($datos['archivo']['name'])) { $ext = substr($datos['archivo']['name'], -4,4); $nombre_archivo = date("YmdHis").$ext; $destino = $folder_path.$nombre_archivo; move_uploaded_file($datos['archivo']['tmp_name'], $destino ) ; if ( is_file( $destino ) ){ $datos['archivo'] = $nombre_archivo; } }elseif (isset($datos['archivo']) and empty($datos['archivo']['name'])) { $datos['archivo'] = $datos['archivo']['name']; }else{ //Mantener el valor anterior $url= $this->dep('datos')->tabla('video')->get_archivo($this->s__id_video); if(empty($url['archivo'])){ $datos['archivo'] = $datos['archivo']['name']; }else{ $datos['archivo'] = $url['archivo']; } }
} else {//Alta
$datos['usuario_alta'] = toba::usuario()->get_id(); $datos['fecha_alta'] = date("Y-m-d H:i:s"); //archivo------------------------------------------------------- if (isset($datos['archivo']) and !empty($datos['archivo']['name'])) {// Mover archivo al servidor. $ext = substr($datos['archivo']['name'], -4,4); $nombre_archivo = date("YmdHis").$ext; $destino= $folder_path.$nombre_archivo; move_uploaded_file($datos['archivo']['tmp_name'], $destino ) ; if ( is_file( $destino ) ){// Le asigno solo el nombre al archivo para que se guarde en la base y no de error $datos['archivo'] = $nombre_archivo; } }else{ $datos['archivo'] = $datos['archivo']['name']; }
}
$this->dep('datos')->tabla('video')->set($datos); }
function resetear() { $this->dep('datos')->resetear(); $this->set_pantalla('pant_seleccion'); }
//---- EVENTOS CI -------------------------------------------------------------------
function evt__agregar() { $this->set_pantalla('pant_edicion'); }
function evt__volver() { $this->resetear(); }
function evt__eliminar() { //$this->dep('datos')->eliminar_todo();
if($this->dep('datos')->tabla('video')->eliminar($this->s__id_video)){ toba::notificacion()->agregar("Video ".$seleccion['id_video']." eliminado.", "info"); }
$this->resetear(); }
function evt__guardar() { $this->dep('datos')->sincronizar(); $this->resetear(); }
}
?>
|