System plugin support: admin menu items, admin routes, API integration

- PluginManager: getAdminMenuItems(), handleAdminRoute(), getPluginType()
- admin.php: load PluginManager, pass plugin_admin_menu to Twig
- admin.php: route to plugin admin pages via handleAdminRoute()
- admin.twig: show 'Plugins' sidebar section for system plugins
- plugins-new.twig: choose content or system plugin type
- handlePluginsNew: generate proper template based on type (content/system)
- plugin-admin.twig: renders plugin output in admin layout
- GeoIPInfo: example system plugin (admin page with GeoIP info)
- System plugins: getAdminMenu(), getAdminRoutes(), handleAdminRoute()
- Content plugins: getSidebarContent() (unchanged)
This commit is contained in:
2026-08-11 18:06:17 +02:00
parent 6ed29e2c6c
commit a9e3b023de
11 changed files with 219 additions and 5 deletions
+57
View File
@@ -0,0 +1,57 @@
<?php
class GeoIPInfo
{
private ?CMSAPI $api = null;
public function setAPI(CMSAPI $api): void
{
$this->api = $api;
}
public function getConfig(): array
{
return [
'title' => 'GeoIP Info',
'type' => 'system',
];
}
/**
* Register admin menu items.
*/
public function getAdminMenu(): array
{
return [
['label' => 'GeoIP Info', 'route' => 'geoip-info', 'icon' => 'bi-globe2'],
];
}
/**
* Register admin routes this plugin handles.
*/
public function getAdminRoutes(): array
{
return ['geoip-info'];
}
/**
* Handle admin route — render the admin page.
*/
public function handleAdminRoute(string $route): void
{
$ip = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1';
$geoip = new GeoIP();
$countryCode = $geoip->lookupCountry($ip);
$country = GeoIP::getCountryName($countryCode);
$flag = GeoIP::getCountryFlagEmoji($countryCode);
echo '<h2 class="mb-4"><i class="bi bi-globe2"></i> GeoIP Info</h2>';
echo '<div class="card shadow-sm"><div class="card-body">';
echo '<table class="table table-sm">';
echo '<tr><td>IP adres</td><td><code>' . htmlspecialchars($ip) . '</code></td></tr>';
echo '<tr><td>Land</td><td>' . $flag . ' ' . htmlspecialchars($country) . '</td></tr>';
echo '</table>';
echo '</div></div>';
}
}