/** * Displays the contact page */ public function actionContacto() { $model = new ContactForm(); if (isset($_POST['ContactForm'])) { $model->attributes = $_POST['ContactForm']; if ($model->validate()) { $name = '=?UTF-8?B?' . base64_encode($model->name) . '?='; $subject = '=?UTF-8?B?' . base64_encode($model->subject) . '?='; $headers = "From: {$name} <{$model->email}>\r\n" . "Reply-To: {$model->email}\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/plain; charset=UTF-8"; mail(Yii::app()->params['adminEmail'], $subject, $model->body, $headers); Yii::app()->user->setFlash('contact', Yii::t('site', 'Gracias por contactarnos. Le daremos respuesta a la brevedad posible.')); $this->refresh(); } } $idioma = Idiomas::model()->find('idioma=:idioma', array(':idioma' => Yii::app()->language)); if ($idioma->idioma == Yii::app()->params->idiomas['Español']) { //español $criteria2 = new CDbCriteria(); $criteria2->select = 't.*'; $criteria2->condition = 't.lugar = :lugar'; $criteria2->params = array(':lugar' => 'direcciones'); } else { //ingles $criteria2 = new CDbCriteria(); $criteria2->select = 't.*, tra_texto.*'; $criteria2->join = 'LEFT JOIN tra_texto ON tra_texto.textoid = t.idtexto'; $criteria2->condition = 'tra_texto.idiomaid =:id and t.lugar = :lugar'; $criteria2->params = array(':id' => $idioma->id, ':lugar' => 'direcciones'); } $direcciones = Texto::model()->find($criteria2); $this->render('contacto', array('model' => $model, 'direcciones' => $direcciones)); }
<?php //echo $form->textField($model,'tipousuario'); > echo $form->dropDownList($model, 'idiomaid', CHtml::listData(Idiomas::model()->findAll(), 'id', 'nombre'), array('empty' => 'Seleccione')); ?> <?php echo $form->error($model, 'idiomaid'); ?> </div> <div class="row"> <?php echo $form->labelEx($model, 'textoid'); ?> <?php //echo $form->textField($model,'tipousuario'); > echo $form->dropDownList($model, 'textoid', CHtml::listData(Texto::model()->findAll(), 'idtexto', 'lugar'), array('empty' => 'Seleccione')); ?> <?php echo $form->error($model, 'textoid'); ?> </div> <div class="row"> <?php $this->widget('ext.ExtEditMe', array('model' => $model, 'attribute' => 'texto', 'width' => '460', 'height' => '250', 'toolbar' => array(array('Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'), array('NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'), array('Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo'), array('Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe'), array('Styles', 'Format', 'FontSize')))); ?> </div> <div class="row buttons">
/** * 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 Texto the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Texto::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }