1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-18 12:31:17 +02:00

Fix issue processwire/processwire-issues#542 in InputfieldRepeater.module repeater item titles, where numbered HTML entities (like the one for apostrophe) were getting their "#" character removed, making it look like double encoding

This commit is contained in:
Ryan Cramer
2018-03-16 07:40:36 -04:00
parent 19a55c6d37
commit 6c4f4103d2

View File

@@ -132,8 +132,19 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
if($page->id && $repeaterTitle) {
// custom repeater titles specified
$hasCnt = stripos($repeaterTitle, '#n') !== false;
if($this->wire('sanitizer')->fieldName($repeaterTitle) === $repeaterTitle) {
// update index numbers?
if($hasCnt) {
// replace "#n" with index number of repeater item
$repeaterTitle = str_replace("#n", "#$cnt", $repeaterTitle);
}
if(strpos($repeaterTitle, '{') !== false) {
// formatted {label}
$out = $page->getMarkup($repeaterTitle);
} else if(!$hasCnt && $this->wire('sanitizer')->fieldName($repeaterTitle) === $repeaterTitle) {
// just a single field name
$value = $page->getFormatted($repeaterTitle);
if(is_object($value)) {
@@ -145,24 +156,12 @@ class InputfieldRepeater extends Inputfield implements InputfieldItemList {
$out = (string) $value;
}
}
} else if(strpos($repeaterTitle, '{') !== false) {
// formatted {label}
$out = $page->getMarkup($repeaterTitle);
} else {
// label, but with no page variables
$out = $repeaterTitle;
}
$out = strip_tags(trim($out));
// update index numbers?
if(stripos($out, '#n') !== false) {
// replace "#n" with index number of repeater item
$out = preg_replace('/#n\b/i', "#$cnt", $out);
} else {
// otherwise remove any pound signs so the JS side doesn't detect them
$out = str_replace('#', '', $out);
}
}
if(!strlen($out)) {