public function init() { $this->baseUrl = Y::config('baseUrl'); Yii::app()->language = isset($_GET['lang']) ? $_GET['lang'] : "ru"; parent::init(); }
public function __construct($config = []) { // 由于多态 此时 $this 是子类 Application Y::$app = $this; $this->errorHandler(); $this->init($config); Y::config($this, $config); }
public function actionClose() { $email = new Email; $this->performAjaxValidation($email); if(isset($_POST['Email'])) { $email->attributes = $_POST['Email']; $email->to = Y::config('email_to_registraiton'); $email->send(); Y::flash('success',Yii::t('interface', "email was sended")); } $this->render('/registration/close', array('model' => $email) ); }
<div> <?php echo Yii::t('errors', 'registration close', array('{email}'=>Y::config('email_to_registraiton') ));?> </div> <div class="form"> <?php if(Y::hasFlash('success')) { echo CHtml::tag('div', array('class'=>'success'), Y::flash('success')); }?> <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'send-mail', 'enableAjaxValidation'=>true )); ?> <?php echo CHtml::errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model,'subject'); ?> <?php echo $form->textField($model,'subject') ?> <?php echo $form->error($model,'subject'); ?> </div> <div class="row"> <?php echo $form->labelEx($model,'message'); ?> <?php echo $form->textArea($model,'message') ?> <?php echo $form->error($model,'message'); ?> </div> <div class="row submit"> <?php echo CHtml::submitButton(Yii::t('interface', "send mail")); ?> </div>
/** * Send mail method */ public static function sendMail($email,$subject,$message) { $model = new Email; $model->email_name = self::t("Your registration"); $model->subject = $subject; $model->message = $message; $model->to = $email; $model->from = Y::config('email_to_registraiton'); return $model->send(); }