Ejemplo n.º 1
0
 /**
  * function ::create ($data)
  */
 public static function create($data)
 {
     $now = strtotime('now');
     $username = Yii::$app->user->identity->username;
     $model = new GeneralInfoTranslation();
     if ($model->load($data)) {
         if ($log = new UserLog()) {
             $log->username = $username;
             $log->action = 'Create';
             $log->object_class = 'GeneralInfoTranslation';
             $log->created_at = $now;
             $log->is_success = 0;
             $log->save();
         }
         do {
             $path = FileUtils::generatePath($now);
         } while (file_exists(Yii::$app->params['images_folder'] . $path));
         $model->image_path = $path;
         $targetFolder = Yii::$app->params['images_folder'] . $model->image_path;
         $targetUrl = Yii::$app->params['images_url'] . $model->image_path;
         $model->content = FileUtils::copyContentImages(['content' => $model->content, 'defaultFromFolder' => Yii::$app->params['uploads_folder'], 'toFolder' => $targetFolder, 'toUrl' => $targetUrl, 'removeInputImage' => true]);
         if ($model->save()) {
             if ($log) {
                 $log->object_pk = $model->id;
                 $log->is_success = 1;
                 $log->save();
             }
             return $model;
         }
         $model->getErrors();
         return $model;
     }
     return false;
 }
Ejemplo n.º 2
0
use yii\web\View;
use yii\widgets\ActiveForm;
/* @var $this View */
/* @var $model GeneralInfoTranslation2 */
/* @var $form ActiveForm */
?>

<div class="general-info-translation-form">

    <?php 
$form = ActiveForm::begin();
?>
    
    <div class="col-md-6">
        <?php 
echo $form->field($model, 'language_id')->dropDownList(array_diff_key($this->context->languages_idToName, ArrayHelper::map(GeneralInfoTranslation::find()->where(['general_info_id' => $model->general_info_id])->andWhere(['<>', 'id', (int) $model->id])->all(), 'language_id', 'language_id')));
?>
        <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>
        <?php 
echo $form->field($model, 'description')->textarea(['maxlength' => true, 'rows' => 3, 'style' => 'resize:vertical']);
?>
        <?php 
// echo $form->field($model, 'search_text')->textInput(['maxlength' => true])
?>
    </div>
    <div class="col-md-6">
        <?php 
echo $form->field($model, 'page_title')->textInput(['maxlength' => true]);
?>
Ejemplo n.º 3
0
 /**
  * @return ActiveQuery
  */
 public function getGeneralInfoTranslations()
 {
     return $this->hasMany(GeneralInfoTranslation::className(), ['general_info_id' => 'id']);
 }