mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-12-03 05:41:52 +09:00
Reworked the settings and introduced new endpoints
This commit is contained in:
1 parent
84bc8b48af
commit
536beb0f81
3 files changed
+63
-30
No files matched your search
@@ -157,6 +157,38 @@ class Box_Mod
|
||||
return file_exists($this->_getModPath() . 'html_admin/mod_'.$this->mod.'_settings.html.twig');
|
||||
}
|
||||
|
||||
public function hasSettingsRoutes()
|
||||
{
|
||||
if($this->hasService()) {
|
||||
$s = $this->getService();
|
||||
if(method_exists($s, 'getSettingsRoutes')) {
|
||||
return (count($s->getSettingsRoutes()) > 0);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getSettingsRoutes()
|
||||
{
|
||||
$result = array();
|
||||
|
||||
if ($this->hasSettingsRoutes()) {
|
||||
foreach ($this->getService()->getSettingsRoutes() as $route) {
|
||||
// Check if it is a valid external link
|
||||
$filtered = filter_var(idn_to_ascii($route["path"]), FILTER_VALIDATE_URL);
|
||||
|
||||
// If it's an external link, return it directly. Otherwise, return the internal link with the /admin prefix.
|
||||
$route['path'] = $filtered ? $filtered : $this->di['url']->adminLink($route["path"], []);
|
||||
$result[] = $route;
|
||||
}
|
||||
|
||||
return $result;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
public function hasAdminController()
|
||||
{
|
||||
return file_exists($this->_getModPath() . 'Controller/Admin.php');
|
||||
|
||||
@@ -133,6 +133,8 @@ class Service implements InjectionAwareInterface
|
||||
$manifest = $m->getManifest();
|
||||
$manifest['status'] = 'core';
|
||||
$manifest['has_settings'] = $m->hasSettingsPage();
|
||||
$manifest['has_settings_routes'] = $m->hasSettingsRoutes();
|
||||
$manifest['settings_routes'] = $m->hasSettingsRoutes() ? $m->getSettingsRoutes() : array();
|
||||
$result[] = $manifest;
|
||||
}
|
||||
}
|
||||
@@ -147,10 +149,10 @@ class Service implements InjectionAwareInterface
|
||||
$manifest['version'] = $im['version'];
|
||||
|
||||
$manifest['status'] = $im['status'];
|
||||
if ('mod' == $im['type'] && 'installed' == $im['status'] && $m->hasSettingsPage()) {
|
||||
$manifest['has_settings'] = true;
|
||||
} else {
|
||||
$manifest['has_settings'] = false;
|
||||
if ('mod' == $im['type'] && 'installed' == $im['status']) {
|
||||
$manifest['has_settings'] = $m->hasSettingsPage();
|
||||
$manifest['has_settings_routes'] = $m->hasSettingsRoutes();
|
||||
$manifest['settings_routes'] = $m->hasSettingsRoutes() ? $m->getSettingsRoutes() : array();
|
||||
}
|
||||
|
||||
$result[] = $manifest;
|
||||
@@ -173,6 +175,8 @@ class Service implements InjectionAwareInterface
|
||||
$manifest = $m->getManifest();
|
||||
$manifest['status'] = null;
|
||||
$manifest['has_settings'] = false;
|
||||
$manifest['has_settings_routes'] = false;
|
||||
$manifest['settings_routes'] = array();
|
||||
|
||||
$result[] = $manifest;
|
||||
}
|
||||
|
||||
Regular → Executable
+23
-26
@@ -9,32 +9,29 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="card">
|
||||
<div class="tabs_container">
|
||||
<div id="tab-index" class="tab_content nopadding">
|
||||
{% include 'partial_search.html.twig' %}
|
||||
<table class="table card-table table-vcenter table-striped text-nowrap">
|
||||
<tbody>
|
||||
{% for ext in admin.extension_get_list({ 'active': 1, 'has_settings': 1 }|merge(request)) %}
|
||||
<tr>
|
||||
<td class="w-5">
|
||||
<a href="{{ 'extension/settings'|alink }}/{{ ext.id }}">
|
||||
<img src="{{ ext.icon_url }}" alt="{{ ext.name }}" style="width: 32px; height: 32px;">
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="{{ 'extension/settings'|alink }}/{{ ext.id }}">{{ ext.name }}</a>
|
||||
</td>
|
||||
<td class="w-1">
|
||||
<a class="btn btn-icon" href="{{ 'extension/settings'|alink }}/{{ ext.id }}">
|
||||
<svg class="icon">
|
||||
<use xlink:href="#play" />
|
||||
</svg>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Settings</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="datagrid">
|
||||
{% for ext in admin.extension_get_list({ 'active': 1, 'has_settings': 1 }|merge(request)) %}
|
||||
<div class="datagrid-item">
|
||||
<div class="datagrid-title">
|
||||
<a href="{{ 'extension/settings'|alink }}/{{ ext.id }}" class="text-reset">
|
||||
<img src="{{ ext.icon_url }}" alt="{{ ext.name }}" style="width: 32px; height: 32px; margin-right: .5rem;"> {{ ext.name }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="datagrid-content">
|
||||
<ul>
|
||||
{% for route in ext.settings_routes %}
|
||||
<li>
|
||||
<a href="{{ route.path }}">{{route.label}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user