Skip to content

Commit

Permalink
Add setting to control display of representations on object summaries
Browse files Browse the repository at this point in the history
  • Loading branch information
collectiveaccess committed Jan 11, 2025
1 parent 67b9091 commit e29be26
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
48 changes: 44 additions & 4 deletions app/models/ca_bundle_displays.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
# ------------------------------------------------------
/**
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions themes/default/views/editor/objects/summary_html.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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')]);
?>
<div id="summary" style="clear: both;">
<?php
Expand Down

0 comments on commit e29be26

Please sign in to comment.