diff --git a/backend/views/specialization/_form.php b/backend/views/specialization/_form.php
index a1117a6..018cc2c 100755
--- a/backend/views/specialization/_form.php
+++ b/backend/views/specialization/_form.php
@@ -27,7 +27,7 @@ use \kartik\color\ColorInput;
'options' => ['placeholder' => 'Select color ...'],
]);
- echo \common\widgets\ImageUploader::widget([
+ echo common\modules\file\widgets\ImageUploader::widget([
'model'=> $model,
'field'=>'image',
'width'=>940,
diff --git a/common/models/Portfolio.php b/common/models/Portfolio.php
index e3b245a..083ab3a 100644
--- a/common/models/Portfolio.php
+++ b/common/models/Portfolio.php
@@ -71,6 +71,7 @@
'name',
'preview',
'link',
+ 'city',
'cover'
],
'required',
diff --git a/common/modules/file/widgets/ImageUploaderInput.php b/common/modules/file/widgets/ImageUploaderInput.php
new file mode 100755
index 0000000..b161889
--- /dev/null
+++ b/common/modules/file/widgets/ImageUploaderInput.php
@@ -0,0 +1,62 @@
+render('image_sizer',
+ [
+ 'model'=>$this->model,
+ 'size' => $this->size,
+ 'field' => $this->attribute,
+ 'height' => $this->height,
+ 'width' => $this->width,
+ 'multi' => $this->multi,
+ 'name' => $this->name,
+ 'remover' => $this->remover
+ ]);
+
+ }
+
+ public function getGallery(){
+ if($this->gallery){
+ $array = explode(",", $this->gallery);
+ if(count($array) > 1){
+ array_pop($array);
+ }
+ return $array;
+ } else {
+ return array();
+ }
+
+ }
+
+}
\ No newline at end of file
diff --git a/common/widgets/ImageResizer.php b/common/widgets/ImageResizer.php
deleted file mode 100755
index 8957517..0000000
--- a/common/widgets/ImageResizer.php
+++ /dev/null
@@ -1,185 +0,0 @@
-request->post();
-
- if ($request) {
-
- if(isset($request['old_img'])){
- $this->deleteImages($request['old_img']);
- }
-
-
- $model->file = UploadedFile::getInstance($model, 'file');
-
- if(!$model->file){
- return json_encode(["error"=>"Не указан файл"]);
- }
-
- $md5_file = md5_file($model->file->tempName);
-
- $imgDir = Yii::getAlias('@storage/'.$md5_file.'/');
-
- $imageOrigAlias = Yii::getAlias($imgDir.'original'.'.'.$model->file->extension);
-
- if(!is_dir($imgDir)) {
- mkdir($imgDir, 0755, true);
- }
-
- $model->file->saveAs($imageOrigAlias);
-
- if($request['width'] && $request['height']){
-
- $imageAlias = Yii::getAlias($imgDir.$request['width'].'x'.$request['height'].'.'.$model->file->extension);
-
- $imageLink = '/storage/'.$md5_file.'/'.$request['width'].'x'.$request['height'].'.'.$model->file->extension;
-
- $this->resizeImg($request['width'],$request['height'], $imageOrigAlias,$imageAlias);
-
- } else {
-
- $imageLink = '/storage/'.$md5_file.'/'.'original'.'.'.$model->file->extension;
-
- }
-
-
- if($model->multi){
-// $view = $this->renderPartial('@app/components/views/_gallery_item', [
-// 'item' => ['image'=>$imageLink],
-// ]);
-//
-// return json_encode(['link'=>$imageLink, 'view' =>$view]);
-
-
- } else {
- $p1[0] = "";
- return json_encode(['success','initialPreview' => $p1, 'append' => false, 'name' =>$imageLink,]);
- }
-
-
- } else {
- return json_encode(['error']);
- }
-
-
-
-
- }
-
-
- public function isBigger($width,$height,$w,$h)
- {
- if($width>$w){
- return true;
- }else if($height >$h) {
- return true;
- }
- return false;
- }
-
-
-
-
-
- public function resizeImg($w, $h, $imageAlias,$imageAliasSave)
- {
- $img = Image::getImagine()->open(Yii::getAlias($imageAlias));
-
- $size = $img->getSize();
-
- $width = $size->getWidth();
- $height = $size->getHeight();
-
- $e_width = $w/$h;
- $e_height = $h/$w;
-
- $e1_width = $width/$height;
- $e1_height = $height/$width;
-
- if($this->isBigger($width,$height,$w,$h)){
- if($e_width<$e1_width){
- $new_width = $width*($e_width/$e1_width);
- $width = $new_width;
- }else {
- $new_height = $height*($e_height/$e1_height);
- $height = $new_height;
- }
-
-
- } else {
- $img->save($imageAliasSave, array('flatten' => false));
- return true;
- }
-
-
- Image::crop($imageAlias, $width, $height,[0,0])
- ->save(Yii::getAlias($imageAliasSave), ['quality' =>
- 100]);
-
-
- $imagine = new Imagine();
- $imagine->open($imageAliasSave)
- ->resize(new Box($w, $h))
- ->save($imageAliasSave, array('flatten' => false));
-
-
-
- }
-
-
- private function deleteImages($old_img){
-
- if(!empty($old_img) && file_exists($_SERVER['DOCUMENT_ROOT'].$old_img)){
-
- $rootDir = explode("/", $old_img);
-
- $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/';
-
- $allFiles = scandir($row);
-
- $allFiles = array_slice($allFiles, 2);
-
- foreach($allFiles as $oldFile){
-
- unlink($row.$oldFile);
-
- }
-
- }
- }
-
- public function actionDeleteImage(){
- $old_img = Yii::$app->request->post('old_img');
-
- if ($old_img) {
- $this->deleteImages($old_img);
- }
- }
-
-
-
-}
\ No newline at end of file
diff --git a/common/widgets/ImageUploader.php b/common/widgets/ImageUploader.php
deleted file mode 100755
index c9cad75..0000000
--- a/common/widgets/ImageUploader.php
+++ /dev/null
@@ -1,63 +0,0 @@
-render('image_sizer',
- [
- 'model'=>$this->model,
- 'size' => $this->size,
- 'field' => $this->field,
- 'height' => $this->height,
- 'width' => $this->width,
- 'multi' => $this->multi,
- 'name' => $this->name,
- 'remover' => $this->remover
- ]);
-
- }
-
- public function getGallery(){
- if($this->gallery){
- $array = explode(",", $this->gallery);
- if(count($array) > 1){
- array_pop($array);
- }
- return $array;
- } else {
- return array();
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/common/widgets/views/image_sizer.php b/common/widgets/views/image_sizer.php
deleted file mode 100755
index 66909a3..0000000
--- a/common/widgets/views/image_sizer.php
+++ /dev/null
@@ -1,184 +0,0 @@
-
-