public function run() { $inModel = $this->model; $model = new File(); $lang = isset($inModel['lang']) ? $inModel->lang : ''; $model->model = $inModel::className(); if ($lang) { $model->model .= '\\' . $lang; } $model->primaryKey = $this->primaryKey; return $this->render('FileUploadView', ['fileUploadData' => $model->getWidgetUploadData(), 'primaryKey' => $this->primaryKey, 'inModel' => $this->model, 'model' => $model, 'maxNumberOfFiles' => $this->maxNumberOfFiles, 'extensions' => '*', 'lang' => $inModel->lang, 'label' => $this->label, 'header' => $this->header]); }
public function actionDelete($id) { $model = File::findOne($id); if ($model) { $model->delete(); $result = (object) ['success' => true, 'path' => Yii::getAlias(File::FILE_DIR) . $model->src, 'file' => is_file(Yii::getAlias(File::FILE_DIROOT) . $model->src)]; echo Json::encode($result); } }
public function getFiles() { return $this->hasMany(File::className(), ['primaryKey' => 'id'])->andWhere(['model' => self::className() . '\\' . \Yii::$app->sourceLanguage]); }