From e29be26c1875823b1a3449293b73e23b02281c36 Mon Sep 17 00:00:00 2001 From: CollectiveAccess Date: Fri, 10 Jan 2025 23:39:29 -0500 Subject: [PATCH] Add setting to control display of representations on object summaries --- app/models/ca_bundle_displays.php | 48 +++++++++++++++++-- .../views/editor/objects/summary_html.php | 6 ++- 2 files changed, 48 insertions(+), 6 deletions(-) diff --git a/app/models/ca_bundle_displays.php b/app/models/ca_bundle_displays.php index 1b59b24851..08b497b296 100755 --- a/app/models/ca_bundle_displays.php +++ b/app/models/ca_bundle_displays.php @@ -7,7 +7,7 @@ * ---------------------------------------------------------------------- * * Software by Whirl-i-Gig (http://www.whirl-i-gig.com) - * Copyright 2010-2024 Whirl-i-Gig + * Copyright 2010-2025 Whirl-i-Gig * * For more information visit http://www.CollectiveAccess.org * @@ -230,8 +230,24 @@ public function __construct($id=null, ?array $options=null) { parent::__construct($id, $options); + $this->initSettings(); + } + # ------------------------------------------------------ + /** + * + */ + public function load($id=null, $use_cache=true) { + $ret = parent::load($id, $use_cache); + $this->initSettings(); + return $ret; + } + # ------------------------------------------------------ + /** + * + */ + public function initSettings() { // - $this->setAvailableSettings([ + $settings = [ 'show_empty_values' => [ 'formatType' => FT_NUMBER, 'displayType' => DT_CHECKBOXES, @@ -268,7 +284,25 @@ public function __construct($id=null, ?array $options=null) { 'label' => _t('Show display in'), 'description' => _t('Restrict display to use in specific contexts. If no contexts are selected the display will be shown in all contexts.') ] - ]); + ]; + if((int)$this->get('table_num') === 57) { + $settings['show_representations'] = [ + 'formatType' => FT_TEXT, + 'displayType' => DT_SELECT, + 'width' => 4, 'height' => 1, + 'takesLocale' => false, + 'default' => 'all', + 'options' => [ + _t('No') => '', + _t('All') => 'all', + _t('Primary only') => 'primary' + ], + 'label' => _t('Display representations?'), + 'description' => _t('Display primary or all representations at top of display?') + ]; + } + + $this->setAvailableSettings($settings); } # ------------------------------------------------------ /** @@ -345,7 +379,13 @@ public function set($pa_fields, $pm_value="", $options=null) { if ($pa_fields === 'table_num') { return false; } } } - return parent::set($pa_fields, $pm_value, $options); + + $ret = parent::set($pa_fields, $pm_value, $options); + if((is_array($pa_fields) && isset($pa_fields['table_num'])) || ($oa_fields === 'table_num')) { + $this->initSettings(); + } + + return $ret; } # ------------------------------------------------------ public function __destruct() { diff --git a/themes/default/views/editor/objects/summary_html.php b/themes/default/views/editor/objects/summary_html.php index 2a9ca9dec0..5c6f1aeabf 100644 --- a/themes/default/views/editor/objects/summary_html.php +++ b/themes/default/views/editor/objects/summary_html.php @@ -7,7 +7,7 @@ * ---------------------------------------------------------------------- * * Software by Whirl-i-Gig (http://www.whirl-i-gig.com) - * Copyright 2010-2021 Whirl-i-Gig + * Copyright 2010-2025 Whirl-i-Gig * * For more information visit http://www.CollectiveAccess.org * @@ -30,7 +30,9 @@ $t_display = $this->getVar('t_display'); $placements = $this->getVar("placements"); - $reps = $t_item->getRepresentations(array("thumbnail", "small", "medium")); + + $show_reps = $t_display->getSetting('show_representations'); + $reps = (!in_array($show_reps, ['all', 'primary'], true)) ? [] : $t_item->getRepresentations(array("thumbnail", "small", "medium"), null, ['primaryOnly' => ($show_reps === 'primary')]); ?>