diff --git a/config/ncms_publisher.publisher.ghi.yml b/config/ncms_publisher.publisher.ghi.yml index 43dd2377..bb0e61c4 100755 --- a/config/ncms_publisher.publisher.ghi.yml +++ b/config/ncms_publisher.publisher.ghi.yml @@ -4,4 +4,4 @@ status: true dependencies: { } id: ghi label: 'Humanitarian Action' -known_hosts: "humanitarianaction.info\r\ndemo.humanitarianaction-info.ahconu.org\r\nstage.humanitarianaction-info.ahconu.org\r\ndev.humanitarianaction-info.ahconu.org\r\nghi-site.docksal.site" +known_hosts: "humanitarianaction.info\r\ndemo.humanitarianaction-info.ahconu.org\r\nstage.humanitarianaction-info.ahconu.org\r\nblue.dev.humanitarianaction-info.ahconu.org\r\nred.dev.humanitarianaction-info.ahconu.org\r\nghi-site.docksal.site" diff --git a/html/modules/custom/ncms_ui/ncms_ui.deploy.php b/html/modules/custom/ncms_ui/ncms_ui.deploy.php index fa1da803..e49608a6 100644 --- a/html/modules/custom/ncms_ui/ncms_ui.deploy.php +++ b/html/modules/custom/ncms_ui/ncms_ui.deploy.php @@ -7,6 +7,7 @@ use Drupal\content_moderation\Entity\ContentModerationState; use Drupal\content_moderation\Entity\ContentModerationStateInterface; +use Drupal\Core\Render\Markup; use Drupal\menu_link_content\Entity\MenuLinkContent; use Drupal\ncms_ui\Entity\ContentInterface; use Drupal\node\NodeInterface; @@ -311,3 +312,39 @@ function ncms_ui_deploy_set_collapsible_field_value(&$sandbox) { $paragraph->save(); } } + +/** + * Correct the text format for footnotes. + */ +function ncms_ui_deploy_correct_text_format_footnotes(&$sandbox) { + $storage = \Drupal::entityTypeManager()->getStorage('paragraph'); + $query = $storage->getQuery(); + $query->condition('type', 'text'); + $query->condition('field_footnotes.format', 'footnotes', '<>'); + $query->accessCheck(FALSE); + $results = $query->execute(); + /** @var \Drupal\paragraphs\ParagraphInterface[] $paragraphs */ + $paragraphs = $storage->loadMultiple($results); + + foreach ($paragraphs as $paragraph) { + $items = $paragraph->get('field_footnotes')->getValue(); + foreach ($items as &$item) { + $value = $item['value']; + if (!str_starts_with($value, '

')) { + $lines = preg_split('/\r\n|\r|\n/', $value); + foreach ($lines as &$line) { + $line = preg_replace("/\s+/u", " ", $line); + $line = (string) Markup::create('

' . trim($line) . '

'); + } + $value = implode("\n", $lines); + } + $item['value'] = $value; + $item['format'] = 'footnotes'; + } + $paragraph->get('field_footnotes')->setValue($items); + $paragraph->save(); + } + return t('Updated footnote text format on @count paragraphs.', [ + '@count' => count($paragraphs), + ]); +}