- Fix template variable replacement in guide pages by removing {{}} brackets
- Escape code blocks in guide markdown to prevent template processing
- Completely rewrite guide documentation with comprehensive CMS features
- Add bilingual guide support (English/Dutch) with detailed examples
- Enhance CodePressCMS core with improved guide page handling
- Update template system with better layout and footer components
- Improve language files with additional translations
- Update configuration with enhanced theme and language settings
Resolves issue where guide pages were showing replaced template variables
instead of displaying them as documentation examples.
77 lines
2.0 KiB
PHP
77 lines
2.0 KiB
PHP
<?php
|
|
|
|
class PluginManager
|
|
{
|
|
private array $plugins = [];
|
|
private string $pluginsPath;
|
|
private ?CMSAPI $api = null;
|
|
|
|
public function __construct(string $pluginsPath)
|
|
{
|
|
$this->pluginsPath = $pluginsPath;
|
|
$this->loadPlugins();
|
|
}
|
|
|
|
public function setAPI(CMSAPI $api): void
|
|
{
|
|
$this->api = $api;
|
|
|
|
// Inject API into all plugins that have setAPI method
|
|
foreach ($this->plugins as $plugin) {
|
|
if (method_exists($plugin, 'setAPI')) {
|
|
$plugin->setAPI($api);
|
|
}
|
|
}
|
|
}
|
|
|
|
private function loadPlugins(): void
|
|
{
|
|
if (!is_dir($this->pluginsPath)) {
|
|
return;
|
|
}
|
|
|
|
$pluginDirs = glob($this->pluginsPath . '/*', GLOB_ONLYDIR);
|
|
|
|
foreach ($pluginDirs as $pluginDir) {
|
|
$pluginName = basename($pluginDir);
|
|
$pluginFile = $pluginDir . '/' . $pluginName . '.php';
|
|
|
|
if (file_exists($pluginFile)) {
|
|
require_once $pluginFile;
|
|
|
|
$className = $pluginName;
|
|
if (class_exists($className)) {
|
|
$this->plugins[$pluginName] = new $className();
|
|
|
|
// Inject API if already available
|
|
if ($this->api && method_exists($this->plugins[$pluginName], 'setAPI')) {
|
|
$this->plugins[$pluginName]->setAPI($this->api);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function getPlugin(string $name): ?object
|
|
{
|
|
return $this->plugins[$name] ?? null;
|
|
}
|
|
|
|
public function getAllPlugins(): array
|
|
{
|
|
return $this->plugins;
|
|
}
|
|
|
|
public function getSidebarContent(): string
|
|
{
|
|
$sidebarContent = '';
|
|
|
|
foreach ($this->plugins as $plugin) {
|
|
if (method_exists($plugin, 'getSidebarContent')) {
|
|
$sidebarContent .= $plugin->getSidebarContent();
|
|
}
|
|
}
|
|
|
|
return $sidebarContent;
|
|
}
|
|
} |