@@ -118,49 +118,49 @@ discard block |
||
118 | 118 | } |
119 | 119 | |
120 | 120 | if(!function_exists('assetThumbnail')) { |
121 | - function assetThumbnail($path) { |
|
122 | - $path = str_replace('uploads/','uploads_thumbnail/',$path); |
|
123 | - return asset($path); |
|
124 | - } |
|
121 | + function assetThumbnail($path) { |
|
122 | + $path = str_replace('uploads/','uploads_thumbnail/',$path); |
|
123 | + return asset($path); |
|
124 | + } |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | if(!function_exists('assetResize')) { |
128 | - function assetResize($path,$width,$height=null,$quality=70) { |
|
129 | - $basename = basename($path); |
|
130 | - $pathWithoutName = str_replace($basename, '', $path); |
|
131 | - $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
|
132 | - if(Storage::exists($newLocation)) { |
|
133 | - return asset($newLocation); |
|
134 | - }else{ |
|
135 | - $img = Image::make(storage_path($path))->fit($width,$height); |
|
136 | - $img->save(storage_path($newLocation),$quality); |
|
137 | - return asset($newLocation); |
|
138 | - } |
|
139 | - } |
|
128 | + function assetResize($path,$width,$height=null,$quality=70) { |
|
129 | + $basename = basename($path); |
|
130 | + $pathWithoutName = str_replace($basename, '', $path); |
|
131 | + $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
|
132 | + if(Storage::exists($newLocation)) { |
|
133 | + return asset($newLocation); |
|
134 | + }else{ |
|
135 | + $img = Image::make(storage_path($path))->fit($width,$height); |
|
136 | + $img->save(storage_path($newLocation),$quality); |
|
137 | + return asset($newLocation); |
|
138 | + } |
|
139 | + } |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if(!function_exists('extract_unit')) { |
143 | - /* |
|
143 | + /* |
|
144 | 144 | Credits: Bit Repository |
145 | 145 | URL: http://www.bitrepository.com/extract-content-between-two-delimiters-with-php.html |
146 | 146 | */ |
147 | - function extract_unit($string, $start, $end) |
|
148 | - { |
|
149 | - $pos = stripos($string, $start); |
|
150 | - $str = substr($string, $pos); |
|
151 | - $str_two = substr($str, strlen($start)); |
|
152 | - $second_pos = stripos($str_two, $end); |
|
153 | - $str_three = substr($str_two, 0, $second_pos); |
|
154 | - $unit = trim($str_three); // remove whitespaces |
|
155 | - return $unit; |
|
156 | - } |
|
147 | + function extract_unit($string, $start, $end) |
|
148 | + { |
|
149 | + $pos = stripos($string, $start); |
|
150 | + $str = substr($string, $pos); |
|
151 | + $str_two = substr($str, strlen($start)); |
|
152 | + $second_pos = stripos($str_two, $end); |
|
153 | + $str_three = substr($str_two, 0, $second_pos); |
|
154 | + $unit = trim($str_three); // remove whitespaces |
|
155 | + return $unit; |
|
156 | + } |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | |
160 | 160 | if(!function_exists('now')) { |
161 | - function now() { |
|
162 | - return date('Y-m-d H:i:s'); |
|
163 | - } |
|
161 | + function now() { |
|
162 | + return date('Y-m-d H:i:s'); |
|
163 | + } |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | /* |
@@ -324,22 +324,22 @@ discard block |
||
324 | 324 | } |
325 | 325 | |
326 | 326 | if(!function_exists('rrmdir')) { |
327 | - /* |
|
327 | + /* |
|
328 | 328 | * http://stackoverflow.com/questions/3338123/how-do-i-recursively-delete-a-directory-and-its-entire-contents-files-sub-dir |
329 | 329 | */ |
330 | - function rrmdir($dir) { |
|
331 | - if (is_dir($dir)) { |
|
332 | - $objects = scandir($dir); |
|
333 | - foreach ($objects as $object) { |
|
334 | - if ($object != "." && $object != "..") { |
|
335 | - if (is_dir($dir."/".$object)) |
|
336 | - rrmdir($dir."/".$object); |
|
337 | - else |
|
338 | - unlink($dir."/".$object); |
|
339 | - } |
|
340 | - } |
|
341 | - rmdir($dir); |
|
342 | - } |
|
343 | - } |
|
330 | + function rrmdir($dir) { |
|
331 | + if (is_dir($dir)) { |
|
332 | + $objects = scandir($dir); |
|
333 | + foreach ($objects as $object) { |
|
334 | + if ($object != "." && $object != "..") { |
|
335 | + if (is_dir($dir."/".$object)) |
|
336 | + rrmdir($dir."/".$object); |
|
337 | + else |
|
338 | + unlink($dir."/".$object); |
|
339 | + } |
|
340 | + } |
|
341 | + rmdir($dir); |
|
342 | + } |
|
343 | + } |
|
344 | 344 | } |
345 | 345 |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | $newLocation = $pathWithoutName.'/w_'.$width.'_h_'.$height.'_'.$basename; |
189 | 189 | if(Storage::exists($newLocation)) { |
190 | 190 | return asset($newLocation); |
191 | - }else{ |
|
191 | + } else{ |
|
192 | 192 | $img = Image::make(storage_path($path))->fit($width,$height); |
193 | 193 | $img->save(storage_path($newLocation),$quality); |
194 | 194 | return asset($newLocation); |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | $settings = file_get_contents(storage_path('.cbconfig')); |
236 | 236 | $settings = decrypt($settings); |
237 | 237 | $settings = unserialize($settings); |
238 | - }else{ |
|
238 | + } else{ |
|
239 | 239 | $settings = []; |
240 | 240 | } |
241 | 241 | |
@@ -260,14 +260,14 @@ discard block |
||
260 | 260 | $settings = file_get_contents(storage_path('.cbconfig')); |
261 | 261 | $settings = decrypt($settings); |
262 | 262 | $settings = unserialize($settings); |
263 | - }else{ |
|
263 | + } else{ |
|
264 | 264 | $settings = []; |
265 | 265 | } |
266 | 266 | |
267 | 267 | if(isset($settings[$key])) { |
268 | 268 | \Illuminate\Support\Facades\Cache::put("setting_".$key, $settings[$key], 180); |
269 | 269 | return $settings[$key]?:$default; |
270 | - }else{ |
|
270 | + } else{ |
|
271 | 271 | return $default; |
272 | 272 | } |
273 | 273 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | $url = request($name); |
354 | 354 | if(filter_var($url, FILTER_VALIDATE_URL)) { |
355 | 355 | return $url; |
356 | - }else{ |
|
356 | + } else{ |
|
357 | 357 | return request()->url(); |
358 | 358 | } |
359 | 359 | } |
@@ -365,14 +365,14 @@ discard block |
||
365 | 365 | $response = request($name); |
366 | 366 | if(is_string($response)) { |
367 | 367 | $response = sanitizeXSS($response); |
368 | - }elseif (is_array($response)) { |
|
368 | + } elseif (is_array($response)) { |
|
369 | 369 | array_walk_recursive($response, function(&$response) { |
370 | 370 | $response = sanitizeXSS($response); |
371 | 371 | }); |
372 | 372 | } |
373 | 373 | |
374 | 374 | return $response; |
375 | - }else{ |
|
375 | + } else{ |
|
376 | 376 | return Request::get($name); |
377 | 377 | } |
378 | 378 | } |
@@ -382,11 +382,13 @@ discard block |
||
382 | 382 | function min_var_export($input) { |
383 | 383 | if(is_array($input)) { |
384 | 384 | $buffer = []; |
385 | - foreach($input as $key => $value) |
|
386 | - $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
385 | + foreach($input as $key => $value) { |
|
386 | + $buffer[] = var_export($key, true)."=>".min_var_export($value); |
|
387 | + } |
|
387 | 388 | return "[".implode(",",$buffer)."]"; |
388 | - } else |
|
389 | - return var_export($input, true); |
|
389 | + } else { |
|
390 | + return var_export($input, true); |
|
391 | + } |
|
390 | 392 | } |
391 | 393 | } |
392 | 394 | |
@@ -399,10 +401,11 @@ discard block |
||
399 | 401 | $objects = scandir($dir); |
400 | 402 | foreach ($objects as $object) { |
401 | 403 | if ($object != "." && $object != "..") { |
402 | - if (is_dir($dir."/".$object)) |
|
403 | - rrmdir($dir."/".$object); |
|
404 | - else |
|
405 | - unlink($dir."/".$object); |
|
404 | + if (is_dir($dir."/".$object)) { |
|
405 | + rrmdir($dir."/".$object); |
|
406 | + } else { |
|
407 | + unlink($dir."/".$object); |
|
408 | + } |
|
406 | 409 | } |
407 | 410 | } |
408 | 411 | rmdir($dir); |
@@ -4,7 +4,7 @@ |
||
4 | 4 | interface CBHook { |
5 | 5 | |
6 | 6 | public function hookGetLogin(); |
7 | - public function hookPostLogin(); |
|
8 | - public function beforeBackendMiddleware($request); |
|
7 | + public function hookPostLogin(); |
|
8 | + public function beforeBackendMiddleware($request); |
|
9 | 9 | public function afterBackendMiddleware($request, $response); |
10 | 10 | } |
11 | 11 | \ No newline at end of file |
@@ -51,7 +51,7 @@ |
||
51 | 51 | if (Request::is(cbConfig('ADMIN_PATH'))) { |
52 | 52 | if($dashboard = cbConfig("ADMIN_DASHBOARD_CONTROLLER")) { |
53 | 53 | cb()->routeGet("/", $dashboard); |
54 | - }else{ |
|
54 | + } else{ |
|
55 | 55 | cb()->routeGet("/", "\crocodicstudio\crudbooster\controllers\AdminDashboardController@getIndex"); |
56 | 56 | } |
57 | 57 | } |
@@ -71,7 +71,9 @@ |
||
71 | 71 | $user = []; |
72 | 72 | $user['name'] = request('name'); |
73 | 73 | $user['email'] = request('email'); |
74 | - if(request('password')) $user['password'] = Hash::make(request('password')); |
|
74 | + if(request('password')) { |
|
75 | + $user['password'] = Hash::make(request('password')); |
|
76 | + } |
|
75 | 77 | $user['cb_roles_id'] = request('cb_roles_id'); |
76 | 78 | DB::table('users')->where('id',$id)->update($user); |
77 | 79 |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | $menu['type'] = request('type'); |
55 | 55 | if(request('type') == 'module') { |
56 | 56 | $menu['cb_modules_id'] = request('cb_modules_id'); |
57 | - }elseif (request('type') == 'url') { |
|
57 | + } elseif (request('type') == 'url') { |
|
58 | 58 | $menu['path'] = request('url_value'); |
59 | - }elseif (request('type') == 'path') { |
|
59 | + } elseif (request('type') == 'path') { |
|
60 | 60 | $menu['path'] = request('path_value'); |
61 | 61 | } |
62 | 62 | |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | $menu['type'] = request('type'); |
80 | 80 | if(request('type') == 'module') { |
81 | 81 | $menu['cb_modules_id'] = request('cb_modules_id'); |
82 | - }elseif (request('type') == 'url') { |
|
82 | + } elseif (request('type') == 'url') { |
|
83 | 83 | $menu['path'] = request('url_value'); |
84 | - }elseif (request('type') == 'path') { |
|
84 | + } elseif (request('type') == 'path') { |
|
85 | 85 | $menu['path'] = request('path_value'); |
86 | 86 | } |
87 | 87 | DB::table("cb_menus")->where("id",$id)->update($menu); |
@@ -76,45 +76,60 @@ discard block |
||
76 | 76 | |
77 | 77 | public function canBrowse() { |
78 | 78 | if($this->privilege) { |
79 | - if($this->privilege->can_browse) return true; |
|
80 | - else return false; |
|
81 | - }else{ |
|
79 | + if($this->privilege->can_browse) { |
|
80 | + return true; |
|
81 | + } else { |
|
82 | + return false; |
|
83 | + } |
|
84 | + } else{ |
|
82 | 85 | return true; |
83 | 86 | } |
84 | 87 | } |
85 | 88 | |
86 | 89 | public function canCreate() { |
87 | 90 | if($this->privilege) { |
88 | - if($this->privilege->can_create) return true; |
|
89 | - else return false; |
|
90 | - }else{ |
|
91 | + if($this->privilege->can_create) { |
|
92 | + return true; |
|
93 | + } else { |
|
94 | + return false; |
|
95 | + } |
|
96 | + } else{ |
|
91 | 97 | return true; |
92 | 98 | } |
93 | 99 | } |
94 | 100 | |
95 | 101 | public function canRead() { |
96 | 102 | if($this->privilege) { |
97 | - if($this->privilege->can_read) return true; |
|
98 | - else return false; |
|
99 | - }else{ |
|
103 | + if($this->privilege->can_read) { |
|
104 | + return true; |
|
105 | + } else { |
|
106 | + return false; |
|
107 | + } |
|
108 | + } else{ |
|
100 | 109 | return true; |
101 | 110 | } |
102 | 111 | } |
103 | 112 | |
104 | 113 | public function canUpdate() { |
105 | 114 | if($this->privilege) { |
106 | - if($this->privilege->can_update) return true; |
|
107 | - else return false; |
|
108 | - }else{ |
|
115 | + if($this->privilege->can_update) { |
|
116 | + return true; |
|
117 | + } else { |
|
118 | + return false; |
|
119 | + } |
|
120 | + } else{ |
|
109 | 121 | return true; |
110 | 122 | } |
111 | 123 | } |
112 | 124 | |
113 | 125 | public function canDelete() { |
114 | 126 | if($this->privilege) { |
115 | - if($this->privilege->can_delete) return true; |
|
116 | - else return false; |
|
117 | - }else{ |
|
127 | + if($this->privilege->can_delete) { |
|
128 | + return true; |
|
129 | + } else { |
|
130 | + return false; |
|
131 | + } |
|
132 | + } else{ |
|
118 | 133 | return true; |
119 | 134 | } |
120 | 135 | } |
@@ -123,7 +138,7 @@ discard block |
||
123 | 138 | { |
124 | 139 | if($this->controller_class && method_exists($this->controller_class, 'getAdd')) { |
125 | 140 | return action($this->controller.'@getAdd'); |
126 | - }else{ |
|
141 | + } else{ |
|
127 | 142 | return null; |
128 | 143 | } |
129 | 144 | } |
@@ -132,7 +147,7 @@ discard block |
||
132 | 147 | { |
133 | 148 | if($this->controller_class && method_exists($this->controller_class, 'postAddSave')) { |
134 | 149 | return action($this->controller.'@postAddSave'); |
135 | - }else{ |
|
150 | + } else{ |
|
136 | 151 | return null; |
137 | 152 | } |
138 | 153 | } |
@@ -141,7 +156,7 @@ discard block |
||
141 | 156 | { |
142 | 157 | if($this->controller_class && method_exists($this->controller_class, 'getEdit')) { |
143 | 158 | return action($this->controller.'@getEdit',['id'=>$id]); |
144 | - }else{ |
|
159 | + } else{ |
|
145 | 160 | return null; |
146 | 161 | } |
147 | 162 | } |
@@ -150,7 +165,7 @@ discard block |
||
150 | 165 | { |
151 | 166 | if(method_exists($this->controller_class, 'postEditSave')) { |
152 | 167 | return action($this->controller.'@postEditSave',['id'=>$id]); |
153 | - }else{ |
|
168 | + } else{ |
|
154 | 169 | return null; |
155 | 170 | } |
156 | 171 | } |
@@ -159,7 +174,7 @@ discard block |
||
159 | 174 | { |
160 | 175 | if($this->controller_class && method_exists($this->controller_class, 'getDetail')) { |
161 | 176 | return action($this->controller.'@getDetail',['id'=>$id]); |
162 | - }else{ |
|
177 | + } else{ |
|
163 | 178 | return null; |
164 | 179 | } |
165 | 180 | } |
@@ -168,7 +183,7 @@ discard block |
||
168 | 183 | { |
169 | 184 | if($this->controller_class && method_exists($this->controller_class, 'getDelete')) { |
170 | 185 | return action($this->controller.'@getDelete',['id'=>$id]); |
171 | - }else{ |
|
186 | + } else{ |
|
172 | 187 | return null; |
173 | 188 | } |
174 | 189 | } |
@@ -177,7 +192,7 @@ discard block |
||
177 | 192 | { |
178 | 193 | if($this->controller_class && method_exists($this->controller_class, 'getIndex')) { |
179 | 194 | return trim(action($this->controller.'@getIndex').'/'.$path,'/'); |
180 | - }else{ |
|
195 | + } else{ |
|
181 | 196 | return null; |
182 | 197 | } |
183 | 198 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | { |
23 | 23 | if($column->getFormat()) { |
24 | 24 | return date($column->getFormat(), strtotime($row->{$column->getField()})); |
25 | - }else{ |
|
25 | + } else{ |
|
26 | 26 | return $row->{$column->getField()}; |
27 | 27 | } |
28 | 28 | } |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $data = DB::table($table); |
37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
40 | 40 | $data->whereRaw($SQLCondition); |
41 | 41 | } |
42 | 42 | $data = $data->get(); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $data = DB::table($table); |
37 | 37 | if($SQLCondition && is_callable($SQLCondition)) { |
38 | 38 | $data = call_user_func($SQLCondition, $data); |
39 | - }elseif ($SQLCondition && is_string($SQLCondition)) { |
|
39 | + } elseif ($SQLCondition && is_string($SQLCondition)) { |
|
40 | 40 | $data->whereRaw($SQLCondition); |
41 | 41 | } |
42 | 42 | $data = $data->get(); |