diff --git a/src/Controller/WikiController.php b/src/Controller/WikiController.php index 39b919c8..fcffd8b0 100644 --- a/src/Controller/WikiController.php +++ b/src/Controller/WikiController.php @@ -58,14 +58,14 @@ class WikiController extends AbstractController $alignedSections = []; // First, process common sections (they already have both en and fr) - if (isset($sectionComparison['common']) && is_array($sectionComparison['common'])) { - foreach ($sectionComparison['common'] as $section) { - $alignedSections[] = [ - 'en' => $section['en'], - 'fr' => $section['fr'] - ]; - } - } +// if (isset($sectionComparison['common']) && is_array($sectionComparison['common'])) { +// foreach ($sectionComparison['common'] as $section) { +// $alignedSections[] = [ +// 'en' => $section['en'], +// 'fr' => $section['fr'] +// ]; +// } +// } // Then, process English-only sections and add empty placeholders for French if (isset($sectionComparison['en_only']) && is_array($sectionComparison['en_only'])) { @@ -83,8 +83,8 @@ class WikiController extends AbstractController ]; } } - - // Finally, process French-only sections (these will be shown at the end) +// +// // Finally, process French-only sections (these will be shown at the end) if (isset($sectionComparison['fr_only']) && is_array($sectionComparison['fr_only'])) { foreach ($sectionComparison['fr_only'] as $section) { $alignedSections[] = [ @@ -121,7 +121,7 @@ class WikiController extends AbstractController if (isset($recentChangesData['recent_changes']) && is_array($recentChangesData['recent_changes'])) { $recentChanges = $recentChangesData['recent_changes']; $lastUpdated = isset($recentChangesData['last_updated']) ? $recentChangesData['last_updated'] : null; - + // Process team members statistics $teamMembers = $this->processTeamMembersStats($recentChanges); } @@ -156,22 +156,22 @@ class WikiController extends AbstractController 'team_members' => $teamMembers ]); } - + /** * Process team members statistics from recent changes data - * + * * @param array $recentChanges Recent changes data * @return array Team members statistics */ private function processTeamMembersStats(array $recentChanges): array { $teamMembers = []; - + // Group changes by user and count modifications foreach ($recentChanges as $change) { $user = $change['user']; $changeSize = $change['change_size']; - + // Initialize user data if not exists if (!isset($teamMembers[$user])) { $teamMembers[$user] = [ @@ -183,13 +183,13 @@ class WikiController extends AbstractController 'user_url' => "https://wiki.openstreetmap.org/wiki/User:" . urlencode($user) ]; } - + // Increment contribution count $teamMembers[$user]['contributions']++; - + // Process change size if (is_numeric($changeSize)) { - $changeSize = (int) $changeSize; + $changeSize = (int)$changeSize; if ($changeSize > 0) { $teamMembers[$user]['chars_added'] += $changeSize; } elseif ($changeSize < 0) { @@ -200,19 +200,19 @@ class WikiController extends AbstractController } } elseif (preg_match('/^\+(\d+)$/', $changeSize, $matches)) { // Format like "+123" - $teamMembers[$user]['chars_added'] += (int) $matches[1]; + $teamMembers[$user]['chars_added'] += (int)$matches[1]; } elseif (preg_match('/^−(\d+)$/', $changeSize, $matches)) { // Format like "−123" (note: this is not a regular minus sign) - $teamMembers[$user]['chars_deleted'] += (int) $matches[1]; + $teamMembers[$user]['chars_deleted'] += (int)$matches[1]; } } - + // Convert to indexed array and sort by contributions count (descending) $teamMembers = array_values($teamMembers); - usort($teamMembers, function($a, $b) { + usort($teamMembers, function ($a, $b) { return $b['contributions'] - $a['contributions']; }); - + return $teamMembers; } @@ -889,7 +889,7 @@ class WikiController extends AbstractController $missingTranslations[$key] = $languages['en']; } } - + // Calculate differences between English and French versions foreach ($wikiPages as $key => $languages) { @@ -933,7 +933,7 @@ class WikiController extends AbstractController $pagesUnavailableInEnglish = $pagesUnavailableInEnglishData['pages']; } } - + // Load specific pages from outdated_pages.json $specificPages = []; $outdatedPagesFile = $this->getParameter('kernel.project_dir') . '/wiki_compare/outdated_pages.json'; @@ -943,7 +943,7 @@ class WikiController extends AbstractController $specificPages = $outdatedPagesData['specific_pages']; } } - + // Load newly created French pages $newlyCreatedPages = []; $newlyCreatedPagesFile = $this->getParameter('kernel.project_dir') . '/wiki_compare/newly_created_french_pages.json'; @@ -1005,7 +1005,7 @@ 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'])) { diff --git a/templates/admin/wiki.html.twig b/templates/admin/wiki.html.twig index a53711b2..9f194894 100644 --- a/templates/admin/wiki.html.twig +++ b/templates/admin/wiki.html.twig @@ -13,6 +13,7 @@

Liste des pages wiki

+
@@ -153,16 +154,16 @@ class="btn btn-sm btn-outline-info" title="Version anglaise"> EN - {# #} - {# créer FR #} - {# #} - {# #} - {# Comparer #} - {# #} + + Traduire + + + Comparer + @@ -180,7 +181,8 @@

Pages spécifiques ({{ specific_pages|length }})

-

Ces pages wiki sont des pages spécifiques qui ont été sélectionnées pour une comparaison particulière.

+

Ces pages wiki sont des pages spécifiques qui ont été sélectionnées pour une comparaison + particulière.

@@ -198,7 +200,8 @@
{% if page.en_page.description_img_url is defined and page.en_page.description_img_url %}
- {{ page.key }}
{% endif %} @@ -215,10 +218,10 @@ {% if page.staleness_score is defined %}
{% set score_class = page.staleness_score > 70 ? 'bg-danger' : (page.staleness_score > 40 ? 'bg-warning' : 'bg-success') %} -
{{ page.staleness_score }}
@@ -277,7 +280,7 @@
{% if page.description_img_url is defined and page.description_img_url %}
- {{ page.title }}
{% endif %} @@ -290,10 +293,10 @@ {% if page.outdatedness_score is defined %}
{% set score_class = page.outdatedness_score > 70 ? 'bg-danger' : (page.outdatedness_score > 40 ? 'bg-warning' : 'bg-success') %} -
{{ page.outdatedness_score }}
@@ -331,7 +334,8 @@

Pages françaises récemment créées ({{ newly_created_pages|length }})

-

Ces pages wiki françaises ont été récemment créées et étaient auparavant dans la liste des pages non disponibles en français.

+

Ces pages wiki françaises ont été récemment créées et étaient auparavant dans la liste des pages + non disponibles en français.

@@ -383,7 +387,7 @@ {% endif %} - +

le score de fraîcheur prend en compte d'avantage la différence entre le nombre de mots que l'ancienneté de modification. diff --git a/templates/admin/wiki_compare.html.twig b/templates/admin/wiki_compare.html.twig index 08c903a2..f95cbffd 100644 --- a/templates/admin/wiki_compare.html.twig +++ b/templates/admin/wiki_compare.html.twig @@ -5,6 +5,46 @@ {% block body %}