search($params); } /** * @param $params * @return \yii\data\ActiveDataProvider */ public function trash($params) { return (new search\Item())->trash($params); } /** * @return \yii\db\ActiveQuery */ public function getTypeItem() { return $this->hasOne(Type::class, ['id' => 'type_id']); } /** * @return array */ public static function type_of_promoterKeyRange() { $l = Yii::$app->params['themes']['language']; Yii::$app->params['themes']['language'] = Yii::$app->language; $r = [ 'Municipal project' => Yii::t('map', 'Municipal project'), 'Commercial project' => Yii::t('map', 'Commercial project'), ]; Yii::$app->params['themes']['language'] = $l; return $r; } /** * @return array */ public static function current_stage_of_project_developmentKeyRange() { $l = Yii::$app->params['themes']['language']; Yii::$app->params['themes']['language'] = Yii::$app->language; $r = [ // 'Idea' => Yii::t('map', 'Idea'), 'Under development' => Yii::t('map', 'Under development'), 'Ready to build' => Yii::t('map', 'Ready to build'), // 'Turnkey' => Yii::t('map', 'Turnkey'), 'Operating' => Yii::t('map', 'Operating'), 'Expansion' => Yii::t('map', 'Expansion'), ]; Yii::$app->params['themes']['language'] = $l; return $r; } public function afterSave($insert, $changedAttributes) { if (isset($changedAttributes['gallery_file'])) { if (is_file($this->module->getItemUploadPath() . $this->getArchiveName())) { unlink($this->module->getItemUploadPath() . $this->getArchiveName()); } $files = $this->getGalleryFileLink(); if (!empty($files)) { //собираем архив $zip = new ZipArchive(); if ($zip->open('..' . $this->module->getItemUploadUrl() . $this->getArchiveName(), ZIPARCHIVE::CREATE)) { foreach ($files as $file) { $zip->addFile('..' . $file); } } $zip->close(); //Завершаем работу с архивом } } parent::afterSave($insert, $changedAttributes); } }