Skip to content

Commit

Permalink
feat: v4
Browse files Browse the repository at this point in the history
  • Loading branch information
Debian committed Apr 10, 2023
1 parent bbcd9ed commit 9a4c943
Show file tree
Hide file tree
Showing 6 changed files with 158 additions and 145 deletions.
4 changes: 2 additions & 2 deletions config/theme.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[info]
name = "Bootstrap 5"
version = "1.0.2"
version = "4.0.0"
author = "Satoru Nakamura"
description = "Omeka S theme based on bootstrap 5 - https://getbootstrap.com/"
theme_link = "https://github.com/ldasjp8/Omeka-S-theme-Bootstrap5"
author_link = "https://researchmap.jp/nakamura.satoru?lang=en"
omeka_version_constraint = "^3.0.0 || ^4.0.0"
omeka_version_constraint = "^4.0.0"

[config]
;elements.accent_color.name = "accent_color"
Expand Down
153 changes: 99 additions & 54 deletions view/common/linked-resources.phtml
Original file line number Diff line number Diff line change
@@ -1,88 +1,133 @@
<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
use Laminas\Form\Element\Select;

$fragment = 'item-linked';
if ('Omeka\Api\Representation\ItemSetRepresentation' === get_class($objectResource)) {
$fragment = 'item-set-linked';
}
// Set up pagination.
$pagination = $this->pagination(null, $totalCount, $page, $perPage);
$fragment = 'resources-linked';
$pagination->setFragment($fragment);
$showAltLabel = false;

// Set up locale.
$lang = null;
$filterLocale = false;
if ($this->status()->isSiteRequest()) {
$lang = $this->lang();
$filterLocale = (bool) $this->siteSetting('filter_locale_values');
}

// Set up resource property select.
$labelMap = [
'items' => 'Items', // @translate
'item_sets' => 'Item sets', // @translate
'media' => 'Media', // @translate
];
$resourcePropertiesSelect = new Select('resource_property');
$resourcePropertiesSelect->setValue($resourceProperty);
$resourcePropertiesSelect->setAttributes([
'id' => 'resource-property-select',
'class' => 'form-control',
'data-url' => $this->url(null, [], true),
'data-fragment' => $fragment,
]);
$valueOptions = [];
foreach ($resourcePropertiesAll as $type => $resourceProperties) {
if (!$resourceProperties) {
continue;
}
$valueOptions[$type] = [
'label' => $labelMap[$type],
'options' => [sprintf('%s:', $type) => sprintf('%s: All', $labelMap[$type])],
];
foreach ($resourceProperties as $resourceProperty) {
$key = sprintf('%s:%s', $type, $resourceProperty['id_concat']);
$value = $resourceProperty['property_alternate_label']
? $this->translate($resourceProperty['property_alternate_label'])
: $this->translate($resourceProperty['property_label']);
$valueOptions[$type]['options'][$key] = sprintf('%s: %s', $labelMap[$type], $value);
}
}
$resourcePropertiesSelect->setValueOptions($valueOptions);
?>
<div id="linked-resources">

<div class="linked-header">
<div id="linked-filter" class="mb-4">
<div class="form-group row">
<label for="staticEmail" class="col-sm-4 col-form-label"><?php echo $translate('Filter by property'); ?></label>
<label class="col-sm-4 col-form-label">
<?php echo $this->translate('Filter by resource type and property:'); ?>
</label>
<div class="col-sm-8">
<select id="filter-property" class="form-control" name="property" data-url="<?php echo $escape($this->url(null, [], true)); ?>" data-fragment="<?php echo $escape($fragment); ?>">
<option value=""><?php echo $translate('All'); ?></option>
<?php foreach ($properties as $prop): ?>
<option value="<?php echo $escape($prop->id()); ?>"<?php echo $prop->id() == $property ? ' selected="selected"' : ''; ?>><?php echo $escape(sprintf('%s (%s)', $prop->label(), $prop->term())); ?></option>
<?php endforeach; ?>
</select>

<?php echo $this->formElement($resourcePropertiesSelect); ?>
</div>
</div>
</div>
<!--
<div id="linked-filter">
<label>
<?php echo $this->translate('Filter by resource type and property:'); ?>
<?php echo $this->formElement($resourcePropertiesSelect); ?>
</label>
</div>
-->
<?php echo ($totalCount > $perPage) ? $pagination : ''; ?>
</div>

