@@ -31,25 +31,25 @@ discard block |
||
31 | 31 | |
32 | 32 | public function getIndex() { |
33 | 33 | |
34 | - if(request("refresh")) { |
|
35 | - $this->fetchPluginData(false ); |
|
36 | - return cb()->redirectBack("Plugin list has been refreshed!","success"); |
|
34 | + if (request("refresh")) { |
|
35 | + $this->fetchPluginData(false); |
|
36 | + return cb()->redirectBack("Plugin list has been refreshed!", "success"); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $data = []; |
40 | 40 | $data['result'] = $this->fetchPluginData(); |
41 | - return view($this->view.'.index',$data); |
|
41 | + return view($this->view.'.index', $data); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | public function getUninstall($key) |
45 | 45 | { |
46 | 46 | $pluginData = $this->fetchPluginData(); |
47 | 47 | |
48 | - if(isset($pluginData[$key])) { |
|
49 | - if(file_exists(app_path("CBPlugins/".$key))) { |
|
48 | + if (isset($pluginData[$key])) { |
|
49 | + if (file_exists(app_path("CBPlugins/".$key))) { |
|
50 | 50 | |
51 | - if(isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
52 | - if(isset($pluginData['package'])) { |
|
51 | + if (isset($pluginData['source']) && $pluginData['source'] == 'composer') { |
|
52 | + if (isset($pluginData['package'])) { |
|
53 | 53 | ComposerHelper::composerRemove($pluginData['package']); |
54 | 54 | } |
55 | 55 | } |
@@ -57,24 +57,24 @@ discard block |
||
57 | 57 | rrmdir(app_path("CBPlugins/".$key)); |
58 | 58 | |
59 | 59 | return response()->json(['status'=>true, 'message'=>'Plugin has been uninstalled!']); |
60 | - }else{ |
|
61 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin is not found']); |
|
60 | + } else { |
|
61 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin is not found']); |
|
62 | 62 | } |
63 | - }else { |
|
64 | - return response()->json(['status'=>false,'message'=>'Failed to uninstall, plugin key is not found']); |
|
63 | + } else { |
|
64 | + return response()->json(['status'=>false, 'message'=>'Failed to uninstall, plugin key is not found']); |
|
65 | 65 | } |
66 | 66 | } |
67 | 67 | |
68 | - private function recursiveCopy($src,$dst) { |
|
68 | + private function recursiveCopy($src, $dst) { |
|
69 | 69 | $dir = opendir($src); |
70 | 70 | @mkdir($dst); |
71 | - while(false !== ( $file = readdir($dir)) ) { |
|
72 | - if (( $file != '.' ) && ( $file != '..' )) { |
|
73 | - if ( is_dir($src . '/' . $file) ) { |
|
74 | - $this->recursiveCopy($src . '/' . $file,$dst . '/' . $file); |
|
71 | + while (false !== ($file = readdir($dir))) { |
|
72 | + if (($file != '.') && ($file != '..')) { |
|
73 | + if (is_dir($src.'/'.$file)) { |
|
74 | + $this->recursiveCopy($src.'/'.$file, $dst.'/'.$file); |
|
75 | 75 | } |
76 | 76 | else { |
77 | - copy($src . '/' . $file,$dst . '/' . $file); |
|
77 | + copy($src.'/'.$file, $dst.'/'.$file); |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | } |
@@ -83,26 +83,26 @@ discard block |
||
83 | 83 | |
84 | 84 | public function getInstall($key) |
85 | 85 | { |
86 | - ini_set("memory_limit","192M"); |
|
86 | + ini_set("memory_limit", "192M"); |
|
87 | 87 | set_time_limit(500); |
88 | 88 | |
89 | 89 | $pluginData = $this->fetchPluginData(); |
90 | 90 | |
91 | 91 | try { |
92 | - if(isset($pluginData[$key])) { |
|
92 | + if (isset($pluginData[$key])) { |
|
93 | 93 | $plugin = $pluginData[$key]; |
94 | 94 | |
95 | - if(isset($plugin['source']) && $plugin['source'] == "composer") { |
|
95 | + if (isset($plugin['source']) && $plugin['source'] == "composer") { |
|
96 | 96 | |
97 | - if(isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
97 | + if (isset($plugin['package']) && isset($plugin['service_provider'])) { |
|
98 | 98 | // Make a composer |
99 | 99 | $output = ComposerHelper::composerRequire($plugin['package'], $plugin['service_provider']); |
100 | 100 | |
101 | 101 | Artisan::call("migrate"); |
102 | 102 | |
103 | - return response()->json(['status'=>true,'message'=>$output]); |
|
103 | + return response()->json(['status'=>true, 'message'=>$output]); |
|
104 | 104 | } else { |
105 | - return response()->json(['status'=>true,'message'=>'Installation is failed, there is no package and or service provider']); |
|
105 | + return response()->json(['status'=>true, 'message'=>'Installation is failed, there is no package and or service provider']); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | } else { |
@@ -121,16 +121,16 @@ discard block |
||
121 | 121 | fclose($temp); |
122 | 122 | |
123 | 123 | // Rename |
124 | - if(file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
124 | + if (file_exists(app_path("CBPlugins/".$key))) rrmdir(app_path("CBPlugins/".$key)); |
|
125 | 125 | rename(app_path("CBPlugins/".$dirName), app_path("CBPlugins/".$key)); |
126 | 126 | |
127 | 127 | // Read Plugin JSON |
128 | 128 | $pluginJson = json_decode(file_get_contents(app_path("CBPlugins/".$key."/plugin.json")), true); |
129 | 129 | |
130 | 130 | // Check if has asset |
131 | - if($pluginJson && $pluginJson['asset']) { |
|
131 | + if ($pluginJson && $pluginJson['asset']) { |
|
132 | 132 | // Check destination folder is ready |
133 | - if(file_exists(public_path("cb_asset/".$key))) { |
|
133 | + if (file_exists(public_path("cb_asset/".$key))) { |
|
134 | 134 | rrmdir(public_path("cb_asset/".$key)); |
135 | 135 | } |
136 | 136 | |
@@ -144,31 +144,31 @@ discard block |
||
144 | 144 | //Migrate |
145 | 145 | Artisan::call("migrate"); |
146 | 146 | |
147 | - return response()->json(['status'=>true,'message'=>'Install / update plugin has been succesfull!']); |
|
147 | + return response()->json(['status'=>true, 'message'=>'Install / update plugin has been succesfull!']); |
|
148 | 148 | |
149 | 149 | } else { |
150 | - return response()->json(['status'=>false,'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
150 | + return response()->json(['status'=>false, 'message'=>"Failed to install/update, can't open the plugin archive"]); |
|
151 | 151 | } |
152 | 152 | } |
153 | 153 | |
154 | - }else{ |
|
155 | - return response()->json(['status'=>false,'message'=>'Failed to install/update, plugin key is not found']); |
|
154 | + } else { |
|
155 | + return response()->json(['status'=>false, 'message'=>'Failed to install/update, plugin key is not found']); |
|
156 | 156 | } |
157 | 157 | } catch (\Exception $e) { |
158 | - return response()->json(['status'=>false,'message'=>'Something went wrong!']); |
|
158 | + return response()->json(['status'=>false, 'message'=>'Something went wrong!']); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | |
162 | 162 | private function fetchPluginData($cache = true) |
163 | 163 | { |
164 | - if($cache === true && $data = Cache::get("plugin_store_data")) { |
|
164 | + if ($cache === true && $data = Cache::get("plugin_store_data")) { |
|
165 | 165 | return $data; |
166 | 166 | } |
167 | 167 | |
168 | 168 | $result = []; |
169 | 169 | |
170 | 170 | try { |
171 | - $no_cache = ($cache)?0:1; |
|
171 | + $no_cache = ($cache) ? 0 : 1; |
|
172 | 172 | $opts = [ |
173 | 173 | "http" => [ |
174 | 174 | "method" => "GET", |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | $context = stream_context_create($opts); |
182 | 182 | $data = file_get_contents(base64_decode("aHR0cDovL2NydWRib29zdGVyLmNvbS9hcGkvcGx1Z2luP2FjY2Vzc190b2tlbj1iVmMvWm5wWU5TWnJNVlpZT0hFNVUydHFjU1U9"), false, $context); |
183 | 183 | |
184 | - if($data) { |
|
184 | + if ($data) { |
|
185 | 185 | $data = json_decode($data, true); |
186 | - if($data['status']==true) { |
|
186 | + if ($data['status'] == true) { |
|
187 | 187 | |
188 | - foreach($data['data'] as $item) { |
|
188 | + foreach ($data['data'] as $item) { |
|
189 | 189 | $key = $item['key']; |
190 | - $result[ $key ] = $item; |
|
190 | + $result[$key] = $item; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | $result = collect($result)->sortBy("name")->all(); |