Example #1
0
 public function run()
 {
     $cacheKey = "ObjectImageWidget:" . implode("_", [$this->model->object->id, $this->model->id, $this->viewFile, $this->limit, $this->offset, $this->thumbnailOnDemand ? '1' : '0', $this->thumbnailWidth, $this->thumbnailHeight, $this->useWatermark]);
     $result = Yii::$app->cache->get($cacheKey);
     if ($result === false) {
         if ($this->offset > 0 || !is_null($this->limit)) {
             $images = $this->model->getImages()->limit($this->limit)->offset($this->offset)->all();
         } else {
             $images = $this->model->images;
         }
         if ($this->noImageOnEmptyImages === true && count($images) === 0) {
             return $this->render('noimage');
         }
         $result = $this->render($this->viewFile, ['images' => $images, 'thumbnailOnDemand' => $this->thumbnailOnDemand, 'thumbnailWidth' => $this->thumbnailWidth, 'thumbnailHeight' => $this->thumbnailHeight, 'useWatermark' => $this->useWatermark, 'additional' => $this->additional]);
         Yii::$app->cache->set($cacheKey, $result, 86400, new \yii\caching\TagDependency(['tags' => 'Images:' . $this->model->object->id . ':' . $this->model->id]));
     }
     return $result;
 }
 public function run()
 {
     $cacheKey = static::className() . ':' . implode("_", [$this->model->object->id, $this->model->id, $this->viewFile, $this->limit, $this->offset, $this->thumbnailOnDemand ? '1' : '0', $this->thumbnailWidth, $this->thumbnailHeight, $this->useWatermark]);
     $result = Yii::$app->cache->get($cacheKey);
     if ($result === false) {
         if ($this->offset > 0 || !is_null($this->limit)) {
             $images = $this->model->getImages()->limit($this->limit)->offset($this->offset)->all();
         } else {
             $images = $this->model->images;
         }
         if ($this->noImageOnEmptyImages === true && count($images) === 0) {
             return $this->render('noimage', ['model' => $this->model, 'thumbnailOnDemand' => $this->thumbnailOnDemand, 'thumbnailWidth' => $this->thumbnailWidth, 'thumbnailHeight' => $this->thumbnailHeight, 'useWatermark' => $this->useWatermark, 'additional' => $this->additional]);
         }
         $result = $this->render($this->viewFile, ['model' => $this->model, 'images' => $images, 'thumbnailOnDemand' => $this->thumbnailOnDemand, 'thumbnailWidth' => $this->thumbnailWidth, 'thumbnailHeight' => $this->thumbnailHeight, 'useWatermark' => $this->useWatermark, 'additional' => $this->additional]);
         Yii::$app->cache->set($cacheKey, $result, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Image::className()), ActiveRecordHelper::getCommonTag($this->model->className())]]));
     }
     return $result;
 }
Example #3
0
 public function behaviors()
 {
     return [['class' => HasProperties::className()], ['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()]];
 }
Example #4
0
 public function behaviors()
 {
     return [['class' => HasProperties::className()], ['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()], ['class' => CleanRelations::className()], ['class' => Tree::className(), 'activeAttribute' => 'active', 'sortOrder' => ['sort_order' => SORT_ASC, 'id' => SORT_ASC]]];
 }
Example #5
0
 public function behaviors()
 {
     return [['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()], ['class' => Tree::className(), 'sortOrder' => ['sort_order' => SORT_ASC], 'activeAttribute' => false, 'cascadeDeleting' => true], ['class' => HasProperties::className()]];
 }
Example #6
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => HasProperties::className()], ['class' => ActiveRecordHelper::className()], ['class' => CleanRelations::className()], ['class' => Tree::className(), 'activeAttribute' => 'published', 'sortOrder' => ['sort_order' => SORT_ASC, 'id' => SORT_ASC]], ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'date_added', 'updatedAtAttribute' => 'date_modified', 'value' => new Expression('NOW()'), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['date_added'], ActiveRecord::EVENT_BEFORE_UPDATE => ['date_modified']]]];
 }
Example #7
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => HasProperties::className()], ['class' => ActiveRecordHelper::className()], ['class' => CleanRelations::className()], ['class' => Tree::className(), 'activeAttribute' => 'published']];
 }
Example #8
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => HasProperties::className()], ['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()], ['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'start_date', 'updatedAtAttribute' => 'update_date', 'value' => new Expression('NOW()')]];
 }
Example #9
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => TimestampBehavior::className(), 'createdAtAttribute' => 'create_time', 'updatedAtAttribute' => 'update_time'], ['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()], ['class' => HasProperties::className()]];
 }
Example #10
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'sort_order'], 'value' => 0], ['class' => ActiveRecordHelper::className()], ['class' => HasProperties::className()]];
 }
Example #11
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => ActiveRecordHelper::className()], ['class' => HasProperties::className()]];
 }
Example #12
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => HasProperties::className()], ['class' => ActiveRecordHelper::className()], ['class' => CleanRelations::className()], ['class' => Tree::className(), 'activeAttribute' => 'published', 'sortOrder' => ['sort_order' => SORT_ASC, 'id' => SORT_ASC]]];
 }
Example #13
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => Tree::className(), 'activeAttribute' => 'active'], ['class' => HasProperties::className()], ['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()], ['class' => CleanRelations::className()]];
 }
Example #14
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [['class' => AttributeBehavior::className(), 'attributes' => [\yii\db\ActiveRecord::EVENT_BEFORE_INSERT => 'sort_order'], 'value' => 0], ['class' => \devgroup\TagDependencyHelper\ActiveRecordHelper::className()], ['class' => HasProperties::className()]];
 }