up templates wiki

This commit is contained in:
Tykayn 2025-09-01 00:53:58 +02:00 committed by tykayn
parent bd3d14e9f8
commit e61d932565

View file

@ -686,8 +686,22 @@ class WikiController extends AbstractController
return $this->redirectToRoute('app_admin_wiki');
}
// Select a random page from the outdated pages
$randomPage = $jsonData[array_rand($jsonData)];
// Combine regular_pages and specific_pages into a single array
$allPages = [];
if (isset($jsonData['regular_pages']) && is_array($jsonData['regular_pages'])) {
$allPages = array_merge($allPages, $jsonData['regular_pages']);
}
if (isset($jsonData['specific_pages']) && is_array($jsonData['specific_pages'])) {
$allPages = array_merge($allPages, $jsonData['specific_pages']);
}
if (empty($allPages)) {
$this->addFlash('error', 'Aucune page à améliorer n\'a été trouvée.');
return $this->redirectToRoute('app_admin_wiki');
}
// Select a random page from the combined pages
$randomPage = $allPages[array_rand($allPages)];
return $this->render('admin/wiki_random_suggestion.html.twig', [
'page' => $randomPage
@ -939,7 +953,7 @@ class WikiController extends AbstractController
]);
}
#[Route('/wiki/compare/{key}', name: 'app_admin_wiki_compare')]
#[Route('/wiki/compare/{key}', name: 'app_admin_wiki_compare', requirements: ['key' => '.+'])]
public function compare(string $key): Response
{
$csvFile = $this->getParameter('kernel.project_dir') . '/wiki_compare/wiki_pages.csv';
@ -980,9 +994,18 @@ class WikiController extends AbstractController
if (file_exists($jsonFile)) {
$jsonData = json_decode(file_get_contents($jsonFile), true);
// Check both regular_pages and specific_pages sections
$allPages = [];
if (isset($jsonData['regular_pages']) && is_array($jsonData['regular_pages'])) {
$allPages = array_merge($allPages, $jsonData['regular_pages']);
}
if (isset($jsonData['specific_pages']) && is_array($jsonData['specific_pages'])) {
$allPages = array_merge($allPages, $jsonData['specific_pages']);
}
foreach ($jsonData as $page) {
if ($page['key'] === $key) {
foreach ($allPages as $page) {
if (isset($page['key']) && $page['key'] === $key) {
$mediaComparison = $page['media_comparison'] ?? null;
// Deduplicate images by URL in the controller and filter out images that appear in both languages