Exemple #1
0
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'title', 'slugAttribute' => 'slug'], ['class' => TimestampBehavior::className()], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url'], ['class' => UploadBehavior::className(), 'attribute' => 'bg_image', 'pathAttribute' => 'bg_image_path', 'baseUrlAttribute' => 'bg_image_base_url']];
 }
Exemple #2
0
 public function behaviors()
 {
     return [TimestampBehavior::className(), 'attach_file' => ['class' => UploadBehavior::className(), 'attribute' => 'attach_file', 'pathAttribute' => 'filename', 'baseUrlAttribute' => 'real_filename']];
 }
Exemple #3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => UploadBehavior::className(), 'attribute' => 'image', 'pathAttribute' => 'image_path', 'baseUrlAttribute' => 'image_base_url']];
 }
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => UploadBehavior::className(), 'attribute' => 'image', 'pathAttribute' => 'path', 'baseUrlAttribute' => 'base_url', 'typeAttribute' => 'type'], 'cacheInvalidate' => ['class' => CacheInvalidateBehavior::className(), 'cacheComponent' => 'frontendCache', 'keys' => [function ($model) {
         return [WidgetCarousel::className(), $model->carousel->key];
     }]]];
 }
Exemple #5
0
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'name', 'immutable' => true], ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'advertImages', 'pathAttribute' => 'image_path', 'baseUrlAttribute' => 'base_url']];
 }
Exemple #6
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'author_id', 'updatedByAttribute' => 'updater_id'], ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true], ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'articleAttachments', 'pathAttribute' => 'path', 'baseUrlAttribute' => 'base_url', 'orderAttribute' => 'order', 'typeAttribute' => 'type', 'sizeAttribute' => 'size', 'nameAttribute' => 'name'], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url']];
 }
 public function behaviors()
 {
     return ['picture' => ['class' => UploadBehavior::className(), 'attribute' => 'picture', 'pathAttribute' => 'avatar_path', 'baseUrlAttribute' => 'avatar_base_url']];
 }
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['img' => ['class' => UploadBehavior::className(), 'attribute' => 'img', 'pathAttribute' => 'img_path', 'baseUrlAttribute' => 'img_base_url']];
 }
Exemple #9
0
 public function behaviors()
 {
     return [['class' => SluggableBehavior::className(), 'attribute' => 'name'], ['class' => UploadBehavior::className(), 'attribute' => 'category_image', 'pathAttribute' => 'main_image', 'baseUrlAttribute' => 'image_path']];
 }
 /**
  * @param ActiveRecord $model
  */
 protected function excludeField($model, $addition = '')
 {
     $this->fieldExclude = ArrayHelper::merge(is_array($this->excludedField) ? $this->excludedField : [$this->excludedField], $this->fieldExclude);
     if (is_callable($this->excludeFieldCallback)) {
         $func = $this->excludeFieldCallback;
         $result = $func($this);
         $result = $result ? is_array($result) ? $result : [$result] : [];
         $this->fieldExclude = ArrayHelper::merge($this->fieldExclude, $result);
     }
     $this->fieldExclude = ArrayHelper::merge($this->fieldExclude, $model->getTableSchema()->primaryKey);
     $behaviors = $model->getBehaviors();
     foreach ($behaviors as $_next) {
         $_nextCopy = $_next;
         $_next = (array) $_next;
         $_next['class'] = $_nextCopy->className();
         if ($_next['class'] === BlameableBehavior::className()) {
             if (isset($_next['updatedByAttribute'])) {
                 if (!empty($_next['updatedByAttribute'])) {
                     $this->fieldExclude[] = $addition . $_next['updatedByAttribute'];
                 }
             } else {
                 $this->fieldExclude[] = $addition . 'updated_by';
             }
             if (isset($_next['createdByAttribute'])) {
                 if (!empty($_next['createdByAttribute'])) {
                     $this->fieldExclude[] = $addition . $_next['createdByAttribute'];
                 }
             } else {
                 $this->fieldExclude[] = $addition . 'created_by';
             }
         } else {
             if ($_next['class'] === TimestampBehavior::className()) {
                 if (isset($_next['updatedAtAttribute'])) {
                     if (!empty($_next['updatedAtAttribute'])) {
                         $this->fieldExclude[] = $addition . $_next['updatedAtAttribute'];
                     }
                 } else {
                     $this->fieldExclude[] = $addition . 'updated_at';
                 }
                 if (isset($_next['createdAtAttribute'])) {
                     if (!empty($_next['createdAtAttribute'])) {
                         $this->fieldExclude[] = $addition . $_next['createdAtAttribute'];
                     }
                 } else {
                     $this->fieldExclude[] = $addition . 'created_at';
                 }
             } else {
                 if ($_next['class'] === PhoneInputBehavior::className()) {
                     if (!$this->searchColumn($_next['phoneAttribute'])) {
                         $this->columns[] = new WidgetsCrud(['fieldName' => $_next['phoneAttribute'], 'widgetType' => 'phone']);
                     }
                 } else {
                     if ($_next['class'] === UploadBehavior::className()) {
                         if (!is_array($this->hasUploadBehavior)) {
                             $this->hasUploadBehavior = ['attributes' => []];
                         }
                         $this->hasUploadBehavior['attributes'][] = isset($_next['attribute']) ? $_next['attribute'] : $_next['attribute'];
                         $this->hasUploadBehavior[] = $_next['pathAttribute'];
                         $this->hasUploadBehavior[] = $_next['baseUrlAttribute'];
                         $this->fieldExclude[] = $addition . $_next['pathAttribute'];
                         $this->fieldExclude[] = $addition . $_next['baseUrlAttribute'];
                         if (!$this->searchColumn($this->hasUploadBehavior)) {
                             $this->columns[] = new WidgetsCrud(['fieldName' => $addition . $_next['attribute'], 'widgetType' => 'upload']);
                         }
                         if (isset($this->columnUsed['upload']) && ($uses = $this->columnUsed['upload'])) {
                             if (isset($uses['expression'])) {
                                 $this->expressions = ArrayHelper::merge($this->expressions, $uses['expression']);
                                 unset($this->columnUsed['expression']);
                             }
                         }
                         $this->used = ArrayHelper::merge($this->used, $uses);
                     } else {
                         if ($_next['class'] === 'omgdef\\multilingual\\MultilingualBehavior') {
                             $this->isMultilingual = true;
                             $this->languageField = $_next['languageField'];
                             $this->translateAttribute = $_next['attributes'];
                             $this->relationField = $_next['langForeignKey'];
                             $class = $_next['langClassName'] . ($_next['dynamicLangClass'] ? isset($_next['langClassSuffix ']) ? $_next['langClassSuffix '] : '' : '');
                             $this->relationClass = $class;
                             if (class_exists($class)) {
                                 /** @var ActiveRecord $class */
                                 $class = new $class();
                                 $this->translateTable = $class::tableName();
                             } else {
                                 $this->translateTable = $_next['tableName'];
                             }
                             $this->excludeField($class, 'translations.');
                         }
                     }
                 }
             }
         }
     }
     $this->columnUsed = ArrayHelper::merge($this->columnUsed, $this->widgetsUseClass);
 }
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => SluggableBehavior::className(), 'attribute' => 'title'], ['attribute' => 'thumbnail', 'baseUrlAttribute' => 'thumbnail_base_url', 'class' => UploadBehavior::className(), 'pathAttribute' => 'thumbnail_path']];
 }
 /**
  * @return array
  */
 public function behaviors()
 {
     return ['trans' => ['class' => TranslateableBehavior::className(), 'translationAttributes' => ['title', 'description', 'position', 'period']], ['class' => UploadBehavior::className(), 'attribute' => 'image', 'pathAttribute' => 'image_path', 'baseUrlAttribute' => 'image_base_url', 'typeAttribute' => 'image_type']];
 }
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => UploadBehavior::className(), 'attribute' => 'image'], 'cacheInvalidate' => ['class' => CacheInvalidateBehavior::className(), 'keys' => [function ($model) {
         return [WidgetCarousel::className(), $model->carousel->key];
     }]]];
 }
 public function uploadValidation()
 {
     if ($this->class === UploadBehavior::className()) {
         if (empty($this->attribute)) {
             $this->addError('attribute', "Attribute empty");
         }
         if (empty($this->pathAttribute)) {
             $this->addError('pathAttribute', "Path attribute empty");
         }
         if (empty($this->baseUrlAttribute)) {
             $this->addError('baseUrlAttribute', "Base url attribute empty");
         }
     }
 }
