Skip to content

Conversation

@d0ubIeU
Copy link
Contributor

@d0ubIeU d0ubIeU commented Jan 25, 2026

A note has been added regarding open questions from other languages ​​in the admin panel.

Screenshot 2026-01-25

Summary by CodeRabbit

  • New Features
    • Show a warning alert on the Open Questions admin page when questions exist in other languages; includes language names, per-language counts (with correct singular/plural), and a hint to change the current language.
  • Localization
    • Added translation strings for the alert heading, descriptions, singular/plural wording, and language-change hint in supported languages.

✏️ Tip: You can customize this high-level summary in your review settings.

A note has been added regarding open questions from other languages ​​in the admin panel.
@coderabbitai
Copy link

coderabbitai bot commented Jan 25, 2026

📝 Walkthrough

Walkthrough

Adds per-language question retrieval and aggregation for the admin "open questions" page, passes per-language counts and UI messages to the template, conditionally renders a warning listing other-language question counts, and adds five new translation keys in German and English.

Changes

Cohort / File(s) Summary
Template UI Enhancement
phpmyfaq/assets/templates/admin/content/open-questions.twig
Adds if (otherCount > 0) block to render a warning alert with heading, pluralized description, a list of other languages with labels and count badges, and a language-change hint.
Controller Logic
phpmyfaq/src/phpMyFAQ/Controller/Administration/OpenQuestionsController.php
Detects current language, retrieves questions by language, aggregates counts for other languages, builds otherLangsData and otherCount, and supplies new UI message keys to the template.
Model API
phpmyfaq/src/phpMyFAQ/Question.php
Updates getAll() signature to getAll(bool $showAll = true, ?string $language = null): array and uses the provided or default language when fetching questions.
Repository Query
phpmyfaq/src/phpMyFAQ/Question/QuestionRepository.php
Adds conditional language filter in getAll(), applies it in the WHERE clause, preserves visibility filter and ordering.
Translations
phpmyfaq/translations/language_de.php, phpmyfaq/translations/language_en.php
Adds five new public translation entries: msgAttention, msgOtherQuestionsDesc, msgOtherQuestionDesc, msgChangeLanguageHint, and msgOpenQuestion.

Sequence Diagram(s)

sequenceDiagram
    participant Admin as Admin User
    participant Controller as OpenQuestionsController
    participant Question as Question Model
    participant Repository as QuestionRepository
    participant Template as Template Engine
    participant Browser as Browser/UI

    Admin->>Controller: Request open questions page
    Controller->>Controller: Determine current language
    Controller->>Question: getAll(showAll, currentLanguage)
    Question->>Question: Resolve target language
    Question->>Repository: getAll(targetLang, showAll)
    Repository->>Repository: Build conditional language filter
    Repository-->>Question: Return questions array
    Question-->>Controller: Return questions
    Controller->>Controller: Aggregate counts by language
    Controller->>Template: Pass currentLocale, questions, otherCount, otherLangsData, messages
    Template->>Template: Render questions table
    Template->>Template: If otherCount > 0: Render warning alert with language list
    Template-->>Browser: HTML response
    Browser->>Admin: Display page with language alert
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hopping through locales with cheer,

Counts and badges now appear,
Alerts that whisper "others near",
Rabbity nose twitches at each tongue clear,
A tiny hop — the admin can steer.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'open questions admin page expanded' accurately describes the main change: adding UI and functionality to display open questions from other languages in the admin panel.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Fix all issues with AI agents
In `@phpmyfaq/assets/templates/admin/content/open-questions.twig`:
- Around line 89-95: The template uses msgOtherQuestionDesc (singular) when
otherCount == 1 but the controller only provides msgOtherQuestionsDesc (plural);
update the controller (e.g., OpenQuestionsController, the method that builds the
template data / calls render) to also set msgOtherQuestionDesc to the correct
singular translation string (or derive it from msgOtherQuestionsDesc) before
rendering so the template has both msgOtherQuestionDesc and
msgOtherQuestionsDesc available.

In `@phpmyfaq/src/phpMyFAQ/Controller/Administration/OpenQuestionsController.php`:
- Line 47: The assigned-but-unused variable $session should be removed to
satisfy static analysis: delete the assignment using $this->container->get(id:
'session') (the $session variable) from the OpenQuestionsController code so no
unused variable remains; if session is actually needed elsewhere, instead access
it inline where used or keep a single reference in the relevant method (search
for $session and OpenQuestionsController to locate the code).
- Around line 97-100: In OpenQuestionsController, the view data array is missing
the singular translation key used by the template; add 'msgOtherQuestionDesc' =>
Translation::get(key: 'msgOtherQuestionDesc') alongside the existing
'msgOtherQuestionsDesc' entry so the template can correctly display the singular
case (otherCount == 1); update the data passed from the method that prepares
these translations in OpenQuestionsController to include this new key.

In `@phpmyfaq/src/phpMyFAQ/Question/QuestionRepository.php`:
- Around line 27-30: The constructor formatting in class QuestionRepository (the
__construct method with the private Configuration $configuration parameter)
violates the project's mago format rules; run the project's formatter (mago
format) on phpMyFAQ/Question/QuestionRepository.php or manually adjust the
constructor declaration to match project style (fix parameter spacing/commas and
indentation) and save so the mago format check passes.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@phpmyfaq/src/phpMyFAQ/Question/QuestionRepository.php`:
- Around line 125-130: The getAll method's behavior when $language is an empty
string currently treats that as "all languages" via $langFilter, which
contradicts the existing PHPDoc that implies a required language; update the
PHPDoc for QuestionRepository::getAll (and mention $language param) to clearly
state that passing an empty string will return questions from all languages, or
alternatively enforce a non-empty $language by validating $language and throwing
or normalizing it; pick one approach and make the doc and implementation
consistent (refer to getAll, $language, and $langFilter).

@thorsten thorsten merged commit 7f1aca7 into thorsten:main Jan 26, 2026
7 checks passed
@d0ubIeU d0ubIeU deleted the 4.2_dev branch January 26, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants