Respect useCustomLinkForClassicWidgets for medialist and linklist#432
Respect useCustomLinkForClassicWidgets for medialist and linklist#432thorol wants to merge 4 commits into
Conversation
|
Moin, WalkthroughDie Änderung stellt Rückwärtskompatibilität her: ChangesWidget-Kompatibilität und Dokumentation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
lib/MForm/Parser/MFormParser.php (1)
1128-1152: ⚡ Quick winMoin, Code-Duplizierung in den Linklist-Widget-Branches.
Die DOM-Verarbeitung (Zeilen 1131-1139 und 1143-1151) ist in beiden Zweigen nahezu identisch. Nur der Aufruf von
getWidget()unterscheidet sich. Die DOM-Verarbeitung sollte nach der bedingten Widget-Auswahl einmalig erfolgen.♻️ Vorgeschlagene Refaktorierung
$value = is_array($item->getValue()) ? '' : (string) ($item->getValue() ?? ''); if (MForm::isUsingCustomLinkForClassicWidgets()) { $html = rex_var_custom_linklist::getWidget($id, $inputValue . '[' . $this->varIdStr($item) . ']', $value, $parameter); - - $dom = new DOMDocument('1.0', 'utf-8'); - @$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html); - $selects = $dom->getElementsByTagName('select'); - $inputs = $dom->getElementsByTagName('input'); - - $this->processNodeFormElements($selects, $item, 'REX_LINKLIST_SELECT_' . $id); - $this->processNodeFormElements($inputs, $item, 'REX_LINKLIST_' . $id); - - $this->prepareLinkInput($dom, $inputs, $item, $attributes); } else { $html = rex_var_linklist::getWidget($id, $inputValue . '[' . $this->varIdStr($item) . ']', $value, $parameter); + } - $dom = new DOMDocument('1.0', 'utf-8'); - @$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html); - $selects = $dom->getElementsByTagName('select'); - $inputs = $dom->getElementsByTagName('input'); - - $this->processNodeFormElements($selects, $item, 'REX_LINKLIST_SELECT_' . $id); - $this->processNodeFormElements($inputs, $item, 'REX_LINKLIST_' . $id); - - $this->prepareLinkInput($dom, $inputs, $item, $attributes); - } + $dom = new DOMDocument('1.0', 'utf-8'); + @$dom->loadHTML('<?xml encoding="utf-8" ?>' . $html); + $selects = $dom->getElementsByTagName('select'); + $inputs = $dom->getElementsByTagName('input'); + + $this->processNodeFormElements($selects, $item, 'REX_LINKLIST_SELECT_' . $id); + $this->processNodeFormElements($inputs, $item, 'REX_LINKLIST_' . $id); + + $this->prepareLinkInput($dom, $inputs, $item, $attributes); break;🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lib/MForm/Parser/MFormParser.php` around lines 1128 - 1152, Extract the differing widget creation into a single $html assignment by first using the conditional to call either rex_var_custom_linklist::getWidget(...) or rex_var_linklist::getWidget(...), then perform the DOM processing once: create DOMDocument, loadHTML, getElementsByTagName for 'select' and 'input', call $this->processNodeFormElements($selects, $item, 'REX_LINKLIST_SELECT_'.$id) and $this->processNodeFormElements($inputs, $item, 'REX_LINKLIST_'.$id), and finally $this->prepareLinkInput($dom, $inputs, $item, $attributes); keep MForm::isUsingCustomLinkForClassicWidgets(), $id, $inputValue.'['.$this->varIdStr($item).']', $value and $parameter exactly as used to build the widget.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@lib/MForm/Parser/MFormParser.php`:
- Line 330: Die Klasse wird ohne Trennzeichen angefügt; ändere den Aufruf so,
dass vor 'active' ein Leerzeichen eingefügt wird (z.B. ersetze
$item->setClass($item->getClass() . 'active') durch
$item->setClass(trim($item->getClass()) . ' active') oder baue bedingt ein
führendes Leerzeichen ein), referenziere dabei die Aufrufe von $item->getClass()
und $item->setClass() in MFormParser.
---
Nitpick comments:
In `@lib/MForm/Parser/MFormParser.php`:
- Around line 1128-1152: Extract the differing widget creation into a single
$html assignment by first using the conditional to call either
rex_var_custom_linklist::getWidget(...) or rex_var_linklist::getWidget(...),
then perform the DOM processing once: create DOMDocument, loadHTML,
getElementsByTagName for 'select' and 'input', call
$this->processNodeFormElements($selects, $item, 'REX_LINKLIST_SELECT_'.$id) and
$this->processNodeFormElements($inputs, $item, 'REX_LINKLIST_'.$id), and finally
$this->prepareLinkInput($dom, $inputs, $item, $attributes); keep
MForm::isUsingCustomLinkForClassicWidgets(), $id,
$inputValue.'['.$this->varIdStr($item).']', $value and $parameter exactly as
used to build the widget.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 4f9a1e4d-f4f5-4041-a2c2-532b4dd83df3
📒 Files selected for processing (2)
lib/MForm.phplib/MForm/Parser/MFormParser.php
| $attributes['data-tab-group-nav-tab-id'] = $item->getGroup() . $item->getGroupCount() . '_' . $item->getGroupKey(); | ||
| if (isset($attributes['data-group-open-tab']) && true === $attributes['data-group-open-tab']) { | ||
| $item->setClass(trim($item->getClass() . ' active')); | ||
| $item->setClass($item->getClass() . 'active'); |
There was a problem hiding this comment.
Moin, fehlendes Leerzeichen vor der CSS-Klasse active.
Die Klasse wird ohne Trennzeichen angehängt, was zu ungültigen CSS-Klassennamen führt (z. B. existing-classactive statt existing-class active).
🐛 Vorgeschlagener Fix
- $item->setClass($item->getClass() . 'active');
+ $item->setClass($item->getClass() . ' active');📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| $item->setClass($item->getClass() . 'active'); | |
| $item->setClass($item->getClass() . ' active'); |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@lib/MForm/Parser/MFormParser.php` at line 330, Die Klasse wird ohne
Trennzeichen angefügt; ändere den Aufruf so, dass vor 'active' ein Leerzeichen
eingefügt wird (z.B. ersetze $item->setClass($item->getClass() . 'active') durch
$item->setClass(trim($item->getClass()) . ' active') oder baue bedingt ein
führendes Leerzeichen ein), referenziere dabei die Aufrufe von $item->getClass()
und $item->setClass() in MFormParser.
Closes #431
Summary by CodeRabbit
Documentation
Bug Fixes