Commit 84a350978d367a7a6cfcf799f1b7242f8b8f4a1d
Merge remote-tracking branch 'origin/master'
Showing
111 changed files
with
2586 additions
and
21 deletions
Show diff stats
Too many changes.
To preserve performance only 100 of 111 files are displayed.
1 | +# yii console command | |
2 | +/yii | |
3 | + | |
4 | +# phpstorm project files | |
5 | +.idea | |
6 | + | |
7 | +# netbeans project files | |
8 | +nbproject | |
9 | + | |
10 | +# zend studio for eclipse project files | |
11 | +.buildpath | |
12 | +.project | |
13 | +.settings | |
14 | + | |
15 | +# windows thumbnail cache | |
16 | +Thumbs.db | |
17 | + | |
18 | +# composer vendor dir | |
19 | +/vendor | |
20 | + | |
21 | +# composer itself is not needed | |
22 | +composer.phar | |
23 | + | |
24 | +# Mac DS_Store Files | |
25 | +.DS_Store | |
26 | + | |
27 | +# phpunit itself is not needed | |
28 | +phpunit.phar | |
29 | +# local phpunit config | |
30 | +/phpunit.xml | |
31 | +storage | |
0 | 32 | \ No newline at end of file | ... | ... |
.htaccess
1 | +AddDefaultCharset utf-8 | |
1 | 2 | <IfModule mod_rewrite.c> |
2 | 3 | |
4 | + | |
3 | 5 | Options +FollowSymlinks |
4 | 6 | |
5 | 7 | RewriteEngine On |
... | ... | @@ -10,6 +12,9 @@ |
10 | 12 | |
11 | 13 | RewriteBase / |
12 | 14 | # deal with admin first |
15 | + | |
16 | + | |
17 | + | |
13 | 18 | RewriteRule ^storage/(.*)?$ /storage/$1 [L,PT] |
14 | 19 | |
15 | 20 | RewriteCond %{REQUEST_URI} ^/(admin) |
... | ... | @@ -59,7 +64,7 @@ |
59 | 64 | |
60 | 65 | RewriteCond %{REQUEST_FILENAME} !-d |
61 | 66 | |
62 | - RewriteRule ^.*$ frontend/web/index.php | |
67 | + RewriteRule ^.*$ frontend/web/index.php [L] | |
63 | 68 | |
64 | 69 | </IfModule> |
65 | 70 | |
... | ... | @@ -67,5 +72,4 @@ |
67 | 72 | <IfModule mod_php5.c> |
68 | 73 | php_value upload_max_filesize 20M |
69 | 74 | php_value post_max_size 30M |
70 | - php_value error_reporting 22527 | |
71 | 75 | </IfModule> |
72 | 76 | \ No newline at end of file | ... | ... |
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 | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace backend\controllers; | |
4 | + | |
5 | +use Yii; | |
6 | +use common\models\Specialization; | |
7 | +use common\models\SpecializationSearch; | |
8 | +use yii\web\Controller; | |
9 | +use yii\web\NotFoundHttpException; | |
10 | +use yii\filters\VerbFilter; | |
11 | + | |
12 | +/** | |
13 | + * SpecializationController implements the CRUD actions for Specialization model. | |
14 | + */ | |
15 | +class SpecializationController extends Controller | |
16 | +{ | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public function behaviors() | |
21 | + { | |
22 | + return [ | |
23 | + 'verbs' => [ | |
24 | + 'class' => VerbFilter::className(), | |
25 | + 'actions' => [ | |
26 | + 'delete' => ['POST'], | |
27 | + ], | |
28 | + ], | |
29 | + ]; | |
30 | + } | |
31 | + | |
32 | + /** | |
33 | + * Lists all Specialization models. | |
34 | + * @return mixed | |
35 | + */ | |
36 | + public function actionIndex() | |
37 | + { | |
38 | + $searchModel = new SpecializationSearch(); | |
39 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
40 | + | |
41 | + return $this->render('index', [ | |
42 | + 'searchModel' => $searchModel, | |
43 | + 'dataProvider' => $dataProvider, | |
44 | + ]); | |
45 | + } | |
46 | + | |
47 | + /** | |
48 | + * Displays a single Specialization model. | |
49 | + * @param integer $id | |
50 | + * @return mixed | |
51 | + */ | |
52 | + public function actionView($id) | |
53 | + { | |
54 | + return $this->render('view', [ | |
55 | + 'model' => $this->findModel($id), | |
56 | + ]); | |
57 | + } | |
58 | + | |
59 | + /** | |
60 | + * Creates a new Specialization model. | |
61 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
62 | + * @return mixed | |
63 | + */ | |
64 | + public function actionCreate() | |
65 | + { | |
66 | + $model = new Specialization(); | |
67 | + | |
68 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
69 | + return $this->redirect(['view', 'id' => $model->specialization_id]); | |
70 | + } else { | |
71 | + return $this->render('create', [ | |
72 | + 'model' => $model, | |
73 | + ]); | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * Updates an existing Specialization model. | |
79 | + * If update is successful, the browser will be redirected to the 'view' page. | |
80 | + * @param integer $id | |
81 | + * @return mixed | |
82 | + */ | |
83 | + public function actionUpdate($id) | |
84 | + { | |
85 | + $model = $this->findModel($id); | |
86 | + | |
87 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
88 | + return $this->redirect(['view', 'id' => $model->specialization_id]); | |
89 | + } else { | |
90 | + return $this->render('update', [ | |
91 | + 'model' => $model, | |
92 | + ]); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + /** | |
97 | + * Deletes an existing Specialization model. | |
98 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
99 | + * @param integer $id | |
100 | + * @return mixed | |
101 | + */ | |
102 | + public function actionDelete($id) | |
103 | + { | |
104 | + $this->findModel($id)->delete(); | |
105 | + | |
106 | + return $this->redirect(['index']); | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * Finds the Specialization model based on its primary key value. | |
111 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
112 | + * @param integer $id | |
113 | + * @return Specialization the loaded model | |
114 | + * @throws NotFoundHttpException if the model cannot be found | |
115 | + */ | |
116 | + protected function findModel($id) | |
117 | + { | |
118 | + if (($model = Specialization::findOne($id)) !== null) { | |
119 | + return $model; | |
120 | + } else { | |
121 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
122 | + } | |
123 | + } | |
124 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace backend\controllers; | |
4 | + | |
5 | +use Yii; | |
6 | +use common\models\UserInfo; | |
7 | +use frontend\models\UserSearch; | |
8 | +use yii\web\Controller; | |
9 | +use yii\web\NotFoundHttpException; | |
10 | +use yii\filters\VerbFilter; | |
11 | + | |
12 | +/** | |
13 | + * UserInfoTestController implements the CRUD actions for UserInfo model. | |
14 | + */ | |
15 | +class UserInfoTestController extends Controller | |
16 | +{ | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public function behaviors() | |
21 | + { | |
22 | + return [ | |
23 | + 'verbs' => [ | |
24 | + 'class' => VerbFilter::className(), | |
25 | + 'actions' => [ | |
26 | + 'delete' => ['POST'], | |
27 | + ], | |
28 | + ], | |
29 | + ]; | |
30 | + } | |
31 | + | |
32 | + /** | |
33 | + * Lists all UserInfo models. | |
34 | + * @return mixed | |
35 | + */ | |
36 | + public function actionIndex() | |
37 | + { | |
38 | + $searchModel = new UserSearch(); | |
39 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
40 | + | |
41 | + return $this->render('index', [ | |
42 | + 'searchModel' => $searchModel, | |
43 | + 'dataProvider' => $dataProvider, | |
44 | + ]); | |
45 | + } | |
46 | + | |
47 | + /** | |
48 | + * Displays a single UserInfo model. | |
49 | + * @param integer $id | |
50 | + * @return mixed | |
51 | + */ | |
52 | + public function actionView($id) | |
53 | + { | |
54 | + return $this->render('view', [ | |
55 | + 'model' => $this->findModel($id), | |
56 | + ]); | |
57 | + } | |
58 | + | |
59 | + /** | |
60 | + * Creates a new UserInfo model. | |
61 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
62 | + * @return mixed | |
63 | + */ | |
64 | + public function actionCreate() | |
65 | + { | |
66 | + $model = new UserInfo(); | |
67 | + | |
68 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
69 | + return $this->redirect(['view', 'id' => $model->user_info_id]); | |
70 | + } else { | |
71 | + return $this->render('create', [ | |
72 | + 'model' => $model, | |
73 | + ]); | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * Updates an existing UserInfo model. | |
79 | + * If update is successful, the browser will be redirected to the 'view' page. | |
80 | + * @param integer $id | |
81 | + * @return mixed | |
82 | + */ | |
83 | + public function actionUpdate($id) | |
84 | + { | |
85 | + $model = $this->findModel($id); | |
86 | + | |
87 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
88 | + return $this->redirect(['view', 'id' => $model->user_info_id]); | |
89 | + } else { | |
90 | + return $this->render('update', [ | |
91 | + 'model' => $model, | |
92 | + ]); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + /** | |
97 | + * Deletes an existing UserInfo model. | |
98 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
99 | + * @param integer $id | |
100 | + * @return mixed | |
101 | + */ | |
102 | + public function actionDelete($id) | |
103 | + { | |
104 | + $this->findModel($id)->delete(); | |
105 | + | |
106 | + return $this->redirect(['index']); | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * Finds the UserInfo model based on its primary key value. | |
111 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
112 | + * @param integer $id | |
113 | + * @return UserInfo the loaded model | |
114 | + * @throws NotFoundHttpException if the model cannot be found | |
115 | + */ | |
116 | + protected function findModel($id) | |
117 | + { | |
118 | + if (($model = UserInfo::findOne($id)) !== null) { | |
119 | + return $model; | |
120 | + } else { | |
121 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
122 | + } | |
123 | + } | |
124 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace backend\controllers; | |
4 | + | |
5 | +use Yii; | |
6 | +use common\models\User; | |
7 | +use frontend\models\UserSearch; | |
8 | +use yii\web\Controller; | |
9 | +use yii\web\NotFoundHttpException; | |
10 | +use yii\filters\VerbFilter; | |
11 | + | |
12 | +/** | |
13 | + * UserTestController implements the CRUD actions for User model. | |
14 | + */ | |
15 | +class UserTestController extends Controller | |
16 | +{ | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public function behaviors() | |
21 | + { | |
22 | + return [ | |
23 | + 'verbs' => [ | |
24 | + 'class' => VerbFilter::className(), | |
25 | + 'actions' => [ | |
26 | + 'delete' => ['POST'], | |
27 | + ], | |
28 | + ], | |
29 | + ]; | |
30 | + } | |
31 | + | |
32 | + /** | |
33 | + * Lists all User models. | |
34 | + * @return mixed | |
35 | + */ | |
36 | + public function actionIndex() | |
37 | + { | |
38 | + $searchModel = new UserSearch(); | |
39 | + $dataProvider = $searchModel->search(Yii::$app->request->queryParams); | |
40 | + | |
41 | + return $this->render('index', [ | |
42 | + 'searchModel' => $searchModel, | |
43 | + 'dataProvider' => $dataProvider, | |
44 | + ]); | |
45 | + } | |
46 | + | |
47 | + /** | |
48 | + * Displays a single User model. | |
49 | + * @param integer $id | |
50 | + * @return mixed | |
51 | + */ | |
52 | + public function actionView($id) | |
53 | + { | |
54 | + return $this->render('view', [ | |
55 | + 'model' => $this->findModel($id), | |
56 | + ]); | |
57 | + } | |
58 | + | |
59 | + /** | |
60 | + * Creates a new User model. | |
61 | + * If creation is successful, the browser will be redirected to the 'view' page. | |
62 | + * @return mixed | |
63 | + */ | |
64 | + public function actionCreate() | |
65 | + { | |
66 | + $model = new User(); | |
67 | + | |
68 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
69 | + return $this->redirect(['view', 'id' => $model->id]); | |
70 | + } else { | |
71 | + return $this->render('create', [ | |
72 | + 'model' => $model, | |
73 | + ]); | |
74 | + } | |
75 | + } | |
76 | + | |
77 | + /** | |
78 | + * Updates an existing User model. | |
79 | + * If update is successful, the browser will be redirected to the 'view' page. | |
80 | + * @param integer $id | |
81 | + * @return mixed | |
82 | + */ | |
83 | + public function actionUpdate($id) | |
84 | + { | |
85 | + $model = $this->findModel($id); | |
86 | + | |
87 | + if ($model->load(Yii::$app->request->post()) && $model->save()) { | |
88 | + return $this->redirect(['view', 'id' => $model->id]); | |
89 | + } else { | |
90 | + return $this->render('update', [ | |
91 | + 'model' => $model, | |
92 | + ]); | |
93 | + } | |
94 | + } | |
95 | + | |
96 | + /** | |
97 | + * Deletes an existing User model. | |
98 | + * If deletion is successful, the browser will be redirected to the 'index' page. | |
99 | + * @param integer $id | |
100 | + * @return mixed | |
101 | + */ | |
102 | + public function actionDelete($id) | |
103 | + { | |
104 | + $this->findModel($id)->delete(); | |
105 | + | |
106 | + return $this->redirect(['index']); | |
107 | + } | |
108 | + | |
109 | + /** | |
110 | + * Finds the User model based on its primary key value. | |
111 | + * If the model is not found, a 404 HTTP exception will be thrown. | |
112 | + * @param integer $id | |
113 | + * @return User the loaded model | |
114 | + * @throws NotFoundHttpException if the model cannot be found | |
115 | + */ | |
116 | + protected function findModel($id) | |
117 | + { | |
118 | + if (($model = User::findOne($id)) !== null) { | |
119 | + return $model; | |
120 | + } else { | |
121 | + throw new NotFoundHttpException('The requested page does not exist.'); | |
122 | + } | |
123 | + } | |
124 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | +use yii\helpers\ArrayHelper; | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\Specialization */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="specialization-form"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin(); ?> | |
14 | + | |
15 | + <?= $form->field($model, 'specialization_pid')->dropDownList(ArrayHelper::map($model->find()->all(), 'specialization_id', 'specialization_name'), ['prompt' => 'ะัะฑะตัะธะต ัะพะดะธัะตะปั']) ?> | |
16 | + <?= $form->field($model, 'specialization_name')->textInput(['maxlength' => true]) ?> | |
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 | + ]); ?> | |
26 | + <div class="form-group"> | |
27 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
28 | + </div> | |
29 | + | |
30 | + <?php ActiveForm::end(); ?> | |
31 | + | |
32 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\SpecializationSearch */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="specialization-search"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin([ | |
14 | + 'action' => ['index'], | |
15 | + 'method' => 'get', | |
16 | + ]); ?> | |
17 | + | |
18 | + <?= $form->field($model, 'specialization_id') ?> | |
19 | + | |
20 | + <?= $form->field($model, 'specialization_pid') ?> | |
21 | + | |
22 | + <?= $form->field($model, 'specialization_name') ?> | |
23 | + | |
24 | + <div class="form-group"> | |
25 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | |
26 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | |
27 | + </div> | |
28 | + | |
29 | + <?php ActiveForm::end(); ?> | |
30 | + | |
31 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\Specialization */ | |
8 | + | |
9 | +$this->title = 'Create Specialization'; | |
10 | +$this->params['breadcrumbs'][] = ['label' => 'Specializations', 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="specialization-create"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <?= $this->render('_form', [ | |
18 | + 'model' => $model, | |
19 | + ]) ?> | |
20 | + | |
21 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\grid\GridView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $searchModel common\models\SpecializationSearch */ | |
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | + | |
10 | +$this->title = 'Specializations'; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="specialization-index"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
17 | + | |
18 | + <p> | |
19 | + <?= Html::a('Create Specialization', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | + </p> | |
21 | + <?= GridView::widget([ | |
22 | + 'dataProvider' => $dataProvider, | |
23 | + 'filterModel' => $searchModel, | |
24 | + 'columns' => [ | |
25 | + ['class' => 'yii\grid\SerialColumn'], | |
26 | + | |
27 | + 'specialization_id', | |
28 | + [ | |
29 | + 'attribute' => 'specialization_parent_name', | |
30 | + 'value' => 'parent.specialization_name' | |
31 | + ], | |
32 | + 'specialization_name', | |
33 | + | |
34 | + ['class' => 'yii\grid\ActionColumn'], | |
35 | + ], | |
36 | + ]); ?> | |
37 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | +/* @var $this yii\web\View */ | |
6 | +/* @var $model common\models\Specialization */ | |
7 | + | |
8 | +$this->title = 'Update Specialization: ' . ' ' . $model->specialization_id; | |
9 | +$this->params['breadcrumbs'][] = ['label' => 'Specializations', 'url' => ['index']]; | |
10 | +$this->params['breadcrumbs'][] = ['label' => $model->specialization_id, 'url' => ['view', 'id' => $model->specialization_id]]; | |
11 | +$this->params['breadcrumbs'][] = 'Update'; | |
12 | +?> | |
13 | +<div class="specialization-update"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <?= $this->render('_form', [ | |
18 | + 'model' => $model, | |
19 | + ]) ?> | |
20 | + | |
21 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\DetailView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\Specialization */ | |
8 | + | |
9 | +$this->title = $model->specialization_id; | |
10 | +$this->params['breadcrumbs'][] = ['label' => 'Specializations', 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="specialization-view"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <p> | |
18 | + <?= Html::a('Update', ['update', 'id' => $model->specialization_id], ['class' => 'btn btn-primary']) ?> | |
19 | + <?= Html::a('Delete', ['delete', 'id' => $model->specialization_id], [ | |
20 | + 'class' => 'btn btn-danger', | |
21 | + 'data' => [ | |
22 | + 'confirm' => 'Are you sure you want to delete this item?', | |
23 | + 'method' => 'post', | |
24 | + ], | |
25 | + ]) ?> | |
26 | + </p> | |
27 | + | |
28 | + <?= DetailView::widget([ | |
29 | + 'model' => $model, | |
30 | + 'attributes' => [ | |
31 | + 'specialization_id', | |
32 | + 'specialization_pid', | |
33 | + 'specialization_name', | |
34 | + ], | |
35 | + ]) ?> | |
36 | + | |
37 | +</div> | ... | ... |
common/config/main-local.php
... | ... | @@ -3,9 +3,9 @@ return [ |
3 | 3 | 'components' => [ |
4 | 4 | 'db' => [ |
5 | 5 | 'class' => 'yii\db\Connection', |
6 | - 'dsn' => 'pgsql:host=127.0.0.1;port=5432;dbname=mfp_local', | |
7 | - 'username' => 'postgres', | |
8 | - 'password' => '', | |
6 | + 'dsn' => 'pgsql:host=195.248.225.149;port=5432;dbname=mfp', | |
7 | + 'username' => 'test33', | |
8 | + 'password' => 'E4q2N7i9', | |
9 | 9 | 'schemaMap' => [ |
10 | 10 | 'pgsql'=> [ |
11 | 11 | 'class'=>'yii\db\pgsql\Schema', | ... | ... |
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', |
... | ... | @@ -49,8 +72,8 @@ return [ |
49 | 72 | ] |
50 | 73 | ], |
51 | 74 | ], |
52 | - 'authManager' => [ | |
53 | - 'class' => 'yii\rbac\DbManager', | |
75 | + 'authManager' => [ | |
76 | + 'class' => 'yii\rbac\DbManager', | |
54 | 77 | ], |
55 | 78 | |
56 | 79 | //ะฟะพะดะบะปััะฐะตะผ ะบะพะฝัะธะณััะฐัะธะธ API ัะพั ัะตัะตะน ะดะปั ะฐะฒัะพัะธะทะฐัะธะธ |
... | ... | @@ -151,7 +174,7 @@ return [ |
151 | 174 | 'clientSecret' => '...', |
152 | 175 | 'clientPublic' => '...', |
153 | 176 | 'title' => 'Odnoklas.', |
154 | - ], | |
177 | + ], | |
155 | 178 | ], |
156 | 179 | ], |
157 | 180 | ... | ... |
1 | +<?php | |
2 | +namespace common\models; | |
3 | + | |
4 | +use yii\base\Model; | |
5 | +use yii\web\UploadedFile; | |
6 | + | |
7 | +/** | |
8 | + * UploadForm is the model behind the upload form. | |
9 | + */ | |
10 | +class ImageSizerForm extends Model | |
11 | +{ | |
12 | + /** | |
13 | + * @var UploadedFile file attribute | |
14 | + */ | |
15 | + public $file; | |
16 | + public $width; | |
17 | + public $height; | |
18 | + public $field; | |
19 | + public $model; | |
20 | + public $form; | |
21 | + public $multi; | |
22 | + public $old_img; | |
23 | + public $img; | |
24 | + public $price_list; | |
25 | + | |
26 | + /** | |
27 | + * @return array the validation rules. | |
28 | + */ | |
29 | + public function rules() | |
30 | + { | |
31 | + return [ | |
32 | + [['width', 'height'], 'integer'], | |
33 | + [['field', 'multi','old_img'], 'string', 'max' => 255], | |
34 | + [['model', 'form',], 'string'], | |
35 | + [['file','img','price_list'], 'file'], | |
36 | + ]; | |
37 | + } | |
38 | +} | |
0 | 39 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | + | |
7 | +/** | |
8 | + * This is the model class for table "specialization". | |
9 | + * | |
10 | + * @property integer $specialization_id | |
11 | + * @property integer $specialization_pid | |
12 | + * @property string $specialization_name | |
13 | + */ | |
14 | +class Specialization extends \yii\db\ActiveRecord | |
15 | +{ | |
16 | + public $img; | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public static function tableName() | |
21 | + { | |
22 | + return 'specialization'; | |
23 | + } | |
24 | + | |
25 | + /** | |
26 | + * @inheritdoc | |
27 | + */ | |
28 | + public function rules() | |
29 | + { | |
30 | + return [ | |
31 | + [['specialization_pid'], 'integer'], | |
32 | + [['specialization_pid'], 'default', 'value' => '0',], | |
33 | + [['specialization_name'], 'required'], | |
34 | + [['specialization_name'], 'string', 'max' => 255], | |
35 | + ]; | |
36 | + } | |
37 | + | |
38 | + /** | |
39 | + * @inheritdoc | |
40 | + */ | |
41 | + public function attributeLabels() | |
42 | + { | |
43 | + return [ | |
44 | + 'specialization_id' => 'Specialization ID', | |
45 | + 'specialization_pid' => 'Specialization Pid', | |
46 | + 'specialization_name' => 'Specialization Name', | |
47 | + 'specialization_parent_name' => 'Specialization Parent Name', | |
48 | + ]; | |
49 | + } | |
50 | + | |
51 | + | |
52 | + public function getParent() | |
53 | + { | |
54 | + return $this->hasOne(self::className(), ['specialization_id' => 'specialization_pid']); | |
55 | + } | |
56 | + | |
57 | +} | ... | ... |
1 | +<?php | |
2 | + | |
3 | +namespace common\models; | |
4 | + | |
5 | +use Yii; | |
6 | +use yii\base\Model; | |
7 | +use yii\data\ActiveDataProvider; | |
8 | +use common\models\Specialization; | |
9 | + | |
10 | +/** | |
11 | + * SpecializationSearch represents the model behind the search form about `\common\models\Specialization`. | |
12 | + */ | |
13 | +class SpecializationSearch extends Specialization | |
14 | +{ | |
15 | + | |
16 | + public $specialization_parent_name; | |
17 | + /** | |
18 | + * @inheritdoc | |
19 | + */ | |
20 | + public function rules() | |
21 | + { | |
22 | + return [ | |
23 | + [['specialization_id'], 'integer'], | |
24 | + [['specialization_pid','specialization_parent_name'], 'string'], | |
25 | + [['specialization_name'], 'safe'], | |
26 | + ]; | |
27 | + } | |
28 | + | |
29 | + /** | |
30 | + * @inheritdoc | |
31 | + */ | |
32 | + public function scenarios() | |
33 | + { | |
34 | + // bypass scenarios() implementation in the parent class | |
35 | + return Model::scenarios(); | |
36 | + } | |
37 | + | |
38 | + /** | |
39 | + * Creates data provider instance with search query applied | |
40 | + * | |
41 | + * @param array $params | |
42 | + * | |
43 | + * @return ActiveDataProvider | |
44 | + */ | |
45 | + public function search($params) | |
46 | + { | |
47 | + $query = Specialization::find(); | |
48 | + | |
49 | + // add conditions that should always apply here | |
50 | + | |
51 | + $dataProvider = new ActiveDataProvider([ | |
52 | + 'query' => $query, | |
53 | + ]); | |
54 | + | |
55 | + $this->load($params); | |
56 | + | |
57 | + if (!$this->validate()) { | |
58 | + // uncomment the following line if you do not want to return any records when validation fails | |
59 | + // $query->where('0=1'); | |
60 | + return $dataProvider; | |
61 | + } | |
62 | + | |
63 | + | |
64 | + | |
65 | + // grid filtering conditions | |
66 | + $query->andFilterWhere([ | |
67 | + 'specialization_id' => $this->specialization_id, | |
68 | + 'specialization_pid' => !empty($this->specialization_parent_name) ? array_keys(Specialization::find()->select('specialization_id')->FilterWhere(['like', 'specialization_name',$this->specialization_parent_name])->asArray()->indexBy('specialization_id')->all()) : $this->specialization_parent_name | |
69 | + ]); | |
70 | + | |
71 | + $query->andFilterWhere(['like', 'specialization_name', $this->specialization_name]); | |
72 | + | |
73 | + return $dataProvider; | |
74 | + } | |
75 | +} | ... | ... |
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 | ... | ... |
1 | +<?php | |
2 | +namespace common\widgets; | |
3 | + | |
4 | +use yii\web\UploadedFile; | |
5 | +use common\models\ImageSizerForm; | |
6 | +use yii\base\Widget; | |
7 | +use Imagine\Image\Box; | |
8 | +use yii\imagine\Image; | |
9 | +use Yii; | |
10 | +use Imagine\Gd\Imagine; | |
11 | + | |
12 | +class ImageResizer extends Widget | |
13 | +{ | |
14 | + | |
15 | + public $height; | |
16 | + public $width; | |
17 | + | |
18 | + public function init(){ | |
19 | + | |
20 | + parent::init(); | |
21 | + | |
22 | + } | |
23 | + | |
24 | + public function run(){ | |
25 | + | |
26 | + $model = new ImageSizerForm(); | |
27 | + | |
28 | + $request = Yii::$app->request->post(); | |
29 | + | |
30 | + if ($request) { | |
31 | + | |
32 | + if(isset($request['old_img'])){ | |
33 | + $this->deleteImages($request['old_img']); | |
34 | + } | |
35 | + | |
36 | + | |
37 | + $model->file = UploadedFile::getInstance($model, 'file'); | |
38 | + | |
39 | + if(!$model->file){ | |
40 | + return json_encode(["error"=>"ะะต ัะบะฐะทะฐะฝ ัะฐะนะป"]); | |
41 | + } | |
42 | + | |
43 | + $md5_file = md5_file($model->file->tempName); | |
44 | + | |
45 | + $imgDir = Yii::getAlias('@storage/'.$md5_file.'/'); | |
46 | + | |
47 | + $imageOrigAlias = Yii::getAlias($imgDir.'original'.'.'.$model->file->extension); | |
48 | + | |
49 | + if(!is_dir($imgDir)) { | |
50 | + mkdir($imgDir, 0755, true); | |
51 | + } | |
52 | + | |
53 | + $model->file->saveAs($imageOrigAlias); | |
54 | + | |
55 | + if($request['width'] && $request['height']){ | |
56 | + | |
57 | + $imageAlias = Yii::getAlias($imgDir.$request['width'].'x'.$request['height'].'.'.$model->file->extension); | |
58 | + | |
59 | + $imageLink = '/storage/'.$md5_file.'/'.$request['width'].'x'.$request['height'].'.'.$model->file->extension; | |
60 | + | |
61 | + $this->resizeImg($request['width'],$request['height'], $imageOrigAlias,$imageAlias); | |
62 | + | |
63 | + } else { | |
64 | + | |
65 | + $imageLink = '/storage/'.$md5_file.'/'.'original'.'.'.$model->file->extension; | |
66 | + | |
67 | + } | |
68 | + | |
69 | + | |
70 | + if($model->multi){ | |
71 | +// $view = $this->renderPartial('@app/components/views/_gallery_item', [ | |
72 | +// 'item' => ['image'=>$imageLink], | |
73 | +// ]); | |
74 | +// | |
75 | +// return json_encode(['link'=>$imageLink, 'view' =>$view]); | |
76 | + | |
77 | + | |
78 | + } else { | |
79 | + $p1[0] = "<img style='height:160px' src='$imageLink' class='file-preview-image'>"; | |
80 | + return json_encode(['success','initialPreview' => $p1, 'append' => false, 'name' =>$imageLink,]); | |
81 | + } | |
82 | + | |
83 | + | |
84 | + } else { | |
85 | + return json_encode(['error']); | |
86 | + } | |
87 | + | |
88 | + | |
89 | + | |
90 | + | |
91 | + } | |
92 | + | |
93 | + | |
94 | + public function isBigger($width,$height,$w,$h) | |
95 | + { | |
96 | + if($width>$w){ | |
97 | + return true; | |
98 | + }else if($height >$h) { | |
99 | + return true; | |
100 | + } | |
101 | + return false; | |
102 | + } | |
103 | + | |
104 | + | |
105 | + | |
106 | + | |
107 | + | |
108 | + public function resizeImg($w, $h, $imageAlias,$imageAliasSave) | |
109 | + { | |
110 | + $img = Image::getImagine()->open(Yii::getAlias($imageAlias)); | |
111 | + | |
112 | + $size = $img->getSize(); | |
113 | + | |
114 | + $width = $size->getWidth(); | |
115 | + $height = $size->getHeight(); | |
116 | + | |
117 | + $e_width = $w/$h; | |
118 | + $e_height = $h/$w; | |
119 | + | |
120 | + $e1_width = $width/$height; | |
121 | + $e1_height = $height/$width; | |
122 | + | |
123 | + if($this->isBigger($width,$height,$w,$h)){ | |
124 | + if($e_width<$e1_width){ | |
125 | + $new_width = $width*($e_width/$e1_width); | |
126 | + $width = $new_width; | |
127 | + }else { | |
128 | + $new_height = $height*($e_height/$e1_height); | |
129 | + $height = $new_height; | |
130 | + } | |
131 | + | |
132 | + | |
133 | + } else { | |
134 | + $img->save($imageAliasSave, array('flatten' => false)); | |
135 | + return true; | |
136 | + } | |
137 | + | |
138 | + | |
139 | + Image::crop($imageAlias, $width, $height,[0,0]) | |
140 | + ->save(Yii::getAlias($imageAliasSave), ['quality' => | |
141 | + 100]); | |
142 | + | |
143 | + | |
144 | + $imagine = new Imagine(); | |
145 | + $imagine->open($imageAliasSave) | |
146 | + ->resize(new Box($w, $h)) | |
147 | + ->save($imageAliasSave, array('flatten' => false)); | |
148 | + | |
149 | + | |
150 | + | |
151 | + } | |
152 | + | |
153 | + | |
154 | + private function deleteImages($old_img){ | |
155 | + | |
156 | + if(!empty($old_img) && file_exists($_SERVER['DOCUMENT_ROOT'].$old_img)){ | |
157 | + | |
158 | + $rootDir = explode("/", $old_img); | |
159 | + | |
160 | + $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/'; | |
161 | + | |
162 | + $allFiles = scandir($row); | |
163 | + | |
164 | + $allFiles = array_slice($allFiles, 2); | |
165 | + | |
166 | + foreach($allFiles as $oldFile){ | |
167 | + | |
168 | + unlink($row.$oldFile); | |
169 | + | |
170 | + } | |
171 | + | |
172 | + } | |
173 | + } | |
174 | + | |
175 | + public function actionDeleteImage(){ | |
176 | + $old_img = Yii::$app->request->post('old_img'); | |
177 | + | |
178 | + if ($old_img) { | |
179 | + $this->deleteImages($old_img); | |
180 | + } | |
181 | + } | |
182 | + | |
183 | + | |
184 | + | |
185 | +} | |
0 | 186 | \ No newline at end of file | ... | ... |
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 | ... | ... |
1 | +<?php | |
2 | +use yii\helpers\Html; | |
3 | + | |
4 | +?> | |
5 | +<div class="gallery_image"> | |
6 | + <?= Html::img($item['image'])?> | |
7 | + <span data-url="<?=$item['image']?>" title="ัะดะฐะปะธัั ะธะทะพะฑัะฐะถะตะฝะธะต" class="glyphicon glyphicon-trash delete-gallery-item"></span> | |
8 | +</div> | |
0 | 9 | \ No newline at end of file | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * Created by PhpStorm. | |
4 | + * User: vitaliy | |
5 | + * Date: 05.10.15 | |
6 | + * Time: 16:20 | |
7 | + */ | |
8 | +use yii\helpers\Html; | |
9 | + | |
10 | +$id = $model::tableName().'_id'; | |
11 | + | |
12 | +?> | |
13 | +<div class="file-uploader-block"> | |
14 | + <?php if(!$multi):?> | |
15 | + <span class="btn btn-success fileinput-button uploader-button"> | |
16 | + <i class="glyphicon glyphicon-plus"></i> | |
17 | + <span><?=$name?></span> | |
18 | + | |
19 | + <?= Html::activeFileInput( new \common\models\ImageSizerForm(),'file',['id'=>$field, 'data-url'=>"/file/download-photo" ]);?> | |
20 | + </span> | |
21 | + | |
22 | + <?= Html::activeHiddenInput( $model,$field,['id' => "{$field}_picture_link"]) ?> | |
23 | + <input type="hidden" id="<?=$field?>_old_img" name="ImageSizerForm[old_img]" value="<?=$model->$field?>"/> | |
24 | + <input type="hidden" id="<?=$field?>_new_img" name="ImageSizerForm[new_img]" value=""/> | |
25 | + <input type="hidden" id="<?=$field?>_row_id" name="ImageSizerForm[new_img]" value="<?=$model->$id?>"/> | |
26 | + <div id="<?= $field?>_img_block"> | |
27 | + <?= $model->$field ? Html::img($model->$field): '' ?> | |
28 | + </div> | |
29 | + | |
30 | + <script> | |
31 | + $(function(){ | |
32 | + | |
33 | + $("#<?= $field?>").fileupload({ | |
34 | + dataType: 'json', | |
35 | + formData: {width: <?=$width?>,height:<?=$height?>}, | |
36 | + done: function (e, data) { | |
37 | + if($("#<?=$field?>_buttons_block").length){ | |
38 | + $("#<?=$field?>_buttons_block").remove() | |
39 | + } | |
40 | + var host = window.location.host.toString(); | |
41 | + var img = '<img src="http://'+host+data.result.link+'">'+ | |
42 | + '<div id="<?=$field?>_buttons_block">'+ | |
43 | + '<button type="button" id="<?=$field?>_save_img" class="btn btn-success img-action-buttons" >ะกะพั ัะฐะฝะธัั</button>'+ | |
44 | + '<button type="button" id="<?=$field?>_remove_img" class="btn btn-danger img-action-buttons" >ะัะผะตะฝะฐ</button>'+ | |
45 | + '</div>'; | |
46 | + var block = $("#<?= $field?>_img_block"); | |
47 | + block.find('img').remove(); | |
48 | + block.append(img); | |
49 | + $("#<?=$field?>_picture_link").val(data.result.link); | |
50 | + $("#<?=$field?>_new_img").val(data.result.link); | |
51 | + } | |
52 | + }); | |
53 | + | |
54 | + | |
55 | + $('body').on('click', '#<?=$field?>_save_img',function(){ | |
56 | + $("#<?=$field?>_buttons_block").remove(); | |
57 | + var old_url = $('#<?=$field?>_old_img').val(); | |
58 | + var new_url = $('#<?=$field?>_new_img').val(); | |
59 | + var model = '<?=str_replace('\\', '-',$model::className());?>'; | |
60 | + $.post( "/admin/site/delete-image",{new_url:new_url,old_img: old_url,model:model,field:"<?= $field?>", id:"<?=$model->$id?>",action:'save'}, function() { | |
61 | + }); | |
62 | + $("#<?=$field?>_picture_link").val(new_url); | |
63 | + }); | |
64 | + | |
65 | + $('body').on('click', '#<?=$field?>_remove_img',function(){ | |
66 | + $("#<?=$field?>_buttons_block").remove(); | |
67 | + $("#<?=$field?>_buttons_block").remove(); | |
68 | + var old_url = $('#<?=$field?>_old_img').val(); | |
69 | + var new_url = $('#<?=$field?>_new_img').val(); | |
70 | + $.post( "/admin/site/delete-image",{old_img: new_url}, function() { | |
71 | + }); | |
72 | + $("#<?=$field?>_picture_link").val(old_url); | |
73 | + $('#<?= $field?>_img_block').find('img').attr('src',old_url); | |
74 | + }); | |
75 | + | |
76 | + | |
77 | + }) | |
78 | +</script> | |
79 | + | |
80 | +<?php else:?> | |
81 | + | |
82 | + <span class="btn btn-success fileinput-button uploader-button"> | |
83 | + <i class="glyphicon glyphicon-plus"></i> | |
84 | + <span><?=$name?></span> | |
85 | + | |
86 | + <?= Html::activeFileInput( new \common\models\ImageSizerForm(),'file',['id'=>$field, 'data-url'=>"/file/download-photo", 'multiple'=> 'multiple' ]);?> | |
87 | + </span> | |
88 | + | |
89 | + <?= Html::activeHiddenInput( $model,$field,['id' => "{$field}_picture_link"]) ?> | |
90 | + | |
91 | + | |
92 | + <input type="hidden" name="ImageSizerForm[multi]" value="<?=$multi?>"/> | |
93 | + | |
94 | + <div id="<?= $field?>_img_block"> | |
95 | + <?php | |
96 | + | |
97 | + foreach($this->context->getGallery() as $image){ | |
98 | + echo $this->render('_gallery_item', [ 'item' => ['image'=>$image]]); | |
99 | + } | |
100 | + ?> | |
101 | + </div> | |
102 | + <script> | |
103 | + $(function(){ | |
104 | + | |
105 | + $("#<?= $field?>").fileupload({ | |
106 | + dataType: 'json', | |
107 | + formData: {width: <?=$width?>,height:<?=$height?>}, | |
108 | + done: function (e, data) { | |
109 | + | |
110 | + var img = data.result.view; | |
111 | + var block = $("#<?= $field?>_img_block"); | |
112 | + block.append(img); | |
113 | + var gallery = $("#<?= $field?>_picture_link"); | |
114 | + gallery.val(gallery.val()+data.result.link+','); | |
115 | + } | |
116 | + }); | |
117 | + $('body').on('click','.delete-gallery-item', function(){ | |
118 | + var url = $(this).data('url'); | |
119 | + $(this).parent('.gallery_image').remove(); | |
120 | + var gallery = $("#<?= $field?>_picture_link"); | |
121 | + var urls = gallery.val(); | |
122 | + gallery.val(urls.replace(url+',', "")); | |
123 | + $.post( "/admin/site/delete-image",{old_img: url}, function( data ) { | |
124 | + $( ".result" ).html( data ); | |
125 | + }); | |
126 | + }) | |
127 | + | |
128 | + }) | |
129 | + </script> | |
130 | + | |
131 | +<?php endif;?> | |
132 | +</div> | |
0 | 133 | \ No newline at end of file | ... | ... |
composer.json
... | ... | @@ -23,7 +23,9 @@ |
23 | 23 | "kartik-v/yii2-widget-select2": "@dev", |
24 | 24 | "mihaildev/yii2-ckeditor": "*", |
25 | 25 | "developeruz/yii2-db-rbac": "*", |
26 | - "nodge/yii2-eauth": "*" | |
26 | + "nodge/yii2-eauth": "*", | |
27 | + "yiisoft/yii2-imagine": "^2.0", | |
28 | + "mihaildev/yii2-elfinder": "^1.1" | |
27 | 29 | }, |
28 | 30 | "require-dev": { |
29 | 31 | "yiisoft/yii2-codeception": "*", | ... | ... |
composer.lock
... | ... | @@ -4,8 +4,8 @@ |
4 | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
5 | 5 | "This file is @generated automatically" |
6 | 6 | ], |
7 | - "hash": "e9b955ba46cc8543c15ffcde1924e173", | |
8 | - "content-hash": "269319a9b7db2499c82b3ac2409e9b8d", | |
7 | + "hash": "d07e2c10b604fb6b814d10b2de6dcd2f", | |
8 | + "content-hash": "2d0acd792b2e28f03338a962c2923bbe", | |
9 | 9 | "packages": [ |
10 | 10 | { |
11 | 11 | "name": "almasaeed2010/adminlte", |
... | ... | @@ -557,6 +557,63 @@ |
557 | 557 | "time": "2013-11-30 08:25:19" |
558 | 558 | }, |
559 | 559 | { |
560 | + "name": "imagine/imagine", | |
561 | + "version": "0.5.x-dev", | |
562 | + "source": { | |
563 | + "type": "git", | |
564 | + "url": "https://github.com/avalanche123/Imagine.git", | |
565 | + "reference": "343580fceed1f89220481ac98480e92f47d91e6c" | |
566 | + }, | |
567 | + "dist": { | |
568 | + "type": "zip", | |
569 | + "url": "https://api.github.com/repos/avalanche123/Imagine/zipball/343580fceed1f89220481ac98480e92f47d91e6c", | |
570 | + "reference": "343580fceed1f89220481ac98480e92f47d91e6c", | |
571 | + "shasum": "" | |
572 | + }, | |
573 | + "require": { | |
574 | + "php": ">=5.3.2" | |
575 | + }, | |
576 | + "require-dev": { | |
577 | + "sami/sami": "dev-master" | |
578 | + }, | |
579 | + "suggest": { | |
580 | + "ext-gd": "to use the GD implementation", | |
581 | + "ext-gmagick": "to use the Gmagick implementation", | |
582 | + "ext-imagick": "to use the Imagick implementation" | |
583 | + }, | |
584 | + "type": "library", | |
585 | + "extra": { | |
586 | + "branch-alias": { | |
587 | + "dev-develop": "0.5-dev" | |
588 | + } | |
589 | + }, | |
590 | + "autoload": { | |
591 | + "psr-0": { | |
592 | + "Imagine": "lib/" | |
593 | + } | |
594 | + }, | |
595 | + "notification-url": "https://packagist.org/downloads/", | |
596 | + "license": [ | |
597 | + "MIT" | |
598 | + ], | |
599 | + "authors": [ | |
600 | + { | |
601 | + "name": "Bulat Shakirzyanov", | |
602 | + "email": "mallluhuct@gmail.com", | |
603 | + "homepage": "http://avalanche123.com" | |
604 | + } | |
605 | + ], | |
606 | + "description": "Image processing for PHP 5.3", | |
607 | + "homepage": "http://imagine.readthedocs.org/", | |
608 | + "keywords": [ | |
609 | + "drawing", | |
610 | + "graphics", | |
611 | + "image manipulation", | |
612 | + "image processing" | |
613 | + ], | |
614 | + "time": "2014-06-13 10:54:04" | |
615 | + }, | |
616 | + { | |
560 | 617 | "name": "kartik-v/yii2-krajee-base", |
561 | 618 | "version": "v1.7.9", |
562 | 619 | "source": { |
... | ... | @@ -612,7 +669,7 @@ |
612 | 669 | }, |
613 | 670 | "dist": { |
614 | 671 | "type": "zip", |
615 | - "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/701bf8069a85fafbac1ced54dcd00e579e60471b", | |
672 | + "url": "https://api.github.com/repos/kartik-v/yii2-widget-select2/zipball/519241c7360a0470624f24d872741e1ea880de75", | |
616 | 673 | "reference": "701bf8069a85fafbac1ced54dcd00e579e60471b", |
617 | 674 | "shasum": "" |
618 | 675 | }, |
... | ... | @@ -764,6 +821,56 @@ |
764 | 821 | "time": "2014-11-19 22:04:08" |
765 | 822 | }, |
766 | 823 | { |
824 | + "name": "mihaildev/yii2-elfinder", | |
825 | + "version": "1.1.3", | |
826 | + "source": { | |
827 | + "type": "git", | |
828 | + "url": "https://github.com/MihailDev/yii2-elfinder.git", | |
829 | + "reference": "64b42572dec94e5c2d0d1630bce8292848a98f4b" | |
830 | + }, | |
831 | + "dist": { | |
832 | + "type": "zip", | |
833 | + "url": "https://api.github.com/repos/MihailDev/yii2-elfinder/zipball/64b42572dec94e5c2d0d1630bce8292848a98f4b", | |
834 | + "reference": "64b42572dec94e5c2d0d1630bce8292848a98f4b", | |
835 | + "shasum": "" | |
836 | + }, | |
837 | + "require": { | |
838 | + "yiisoft/yii2-jui": "*" | |
839 | + }, | |
840 | + "type": "yii2-extension", | |
841 | + "extra": { | |
842 | + "asset-installer-paths": { | |
843 | + "npm-asset-library": "vendor/npm", | |
844 | + "bower-asset-library": "vendor/bower" | |
845 | + } | |
846 | + }, | |
847 | + "autoload": { | |
848 | + "psr-4": { | |
849 | + "mihaildev\\elfinder\\": "" | |
850 | + } | |
851 | + }, | |
852 | + "notification-url": "https://packagist.org/downloads/", | |
853 | + "license": [ | |
854 | + "BSD-3-Clause" | |
855 | + ], | |
856 | + "authors": [ | |
857 | + { | |
858 | + "name": "Mihail", | |
859 | + "email": "mihail.kucher@gmail.com", | |
860 | + "homepage": "https://github.com/MihailDev", | |
861 | + "role": "Developer" | |
862 | + } | |
863 | + ], | |
864 | + "description": "Yii2 ElFinder", | |
865 | + "homepage": "https://github.com/MihailDev/yii2-elfinder", | |
866 | + "keywords": [ | |
867 | + "elfinder", | |
868 | + "filemanager", | |
869 | + "yii" | |
870 | + ], | |
871 | + "time": "2015-07-03 07:08:52" | |
872 | + }, | |
873 | + { | |
767 | 874 | "name": "nodge/lightopenid", |
768 | 875 | "version": "1.1.2", |
769 | 876 | "source": { |
... | ... | @@ -977,7 +1084,7 @@ |
977 | 1084 | }, |
978 | 1085 | "dist": { |
979 | 1086 | "type": "zip", |
980 | - "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/e4359f68b70caede1e09ecefb56e9435f7d140af", | |
1087 | + "url": "https://api.github.com/repos/yiisoft/yii2-framework/zipball/7ccbfdf4cfb0ce025e27455dc3e516af23eb2800", | |
981 | 1088 | "reference": "e4359f68b70caede1e09ecefb56e9435f7d140af", |
982 | 1089 | "shasum": "" |
983 | 1090 | }, |
... | ... | @@ -1159,6 +1266,54 @@ |
1159 | 1266 | "time": "2015-12-01 20:06:03" |
1160 | 1267 | }, |
1161 | 1268 | { |
1269 | + "name": "yiisoft/yii2-imagine", | |
1270 | + "version": "dev-master", | |
1271 | + "source": { | |
1272 | + "type": "git", | |
1273 | + "url": "https://github.com/yiisoft/yii2-imagine.git", | |
1274 | + "reference": "586c9c99cb541ec4d4d2ec2a206b08a6fd6de888" | |
1275 | + }, | |
1276 | + "dist": { | |
1277 | + "type": "zip", | |
1278 | + "url": "https://api.github.com/repos/yiisoft/yii2-imagine/zipball/586c9c99cb541ec4d4d2ec2a206b08a6fd6de888", | |
1279 | + "reference": "586c9c99cb541ec4d4d2ec2a206b08a6fd6de888", | |
1280 | + "shasum": "" | |
1281 | + }, | |
1282 | + "require": { | |
1283 | + "imagine/imagine": "0.5.*", | |
1284 | + "yiisoft/yii2": "*" | |
1285 | + }, | |
1286 | + "type": "yii2-extension", | |
1287 | + "extra": { | |
1288 | + "branch-alias": { | |
1289 | + "dev-master": "2.0.x-dev" | |
1290 | + } | |
1291 | + }, | |
1292 | + "autoload": { | |
1293 | + "psr-4": { | |
1294 | + "yii\\imagine\\": "" | |
1295 | + } | |
1296 | + }, | |
1297 | + "notification-url": "https://packagist.org/downloads/", | |
1298 | + "license": [ | |
1299 | + "BSD-3-Clause" | |
1300 | + ], | |
1301 | + "authors": [ | |
1302 | + { | |
1303 | + "name": "Antonio Ramirez", | |
1304 | + "email": "amigo.cobos@gmail.com" | |
1305 | + } | |
1306 | + ], | |
1307 | + "description": "The Imagine integration for the Yii framework", | |
1308 | + "keywords": [ | |
1309 | + "helper", | |
1310 | + "image", | |
1311 | + "imagine", | |
1312 | + "yii2" | |
1313 | + ], | |
1314 | + "time": "2015-09-29 10:49:20" | |
1315 | + }, | |
1316 | + { | |
1162 | 1317 | "name": "yiisoft/yii2-jui", |
1163 | 1318 | "version": "dev-master", |
1164 | 1319 | "source": { |
... | ... | @@ -1168,7 +1323,7 @@ |
1168 | 1323 | }, |
1169 | 1324 | "dist": { |
1170 | 1325 | "type": "zip", |
1171 | - "url": "https://api.github.com/repos/yiisoft/yii2-jui/zipball/7ab7ff56bd54500212523e38f5fe3b9210325041", | |
1326 | + "url": "https://api.github.com/repos/yiisoft/yii2-jui/zipball/1425ab29929dd195f468d3c4eb340ab509f28b83", | |
1172 | 1327 | "reference": "7ab7ff56bd54500212523e38f5fe3b9210325041", |
1173 | 1328 | "shasum": "" |
1174 | 1329 | }, |
... | ... | @@ -1297,7 +1452,7 @@ |
1297 | 1452 | }, |
1298 | 1453 | "dist": { |
1299 | 1454 | "type": "zip", |
1300 | - "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/de2ed3bbe68254efeff68db60092fc8ed5298055", | |
1455 | + "url": "https://api.github.com/repos/fzaninotto/Faker/zipball/e493d3dc48d15a6d44e213d02c729ad61cc758a9", | |
1301 | 1456 | "reference": "de2ed3bbe68254efeff68db60092fc8ed5298055", |
1302 | 1457 | "shasum": "" |
1303 | 1458 | }, | ... | ... |
console/migrations/m160125_151635_delete_lang_field.php
100644 โ 100755
console/migrations/m160128_101543_fields.php
100644 โ 100755
console/migrations/m160202_084703_specialization.php
0 โ 100755
1 | +<?php | |
2 | + | |
3 | +use yii\db\Migration; | |
4 | + | |
5 | +class m160202_084703_specialization extends Migration | |
6 | +{ | |
7 | + public function up() | |
8 | + { | |
9 | + $tableOptions = null; | |
10 | + | |
11 | + $this->createTable('{{%specialization}}', [ | |
12 | + 'specialization_id' => $this->primaryKey(), | |
13 | + 'specialization_pid' => $this->integer(), | |
14 | + 'specialization_name' => $this->string(255)->notNull() | |
15 | + ], $tableOptions); | |
16 | + | |
17 | + } | |
18 | + | |
19 | + public function down() | |
20 | + { | |
21 | + $this->dropTable('{{%specialization}}'); | |
22 | + } | |
23 | +} | ... | ... |
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
frontend/config/main.php
... | ... | @@ -18,7 +18,7 @@ return [ |
18 | 18 | 'modules' => [ |
19 | 19 | |
20 | 20 | ], |
21 | - 'components' => [ | |
21 | + 'components' => [ | |
22 | 22 | //'PageController'=>[ |
23 | 23 | // 'class' => 'frontend\controllers\PageController' |
24 | 24 | //], |
... | ... | @@ -44,7 +44,7 @@ return [ |
44 | 44 | 'urlManager' => [ |
45 | 45 | 'baseUrl' => '/', |
46 | 46 | 'enablePrettyUrl' => true, |
47 | - 'showScriptName' => false, | |
47 | + 'showScriptName' => false, | |
48 | 48 | 'rules' => [ |
49 | 49 | 'landing/<view:[\w-]+>' => 'landing/view', |
50 | 50 | ] | ... | ... |
1 | +<?php | |
2 | +/** | |
3 | + * Created by PhpStorm. | |
4 | + * User: Cibermag | |
5 | + * Date: 31.08.2015 | |
6 | + * Time: 9:58 | |
7 | + */ | |
8 | +namespace frontend\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 | + | |
30 | + private function resizeImg($w, $h, $imageAlias,$imageAliasSave){ | |
31 | + $img = Image::getImagine()->open(Yii::getAlias($imageAlias)); | |
32 | + | |
33 | + $size = $img->getSize(); | |
34 | + | |
35 | + $width = $size->getWidth(); | |
36 | + $height = $size->getHeight(); | |
37 | + | |
38 | + $e_width = $w/$h; | |
39 | + $e_height = $h/$w; | |
40 | + | |
41 | + $e1_width = $width/$height; | |
42 | + $e1_height = $height/$width; | |
43 | + | |
44 | + | |
45 | + if($this->isBigger($width,$height,$w,$h)){ | |
46 | + if($e_width<$e1_width){ | |
47 | + | |
48 | + $new_width = $width*($e_width/$e1_width); | |
49 | + | |
50 | + $y = 0; | |
51 | + $x = $width/ 2-($new_width/2); | |
52 | + $width = $new_width; | |
53 | + | |
54 | + }else { | |
55 | + | |
56 | + $new_height = $height*($e_height/$e1_height); | |
57 | + $x = 0; | |
58 | + $y = $height/2-($new_height/2); | |
59 | + $height = $new_height; | |
60 | + } | |
61 | + | |
62 | + | |
63 | + } else { | |
64 | + $img->save($imageAliasSave, array('flatten' => false)); | |
65 | + return true; | |
66 | + } | |
67 | + | |
68 | + | |
69 | + Image::crop($imageAlias, $width, $height,[$x,$y]) | |
70 | + ->save(Yii::getAlias($imageAliasSave), ['quality' => | |
71 | + 100]); | |
72 | + | |
73 | + | |
74 | + $imagine = new Imagine(); | |
75 | + $imagine->open($imageAliasSave) | |
76 | + ->resize(new Box($w, $h)) | |
77 | + ->save($imageAliasSave, array('flatten' => false)); | |
78 | + | |
79 | + | |
80 | + | |
81 | + } | |
82 | + | |
83 | + private function deleteImages($old_img){ | |
84 | + | |
85 | + if(!empty($old_img) && file_exists($_SERVER['DOCUMENT_ROOT'].$old_img)){ | |
86 | + | |
87 | +// $rootDir = explode("/", $old_img); | |
88 | +// | |
89 | +// $row = $_SERVER['DOCUMENT_ROOT'].'/'.$rootDir[1].'/'.$rootDir[2].'/'; | |
90 | +// | |
91 | +// $allFiles = scandir($row); | |
92 | +// | |
93 | +// $allFiles = array_slice($allFiles, 2); | |
94 | +// | |
95 | +// foreach($allFiles as $oldFile){ | |
96 | +// | |
97 | +// unlink($row.$oldFile); | |
98 | +// | |
99 | +// } | |
100 | + | |
101 | + } | |
102 | + } | |
103 | + | |
104 | + public function actionDeleteImage(){ | |
105 | + | |
106 | + $request = Yii::$app->request->post(); | |
107 | + | |
108 | + if($request){ | |
109 | + if ($request['old_img']) { | |
110 | + $this->deleteImages($request['old_img']); | |
111 | + } | |
112 | + if(isset($request['action']) && $request['action']=='save'){ | |
113 | + $object = str_replace('-', '\\',$request['model']); | |
114 | + $model = new $object; | |
115 | + $model = $model->findOne($request['id']); | |
116 | + $model->$request['field'] = $request['new_url']; | |
117 | +// print_r($model->validate()); | |
118 | +// print_r($model->getErrors()); | |
119 | +// die(var_dump($model->save())); | |
120 | + $model->save(); | |
121 | + } | |
122 | + } | |
123 | + | |
124 | + } | |
125 | + | |
126 | + | |
127 | + public function actionDownloadPhoto() | |
128 | + { | |
129 | + | |
130 | + $model = new ImageSizerForm(); | |
131 | + | |
132 | + $request = Yii::$app->request->post(); | |
133 | + if ($request) { | |
134 | + | |
135 | + $model->file = UploadedFile::getInstance($model, 'file'); | |
136 | + | |
137 | + $md5_file = md5_file($model->file->tempName); | |
138 | + | |
139 | + $imgDir = Yii::getAlias('@storage/'.$md5_file.'/'); | |
140 | + | |
141 | + $imageOrigAlias = Yii::getAlias($imgDir.'original'.'.'.$model->file->extension); | |
142 | + | |
143 | + if(!is_dir($imgDir)) { | |
144 | + mkdir($imgDir, 0755, true); | |
145 | + } | |
146 | + | |
147 | + $model->file->saveAs($imageOrigAlias); | |
148 | + | |
149 | + if($request['width'] && $request['height']){ | |
150 | + | |
151 | + $imageAlias = Yii::getAlias($imgDir.$request['width'].'x'.$request['height'].'.'.$model->file->extension); | |
152 | + | |
153 | + $imageLink = '/storage/'.$md5_file.'/'.$request['width'].'x'.$request['height'].'.'.$model->file->extension; | |
154 | + | |
155 | + $this->resizeImg($request['width'], $request['height'], $imageOrigAlias,$imageAlias); | |
156 | + | |
157 | + } else { | |
158 | + | |
159 | + $imageLink = '/storage/'.$md5_file.'/'.'original'.'.'.$model->file->extension; | |
160 | + | |
161 | + } | |
162 | + | |
163 | + | |
164 | + if($model->multi){ | |
165 | + $view = $this->renderPartial('@app/components/views/_gallery_item', [ | |
166 | + 'item' => ['image'=>$imageLink], | |
167 | + ]); | |
168 | + | |
169 | + return json_encode(['link'=>$imageLink, 'view' =>$view]); | |
170 | + | |
171 | + | |
172 | + } else { | |
173 | + return json_encode(['link'=>$imageLink]); | |
174 | + } | |
175 | + | |
176 | + | |
177 | + } | |
178 | + } | |
179 | + | |
180 | + | |
181 | + public function getex($filename) { | |
182 | + return end(explode(".", $filename)); | |
183 | + } | |
184 | + | |
185 | + | |
186 | + public function actionImagesUpload(){ | |
187 | + if($_FILES['upload']) | |
188 | + { | |
189 | + if (($_FILES['upload'] == "none") OR (empty($_FILES['upload']['name'])) ) | |
190 | + { | |
191 | + $message = "ะั ะฝะต ะฒัะฑัะฐะปะธ ัะฐะนะป"; | |
192 | + } | |
193 | + else if ($_FILES['upload']["size"] == 0 OR $_FILES['upload']["size"] > 2050000) | |
194 | + { | |
195 | + $message = "ะ ะฐะทะผะตั ัะฐะนะปะฐ ะฝะต ัะพะพัะฒะตัััะฒัะตั ะฝะพัะผะฐะผ"; | |
196 | + } | |
197 | + 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')) | |
198 | + { | |
199 | + $message = "ะะพะฟััะบะฐะตััั ะทะฐะณััะทะบะฐ ัะพะปัะบะพ ะบะฐััะธะฝะพะบ JPG ะธ PNG."; | |
200 | + } | |
201 | + else if (!is_uploaded_file($_FILES['upload']["tmp_name"])) | |
202 | + { | |
203 | + $message = "ะงัะพ-ัะพ ะฟะพัะปะพ ะฝะต ัะฐะบ. ะะพะฟััะฐะนัะตัั ะทะฐะณััะทะธัั ัะฐะนะป ะตัั ัะฐะท."; | |
204 | + } | |
205 | + else{ | |
206 | + $name =rand(1, 1000).md5($_FILES['upload']['name']).'.'.$this->getex($_FILES['upload']['name']); | |
207 | + move_uploaded_file($_FILES['upload']['tmp_name'], "../../storage/images/".$name); | |
208 | + $full_path = '/storage/images/'.$name; | |
209 | + $message = "ะคะฐะนะป ".$_FILES['upload']['name']." ะทะฐะณััะถะตะฝ"; | |
210 | + $size=@getimagesize('images/'.$name); | |
211 | + | |
212 | + } | |
213 | + $callback = $_REQUEST['CKEditorFuncNum']; | |
214 | + echo '<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction("'.$callback.'", "'.$full_path.'", "'.$message.'" );</script>'; | |
215 | + } | |
216 | + } | |
217 | + | |
218 | + | |
219 | +} | |
0 | 220 | \ No newline at end of file | ... | ... |
frontend/controllers/OptionLangController.php
100644 โ 100755
frontend/controllers/PerformerController.php
100644 โ 100755
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 | +use mihaildev\elfinder\ElFinder; | |
6 | 7 | ?> |
7 | 8 | |
8 | 9 | <?php $form = ActiveForm::begin(); ?> |
... | ... | @@ -41,7 +42,15 @@ use yii\widgets\ActiveForm; |
41 | 42 | |
42 | 43 | <?= $form->field($user_info, 'prepayment')->textInput() ?> |
43 | 44 | |
44 | -<?= $form->field($user_info, 'about')->textarea(['rows' => 6]) ?> | |
45 | +<?= $form->field($user_info, 'about')->widget(CKEditor::className(),[ | |
46 | + 'editorOptions' => ElFinder::ckeditorOptions('elfinder',[ | |
47 | + 'preset' => 'full', //ัะฐะทัะฐะฑะพัะฐะฝะฝั ััะฐะฝะดะฐััะฝัะต ะฝะฐัััะพะนะบะธ basic, standard, full ะดะฐะฝะฝัั ะฒะพะทะผะพะถะฝะพััั ะฝะต ะพะฑัะทะฐัะตะปัะฝะพ ะธัะฟะพะปัะทะพะฒะฐัั | |
48 | + 'inline' => false, //ะฟะพ ัะผะพะปัะฐะฝะธั false]), | |
49 | + 'filebrowserUploadUrl'=>Yii::$app->getUrlManager()->createUrl('file/images-upload') | |
50 | + ] | |
51 | + ) | |
52 | +]); ?> | |
53 | + | |
45 | 54 | |
46 | 55 | <?= \common\widgets\FieldEditor::widget([ |
47 | 56 | 'template'=>'education', | ... | ... |
frontend/views/landing/landing-freelance.php
100644 โ 100755
frontend/views/landing/landing-order-project.php
100644 โ 100755
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\User */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="user-form"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin(); ?> | |
14 | + | |
15 | + <?= $form->field($model, 'status')->textInput() ?> | |
16 | + | |
17 | + <div class="form-group"> | |
18 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
19 | + </div> | |
20 | + | |
21 | + <?php ActiveForm::end(); ?> | |
22 | + | |
23 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model frontend\models\UserSearch */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="user-search"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin([ | |
14 | + 'action' => ['index'], | |
15 | + 'method' => 'get', | |
16 | + ]); ?> | |
17 | + | |
18 | + <?= $form->field($model, 'id') ?> | |
19 | + | |
20 | + <?= $form->field($model, 'username') ?> | |
21 | + | |
22 | + <?= $form->field($model, 'lastname') ?> | |
23 | + | |
24 | + <?= $form->field($model, 'firstname') ?> | |
25 | + | |
26 | + <?= $form->field($model, 'middlename') ?> | |
27 | + | |
28 | + <?php // echo $form->field($model, 'auth_key') ?> | |
29 | + | |
30 | + <?php // echo $form->field($model, 'password_hash') ?> | |
31 | + | |
32 | + <?php // echo $form->field($model, 'password_reset_token') ?> | |
33 | + | |
34 | + <?php // echo $form->field($model, 'email') ?> | |
35 | + | |
36 | + <?php // echo $form->field($model, 'status') ?> | |
37 | + | |
38 | + <?php // echo $form->field($model, 'created_at') ?> | |
39 | + | |
40 | + <?php // echo $form->field($model, 'updated_at') ?> | |
41 | + | |
42 | + <div class="form-group"> | |
43 | + <?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?> | |
44 | + <?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?> | |
45 | + </div> | |
46 | + | |
47 | + <?php ActiveForm::end(); ?> | |
48 | + | |
49 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\User */ | |
8 | + | |
9 | +$this->title = 'Create User'; | |
10 | +$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="user-create"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <?= $this->render('_form', [ | |
18 | + 'model' => $model, | |
19 | + ]) ?> | |
20 | + | |
21 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\grid\GridView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $searchModel frontend\models\UserSearch */ | |
8 | +/* @var $dataProvider yii\data\ActiveDataProvider */ | |
9 | + | |
10 | +$this->title = 'Users'; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="user-index"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + <?php // echo $this->render('_search', ['model' => $searchModel]); ?> | |
17 | + | |
18 | + <p> | |
19 | + <?= Html::a('Create User', ['create'], ['class' => 'btn btn-success']) ?> | |
20 | + </p> | |
21 | + <?= GridView::widget([ | |
22 | + 'dataProvider' => $dataProvider, | |
23 | + 'filterModel' => $searchModel, | |
24 | + 'columns' => [ | |
25 | + ['class' => 'yii\grid\SerialColumn'], | |
26 | + | |
27 | + 'id', | |
28 | + 'username', | |
29 | + 'lastname', | |
30 | + 'firstname', | |
31 | + 'middlename', | |
32 | + // 'auth_key', | |
33 | + // 'password_hash', | |
34 | + // 'password_reset_token', | |
35 | + // 'email:email', | |
36 | + // 'status', | |
37 | + // 'created_at', | |
38 | + // 'updated_at', | |
39 | + | |
40 | + ['class' => 'yii\grid\ActionColumn'], | |
41 | + ], | |
42 | + ]); ?> | |
43 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | + | |
5 | +/* @var $this yii\web\View */ | |
6 | +/* @var $model common\models\User */ | |
7 | + | |
8 | +$this->title = 'Update User: ' . ' ' . $model->id; | |
9 | +$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; | |
10 | +$this->params['breadcrumbs'][] = ['label' => $model->id, 'url' => ['view', 'id' => $model->id]]; | |
11 | +$this->params['breadcrumbs'][] = 'Update'; | |
12 | +?> | |
13 | +<div class="user-update"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <?= $this->render('_form', [ | |
18 | + 'model' => $model, | |
19 | + ]) ?> | |
20 | + | |
21 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\DetailView; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\User */ | |
8 | + | |
9 | +$this->title = $model->id; | |
10 | +$this->params['breadcrumbs'][] = ['label' => 'Users', 'url' => ['index']]; | |
11 | +$this->params['breadcrumbs'][] = $this->title; | |
12 | +?> | |
13 | +<div class="user-view"> | |
14 | + | |
15 | + <h1><?= Html::encode($this->title) ?></h1> | |
16 | + | |
17 | + <p> | |
18 | + <?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?> | |
19 | + <?= Html::a('Delete', ['delete', 'id' => $model->id], [ | |
20 | + 'class' => 'btn btn-danger', | |
21 | + 'data' => [ | |
22 | + 'confirm' => 'Are you sure you want to delete this item?', | |
23 | + 'method' => 'post', | |
24 | + ], | |
25 | + ]) ?> | |
26 | + </p> | |
27 | + | |
28 | + <?= DetailView::widget([ | |
29 | + 'model' => $model, | |
30 | + 'attributes' => [ | |
31 | + 'id', | |
32 | + 'username', | |
33 | + 'lastname', | |
34 | + 'firstname', | |
35 | + 'middlename', | |
36 | + 'auth_key', | |
37 | + 'password_hash', | |
38 | + 'password_reset_token', | |
39 | + 'email:email', | |
40 | + 'status', | |
41 | + 'created_at', | |
42 | + 'updated_at', | |
43 | + ], | |
44 | + ]) ?> | |
45 | + | |
46 | +</div> | ... | ... |
1 | +<?php | |
2 | + | |
3 | +use yii\helpers\Html; | |
4 | +use yii\widgets\ActiveForm; | |
5 | + | |
6 | +/* @var $this yii\web\View */ | |
7 | +/* @var $model common\models\UserInfo */ | |
8 | +/* @var $form yii\widgets\ActiveForm */ | |
9 | +?> | |
10 | + | |
11 | +<div class="user-info-form"> | |
12 | + | |
13 | + <?php $form = ActiveForm::begin(); ?> | |
14 | + | |
15 | + <?= $form->field($model, 'user_id')->textInput() ?> | |
16 | + | |
17 | + <?= $form->field($model, 'view_count')->textInput() ?> | |
18 | + | |
19 | + <?= $form->field($model, 'busy')->textInput(['maxlength' => true]) ?> | |
20 | + | |
21 | + <?= $form->field($model, 'date_visit')->textInput() ?> | |
22 | + | |
23 | + <?= $form->field($model, 'experience')->textInput() ?> | |
24 | + | |
25 | + <?= $form->field($model, 'rank')->textInput(['maxlength' => true]) ?> | |
26 | + | |
27 | + <?= $form->field($model, 'salary')->textInput(['maxlength' => true]) ?> | |
28 | + | |
29 | + <?= $form->field($model, 'job')->textInput(['maxlength' => true]) ?> | |
30 | + | |
31 | + <?= $form->field($model, 'location')->textInput(['maxlength' => true]) ?> | |
32 | + | |
33 | + <?= $form->field($model, 'soft')->textInput() ?> | |
34 | + | |
35 | + <?= $form->field($model, 'guarantee')->textInput() ?> | |
36 | + | |
37 | + <?= $form->field($model, 'contract')->textInput() ?> | |
38 | + | |
39 | + <?= $form->field($model, 'estimate')->textInput() ?> | |
40 | + | |
41 | + <?= $form->field($model, 'purchase')->textInput() ?> | |
42 | + | |
43 | + <?= $form->field($model, 'delivery')->textInput() ?> | |
44 | + | |
45 | + <?= $form->field($model, 'prepayment')->textInput() ?> | |
46 | + | |
47 | + <?= $form->field($model, 'about')->textarea(['rows' => 6]) ?> | |
48 | + | |
49 | + <div class="form-group"> | |
50 | + <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> | |
51 | + </div> | |
52 | + | |
53 | + <?php ActiveForm::end(); ?> | |
54 | + | |
55 | +</div> | ... | ... |