Está en la página 1de 3

<?

php
class Admin_VideoproductoController extends Z_Admin_ControllerFile {
public function _init() {
/*indespensables*/
$this->url = '/admin/videoproducto';
$this->data = new Model_Producto_Video();
$this->form = new Admin_Form_Producto_Video();
$this->view->title = 'Videos';
/*para subir archivos*/
$this->file = array('vid_flv','vid_img');
$this->upload = array('upload/videos/','upload/videos/');
$this->resize=array(false,true);
$this->thumb=array(false,false);
$this->img_size=array(null,array('width'=>110,'height'=>72));
$this->thumb_size=array(null,null);
$this->nro_imgs=2;
/*listado*/
/*listado*/
$this->numero_registros=20;
$this->rango_paginas=20;
$this->view->hidden=array('id');
/*$this->view->orden=true;*/
$sesion_img=new Zend_Session_Namespace('producto_video');//var_d
ump($sesion_img->not_id);
if($this->_request->isPost()&&$this->_request->getParam('product
o_id'))
{
$sesion_img->pro_id=$this->_request->getParam('producto_
id');
}
if($sesion_img->pro_id)
{
$this->pro_id=$sesion_img->pro_id;
$this->form->pro_id->setValue($sesion_img->pro_id);
$this->view->volver="/admin/producto/editar/id/".$sesion
_img->pro_id;
}
else
$this->pro_id=0;
$model_not=new Model_Producto_Producto();
$fila=$model_not->find($sesion_img->pro_id)->current()->toArray(
);
$this->view->mensaje="Videos para el producto:<br/>".$fila['pro_
nombre'];
$this->pro_id=$sesion_img->pro_id;
//$this->upload = array('upload/videos/');
//echo"->". $this->_request->getParam('producto_id');
// exit();
}
public function indexAction()
{
$tabla_imagenes=$this->data->fetchAll("pro_id=".$this->pro_id);
/*foreach ($tabla_imagenes as $fila_imagen)
{
if($fila_imagen['fot_pos']!=11)
$this->form->fot_pos->removeMultiOption($fila_im
agen['fot_pos']);
}
$orden=$this->view->Form->getElement($this->data->prefijo."orden
");
if($orden)
{
$fila=$this->data->fetchRow(null,$this->data->prefijo."o
rden DESC")->toArray();
$n_orden=(int)$fila[$this->data->prefijo."orden"];
$orden->setValue($n_orden+1);
}*/
$sesion_agregar=new Zend_Session_Namespace('agregar');
$sesion_agregar->id=rand(0,9999);
$this->view->pre_title="Agregar";
if($this->no_auto_agregar)
$this->render($this->no_auto_agregar);
else
$this->render('z/files', null, true);
}
public function _listar() {
$tipo=$this->_request->getParam('tipo');
if($tipo==1){
$db = Zend_Registry::get ( 'db' );
$select = $db->select ()
->from (array('v'=>$this->data->info('name')),
array('id'=>'v.vid_id',
'Titulo'=>'v.vid_nombre',
// 'id_noticia'=>'vid_not_id',
// 'Nombre'=>'v.vid_nombre',
//'Tipo'=>new Zend_Db_Expr("CASE g.gal_tipo WHEN 1 TH
EN 'Fotografia' WHEN 2 THEN 'Video' ELSE 'Error' END"),
//'Elementos'=>new Zend_Db_Expr("count(e.fot_id)"),
//'Fecha Creación'=>'gal_fecha_creacion',
// 'Fecha Creación'=>new Zend_Db_Expr("DATE_FORMAT(v.vid
_fecha_creacion,'%d/%m/%y')"),
// 'orden'=>'v.vid_orden'
))
// ->where("vid_estado='1'")
// ->where("vid_id <> 10")
;
return $select;
}
else
{
$db = Zend_Registry::get ( 'db' );
$select = $db->select ()
->from (array('v'=>$this->data->info('name')),
array('id'=>'v.vid_id',
//'Titulo'=>'v.vid_titulo',
// 'id_noticia'=>'vid_not_id',
'Nombre'=>'v.vid_nombre',
//'Tipo'=>new Zend_Db_Expr("CASE g.gal_tipo WHEN 1 TH
EN 'Fotografia' WHEN 2 THEN 'Video' ELSE 'Error' END"),
//'Elementos'=>new Zend_Db_Expr("count(e.fot_id)"),
//'Fecha Creación'=>'gal_fecha_creacion',
// 'Fecha Creación'=>new Zend_Db_Expr("DATE_FORMAT(v.vid
_fecha_creacion,'%d/%m/%y')")
//'orden'=>'v.vid_orden'))
// ->where("vid_not_id='".$this->not_id."'")
// ->where("vid_id <> 10")
));
return $select;
}
}
public function agregarAction() {
$id_pro=$this->_request->getParam('pro_id');
$this->form->removeElement('not_url');
$sesion=new Zend_Session_Namespace('edicion_actual');
$auth = Zend_Auth::getInstance();
$rol = $auth->getIdentity()->rol;
if($rol=='lector'||$rol=='revisor'||$rol=='redactor')
{
$ultima_edicion=$this->db->fetchRow("select * from notic
ia_edicion order by edi_id desc limit 0,1");
if($sesion->id!=EDICION_TRABAJO&&$sesion->id!=EDICION_PU
BLICADA&&$sesion->id!=$ultima_edicion)
$this->_redirect("/admin/index/noautorizado");
}
$request = $this->_request;
if ($request->isPost()) {
$form = $this->form;
if ($form->isValid($request->getPost()))
{
$id = $this->data->add($form->getValues());
//$this->crearPDF($id);
$this->view->mensaje="Imagen Guardada";
$this->_redirect($this->url.'/_listar/producto_i
d/'.$id_pro);///id/.$id
} else
{$form->populate($request->getPost());
$this->view->mensaje="Imagen no Guardada";
}
}
$form->populate($request->getPost());
$this->render('index');
}
}

También podría gustarte