From f4cf40d715d650aea4d180bd2ad724e6e947dc77 Mon Sep 17 00:00:00 2001 From: Jim Safley Date: Thu, 1 Jun 2023 14:39:19 -0400 Subject: [PATCH] Add media render to media resource pages (fix #2058) --- application/Module.php | 2 +- .../20230601060113_AddMediaRender.php | 41 +++++++++++++++++++ .../Site/ResourcePageBlockLayout/Manager.php | 1 + 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 application/data/migrations/20230601060113_AddMediaRender.php diff --git a/application/Module.php b/application/Module.php index 6154879fc1..afa694a644 100644 --- a/application/Module.php +++ b/application/Module.php @@ -19,7 +19,7 @@ class Module extends AbstractModule /** * This Omeka version. */ - const VERSION = '4.1.0-alpha'; + const VERSION = '4.1.0-alpha5'; /** * The vocabulary IRI used to define Omeka application data. diff --git a/application/data/migrations/20230601060113_AddMediaRender.php b/application/data/migrations/20230601060113_AddMediaRender.php new file mode 100644 index 0000000000..4338299e29 --- /dev/null +++ b/application/data/migrations/20230601060113_AddMediaRender.php @@ -0,0 +1,41 @@ +get('Omeka\EntityManager')); + } + + public function __construct($em) + { + $this->em = $em; + } + + public function up(Connection $conn) + { + // Add the mediaRender resource page block layout to media pages that + // only have the values block layout. + $query = $this->em->createQuery('SELECT s FROM Omeka\Entity\SiteSetting s WHERE s.id LIKE :id'); + $query->setParameter('id', 'theme_settings_%'); + $siteSettings = $query->getResult(); + foreach ($siteSettings as $siteSetting) { + $value = $siteSetting->getValue(); + if (isset($value['resource_page_blocks']['media']['main']) + && 1 === count($value['resource_page_blocks']['media']['main']) + && 'values' === reset($value['resource_page_blocks']['media']['main']) + ) { + $value['resource_page_blocks']['media']['main'][] = 'mediaRender'; + $siteSetting->setValue($value); + } + } + $this->em->flush(); + } +} diff --git a/application/src/Site/ResourcePageBlockLayout/Manager.php b/application/src/Site/ResourcePageBlockLayout/Manager.php index b89afdb215..51ddc5ea1b 100644 --- a/application/src/Site/ResourcePageBlockLayout/Manager.php +++ b/application/src/Site/ResourcePageBlockLayout/Manager.php @@ -34,6 +34,7 @@ class Manager extends AbstractPluginManager 'media' => [ 'main' => [ 'values', + 'mediaRender', ], ], ];