コード例 #1
0
 public function run($action)
 {
     $this->type = Yii::$app->request->get('type');
     $this->behaviorName = Yii::$app->request->get('behaviorName');
     $this->galleryId = Yii::$app->request->get('galleryId');
     $pkNames = call_user_func([$this->types[$this->type], 'primaryKey']);
     $pkValues = explode($this->pkGlue, $this->galleryId);
     $pk = array_combine($pkNames, $pkValues);
     $this->owner = call_user_func([$this->types[$this->type], 'findOne'], $pk);
     $this->behavior = $this->owner->getBehavior($this->behaviorName);
     switch ($action) {
         case 'delete':
             return $this->actionDelete(Yii::$app->request->post('id'));
             break;
         case 'ajaxUpload':
             return $this->actionAjaxUpload();
             break;
         case 'changeData':
             return $this->actionChangeData(Yii::$app->request->post('photo'));
             break;
         case 'order':
             return $this->actionOrder(Yii::$app->request->post('order'));
             break;
         default:
             throw new HttpException(400, 'Action do not exists');
             break;
     }
 }
コード例 #2
0
 /**
  * @return null|string
  */
 public function run()
 {
     /**
      * @var \notgosu\yii2\modules\metaTag\components\MetaTagBehavior $behavior
      */
     $behavior = $this->model->getBehavior('seo');
     if (!$behavior) {
         return null;
     }
     $languageList = $behavior->languages;
     return $this->render('default', ['model' => $this->model, 'languageList' => $languageList]);
 }
コード例 #3
0
 public function run($action)
 {
     $this->type = Yii::$app->request->get('type');
     $this->behaviorName = Yii::$app->request->get('behaviorName');
     $this->galleryId = Yii::$app->request->get('galleryId');
     $this->owner = $this->types[$this->type]->andWhere(['id' => $this->galleryId])->one();
     if ($this->owner == null) {
         throw new NotFoundHttpException('Gallery not found.');
     }
     $this->behavior = $this->owner->getBehavior($this->behaviorName);
     switch ($action) {
         case 'delete':
             return $this->actionDelete(Yii::$app->request->post('id'));
         case 'ajaxUpload':
             return $this->actionAjaxUpload();
         case 'changeData':
             return $this->actionChangeData(Yii::$app->request->post('photo'));
         case 'order':
             return $this->actionOrder(Yii::$app->request->post('order'));
         default:
             throw new BadRequestHttpException('Action do not exists');
     }
 }
コード例 #4
0
 /**
  *
  * @param array $attributes
  * @param ActiveRecord $destination Destination model
  * @return boolean
  */
 public function copyFiles($attributes, $destination)
 {
     foreach ($attributes as $attribute) {
         $behavior = $destination->getBehavior('upload-' . $attribute);
         if ($this->getUploadedFilePath($attribute) != '') {
             $filePath = pathinfo($behavior->getUploadedFilePath($attribute), PATHINFO_DIRNAME);
             if (!FileHelper::createDirectory($filePath, 0775, true)) {
                 return false;
             }
             copy($this->getUploadedFilePath($attribute), $behavior->getUploadedFilePath($attribute));
             foreach ($behavior->thumbs as $profile => $config) {
                 $thumbPath = $behavior->getThumbFilePath($attribute, $profile);
                 FileHelper::createDirectory(pathinfo($thumbPath, PATHINFO_DIRNAME), 0775, true);
                 copy($this->getThumbFilePath($attribute, $profile), $thumbPath);
             }
         }
     }
     return true;
 }
コード例 #5
0
 public function init()
 {
     parent::init();
     $this->behavior = $this->model->getBehavior($this->behaviorName);
     $this->registerTranslations();
 }
コード例 #6
0
 public function init()
 {
     parent::init();
     $this->behavior = $this->model->getBehavior($this->behaviorName);
 }
コード例 #7
0
 /**
  * @return ImageAttachmentBehavior
  */
 public function getAttachmentBehavior()
 {
     return $this->model->getBehavior($this->behaviorName);
 }