コード例 #1
0
 public function run()
 {
     $inModel = $this->model;
     $model = new Image();
     $model->model = $inModel::className();
     $model->primaryKey = $this->primaryKey;
     return $this->render('ImageUploadView', ['fileUploadData' => $model->getWidgetUploadData(), 'primaryKey' => $this->primaryKey, 'inModel' => $this->model, 'model' => $model, 'maxNumberOfFiles' => $this->maxNumberOfFiles]);
 }
コード例 #2
0
 public function actionDelete($id)
 {
     $model = Image::findOne($id);
     if ($model) {
         $model->delete();
         $result = (object) ['success' => true, 'path' => Yii::getAlias(Image::FILE_DIR) . $model->src, 'file' => is_file(Yii::getAlias(Image::FILE_DIROOT) . $model->src)];
         echo Json::encode($result);
     }
 }
コード例 #3
0
ファイル: Image.php プロジェクト: nurastana/familyclinickz
 public function getWidgetUploadData()
 {
     $results = [];
     $items = Image::find()->where(['model' => $this->model, 'primaryKey' => $this->primaryKey])->all();
     $web = Yii::getAlias(self::FILE_DIR);
     $webroot = Yii::getAlias(self::FILE_DIROOT);
     foreach ($items as $item) {
         $webImage = $web . $item->src;
         $webrootImage = $webroot . $item->src;
         $thumb = $item->resize();
         $size = filesize($webrootImage);
         $result = ['name' => $item->src, 'size' => $size, 'url' => $webImage, 'thumbnailUrl' => $thumb, 'deleteUrl' => Url::to(['/cms/admin/image/delete', 'id' => $item->id]), 'deleteType' => "DELETE"];
         $results[] = $result;
     }
     if ($results) {
         return Json::encode($results);
     }
     return null;
 }
コード例 #4
0
ファイル: Reviews.php プロジェクト: nurastana/familyclinickz
 public function getImage()
 {
     return $this->hasOne(Image::className(), ['primaryKey' => 'id'])->andWhere(['model' => self::className()]);
 }
コード例 #5
0
ファイル: Service.php プロジェクト: nurastana/familyclinickz
 protected function getImages()
 {
     return $this->hasMany(Image::className(), ['primaryKey' => 'id'])->andFilterWhere(['model' => self::className()]);
 }