Security: verwijder hardcoded wachtwoord, voeg random-wachtwoord-generator toe bij eerste installatie
This commit is contained in:
@@ -1,16 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Lightweight API wrapper for plugins in the admin context.
|
||||
* Provides read-only access to the site config (no CMS instance needed).
|
||||
* Lichtgewicht API-wrapper voor plugins in de admin-context.
|
||||
*
|
||||
* Biedt alleen-lezen toegang tot de site-config (zonder CMS-instance nodig).
|
||||
*
|
||||
* @since 2.6.4
|
||||
*/
|
||||
class AdminPluginAPI implements PluginAPIInterface
|
||||
{
|
||||
/**
|
||||
* De site-configuratie als associatieve array.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var array<string,mixed>
|
||||
*/
|
||||
private array $config;
|
||||
|
||||
/**
|
||||
* Het absolute pad naar de project-root.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var string
|
||||
*/
|
||||
private string $projectRoot;
|
||||
|
||||
/**
|
||||
* De actieve admin-taalcode (bijv. 'nl', 'en').
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var string
|
||||
*/
|
||||
private string $adminLanguage;
|
||||
|
||||
/**
|
||||
* De admin PluginManager-instantie, optioneel via setPluginManager geïnjecteerd.
|
||||
*
|
||||
* @since 2.6.4
|
||||
* @var PluginManager|null
|
||||
*/
|
||||
private ?PluginManager $pluginManager = null;
|
||||
|
||||
/**
|
||||
* Construeer een AdminPluginAPI-instantie met de opgegeven site-config.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param array<string,mixed> $siteConfig De site-configuratie.
|
||||
* @param string $projectRoot Optioneel absoluut pad naar de project-root.
|
||||
*/
|
||||
public function __construct(array $siteConfig, string $projectRoot = '')
|
||||
{
|
||||
$this->config = $siteConfig;
|
||||
@@ -20,8 +58,13 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the admin PluginManager so plugins can resolve their own
|
||||
* translations through the same fallback chain.
|
||||
* Injecteer de admin PluginManager zodat plugins hun eigen vertalingen
|
||||
* via dezelfde fallback-keten kunnen resolven.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param PluginManager $pm De admin PluginManager-instantie.
|
||||
* @return void
|
||||
*/
|
||||
public function setPluginManager(PluginManager $pm): void
|
||||
{
|
||||
@@ -29,7 +72,13 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration value using dot notation.
|
||||
* Haal een configuratiewaarde op via dot-notatie.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param string $key Configuratie-sleutel in dot-notatie (bijv. 'language.default').
|
||||
* @param mixed $default Standaardwaarde indien de sleutel niet bestaat.
|
||||
* @return mixed De gevonden waarde of $default indien niet gevonden.
|
||||
*/
|
||||
public function getConfig(string $key, $default = null)
|
||||
{
|
||||
@@ -47,7 +96,11 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the project root directory.
|
||||
* Haal de project-rootdirectory op.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @return string Absoluut pad naar de project-root.
|
||||
*/
|
||||
public function getProjectRoot(): string
|
||||
{
|
||||
@@ -55,15 +108,30 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the content directory path.
|
||||
* Haal het pad naar de contentdirectory op als absoluut pad.
|
||||
*
|
||||
* Relatieve paden uit config.json (bijv. 'content') worden afgezet tegen
|
||||
* de project-root, conform het gedrag van cms/core/config.php.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @return string Absoluut pad naar de contentdirectory.
|
||||
*/
|
||||
public function getContentDir(): string
|
||||
{
|
||||
return $this->config['content_dir'] ?? ($this->projectRoot . '/content');
|
||||
$dir = $this->config['content_dir'] ?? ($this->projectRoot . '/content');
|
||||
if ($dir !== '' && $dir[0] !== DIRECTORY_SEPARATOR && !preg_match('#^[A-Za-z]:[/\\\\]#', $dir)) {
|
||||
$dir = $this->projectRoot . '/' . $dir;
|
||||
}
|
||||
return rtrim($dir, '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugins directory path.
|
||||
* Haal het pad naar de pluginsdirectory op.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @return string Absoluut pad naar de pluginsdirectory.
|
||||
*/
|
||||
public function getPluginsDir(): string
|
||||
{
|
||||
@@ -71,7 +139,11 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of enabled plugins.
|
||||
* Haal de lijst met ingeschakelde plugins op.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @return array<int,string> Lijst met ingeschakelde plugin-namen.
|
||||
*/
|
||||
public function getEnabledPlugins(): array
|
||||
{
|
||||
@@ -79,7 +151,11 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the version info from version.php.
|
||||
* Haal de versie-informatie uit version.php op.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @return array<string,mixed> Versie-informatie met minimaal de sleutel 'version'.
|
||||
*/
|
||||
public function getVersionInfo(): array
|
||||
{
|
||||
@@ -94,8 +170,13 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active admin language code (e.g. 'nl', 'en').
|
||||
* System plugins should use this to resolve their translations.
|
||||
* Haal de actieve admin-taalcode op (bijv. 'nl', 'en').
|
||||
*
|
||||
* System-plugins gebruiken deze om hun vertalingen te resolven.
|
||||
*
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @return string De actieve admin-taalcode.
|
||||
*/
|
||||
public function getAdminLanguage(): string
|
||||
{
|
||||
@@ -103,14 +184,16 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the translations for a plugin in the admin context.
|
||||
* Haal de vertalingen voor een plugin op in de admin-context.
|
||||
*
|
||||
* Fallback chain (handled by PluginManager):
|
||||
* requested language -> plugin default_language -> empty array.
|
||||
* Fallback-keten (afgehandeld door PluginManager):
|
||||
* aangevraagde taal -> default_language van de plugin -> lege array.
|
||||
*
|
||||
* @param string $pluginName Plugin directory name
|
||||
* @param string|null $lang Override language; defaults to the active admin language
|
||||
* @return array Translations [key => value]
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param string $pluginName Plugin-directorynaam.
|
||||
* @param string|null $lang Override-taal; standaard de actieve admin-taal.
|
||||
* @return array<string,string> Vertalingen als [key => value].
|
||||
*/
|
||||
public function getPluginTranslations(string $pluginName, ?string $lang = null): array
|
||||
{
|
||||
@@ -122,12 +205,14 @@ class AdminPluginAPI implements PluginAPIInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Translate a single key for a plugin in the admin context.
|
||||
* Vertaal een enkele sleutel voor een plugin in de admin-context.
|
||||
*
|
||||
* @param string $key Translation key
|
||||
* @param string $pluginName Plugin directory name
|
||||
* @param string|null $lang Override language; defaults to the active admin language
|
||||
* @return string Translated string, or $key if not found
|
||||
* @since 2.6.4
|
||||
*
|
||||
* @param string $key Vertaalsleutel.
|
||||
* @param string $pluginName Plugin-directorynaam.
|
||||
* @param string|null $lang Override-taal; standaard de actieve admin-taal.
|
||||
* @return string Vertaalde string, of $key indien niet gevonden.
|
||||
*/
|
||||
public function t(string $key, string $pluginName, ?string $lang = null): string
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user