";
- $action = '
'.$delete.' | '.$settings.$activate;
+ $action = "
" . $delete . " | " . $settings . $activate;
} else {
$action = '';
}
-
- return ucfirst($model['name']).$action;
+ return ucfirst($model['name']) . $action;
})
- ->addColumn('description', function ($model) {
+ ->addColumn('description', function($model) {
return ucfirst($model['description']);
})
- ->addColumn('author', function ($model) {
+ ->addColumn('author', function($model) {
return ucfirst($model['author']);
})
- ->addColumn('website', function ($model) {
- return '
'.$model['website'].'';
+ ->addColumn('website', function($model) {
+ return "
" . $model['website'] . "";
})
- ->addColumn('version', function ($model) {
+ ->addColumn('version', function($model) {
return $model['version'];
})
->make();
}
/**
- * Reading the Filedirectory.
- *
+ * Reading the Filedirectory
* @return type
*/
- public function ReadPlugins()
- {
- $dir = app_path().'/Plugins';
- $plugins = array_diff(scandir($dir), ['.', '..']);
-
+ public function ReadPlugins() {
+ $dir = app_path() .DIRECTORY_SEPARATOR.'Plugins';
+ $plugins = array_diff(scandir($dir), array('.', '..'));
return $plugins;
}
/**
- * After plugin post.
- *
+ * After plugin post
* @param Request $request
- *
* @return type
*/
- public function PostPlugins(Request $request)
- {
+ public function PostPlugins(Request $request) {
$v = $this->validate($request, ['plugin' => 'required|mimes:application/zip,zip,Zip']);
$plug = new Plugin();
$file = $request->file('plugin');
//dd($file);
- $destination = app_path().'/Plugins';
+ $destination = app_path() .DIRECTORY_SEPARATOR.'Plugins';
$zipfile = $file->getRealPath();
- /*
+ /**
* get the file name and remove .zip
*/
$filename2 = $file->getClientOriginalName();
$filename2 = str_replace('.zip', '', $filename2);
$filename1 = ucfirst($file->getClientOriginalName());
$filename = str_replace('.zip', '', $filename1);
- mkdir($destination.'/'.$filename);
- /*
+ mkdir($destination . DIRECTORY_SEPARATOR . $filename);
+ /**
* extract the zip file using zipper
*/
- \Zipper::make($zipfile)->folder($filename2)->extractTo($destination.'/'.$filename);
+ \Zipper::make($zipfile)->folder($filename2)->extractTo($destination .DIRECTORY_SEPARATOR. $filename);
- $file = app_path().'/Plugins/'.$filename; // Plugin file path
+ $file = app_path() .DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR. $filename; // Plugin file path
if (file_exists($file)) {
- $seviceporvider = $file.'/ServiceProvider.php';
- $config = $file.'/config.php';
+
+ $seviceporvider = $file .DIRECTORY_SEPARATOR.'ServiceProvider.php';
+ $config = $file .DIRECTORY_SEPARATOR.'config.php';
if (file_exists($seviceporvider) && file_exists($config)) {
- /*
+ /**
* move to faveo config
*/
- $faveoconfig = config_path().'/plugins/'.$filename.'.php';
+ $faveoconfig = config_path() .DIRECTORY_SEPARATOR.'plugins' .DIRECTORY_SEPARATOR.$filename . '.php';
if ($faveoconfig) {
//copy($config, $faveoconfig);
- /*
+ /**
* write provider list in app.php line 128
*/
- $app = base_path().'/config/app.php';
- $str = "\n\t\t'App\\Plugins\\$filename"."\\ServiceProvider',";
- $line_i_am_looking_for = 140;
+ $app = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
+ $str = "\n\n\t\t\t'App\\Plugins\\$filename" . "\\ServiceProvider',";
+ $line_i_am_looking_for = 144;
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines));
$plug->create(['name' => $filename, 'path' => $filename, 'status' => 1]);
-
return redirect()->back()->with('success', 'Installed SuccessFully');
} else {
- /*
+ /**
* delete if the plugin hasn't config.php and ServiceProvider.php
*/
$this->deleteDirectory($file);
-
- return redirect()->back()->with('fails', 'Their is no '.$file);
+ return redirect()->back()->with('fails', 'Their is no ' . $file);
}
} else {
- /*
+ /**
* delete if the plugin hasn't config.php and ServiceProvider.php
*/
$this->deleteDirectory($file);
-
- return redirect()->back()->with('fails', 'Their is no
config.php or ServiceProvider.php '.$file);
+ return redirect()->back()->with('fails', 'Their is no
config.php or ServiceProvider.php ' . $file);
}
} else {
- /*
+ /**
* delete if the plugin Name is not equal to the folder name
*/
$this->deleteDirectory($file);
-
- return redirect()->back()->with('fails', '
Plugin File Path is not exist '.$file);
+ return redirect()->back()->with('fails', '
Plugin File Path is not exist ' . $file);
}
}
/**
- * Delete the directory.
- *
+ * Delete the directory
* @param type $dir
- *
- * @return bool
+ * @return boolean
*/
- public function deleteDirectory($dir)
- {
+ public function deleteDirectory($dir) {
+
if (!file_exists($dir)) {
return true;
}
@@ -626,23 +591,34 @@ class SettingsController extends Controller
if ($item == '.' || $item == '..') {
continue;
}
- if (!$this->deleteDirectory($dir.DIRECTORY_SEPARATOR.$item)) {
+ chmod($dir . DIRECTORY_SEPARATOR . $item,0777);
+ if (!$this->deleteDirectory($dir . DIRECTORY_SEPARATOR . $item)) {
return false;
}
}
-
+ chmod($dir, 0777);
return rmdir($dir);
}
- public function ReadConfigs()
- {
- $dir = app_path().'/Plugins/';
- $files = array_diff(scandir($dir), ['.', '..', 'ServiceProvider.php']);
- $plugins = [];
- if ($files) {
+ public function ReadConfigs() {
+ $dir = app_path() .DIRECTORY_SEPARATOR.'Plugins'.DIRECTORY_SEPARATOR;
+ $directories = scandir($dir);
+ $files = [];
+ foreach ($directories as $key => $file) {
+ if ($file === '.' or $file === '..')
+ continue;
+
+ if (is_dir($dir .DIRECTORY_SEPARATOR. $file)) {
+ $files[$key] = $file;
+ }
+ }
+ //dd($files);
+ $config=[];
+ $plugins = array();
+ if (count($files) > 0) {
foreach ($files as $key => $file) {
- $plugin = $dir.$file;
- $plugins[$key] = array_diff(scandir($plugin), ['.', '..', 'ServiceProvider.php']);
+ $plugin = $dir . $file;
+ $plugins[$key] = array_diff(scandir($plugin), array('.', '..', 'ServiceProvider.php'));
$plugins[$key]['file'] = $plugin;
}
foreach ($plugins as $plugin) {
@@ -651,89 +627,98 @@ class SettingsController extends Controller
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
if ($file == 'config.php') {
- $config[] = $dir.'/'.$file;
+ $config[] = $dir .DIRECTORY_SEPARATOR. $file;
}
}
closedir($dh);
}
}
-
return $config;
} else {
return 'null';
}
}
- public function fetchConfig()
- {
+ public function fetchConfig() {
$configs = $this->ReadConfigs();
//dd($configs);
- $plug = new Plugin();
+ $plug = new Plugin;
$plug = $plug->select('path', 'status')->orderBy('name')->get()->toArray();
- //dd($plug[0]['path']);
+ //$fields = [];
if ($configs !== 'null') {
foreach ($configs as $key => $config) {
+
$fields[$key] = include $config;
+
if ($plug != null) {
$fields[$key]['path'] = $plug[$key]['path'];
$fields[$key]['status'] = $plug[$key]['status'];
+ } else {
+ $fields[$key]['path'] = $fields[$key]['name'];
+ $fields[$key]['status'] = 0;
}
}
-
return $fields;
- } else {
- return [];
}
}
- public function DeletePlugin($slug)
- {
- $dir = app_path().'/Plugins/'.$slug;
+ public function DeletePlugin($slug) {
+ $dir = app_path() . DIRECTORY_SEPARATOR . 'Plugins' . DIRECTORY_SEPARATOR . $slug;
$this->deleteDirectory($dir);
- /*
+ /**
* remove service provider from app.php
*/
- $str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
- $path_to_file = base_path().'/config/app.php';
+ $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
+ $path_to_file = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$file_contents = file_get_contents($path_to_file);
- $file_contents = str_replace($str, '', $file_contents);
+ $file_contents = str_replace($str, "//", $file_contents);
file_put_contents($path_to_file, $file_contents);
$plugin = new Plugin();
$plugin = $plugin->where('path', $slug)->first();
- $plugin->delete();
-
+ if ($plugin) {
+ $plugin->delete();
+ }
return redirect()->back()->with('success', 'Deleted Successfully');
}
- public function StatusPlugin($slug)
- {
- $plug = new Plugin();
- $plug = $plug->where('name', $slug)->first();
+ public function StatusPlugin($slug) {
+ $plugs = new Plugin;
+ $plug = $plugs->where('name', $slug)->first();
+ if (!$plug) {
+ $app = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
+ $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
+ $line_i_am_looking_for = 144;
+ $lines = file($app, FILE_IGNORE_NEW_LINES);
+ $lines[$line_i_am_looking_for] = $str;
+ file_put_contents($app, implode("\n", $lines));
+ $plugs->create(['name' => $slug, 'path' => $slug, 'status' => 1]);
+ return redirect()->back()->with('success', 'Status has changed');
+ }
$status = $plug->status;
if ($status == 0) {
$plug->status = 1;
- $app = base_path().'/config/app.php';
- $str = "\n\t\t'App\\Plugins\\$slug"."\\ServiceProvider',";
- $line_i_am_looking_for = 140;
+ $app = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
+ $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
+ $line_i_am_looking_for = 144;
$lines = file($app, FILE_IGNORE_NEW_LINES);
$lines[$line_i_am_looking_for] = $str;
file_put_contents($app, implode("\n", $lines));
}
if ($status == 1) {
$plug->status = 0;
- /*
+ /**
* remove service provider from app.php
*/
- $str = "'App\\Plugins\\$slug"."\\ServiceProvider',";
- $path_to_file = base_path().'/config/app.php';
+ $str = "'App\\Plugins\\$slug" . "\\ServiceProvider',";
+ $path_to_file = base_path() .DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'app.php';
$file_contents = file_get_contents($path_to_file);
- $file_contents = str_replace($str, '', $file_contents);
+ $file_contents = str_replace($str, "//", $file_contents);
file_put_contents($path_to_file, $file_contents);
}
$plug->save();
-
return redirect()->back()->with('success', 'Status has changed');
}
+
}
diff --git a/config/app.php b/config/app.php
index f97afa3a0..83329f97a 100644
--- a/config/app.php
+++ b/config/app.php
@@ -38,7 +38,7 @@ return [
|
*/
- 'version' => 'Community 1.0.7.1',
+ 'version' => 'Community 1.0.7.2',
/*
|--------------------------------------------------------------------------