Files
backPRO/templates/articles/show.php
Jacek Pyziak b653cea252 Add installer functionality for WordPress with FTP and database configuration
- Create SQL migration for prompt templates used in article and image generation.
- Add migration to change publish interval from days to hours in the sites table.
- Implement InstallerController to handle installation requests and validation.
- Develop FtpService for FTP connections and file uploads.
- Create InstallerService to manage the WordPress installation process, including downloading, extracting, and configuring WordPress.
- Add index view for the installer with form inputs for FTP, database, and WordPress admin settings.
- Implement progress tracking for the installation process with AJAX polling.
2026-02-16 21:55:24 +01:00

112 lines
4.5 KiB
PHP

<div class="mb-4">
<a href="/articles" class="text-muted small">&larr; Powrót do listy</a>
<h2 class="mt-2"><?= htmlspecialchars($article['title']) ?></h2>
<div class="d-flex gap-3 text-muted small">
<span><i class="bi bi-globe me-1"></i><?= htmlspecialchars($article['site_name']) ?></span>
<span><i class="bi bi-tag me-1"></i><?= htmlspecialchars($article['topic_name']) ?></span>
<span><i class="bi bi-calendar me-1"></i><?= date('d.m.Y H:i', strtotime($article['created_at'])) ?></span>
<span><i class="bi bi-cpu me-1"></i><?= htmlspecialchars($article['ai_model'] ?? 'N/A') ?></span>
<?php if ($article['status'] === 'published'): ?>
<span class="badge bg-success">Opublikowany</span>
<?php elseif ($article['status'] === 'failed'): ?>
<span class="badge bg-danger">Błąd</span>
<?php else: ?>
<span class="badge bg-warning">Wygenerowany</span>
<?php endif; ?>
</div>
</div>
<?php if ($article['status'] === 'failed' && $article['error_message']): ?>
<div class="alert alert-danger">
<strong>Błąd:</strong> <?= htmlspecialchars($article['error_message']) ?>
</div>
<?php endif; ?>
<?php if ($article['wp_post_id'] && !empty($article['site_url'])): ?>
<div class="alert alert-info d-flex justify-content-between align-items-center">
<div>
<i class="bi bi-wordpress me-1"></i>
Post WordPress ID: <strong><?= $article['wp_post_id'] ?></strong>
| <a href="<?= htmlspecialchars($article['site_url']) ?>/?p=<?= $article['wp_post_id'] ?>" target="_blank">Zobacz na stronie</a>
</div>
<div class="d-flex align-items-center gap-2">
<input type="file" id="imageFile" accept="image/jpeg,image/png,image/gif,image/webp" class="form-control form-control-sm" style="max-width: 250px;">
<button class="btn btn-sm btn-outline-warning" id="btnReplaceImage" onclick="replaceImage()" disabled>
<i class="bi bi-upload me-1"></i>Podmień
</button>
</div>
</div>
<?php endif; ?>
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">Treść artykułu</h5>
</div>
<div class="card-body article-content">
<?= $article['content'] ?>
</div>
</div>
<?php if (!empty($article['prompt_used'])): ?>
<div class="card mb-4">
<div class="card-header">
<h5 class="mb-0">Prompt użyty do generowania</h5>
</div>
<div class="card-body">
<pre class="mb-0" style="white-space: pre-wrap;"><?= htmlspecialchars($article['prompt_used']) ?></pre>
</div>
</div>
<?php endif; ?>
<?php if ($article['wp_post_id']): ?>
<script>
document.getElementById('imageFile').addEventListener('change', function() {
document.getElementById('btnReplaceImage').disabled = !this.files.length;
});
function replaceImage() {
var fileInput = document.getElementById('imageFile');
if (!fileInput.files.length) return;
if (!confirm('Podmienić zdjęcie wyróżniające na WordPressie?\n\nStare zdjęcie zostanie usunięte.')) return;
var btn = document.getElementById('btnReplaceImage');
btn.disabled = true;
btn.innerHTML = '<span class="spinner-border spinner-border-sm me-1"></span>Wgrywanie...';
var formData = new FormData();
formData.append('image', fileInput.files[0]);
fetch('/articles/<?= $article['id'] ?>/replace-image', {
method: 'POST',
headers: { 'X-Requested-With': 'XMLHttpRequest' },
body: formData
})
.then(function(r) { return r.json(); })
.then(function(data) {
if (data.success) {
btn.classList.remove('btn-outline-warning');
btn.classList.add('btn-outline-success');
btn.innerHTML = '<i class="bi bi-check-lg me-1"></i>Podmieniono!';
fileInput.value = '';
setTimeout(function() {
btn.classList.remove('btn-outline-success');
btn.classList.add('btn-outline-warning');
btn.innerHTML = '<i class="bi bi-upload me-1"></i>Podmień';
btn.disabled = true;
}, 3000);
} else {
alert(data.message || 'Błąd podmiany zdjęcia');
btn.disabled = false;
btn.innerHTML = '<i class="bi bi-upload me-1"></i>Podmień';
}
})
.catch(function() {
alert('Błąd połączenia');
btn.disabled = false;
btn.innerHTML = '<i class="bi bi-upload me-1"></i>Podmień';
});
}
</script>
<?php endif; ?>