Skip to content

Commit

Permalink
Merge pull request #283 from UN-OCHA/release-versions/v3.7.4
Browse files Browse the repository at this point in the history
release versions/v3.7.4
  • Loading branch information
berliner authored Dec 2, 2024
2 parents bea8bc6 + 22b36b2 commit 5da8d5a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/ncms_publisher.publisher.ghi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
37 changes: 37 additions & 0 deletions html/modules/custom/ncms_ui/ncms_ui.deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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, '<p>')) {
$lines = preg_split('/\r\n|\r|\n/', $value);
foreach ($lines as &$line) {
$line = preg_replace("/\s+/u", " ", $line);
$line = (string) Markup::create('<p>' . trim($line) . '</p>');
}
$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),
]);
}

0 comments on commit 5da8d5a

Please sign in to comment.