@@ -26,13 +26,13 @@ discard block |
||
26 | 26 | // Register views |
27 | 27 | $this->loadViewsFrom(__DIR__.'/views', 'crudbooster'); |
28 | 28 | $this->loadViewsFrom(__DIR__.'/types', 'types'); |
29 | - $this->loadTranslationsFrom(__DIR__."/localization","cb"); |
|
29 | + $this->loadTranslationsFrom(__DIR__."/localization", "cb"); |
|
30 | 30 | |
31 | 31 | // Publish the files |
32 | - $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')],'cb_config'); |
|
33 | - $this->publishes([__DIR__.'/database' => base_path('database')],'cb_migration'); |
|
34 | - $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')],'cb_hook'); |
|
35 | - $this->publishes([__DIR__ . '/assets' =>public_path('cb_asset')],'cb_asset'); |
|
32 | + $this->publishes([__DIR__.'/configs/crudbooster.php' => config_path('crudbooster.php')], 'cb_config'); |
|
33 | + $this->publishes([__DIR__.'/database' => base_path('database')], 'cb_migration'); |
|
34 | + $this->publishes([__DIR__.'/templates/CBHook.stub'=> app_path('Http/CBHook.php')], 'cb_hook'); |
|
35 | + $this->publishes([__DIR__.'/assets' =>public_path('cb_asset')], 'cb_asset'); |
|
36 | 36 | |
37 | 37 | // Override Local FileSystem |
38 | 38 | Config::set("filesystems.disks.local.root", cbConfig("LOCAL_FILESYSTEM_PATH", public_path("storage"))); |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | require __DIR__.'/helpers/Helper.php'; |
55 | 55 | |
56 | 56 | // Singletons |
57 | - $this->app->singleton('crudbooster', function () |
|
57 | + $this->app->singleton('crudbooster', function() |
|
58 | 58 | { |
59 | 59 | return true; |
60 | 60 | }); |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | // Merging configuration |
80 | - $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php','crudbooster'); |
|
80 | + $this->mergeConfigFrom(__DIR__.'/configs/crudbooster.php', 'crudbooster'); |
|
81 | 81 | |
82 | 82 | // Register additional library |
83 | 83 | $this->app->register('Intervention\Image\ImageServiceProvider'); |
@@ -88,13 +88,13 @@ discard block |
||
88 | 88 | |
89 | 89 | private function registerPlugin() |
90 | 90 | { |
91 | - if(file_exists(app_path("CBPlugins"))) { |
|
91 | + if (file_exists(app_path("CBPlugins"))) { |
|
92 | 92 | $views = scandir(app_path("CBPlugins")); |
93 | - foreach($views as $view) { |
|
94 | - if($view != "." && $view != "..") { |
|
93 | + foreach ($views as $view) { |
|
94 | + if ($view != "." && $view != "..") { |
|
95 | 95 | $basename = basename($view); |
96 | 96 | // register view |
97 | - $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"),$basename); |
|
97 | + $this->loadViewsFrom(app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Views"), $basename); |
|
98 | 98 | // register route |
99 | 99 | require app_path("CBPlugins".DIRECTORY_SEPARATOR.$basename.DIRECTORY_SEPARATOR."Routes".DIRECTORY_SEPARATOR."Route.php"); |
100 | 100 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | |
107 | 107 | private function registerTypeRoutes() { |
108 | 108 | $routes = rglob(__DIR__.DIRECTORY_SEPARATOR."types".DIRECTORY_SEPARATOR."Route.php"); |
109 | - foreach($routes as $route) { |
|
109 | + foreach ($routes as $route) { |
|
110 | 110 | require $route; |
111 | 111 | } |
112 | 112 | } |
@@ -28,14 +28,14 @@ discard block |
||
28 | 28 | |
29 | 29 | public function getIndex() { |
30 | 30 | |
31 | - if(request("refresh")) { |
|
32 | - $this->fetchPluginData(false ); |
|
33 | - return cb()->redirectBack("Plugin list has been refreshed!","success"); |
|
31 | + if (request("refresh")) { |
|
32 | + $this->fetchPluginData(false); |
|
33 | + return cb()->redirectBack("Plugin list has been refreshed!", "success"); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | $data = []; |
37 | 37 | $data['result'] = $this->fetchPluginData(); |
38 | - return view($this->view.'.index',$data); |
|
38 | + return view($this->view.'.index', $data); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | public function postLoginAccount() { |
@@ -50,13 +50,13 @@ discard block |
||
50 | 50 | ]); |
51 | 51 | $response = $curl->send(); |
52 | 52 | |
53 | - if($respArray = json_decode($response, true)) { |
|
54 | - if($respArray['status'] && isset($respArray['token'])) { |
|
53 | + if ($respArray = json_decode($response, true)) { |
|
54 | + if ($respArray['status'] && isset($respArray['token'])) { |
|
55 | 55 | session(['account_token'=>$respArray['token']]); |
56 | 56 | } |
57 | - return response()->make($response,200,["Content-Type"=>"application/json"]); |
|
57 | + return response()->make($response, 200, ["Content-Type"=>"application/json"]); |
|
58 | 58 | } else { |
59 | - return response()->json(['status'=>false,'message'=>'failed']); |
|
59 | + return response()->json(['status'=>false, 'message'=>'failed']); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -73,15 +73,15 @@ discard block |
||
73 | 73 | ]); |
74 | 74 | $response = $curl->send(); |
75 | 75 | |
76 | - if($respArray = json_decode($response, true)) { |
|
77 | - if($respArray['status']) { |
|
76 | + if ($respArray = json_decode($response, true)) { |
|
77 | + if ($respArray['status']) { |
|
78 | 78 | $form = base64_decode($respArray['payment']); |
79 | - return response()->json(['status'=>true,'form'=>$form]); |
|
79 | + return response()->json(['status'=>true, 'form'=>$form]); |
|
80 | 80 | } else { |
81 | 81 | return response()->json($respArray); |
82 | 82 | } |
83 | 83 | } else { |
84 | - return response()->json(['status'=>false,'message'=>'failed','raw'=>$response]); |
|
84 | + return response()->json(['status'=>false, 'message'=>'failed', 'raw'=>$response]); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
@@ -89,28 +89,28 @@ discard block |
||
89 | 89 | { |
90 | 90 | $pluginData = $this->fetchPluginData(); |
91 | 91 | |
92 | - if(isset($pluginData[$key])) { |
|
93 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
92 | + if (isset($pluginData[$key])) { |
|
93 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
94 | 94 | rrmdir(app_path("CBPlugins/".$key)); |
95 | 95 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
96 | - }else{ |
|
97 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
96 | + } else { |
|
97 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
98 | 98 | } |
99 | - }else { |
|
100 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
99 | + } else { |
|
100 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
101 | 101 | } |
102 | 102 | } |
103 | 103 | |
104 | - private function recursiveCopy($src,$dst) { |
|
104 | + private function recursiveCopy($src, $dst) { |
|
105 | 105 | $dir = opendir($src); |
106 | 106 | @mkdir($dst); |
107 | - while(false !== ( $file = readdir($dir)) ) { |
|
108 | - if (( $file != '.' ) && ( $file != '..' )) { |
|
109 | - if ( is_dir($src . '/' . $file) ) { |
|
110 | - $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
|
107 | + while (false !== ($file = readdir($dir))) { |
|
108 | + if (($file != '.') && ($file != '..')) { |
|
109 | + if (is_dir($src.'/'.$file)) { |
|
110 | + $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file); |
|
111 | 111 | } |
112 | 112 | else { |
113 | - copy($src . '/' . $file,$dst . '/' . $file); |
|
113 | + copy($src.'/'.$file, $dst.'/'.$file); |
|
114 | 114 | } |
115 | 115 | } |
116 | 116 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $pluginData = $this->fetchPluginData(); |
123 | 123 | |
124 | 124 | try { |
125 | - if(isset($pluginData[$key])) { |
|
125 | + if (isset($pluginData[$key])) { |
|
126 | 126 | $plugin = $pluginData[$key]; |
127 | 127 | |
128 | 128 | // Create temp file of zip plugin |
@@ -140,16 +140,16 @@ discard block |
||
140 | 140 | fclose($temp); |
141 | 141 | |
142 | 142 | // Rename |
143 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
143 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
144 | 144 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
145 | 145 | |
146 | 146 | // Read Plugin JSON |
147 | 147 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true); |
148 | 148 | |
149 | 149 | // Check if has asset |
150 | - if($pluginJson && $pluginJson['asset']) { |
|
150 | + if ($pluginJson && $pluginJson['asset']) { |
|
151 | 151 | // Check destination folder is ready |
152 | - if(file_exists(public_path("cb_asset/".$key))) { |
|
152 | + if (file_exists(public_path("cb_asset/".$key))) { |
|
153 | 153 | rrmdir(public_path("cb_asset/".$key)); |
154 | 154 | } |
155 | 155 | |
@@ -160,22 +160,22 @@ discard block |
||
160 | 160 | $this->recursiveCopy(app_path("CBPlugins/".$key."/".$pluginJson['asset']), public_path("cb_asset/".$key)); |
161 | 161 | } |
162 | 162 | |
163 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
163 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
164 | 164 | |
165 | 165 | } else { |
166 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
166 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
167 | 167 | } |
168 | - }else{ |
|
169 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
168 | + } else { |
|
169 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
170 | 170 | } |
171 | 171 | } catch (\Exception $e) { |
172 | - return response()->json(['status'=>false,'message'=>'Something went wrong!']); |
|
172 | + return response()->json(['status'=>false, 'message'=>'Something went wrong!']); |
|
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | 176 | private function fetchPluginData($cache = true) |
177 | 177 | { |
178 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
178 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
179 | 179 | return $data; |
180 | 180 | } |
181 | 181 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | $context = stream_context_create($opts); |
193 | 193 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
194 | 194 | |
195 | - if($data) { |
|
195 | + if ($data) { |
|
196 | 196 | $data = json_decode($data, true); |
197 | - if($data['status']==true) { |
|
197 | + if ($data['status'] == true) { |
|
198 | 198 | |
199 | - foreach($data['data'] as $item) { |
|
199 | + foreach ($data['data'] as $item) { |
|
200 | 200 | $key = $item['key']; |
201 | - $result[ $key ] = $item; |
|
201 | + $result[$key] = $item; |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | $result = collect($result)->sortBy("name")->all(); |
@@ -93,10 +93,10 @@ discard block |
||
93 | 93 | if(file_exists(app_path("CBPlugins/".$key))) { |
94 | 94 | rrmdir(app_path("CBPlugins/".$key)); |
95 | 95 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
96 | - }else{ |
|
96 | + } else{ |
|
97 | 97 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
98 | 98 | } |
99 | - }else { |
|
99 | + } else { |
|
100 | 100 | return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
101 | 101 | } |
102 | 102 | } |
@@ -108,8 +108,7 @@ discard block |
||
108 | 108 | if (( $file != '.' ) && ( $file != '..' )) { |
109 | 109 | if ( is_dir($src . '/' . $file) ) { |
110 | 110 | $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
111 | - } |
|
112 | - else { |
|
111 | + } else { |
|
113 | 112 | copy($src . '/' . $file,$dst . '/' . $file); |
114 | 113 | } |
115 | 114 | } |
@@ -140,7 +139,9 @@ discard block |
||
140 | 139 | fclose($temp); |
141 | 140 | |
142 | 141 | // Rename |
143 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
142 | + if(file_exists(app_path("CBPlugins/".$key))) { |
|
143 | + rrmdir(app_path("CBPlugins/".$key)); |
|
144 | + } |
|
144 | 145 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
145 | 146 | |
146 | 147 | // Read Plugin JSON |
@@ -165,7 +166,7 @@ discard block |
||
165 | 166 | } else { |
166 | 167 | return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
167 | 168 | } |
168 | - }else{ |
|
169 | + } else{ |
|
169 | 170 | return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
170 | 171 | } |
171 | 172 | } catch (\Exception $e) { |