Commit 06d508f34e1a32f4c97f1d3856f6878c0b9acb96
1 parent
71f66dca
add Vitaliy's widgets
Showing
105 changed files
with
629 additions
and
16 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 105 files are displayed.
.gitignore
backend/assets/AppAsset.php
... | ... | @@ -17,6 +17,7 @@ class AppAsset extends AssetBundle |
17 | 17 | { |
18 | 18 | public $basePath = '@webroot'; |
19 | 19 | public $baseUrl = '@web'; |
20 | + public $jsOptions = ['position' => \yii\web\View::POS_HEAD]; | |
20 | 21 | public $css = [ |
21 | 22 | 'css/site.css', |
22 | 23 | 'css/flags32.css' |
... | ... | @@ -25,8 +26,9 @@ class AppAsset extends AssetBundle |
25 | 26 | 'js/option.js' |
26 | 27 | ]; |
27 | 28 | public $depends = [ |
29 | + 'yii\web\JqueryAsset', | |
28 | 30 | 'yii\web\YiiAsset', |
29 | 31 | 'yii\bootstrap\BootstrapAsset', |
30 | - 'yii\web\JqueryAsset' | |
32 | + 'backend\assets\FileUploadAsset' | |
31 | 33 | ]; |
32 | 34 | } | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * @link http://www.yiiframework.com/ | |
4 | + * @copyright Copyright (c) 2008 Yii Software LLC | |
5 | + * @license http://www.yiiframework.com/license/ | |
6 | + */ | |
7 | + | |
8 | + | |
9 | +namespace backend\assets; | |
10 | + | |
11 | +use yii\web\AssetBundle; | |
12 | + | |
13 | +/** | |
14 | + * Asset bundle for the Twitter bootstrap javascript files. | |
15 | + * | |
16 | + * @author Qiang Xue <qiang.xue@gmail.com> | |
17 | + * @since 2.0 | |
18 | + */ | |
19 | +class FileUploadAsset extends AssetBundle | |
20 | +{ | |
21 | + public $sourcePath = '@bower/blueimp-file-upload/'; | |
22 | + public $css = [ | |
23 | + 'css/jquery.fileupload.css' | |
24 | + ]; | |
25 | + public $js = [ | |
26 | + 'js/vendor/jquery.ui.widget.js', | |
27 | + 'js/jquery.iframe-transport.js', | |
28 | + 'js/jquery.fileupload.js' | |
29 | + ]; | |
30 | +} | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * Created by PhpStorm. | |
4 | + * User: Cibermag | |
5 | + * Date: 31.08.2015 | |
6 | + * Time: 9:58 | |
7 | + */ | |
8 | +namespace backend\controllers; | |
9 | +use Yii; | |
10 | +use yii\web\UploadedFile; | |
11 | +use common\models\ImageSizerForm; | |
12 | +use yii\web\Controller; | |
13 | +use Imagine\Gd\Imagine; | |
14 | +use Imagine\Image\Box; | |
15 | +use yii\imagine\Image; | |
16 | + | |
17 | +class FileController extends Controller { | |
18 | + | |
19 | + public function isBigger($width,$height,$w,$h) | |
20 | + { | |
21 | + if($width>$w){ | |
22 | + return true; | |
23 | + }else if($height >$h) { | |
24 | + return true; | |
25 | + } | |
26 | + return false; | |
27 | + } | |
28 | + | |
29 | + public function actionIndex(){ | |
30 | + die('hello'); | |
31 | + } | |
32 | + | |
33 | + private function resizeImg($w, $h, $imageAlias,$imageAliasSave){ | |
34 | + $img = Image::getImagine()->open(Yii::getAlias($imageAlias)); | |
35 | + | |
36 | + $size = $img->getSize(); | |
37 | + | |
38 | + $width = $size->getWidth(); | |
39 | + $height = $size->getHeight(); | |
40 | + | |
41 | + $e_width = $w/$h; | |
42 | + $e_height = $h/$w; | |
43 | + | |
44 | + $e1_width = $width/$height; | |
45 | + $e1_height = $height/$width; | |
46 | + | |
47 | + | |
48 | + if($this->isBigger($width,$height,$w,$h)){ | |
49 | + if($e_width<$e1_width){ | |
50 | + | |
51 | + $new_width = $width*($e_width/$e1_width); | |
52 | + | |
53 | + $y = 0; | |
54 | + $x = $width/ 2-($new_width/2); | |
55 | + $width = $new_width; | |
56 | + | |
57 | + }else { | |
58 | + | |
59 | + $new_height = $height*($e_height/$e1_height); | |
60 | + $x = 0; | |
61 | + $y = $height/2-($new_height/2); | |
62 | + $height = $new_height; | |
63 | + } | |
64 | + | |
65 | + | |
66 | + } else { | |
67 | + $img->save($imageAliasSave, array('flatten' => false)); | |
68 | + return true; | |
69 | + } | |
70 | + | |
71 | + | |
72 | + Image::crop($imageAlias, $width, $height,[$x,$y]) | |
73 | + ->save(Yii::getAlias($imageAliasSave), ['quality' => | |
74 | + 100]); | |
75 | + | |
76 | + | |
77 | + $imagine = new Imagine(); | |
78 | + $imagine->open($imageAliasSave) | |
79 | + ->resize(new Box($w, $h)) | |
80 | + ->save($imageAliasSave, array('flatten' => false)); | |
81 | + | |
82 | + | |
83 | + | |
84 | + } | |
85 | + | |
86 | + private function deleteImages($old_img){ | |
87 | + | |
88 | + if(!empty($old_img) && file_exists($_SERVER['DOCUMENT_ROOT'].$old_img)){ | |
89 | + | |
90 | +// $rootDir = explode("/", $old_img); | |
91 | +// | |
92 | +// $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/'; | |
93 | +// | |
94 | +// $allFiles = scandir($row); | |
95 | +// | |
96 | +// $allFiles = array_slice($allFiles, 2); | |
97 | +// | |
98 | +// foreach($allFiles as $oldFile){ | |
99 | +// | |
100 | +// unlink($row.$oldFile); | |
101 | +// | |
102 | +// } | |
103 | + | |
104 | + } | |
105 | + } | |
106 | + | |
107 | + public function actionDeleteImage(){ | |
108 | + | |
109 | + $request = Yii::$app->request->post(); | |
110 | + | |
111 | + if($request){ | |
112 | + if ($request['old_img']) { | |
113 | + $this->deleteImages($request['old_img']); | |
114 | + } | |
115 | + if(isset($request['action']) && $request['action']=='save'){ | |
116 | + $object = str_replace('-', '\\',$request['model']); | |
117 | + $model = new $object; | |
118 | + $model = $model->findOne($request['id']); | |
119 | + $model->$request['field'] = $request['new_url']; | |
120 | +// print_r($model->validate()); | |
121 | +// print_r($model->getErrors()); | |
122 | +// die(var_dump($model->save())); | |
123 | + $model->save(); | |
124 | + } | |
125 | + } | |
126 | + | |
127 | + } | |
128 | + | |
129 | + | |
130 | + public function actionDownloadPhoto() | |
131 | + { | |
132 | + | |
133 | + $model = new ImageSizerForm(); | |
134 | + | |
135 | + $request = Yii::$app->request->post(); | |
136 | + if ($request) { | |
137 | + | |
138 | + $model->file = UploadedFile::getInstance($model, 'file'); | |
139 | + | |
140 | + $md5_file = md5_file($model->file->tempName); | |
141 | + | |
142 | + $imgDir = Yii::getAlias('@storage/'.$md5_file.'/'); | |
143 | + | |
144 | + $imageOrigAlias = Yii::getAlias($imgDir.'original'.'.'.$model->file->extension); | |
145 | + | |
146 | + if(!is_dir($imgDir)) { | |
147 | + mkdir($imgDir, 0755, true); | |
148 | + } | |
149 | + | |
150 | + $model->file->saveAs($imageOrigAlias); | |
151 | + | |
152 | + if($request['width'] && $request['height']){ | |
153 | + | |
154 | + $imageAlias = Yii::getAlias($imgDir.$request['width'].'x'.$request['height'].'.'.$model->file->extension); | |
155 | + | |
156 | + $imageLink = '/storage/'.$md5_file.'/'.$request['width'].'x'.$request['height'].'.'.$model->file->extension; | |
157 | + | |
158 | + $this->resizeImg($request['width'], $request['height'], $imageOrigAlias,$imageAlias); | |
159 | + | |
160 | + } else { | |
161 | + | |
162 | + $imageLink = '/storage/'.$md5_file.'/'.'original'.'.'.$model->file->extension; | |
163 | + | |
164 | + } | |
165 | + | |
166 | + | |
167 | + if($model->multi){ | |
168 | + $view = $this->renderPartial('@app/components/views/_gallery_item', [ | |
169 | + 'item' => ['image'=>$imageLink], | |
170 | + ]); | |
171 | + | |
172 | + return json_encode(['link'=>$imageLink, 'view' =>$view]); | |
173 | + | |
174 | + | |
175 | + } else { | |
176 | + return json_encode(['link'=>$imageLink]); | |
177 | + } | |
178 | + | |
179 | + | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + | |
184 | + public function getex($filename) { | |
185 | + return end(explode(".", $filename)); | |
186 | + } | |
187 | + | |
188 | + | |
189 | + public function actionImagesUpload(){ | |
190 | + if($_FILES['upload']) | |
191 | + { | |
192 | + if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name'])) ) | |
193 | + { | |
194 | + $message = "Вы не выбрали файл"; | |
195 | + } | |
196 | + else if ($_FILES['upload']["size"] == 0 OR $_FILES['upload']["size"] > 2050000) | |
197 | + { | |
198 | + $message = "Размер файла не соответствует нормам"; | |
199 | + } | |
200 | + else if (($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png") AND ($_FILES['upload']['type'] != 'image/gif')) | |
201 | + { | |
202 | + $message = "Допускается загрузка только картинок JPG и PNG."; | |
203 | + } | |
204 | + else if (!is_uploaded_file($_FILES['upload']["tmp_name"])) | |
205 | + { | |
206 | + $message = "Что-то пошло не так. Попытайтесь загрузить файл ещё раз."; | |
207 | + } | |
208 | + else{ | |
209 | + $name =rand(1, 1000).md5($_FILES['upload']['name']).'.'.$this->getex($_FILES['upload']['name']); | |
210 | + move_uploaded_file($_FILES['upload']['tmp_name'], "../../storage/images/".$name); | |
211 | + $full_path = '/storage/images/'.$name; | |
212 | + $message = "Файл ".$_FILES['upload']['name']." загружен"; | |
213 | + $size=@getimagesize('images/'.$name); | |
214 | + | |
215 | + } | |
216 | + $callback = $_REQUEST['CKEditorFuncNum']; | |
217 | + echo '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction("'.$callback.'", "'.$full_path.'", "'.$message.'" );</script>'; | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + | |
222 | +} | |
0 | 223 | \ No newline at end of file | ... | ... |
backend/controllers/SpecializationController.php
100644 → 100755
backend/controllers/UserInfoTestController.php
100644 → 100755
... | ... | @@ -14,7 +14,15 @@ use yii\helpers\ArrayHelper; |
14 | 14 | |
15 | 15 | <?= $form->field($model, 'specialization_pid')->dropDownList(ArrayHelper::map($model->find()->all(), 'specialization_id', 'specialization_name'), ['prompt' => 'Выберие родителя']) ?> |
16 | 16 | <?= $form->field($model, 'specialization_name')->textInput(['maxlength' => true]) ?> |
17 | - | |
17 | + <?= \common\widgets\ImageUploader::widget([ | |
18 | + 'model'=> $model, | |
19 | + 'field'=>'img', | |
20 | + 'width'=>240, | |
21 | + 'height'=>160, | |
22 | + 'multi'=>false, | |
23 | + 'gallery' =>$model->img, | |
24 | + 'name' => 'Загрузить картинку' | |
25 | + ]); ?> | |
18 | 26 | <div class="form-group"> |
19 | 27 | <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> |
20 | 28 | </div> | ... | ... |
common/config/main.php
1 | 1 | <?php |
2 | 2 | return [ |
3 | 3 | 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', |
4 | + 'controllerMap' => [ | |
5 | + 'elfinder' => [ | |
6 | + 'class' => 'mihaildev\elfinder\Controller', | |
7 | + 'access' => ['@'], //глобальный доступ к фаил менеджеру @ - для авторизорованных , ? - для гостей , чтоб открыть всем ['@', '?'] | |
8 | + 'disabledCommands' => ['netmount'], //отключение ненужных команд https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands | |
9 | + 'roots' => [ | |
10 | + [ | |
11 | + 'class' => 'mihaildev\elfinder\UserPath', | |
12 | + 'path' => '../../storage/user_{id}', | |
13 | + 'name' => 'My Documents' | |
14 | + ], | |
15 | + ], | |
16 | + 'watermark' => [ | |
17 | + 'source' => __DIR__.'/logo.png', // Path to Water mark image | |
18 | + 'marginRight' => 5, // Margin right pixel | |
19 | + 'marginBottom' => 5, // Margin bottom pixel | |
20 | + 'quality' => 95, // JPEG image save quality | |
21 | + 'transparency' => 70, // Water mark image transparency ( other than PNG ) | |
22 | + 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field ) | |
23 | + 'targetMinPixel' => 200 // Target image minimum pixel size | |
24 | + ] | |
25 | + ] | |
26 | + ], | |
4 | 27 | 'modules' => [ |
5 | 28 | 'permit' => [ |
6 | 29 | 'class' => 'common\components\developeruz\db_rbac\Yii2DbRbac', | ... | ... |
common/models/ImageSizerForm.php
common/modules/file/controller/DefaultController.php
0 → 100755
1 | +<?php | |
2 | +/** | |
3 | + * Created by PhpStorm. | |
4 | + * User: Cibermag | |
5 | + * Date: 31.08.2015 | |
6 | + * Time: 9:58 | |
7 | + */ | |
8 | +namespace common\modules\file\controllers; | |
9 | +use Yii; | |
10 | +use yii\web\UploadedFile; | |
11 | +use common\models\ImageSizerForm; | |
12 | +use yii\web\Controller; | |
13 | +use Imagine\Gd\Imagine; | |
14 | +use Imagine\Image\Box; | |
15 | +use yii\imagine\Image; | |
16 | + | |
17 | +class DefaultController extends Controller { | |
18 | + | |
19 | + public function isBigger($width,$height,$w,$h) | |
20 | + { | |
21 | + if($width>$w){ | |
22 | + return true; | |
23 | + }else if($height >$h) { | |
24 | + return true; | |
25 | + } | |
26 | + return false; | |
27 | + } | |
28 | + | |
29 | + public function actionIndex(){ | |
30 | + die('hello'); | |
31 | + } | |
32 | + | |
33 | + private function resizeImg($w, $h, $imageAlias,$imageAliasSave){ | |
34 | + $img = Image::getImagine()->open(Yii::getAlias($imageAlias)); | |
35 | + | |
36 | + $size = $img->getSize(); | |
37 | + | |
38 | + $width = $size->getWidth(); | |
39 | + $height = $size->getHeight(); | |
40 | + | |
41 | + $e_width = $w/$h; | |
42 | + $e_height = $h/$w; | |
43 | + | |
44 | + $e1_width = $width/$height; | |
45 | + $e1_height = $height/$width; | |
46 | + | |
47 | + | |
48 | + if($this->isBigger($width,$height,$w,$h)){ | |
49 | + if($e_width<$e1_width){ | |
50 | + | |
51 | + $new_width = $width*($e_width/$e1_width); | |
52 | + | |
53 | + $y = 0; | |
54 | + $x = $width/ 2-($new_width/2); | |
55 | + $width = $new_width; | |
56 | + | |
57 | + }else { | |
58 | + | |
59 | + $new_height = $height*($e_height/$e1_height); | |
60 | + $x = 0; | |
61 | + $y = $height/2-($new_height/2); | |
62 | + $height = $new_height; | |
63 | + } | |
64 | + | |
65 | + | |
66 | + } else { | |
67 | + $img->save($imageAliasSave, array('flatten' => false)); | |
68 | + return true; | |
69 | + } | |
70 | + | |
71 | + | |
72 | + Image::crop($imageAlias, $width, $height,[$x,$y]) | |
73 | + ->save(Yii::getAlias($imageAliasSave), ['quality' => | |
74 | + 100]); | |
75 | + | |
76 | + | |
77 | + $imagine = new Imagine(); | |
78 | + $imagine->open($imageAliasSave) | |
79 | + ->resize(new Box($w, $h)) | |
80 | + ->save($imageAliasSave, array('flatten' => false)); | |
81 | + | |
82 | + | |
83 | + | |
84 | + } | |
85 | + | |
86 | + private function deleteImages($old_img){ | |
87 | + | |
88 | + if(!empty($old_img) && file_exists($_SERVER['DOCUMENT_ROOT'].$old_img)){ | |
89 | + | |
90 | +// $rootDir = explode("/", $old_img); | |
91 | +// | |
92 | +// $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/'; | |
93 | +// | |
94 | +// $allFiles = scandir($row); | |
95 | +// | |
96 | +// $allFiles = array_slice($allFiles, 2); | |
97 | +// | |
98 | +// foreach($allFiles as $oldFile){ | |
99 | +// | |
100 | +// unlink($row.$oldFile); | |
101 | +// | |
102 | +// } | |
103 | + | |
104 | + } | |
105 | + } | |
106 | + | |
107 | + public function actionDeleteImage(){ | |
108 | + | |
109 | + $request = Yii::$app->request->post(); | |
110 | + | |
111 | + if($request){ | |
112 | + if ($request['old_img']) { | |
113 | + $this->deleteImages($request['old_img']); | |
114 | + } | |
115 | + if(isset($request['action']) && $request['action']=='save'){ | |
116 | + $object = str_replace('-', '\\',$request['model']); | |
117 | + $model = new $object; | |
118 | + $model = $model->findOne($request['id']); | |
119 | + $model->$request['field'] = $request['new_url']; | |
120 | +// print_r($model->validate()); | |
121 | +// print_r($model->getErrors()); | |
122 | +// die(var_dump($model->save())); | |
123 | + $model->save(); | |
124 | + } | |
125 | + } | |
126 | + | |
127 | + } | |
128 | + | |
129 | + | |
130 | + public function actionDownloadPhoto() | |
131 | + { | |
132 | + | |
133 | + $model = new ImageSizerForm(); | |
134 | + | |
135 | + $request = Yii::$app->request->post(); | |
136 | + if ($request) { | |
137 | + | |
138 | + $model->file = UploadedFile::getInstance($model, 'file'); | |
139 | + | |
140 | + $md5_file = md5_file($model->file->tempName); | |
141 | + | |
142 | + $imgDir = Yii::getAlias('@storage/'.$md5_file.'/'); | |
143 | + | |
144 | + $imageOrigAlias = Yii::getAlias($imgDir.'original'.'.'.$model->file->extension); | |
145 | + | |
146 | + if(!is_dir($imgDir)) { | |
147 | + mkdir($imgDir, 0755, true); | |
148 | + } | |
149 | + | |
150 | + $model->file->saveAs($imageOrigAlias); | |
151 | + | |
152 | + if($request['width'] && $request['height']){ | |
153 | + | |
154 | + $imageAlias = Yii::getAlias($imgDir.$request['width'].'x'.$request['height'].'.'.$model->file->extension); | |
155 | + | |
156 | + $imageLink = '/storage/'.$md5_file.'/'.$request['width'].'x'.$request['height'].'.'.$model->file->extension; | |
157 | + | |
158 | + $this->resizeImg($request['width'], $request['height'], $imageOrigAlias,$imageAlias); | |
159 | + | |
160 | + } else { | |
161 | + | |
162 | + $imageLink = '/storage/'.$md5_file.'/'.'original'.'.'.$model->file->extension; | |
163 | + | |
164 | + } | |
165 | + | |
166 | + | |
167 | + if($model->multi){ | |
168 | + $view = $this->renderPartial('@app/components/views/_gallery_item', [ | |
169 | + 'item' => ['image'=>$imageLink], | |
170 | + ]); | |
171 | + | |
172 | + return json_encode(['link'=>$imageLink, 'view' =>$view]); | |
173 | + | |
174 | + | |
175 | + } else { | |
176 | + return json_encode(['link'=>$imageLink]); | |
177 | + } | |
178 | + | |
179 | + | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + | |
184 | + public function getex($filename) { | |
185 | + return end(explode(".", $filename)); | |
186 | + } | |
187 | + | |
188 | + | |
189 | + public function actionImagesUpload(){ | |
190 | + if($_FILES['upload']) | |
191 | + { | |
192 | + if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name'])) ) | |
193 | + { | |
194 | + $message = "Вы не выбрали файл"; | |
195 | + } | |
196 | + else if ($_FILES['upload']["size"] == 0 OR $_FILES['upload']["size"] > 2050000) | |
197 | + { | |
198 | + $message = "Размер файла не соответствует нормам"; | |
199 | + } | |
200 | + else if (($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/jpeg") AND ($_FILES['upload']["type"] != "image/png") AND ($_FILES['upload']['type'] != 'image/gif')) | |
201 | + { | |
202 | + $message = "Допускается загрузка только картинок JPG и PNG."; | |
203 | + } | |
204 | + else if (!is_uploaded_file($_FILES['upload']["tmp_name"])) | |
205 | + { | |
206 | + $message = "Что-то пошло не так. Попытайтесь загрузить файл ещё раз."; | |
207 | + } | |
208 | + else{ | |
209 | + $name =rand(1, 1000).md5($_FILES['upload']['name']).'.'.$this->getex($_FILES['upload']['name']); | |
210 | + move_uploaded_file($_FILES['upload']['tmp_name'], "../../storage/images/".$name); | |
211 | + $full_path = '/storage/images/'.$name; | |
212 | + $message = "Файл ".$_FILES['upload']['name']." загружен"; | |
213 | + $size=@getimagesize('images/'.$name); | |
214 | + | |
215 | + } | |
216 | + $callback = $_REQUEST['CKEditorFuncNum']; | |
217 | + echo '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction("'.$callback.'", "'.$full_path.'", "'.$message.'" );</script>'; | |
218 | + } | |
219 | + } | |
220 | + | |
221 | + | |
222 | +} | |
0 | 223 | \ No newline at end of file | ... | ... |
common/widgets/ImageResizer.php
1 | +<?php | |
2 | +/** | |
3 | + * Created by PhpStorm. | |
4 | + * User: vitaliy | |
5 | + * Date: 05.10.15 | |
6 | + * Time: 16:18 | |
7 | + */ | |
8 | + | |
9 | +namespace common\widgets; | |
10 | +use yii\base\Widget; | |
11 | + | |
12 | + | |
13 | +class ImageUploader extends Widget | |
14 | +{ | |
15 | + public $height = 0; | |
16 | + public $width = 0; | |
17 | + public $field; | |
18 | + public $file; | |
19 | + public $model; | |
20 | + public $multi = false; | |
21 | + public $gallery; | |
22 | + public $name = 'Add file...'; | |
23 | + | |
24 | + public function init(){ | |
25 | + | |
26 | + parent::init(); | |
27 | + | |
28 | + } | |
29 | + | |
30 | + | |
31 | + public function run() | |
32 | + { | |
33 | + | |
34 | + return $this->render('image_sizer', | |
35 | + [ | |
36 | + 'model'=>$this->model, | |
37 | + 'field' => $this->field, | |
38 | + 'height' => $this->height, | |
39 | + 'width' => $this->width, | |
40 | + 'multi' => $this->multi, | |
41 | + 'name' => $this->name | |
42 | + ]); | |
43 | + | |
44 | + } | |
45 | + | |
46 | + public function getGallery(){ | |
47 | + if($this->gallery){ | |
48 | + $array = explode(",", $this->gallery); | |
49 | + if(count($array) > 1){ | |
50 | + array_pop($array); | |
51 | + } | |
52 | + return $array; | |
53 | + } else { | |
54 | + return array(); | |
55 | + } | |
56 | + | |
57 | + } | |
58 | + | |
59 | +} | |
0 | 60 | \ No newline at end of file | ... | ... |
common/widgets/views/image_sizer.php
... | ... | @@ -6,10 +6,8 @@ |
6 | 6 | * Time: 16:20 |
7 | 7 | */ |
8 | 8 | use yii\helpers\Html; |
9 | -$this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/vendor/jquery.ui.widget.js'); | |
10 | -$this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/jquery.iframe-transport.js'); | |
11 | -$this->registerJsFile('@web/js/vendor/bower/jquery-file-upload/js/jquery.fileupload.js'); | |
12 | -$this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileupload.css'); | |
9 | + | |
10 | +$id = $model::tableName().'_id'; | |
13 | 11 | |
14 | 12 | ?> |
15 | 13 | <div class="file-uploader-block"> |
... | ... | @@ -18,13 +16,13 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu |
18 | 16 | <i class="glyphicon glyphicon-plus"></i> |
19 | 17 | <span><?=$name?></span> |
20 | 18 | |
21 | - <?= Html::activeFileInput( new \backend\models\ImageSizerForm(),'file',['id'=>$field, 'data-url'=>"/admin/site/download-photo" ]);?> | |
19 | + <?= Html::activeFileInput( new \common\models\ImageSizerForm(),'file',['id'=>$field, 'data-url'=>"/file/download-photo" ]);?> | |
22 | 20 | </span> |
23 | 21 | |
24 | 22 | <?= Html::activeHiddenInput( $model,$field,['id' => "{$field}_picture_link"]) ?> |
25 | 23 | <input type="hidden" id="<?=$field?>_old_img" name="ImageSizerForm[old_img]" value="<?=$model->$field?>"/> |
26 | 24 | <input type="hidden" id="<?=$field?>_new_img" name="ImageSizerForm[new_img]" value=""/> |
27 | - <input type="hidden" id="<?=$field?>_row_id" name="ImageSizerForm[new_img]" value="<?=$model->id?>"/> | |
25 | + <input type="hidden" id="<?=$field?>_row_id" name="ImageSizerForm[new_img]" value="<?=$model->$id?>"/> | |
28 | 26 | <div id="<?= $field?>_img_block"> |
29 | 27 | <?= $model->$field ? Html::img($model->$field): '' ?> |
30 | 28 | </div> |
... | ... | @@ -59,7 +57,7 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu |
59 | 57 | var old_url = $('#<?=$field?>_old_img').val(); |
60 | 58 | var new_url = $('#<?=$field?>_new_img').val(); |
61 | 59 | var model = '<?=str_replace('\\', '-',$model::className());?>'; |
62 | - $.post( "/admin/site/delete-image",{new_url:new_url,old_img: old_url,model:model,field:"<?= $field?>", id:"<?=$model->id?>",action:'save'}, function() { | |
60 | + $.post( "/admin/site/delete-image",{new_url:new_url,old_img: old_url,model:model,field:"<?= $field?>", id:"<?=$model->$id?>",action:'save'}, function() { | |
63 | 61 | }); |
64 | 62 | $("#<?=$field?>_picture_link").val(new_url); |
65 | 63 | }); |
... | ... | @@ -85,7 +83,7 @@ $this->registerCssFile('@web/js/vendor/bower/jquery-file-upload/css/jquery.fileu |
85 | 83 | <i class="glyphicon glyphicon-plus"></i> |
86 | 84 | <span><?=$name?></span> |
87 | 85 | |
88 | - <?= Html::activeFileInput( new \backend\models\ImageSizerForm(),'file',['id'=>$field, 'data-url'=>"/admin/site/download-photo", 'multiple'=> 'multiple' ]);?> | |
86 | + <?= Html::activeFileInput( new \common\models\ImageSizerForm(),'file',['id'=>$field, 'data-url'=>"/file/download-photo", 'multiple'=> 'multiple' ]);?> | |
89 | 87 | </span> |
90 | 88 | |
91 | 89 | <?= Html::activeHiddenInput( $model,$field,['id' => "{$field}_picture_link"]) ?> | ... | ... |
console/migrations/m160125_151635_delete_lang_field.php
100644 → 100755
console/migrations/m160202_084703_specialization.php
100644 → 100755
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m160203_082111_jobs extends Migration | |
6 | +{ | |
7 | + public function up() | |
8 | + { | |
9 | + $tableOptions = null; | |
10 | + | |
11 | + $this->createTable('{{%job}}', [ | |
12 | + 'job_id' => $this->primaryKey(), | |
13 | + 'name' => $this->string(255)->notNull(), | |
14 | + 'link' => $this->string(255), | |
15 | + 'date_start' => $this->timestamp(), | |
16 | + 'date_end' => $this->timestamp(), | |
17 | + 'position' => $this->string(255), | |
18 | + 'user_id' => $this->integer(), | |
19 | + 'total_count' => $this->integer(), | |
20 | + 'complete_count' => $this->integer(), | |
21 | + ], $tableOptions); | |
22 | + | |
23 | + } | |
24 | + | |
25 | + public function down() | |
26 | + { | |
27 | + $this->dropTable('{{%job}}'); | |
28 | + } | |
29 | +} | ... | ... |
No preview for this file type
... | ... | @@ -6,10 +6,9 @@ |
6 | 6 | * Time: 9:58 |
7 | 7 | */ |
8 | 8 | namespace frontend\controllers; |
9 | - | |
10 | 9 | use Yii; |
11 | 10 | use yii\web\UploadedFile; |
12 | -use backend\models\ImageSizerForm; | |
11 | +use common\models\ImageSizerForm; | |
13 | 12 | use yii\web\Controller; |
14 | 13 | use Imagine\Gd\Imagine; |
15 | 14 | use Imagine\Image\Box; | ... | ... |
1 | 1 | <?php |
2 | - | |
3 | 2 | use yii\helpers\Html; |
4 | 3 | use yii\widgets\ActiveForm; |
5 | 4 | use mihaildev\ckeditor\CKEditor; |
5 | +use mihaildev\elfinder\InputFile; | |
6 | 6 | use mihaildev\elfinder\ElFinder; |
7 | 7 | ?> |
8 | 8 | |
... | ... | @@ -51,6 +51,7 @@ use mihaildev\elfinder\ElFinder; |
51 | 51 | ) |
52 | 52 | ]); ?> |
53 | 53 | |
54 | + | |
54 | 55 | <?= \common\widgets\FieldEditor::widget([ |
55 | 56 | 'template'=>'education', |
56 | 57 | 'item_id'=> $user->id, | ... | ... |
frontend/views/landing/landing-order-project.php
100644 → 100755