<?php foreach ($subjectValues as $term => $values): ?>
<?php foreach ($subjectValues as $values): ?>

<?php
$caption = sprintf(
$this->translate('%s with "%s: %s"'),
$this->translate($labelMap[$resourceType]),
$values[0]['property_alternate_label'] ?? $this->translate($values[0]['property_label']),
$objectResource->displayTitle()
);
?>

<div class="card my-4">
<div class="card-header">
<?php echo $escape($this->translate($values[0]->property()->label())); ?>
<?php echo $this->escapeHtml($caption); ?>
</div>
<div class="card-body">


<table class="table">
<thead>
<tr>
<th><?php echo $translate('Title'); ?></th>
<?php if ($showAltLabel): ?>
<th width="40%"><?php echo $translate('Alternate label'); ?></th>
<?php endif; ?>
<th width="20%"><?php echo $translate('Class'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($values as $value): ?>
<?php
$template = $value->resource()->resourceTemplate();
$templateProperty = $template ? $template->resourceTemplateProperty($value->property()->id()) : null;
$altLabel = $templateProperty ? $templateProperty->alternateLabel() : null;
?>
<tr class="linked-resource">
<td><?php echo $value->resource()->linkPretty(); ?></td>
<?php if ($showAltLabel): ?>
<td width="40%">
<?php if ($altLabel): ?>
<span class="alternate-label"><?php echo $this->escapeHtml($altLabel); ?></span>
<?php endif; ?>
<!-- <caption class="linked-resource-property"><?php echo $this->escapeHtml($caption); ?></caption> -->
<thead>
<tr>
<th><?php echo $this->translate('Title'); ?></th>
<th><?php echo $this->translate('Class'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($values as $value): ?>
<tr class="linked-resource">
<td><?php echo $value['val']->resource()->linkPretty('square', null, null, null, ($filterLocale ? $lang : null)); ?></td>
<td>
<?php if ($value['val']->resource()->resourceClass()): ?>
<span class="resource-class"><?php echo $this->escapeHtml($this->translate($value['val']->resource()->resourceClass()->label())); ?></span>
<?php endif; ?>
</td>
<?php endif; ?>
<td width="20%">
<?php if ($value->resource()->resourceClass()): ?>
<span class="resource-class"><?php echo $this->escapeHtml($value->resource()->resourceClass()->label()); ?></span>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</tr>
<?php endforeach; ?>
</tbody>
</table>

</div>
</div>

<?php endforeach; ?>

<?php echo ($totalCount > $perPage) ? '<div class="linked-footer">' . $pagination . '</div>' : ''; ?>

</div>

<script>
$('#filter-property').on('change', function(e) {
var thisSelect = $(this);
var property = thisSelect.find(':selected').val();
var url = thisSelect.data('url');
var fragment = thisSelect.data('fragment');
window.location = url + '?' + $.param({property: property}) + '#' + fragment;
const propertySelect = $('#resource-property-select');
const url = propertySelect.data('url');
const fragment = propertySelect.data('fragment');
propertySelect.on('change', function(e) {
const selectedOption = propertySelect.find(':selected');
const resourceProperty = selectedOption.val();
window.location = url + '?' + $.param({resource_property: resourceProperty}) + '#' + fragment;
});
</script>
29 changes: 29 additions & 0 deletions view/common/resource-page-block-layout/linked-resources.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
$translate = $this->plugin('translate');
$options = [
'page' => $this->params()->fromQuery('page', 1),
'perPage' => 25,
'resourceProperty' => $this->params()->fromQuery('resource_property'),
];
if ($this->siteSetting('exclude_resources_not_in_site')) {
$options['siteId'] = $this->currentSite()->id();
}
$subjectValues = $resource->displaySubjectValues($options);
?>
<?php if ($subjectValues): ?>

<div class="card my-5">
<div class="card-header">
<?php echo $translate('Linked resources'); ?>
</div>
<div class="card-body">

<div id="resources-linked">
<!-- <h3><?php echo $this->translate('Linked resources'); ?></h3> -->
<?php echo $subjectValues; ?>
</div>

</div>
</div>

<?php endif; ?>
10 changes: 10 additions & 0 deletions view/common/resource-page-block-layout/media-embeds.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
$resourceMedia = $resource->media();
?>
<?php if (false && $resourceMedia): ?>
<div class="media-embeds">
<?php foreach ($resourceMedia as $media): ?>
<?php echo $media->render(); ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
7 changes: 7 additions & 0 deletions view/common/resource-page-block-layout/values.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php
$options = [];
if ($this->siteSetting('exclude_resources_not_in_site')) {
$options['siteId'] = $this->currentSite()->id();
}
echo $resource->displayValues($options);
?>
100 changes: 11 additions & 89 deletions view/omeka/site/item/show.phtml
Original file line number Diff line number Diff line change
@@ -1,81 +1,27 @@
<?php
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');
$this->headLink()->appendStylesheet($this->assetUrl('css/resource-page-blocks.css', 'Omeka'));
$this->htmlElement('body')->appendAttribute('class', 'item resource show');
$embedMedia = $this->siteSetting('item_media_embed', false);
$itemMedia = $item->media();
$filterLocale = (bool) $this->siteSetting('filter_locale_values');
$lang = $this->lang();
?>

<!--
<?php if (/*$embedMedia && */$itemMedia): ?>
<div class="text-center bg-light mb-5">
<?php
$media = $itemMedia[0];
?>
<img src="<?php echo $media->thumbnailUrl('medium'); ?>"/>
</div>
<?php endif; ?>
-->

<?php $this->trigger('view.show.before'); ?>

<div class="container mt-4 mb-5" style="word-wrap : break-word;">
<div class="my-5">
<?php echo $this->pageTitle($item->displayTitle(null, ($filterLocale ? $lang : null)), 2); ?>
</div>

<?php echo $this->pageTitle($item->displayTitle(), 3); ?>

<div class="mt-5 mb-4">

<div class="card-body pt-4">

<?php echo $item->displayValues(); ?>

<div class="property">
<?php $itemSets = $item->itemSets(); ?>
<?php if (count($itemSets) > 0 and false): ?>
<dl class="row">
<dt class="col-sm-2">
<?php echo $translate('Item sets'); ?>
</dt>
<dd class="col-sm-10">
<?php foreach ($itemSets as $itemSet): ?>
<div class="value"><a
href="<?php echo $escape($itemSet->url()); ?>"><?php echo $itemSet->displayTitle(); ?></a>
</div>
<?php endforeach; ?>
</dd>
</dl>
<?php endif; ?>

</div>
</div>


<?php if (count($itemSets) > 0 and $this->themeSetting('show_collection') != "false"): ?>

<div class="my-5 pb-5 text-center">
<h4><?php echo $translate('Collection'); ?>
</h4>
<div>
<?php foreach ($itemSets as $itemSet): ?>
<div class="value mt-3"><a
href="<?php echo $escape($itemSet->url()); ?>"><?php echo $itemSet->displayTitle(); ?></a>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<!-- <h3><?php echo $translate('Item'); ?></h3> -->

</div>

<?php if ($embedMedia && $itemMedia): ?>
<div class="media-list">
<?php foreach ($itemMedia as $media): ?>
<?php echo $media->linkPretty(); ?>
<?php endforeach; ?>
<div class="my-5">
<?php echo $this->resourcePageBlocks($item)->getBlocks(); ?>
</div>
<?php endif; ?>

<div class="my-5 pb-5 text-center">
<div class="my-5 pb-5 text-center">
<div>
<b><?php echo $translate('Date Created'); ?>
</b>
Expand All @@ -93,29 +39,5 @@ $itemMedia = $item->media();
</div>
</div>

<?php
$page = $this->params()->fromQuery('page', 1);
$property = $this->params()->fromQuery('property');
try {
$subjectValues = $item->displaySubjectValues($page, 25, $property);
} catch (Throwable $e) {
$subjectValues = null;
}
?>
<?php if ($subjectValues): ?>
<div class="card">
<div class="card-header">
<?php echo $translate('Linked resources'); ?>
</div>
<div class="card-body">
<?php echo $subjectValues; ?>
</div>

</div>
<?php endif; ?>

<div class="my-4">
<?php $this->trigger('view.show.after'); ?>
</div>

<?php $this->trigger('view.show.after'); ?>
</div>

0 comments on commit 9a4c943

Please sign in to comment.