Exemple #15
0
 public function behaviors()
 {
     return [TimestampBehavior::className(), 'picture' => ['class' => UploadBehavior::className(), 'attribute' => 'picture', 'pathAttribute' => 'banner_path', 'baseUrlAttribute' => 'banner_base_url', 'nameAttribute' => false]];
 }
 public function getAnotherPublicAttribute()
 {
     $attribute = [];
     foreach ($this->behaviorModels as $behaviorModel) {
         if ($behaviorModel->class === UploadBehavior::className()) {
             $attribute[] = $behaviorModel->attribute;
         }
     }
     return $attribute;
 }
Exemple #17
0
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => UploadBehavior::className(), 'attribute' => 'identity_front', 'pathAttribute' => 'identity_front_path', 'baseUrlAttribute' => 'identity_front_base_url'], ['class' => UploadBehavior::className(), 'attribute' => 'identity_back', 'pathAttribute' => 'identity_back_path', 'baseUrlAttribute' => 'identity_back_base_url']];
 }
Exemple #18
0
 /**
  * @return array
  */
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className()], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url']];
 }
Exemple #19
0
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'kefuSelfserviceAttachments', 'pathAttribute' => 'path', 'baseUrlAttribute' => 'base_url', 'orderAttribute' => 'order', 'typeAttribute' => 'type', 'sizeAttribute' => 'size', 'nameAttribute' => 'name']];
 }
Exemple #20
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'author_id', 'updatedByAttribute' => 'updater_id'], ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'memberAttachments'], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url']];
 }
Exemple #21
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'author_id', 'updatedByAttribute' => 'updater_id'], ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'immutable' => true], ['class' => UploadBehavior::className(), 'attribute' => 'attachments', 'multiple' => true, 'uploadRelation' => 'financeAttachments'], ['class' => UploadBehavior::className(), 'attribute' => 'thumbnail', 'pathAttribute' => 'thumbnail_path', 'baseUrlAttribute' => 'thumbnail_base_url'], ['class' => ChangeLogBehavior::className()]];
 }
Exemple #22
0
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => ChangeLogBehavior::className()], 'logo' => ['class' => UploadBehavior::className(), 'attribute' => 'logo', 'pathAttribute' => 'logo_path', 'baseUrlAttribute' => 'logo_base_url'], 'm_logo' => ['class' => UploadBehavior::className(), 'attribute' => 'm_logo', 'pathAttribute' => 'm_logo_path', 'baseUrlAttribute' => 'm_logo_base_url']];
 }
Exemple #23
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'create_time', 'updatedAtAttribute' => 'update_time'], ['class' => UploadBehavior::className(), 'attribute' => 'qrcode_file', 'pathAttribute' => 'qrcode', 'baseUrlAttribute' => 'qrcode_url']];
 }
 /**
  * @return array
  */
 public function behaviors()
 {
     return [['class' => UploadBehavior::className(), 'attribute' => 'flag', 'pathAttribute' => 'flag_path', 'baseUrlAttribute' => 'flag_base_url', 'typeAttribute' => 'flag_type'], 'trans' => ['class' => TranslateableBehavior::className(), 'translationAttributes' => ['name']]];
 }