fix url to config pages of plugins
This commit is contained in:
parent
fd17d3ac75
commit
db15ff2314
|
|
@ -12,61 +12,54 @@ class PluginController extends Controller
|
|||
{
|
||||
public function showMarket()
|
||||
{
|
||||
return "developing";
|
||||
return 'Plugin market is under development. Maybe you will want to check <a href="https://github.com/g-plane/unofficial-plugins-market">this</a>.';
|
||||
}
|
||||
|
||||
public function showManage()
|
||||
{
|
||||
return view('admin.plugins');
|
||||
}
|
||||
|
||||
public function config($name, Request $request)
|
||||
{
|
||||
$plugin = plugin($name);
|
||||
|
||||
if ($plugin && $plugin->isEnabled() && $plugin->hasConfigView()) {
|
||||
return $plugin->getConfigView();
|
||||
} else {
|
||||
abort(404, trans('admin.plugins.operations.no-config-notice'));
|
||||
}
|
||||
}
|
||||
|
||||
public function manage(Request $request, PluginManager $plugins)
|
||||
{
|
||||
if ($request->has('action') && $request->has('name')) {
|
||||
$name = $request->get('name');
|
||||
$plugin = plugin($name = $request->get('name'));
|
||||
|
||||
if ($plugins->getPlugins()->has($name)) {
|
||||
$plugin = $plugins->getPlugin($name);
|
||||
if ($plugin) {
|
||||
// pass the plugin title through the translator
|
||||
$plugin->title = trans($plugin->title);
|
||||
|
||||
// pass the plugin title through the translator
|
||||
$plugin->title = trans($plugin->title);
|
||||
switch ($request->get('action')) {
|
||||
case 'enable':
|
||||
$plugins->enable($name);
|
||||
|
||||
switch ($request->get('action')) {
|
||||
case 'enable':
|
||||
$plugins->enable($name);
|
||||
return json(trans('admin.plugins.operations.enabled', ['plugin' => $plugin->title]), 0);
|
||||
|
||||
return json(trans('admin.plugins.operations.enabled', ['plugin' => $plugin->title]), 0);
|
||||
break;
|
||||
case 'disable':
|
||||
$plugins->disable($name);
|
||||
|
||||
case 'disable':
|
||||
$plugins->disable($name);
|
||||
return json(trans('admin.plugins.operations.disabled', ['plugin' => $plugin->title]), 0);
|
||||
|
||||
return json(trans('admin.plugins.operations.disabled', ['plugin' => $plugin->title]), 0);
|
||||
break;
|
||||
case 'delete':
|
||||
$plugins->uninstall($name);
|
||||
|
||||
case 'delete':
|
||||
if ($request->isMethod('post')) {
|
||||
event(new Events\PluginWasDeleted($plugin));
|
||||
return json(trans('admin.plugins.operations.deleted'), 0);
|
||||
|
||||
$plugins->uninstall($name);
|
||||
|
||||
return json(trans('admin.plugins.operations.deleted'), 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'config':
|
||||
if ($plugin->isEnabled() && $plugin->hasConfigView()) {
|
||||
return View::file($plugin->getViewPath('config'));
|
||||
} else {
|
||||
abort(404);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
default:
|
||||
# code...
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('admin.plugins');
|
||||
}
|
||||
|
||||
public function getPluginData(PluginManager $plugins)
|
||||
|
|
|
|||
|
|
@ -113,9 +113,12 @@ Route::group(['middleware' => 'admin', 'prefix' => 'admin'], function ()
|
|||
Route::post('/players', 'AdminController@playerAjaxHandler');
|
||||
|
||||
Route::group(['prefix' => 'plugins'], function () {
|
||||
Route::any('/manage', 'PluginController@manage');
|
||||
Route::get('/data', 'PluginController@getPluginData');
|
||||
Route::any('/market', 'PluginController@showMarket');
|
||||
Route::get ('/data', 'PluginController@getPluginData');
|
||||
Route::any ('/market', 'PluginController@showMarket');
|
||||
|
||||
Route::get ('/manage', 'PluginController@showManage');
|
||||
Route::post('/manage', 'PluginController@manage');
|
||||
Route::any ('/config/{name}', 'PluginController@config');
|
||||
});
|
||||
|
||||
Route::group(['prefix' => 'update'], function () {
|
||||
|
|
|
|||
|
|
@ -153,12 +153,24 @@ class Plugin implements Arrayable, ArrayAccess
|
|||
|
||||
public function getViewPath($name)
|
||||
{
|
||||
return $this->path."/views/$name.tpl";
|
||||
return $this->getViewPathByFileName("$name.tpl");
|
||||
}
|
||||
|
||||
public function getViewPathByFileName($filename)
|
||||
{
|
||||
return $this->path."/views/$filename";
|
||||
}
|
||||
|
||||
public function getConfigView()
|
||||
{
|
||||
return $this->hasConfigView() ? view()->file($this->getViewPathByFileName(Arr::get($this->packageInfo, 'config'))) : null;
|
||||
}
|
||||
|
||||
public function hasConfigView()
|
||||
{
|
||||
return Arr::get($this->packageInfo, 'config') != "";
|
||||
$filename = Arr::get($this->packageInfo, 'config');
|
||||
|
||||
return $filename && file_exists($this->getViewPathByFileName($filename));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -167,12 +167,13 @@ class PluginManager
|
|||
|
||||
$this->disable($name);
|
||||
|
||||
// fire event before deleeting plugin files
|
||||
$this->dispatcher->fire(new Events\PluginWasDeleted($plugin));
|
||||
|
||||
$this->filesystem->deleteDirectory($plugin->getPath());
|
||||
|
||||
// refresh plugin list
|
||||
$this->plugins = null;
|
||||
|
||||
$this->dispatcher->fire(new Events\PluginWasDeleted($plugin));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
@endif
|
||||
|
||||
@if ($plugin->isEnabled() && $plugin->hasConfigView())
|
||||
<a class="btn btn-default btn-sm" href="?action=config&id={{ $plugin->name }}">{{ trans('admin.plugins.operations.configure') }}</a>
|
||||
<a class="btn btn-default btn-sm" href="{{ url('admin/plugins/config/'.$plugin->name) }}">{{ trans('admin.plugins.operations.configure') }}</a>
|
||||
@else
|
||||
<a class="btn btn-default btn-sm" disabled="disabled" title="{{ trans('admin.plugins.operations.no-config-notice') }}" data-toggle="tooltip" data-placement="top">{{ trans('admin.plugins.operations.configure') }}</a>
|
||||
@endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user