implemented step 18 by Gemini

- Contact formular and emailer script
This commit is contained in:
2026-06-15 04:49:26 +02:00
parent 029d7a232a
commit 269cc5f5d5
6 changed files with 254 additions and 7 deletions

View File

@ -71,18 +71,44 @@ class Renderer
}
$projectExportDir = $this->exportsPath . DIRECTORY_SEPARATOR . $projectId;
$assetsDir = $projectExportDir . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'css';
$assetsDir = $projectExportDir . DIRECTORY_SEPARATOR . 'assets';
$cssDir = $assetsDir . DIRECTORY_SEPARATOR . 'css';
$jsDir = $assetsDir . DIRECTORY_SEPARATOR . 'js';
// 1. Create directory structure
if (!is_dir($assetsDir)) {
mkdir($assetsDir, 0777, true);
}
if (!is_dir($cssDir)) mkdir($cssDir, 0777, true);
if (!is_dir($jsDir)) mkdir($jsDir, 0777, true);
// 2. Copy static assets
$siteCssSource = $this->templatesPath . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'site.css';
copy($siteCssSource, $assetsDir . DIRECTORY_SEPARATOR . 'site.css');
copy($this->templatesPath . '/css/site.css', $cssDir . '/site.css');
copy($this->templatesPath . '/js/site.js', $jsDir . '/site.js');
// 3. Prepare relative paths for assets
// 3. Handle Contact Form Logic
$formConfig = $projectData['wizard_data']['modules']['contact_form'] ?? [];
if (!empty($formConfig['enabled'])) {
// Copy handler
copy($this->templatesPath . '/emailer.php', $projectExportDir . '/ajax.php');
// Create config for handler
$siteConfig = [
'site_name' => $projectData['wizard_data']['identity']['business_name'],
'form_mode' => $formConfig['mode'] ?? 'local',
'smtp' => $formConfig['smtp'] ?? null,
'local_password_hash' => $formConfig['local_viewer']['password_hash'] ?? null
];
file_put_contents($projectExportDir . '/config.json', json_encode($siteConfig, JSON_PRETTY_PRINT));
if ($siteConfig['form_mode'] === 'local') {
// Copy viewer
copy($this->templatesPath . '/form-viewer.php', $projectExportDir . '/form-viewer.php');
// Create messages dir
$msgDir = $projectExportDir . '/messages';
if (!is_dir($msgDir)) mkdir($msgDir, 0777, true);
file_put_contents($msgDir . '/.htaccess', "Deny from all");
}
}
// 4. Prepare relative paths for assets
if (!empty($projectData['wizard_data']['assets']['logo'])) {
$projectData['wizard_data']['assets']['logo'] = $this->makePathRelative($projectData['wizard_data']['assets']['logo'], $projectId);
}