public function actionView($id)
 {
     if (!empty($id)) {
         $contenido = Contenido::model()->findByPk($id);
     }
     if (isset($_POST['Contenido'])) {
         $contenido->texto = $_POST['Contenido']['texto'];
         $log = new Logs();
         try {
             $log->accion = 'Edito el contenido  de ' . $contenido->nombre . ' como admin';
             $log->usuario = Yii::app()->user->id;
             $log->msg = 'IP: ' . $_SERVER['REMOTE_ADDR'] . ' : ' . $_SERVER['REMOTE_PORT'];
             $log->fecha = date('Y-m-d G:i:s');
             $log->save();
         } catch (Exception $e) {
             $log->accion = 'Error log';
             $log->msg = '';
             $log->fecha = '';
             $log->save();
         }
         $contenido->save('update');
     }
     // render - 1. vista 2. array con los objetos de tipo CActiveReord
     $this->render('form', array('model' => $contenido));
 }
Example #2
0
 public function actionOtros()
 {
     Yii::app()->controller->menu_activo = 'otros';
     $id = Yii::app()->request->getParam('id');
     $model = Contenido::model()->findByPk($id);
     $top = false;
     $rigth = false;
     $bottom = false;
     $top_model = '';
     $right_model = '';
     $bottom_model = '';
     if (count($model->contenidoAdicionals) > 0) {
         foreach ($model->contenidoAdicionals as $adicional) {
             if ($adicional->contenido_adicional_posicion_id == 1) {
                 //top
                 $top_model = $adicional;
                 $top = true;
             } else {
                 if ($adicional->contenido_adicional_posicion_id == 2) {
                     //right
                     $right_model = $adicional;
                     $rigth = true;
                 } else {
                     if ($adicional->contenido_adicional_posicion_id == 3) {
                         //bottom
                         $bottom_model = $adicional;
                         $bottom = true;
                     }
                 }
             }
         }
     }
     $this->render('contenido', array('model' => $model, 'top' => $top, 'top_model' => $top_model, 'right' => $rigth, 'right_model' => $right_model, 'bottom' => $bottom, 'bottom_model' => $bottom_model));
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Contenido the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Contenido::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
        <div class="container" id="page">



            <div id="mainmenu" class="row">

<?php 
$programas = Programa::model()->findAll(array('condition' => 'activo =1 and programa_tipo_id = ' . $this->programas));
$bloqueos = Programa::model()->findAll(array('condition' => 'activo =1 and programa_tipo_id = ' . $this->bloqueos));
$otroDestinos = Programa::model()->findAll(array('condition' => 'activo =1 and programa_tipo_id = ' . $this->otroDestino));
$turismoSaluds = Programa::model()->findAll(array('condition' => 'activo =1 and programa_tipo_id = ' . $this->turismoSalud));
$otroServicios = Programa::model()->findAll(array('condition' => 'activo =1 and programa_tipo_id = ' . $this->otroServicio));
$quienesSomos = Contenido::model()->findAllByAttributes(array('contenido_tipo_id' => $this->quienessomos));
$informaciones = Contenido::model()->findAllByAttributes(array('contenido_tipo_id' => $this->informaciones));
$otros = Contenido::model()->findAllByAttributes(array('contenido_tipo_id' => $this->otros));
$turismos = Contenido::model()->findAllByAttributes(array('contenido_tipo_id' => $this->turismo));
$programa = array();
foreach ($programas as $pro) {
    $programa[] = array('label' => $pro->nombre, 'url' => array('site/programa', 'id' => $pro->id));
}
$bloqueo = array();
foreach ($bloqueos as $blo) {
    $bloqueo[] = array('label' => $blo->nombre, 'url' => array('site/programa', 'id' => $blo->id));
}
/* $otroDestino = array();

  foreach($otroDestinos as $otro){

  $otroDestino[] = array('label' => $otro->nombre, 'url' => array('site/programa','id'=>$otro->id));

  } */