From 2882f5c11511379351412b45fc66f7c676ad8384 Mon Sep 17 00:00:00 2001
From: buttle
Date: Mon, 31 May 2021 19:29:45 +0200
Subject: [PATCH] renders source link and subtitle
---
config/module.config.php | 1 +
src/Form/ImageViewerBlockForm.php | 23 +++++------
src/Site/BlockLayout/ImageViewer.php | 4 +-
view/common/block-layout/imageViewer.phtml | 46 ++++++++++++++--------
4 files changed, 43 insertions(+), 31 deletions(-)
diff --git a/config/module.config.php b/config/module.config.php
index 63f5f66..808942b 100644
--- a/config/module.config.php
+++ b/config/module.config.php
@@ -20,6 +20,7 @@ return [
'DefaultSettings' => [
'ImageViewerBlockForm' => [
'title' => '',
+ 'renderSourceLink' => true,
'width' => 600,
'zoom_type' => '',
'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;',
diff --git a/src/Form/ImageViewerBlockForm.php b/src/Form/ImageViewerBlockForm.php
index 53d45ca..df185a5 100644
--- a/src/Form/ImageViewerBlockForm.php
+++ b/src/Form/ImageViewerBlockForm.php
@@ -10,15 +10,6 @@ class ImageViewerBlockForm extends Form
public function init()
{
- $this->add([
- 'name' => 'o:block[__blockIndex__][o:data][title]',
- 'type' => Element\Text::class,
- 'options' => [
- 'label' => 'Title (option)',
- ]
- ]);
-
-
$this->add([
'name' => 'o:block[__blockIndex__][o:data][width]',
'type' => Element\Select::class,
@@ -37,17 +28,23 @@ class ImageViewerBlockForm extends Form
],
]);
- /*
$this->add([
'type' => Element\Checkbox::class,
- 'name' => 'o:block[__blockIndex__][o:data][zoom]',
+ 'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]',
'options' => [
- 'label' => 'Zoom',
+ 'label' => 'Display a link to the item',
//'use_hidden_element' => true,
'checked_value' => true,
'unchecked_value' => false,
],
]);
- */
+
+ $this->add([
+ 'name' => 'o:block[__blockIndex__][o:data][title]',
+ 'type' => Element\Text::class,
+ 'options' => [
+ 'label' => 'Sub-title',
+ ]
+ ]);
}
}
diff --git a/src/Site/BlockLayout/ImageViewer.php b/src/Site/BlockLayout/ImageViewer.php
index 0bca3b6..30e7529 100644
--- a/src/Site/BlockLayout/ImageViewer.php
+++ b/src/Site/BlockLayout/ImageViewer.php
@@ -50,7 +50,7 @@ class ImageViewer extends AbstractBlockLayout
'o:block[__blockIndex__][o:data][title]' => $data['title'],
'o:block[__blockIndex__][o:data][width]' => $data['width'],
'o:block[__blockIndex__][o:data][zoom_type]' => $data['zoom_type'],
- //'o:block[__blockIndex__][o:data][zoom]' => $data['zoom'],
+ 'o:block[__blockIndex__][o:data][renderSourceLink]' => $data['renderSourceLink'],
]);
$form->prepare();
@@ -78,6 +78,8 @@ class ImageViewer extends AbstractBlockLayout
return $view->partial('common/block-layout/imageViewer', [
'zoom_type' => $block->dataValue('zoom_type'),
'title' => $block->dataValue('title'),
+ 'item_url' => $attachments[0]->item()->url(),
+ 'renderSourceLink' => $block->dataValue('renderSourceLink'),
'width' => $block->dataValue('width'),
'image' => $media->primaryMedia()->thumbnailUrl('large'),
'id' => 'iv-' . ++$id,
diff --git a/view/common/block-layout/imageViewer.phtml b/view/common/block-layout/imageViewer.phtml
index 2be22db..965823c 100644
--- a/view/common/block-layout/imageViewer.phtml
+++ b/view/common/block-layout/imageViewer.phtml
@@ -15,35 +15,23 @@
}
?>
- %s
', $title);
- } else {
- $title = false;
- }
- ?>
+
+
+
-
-
@@ -54,3 +42,27 @@
/>
+
+
+
+ = $title ?>
+
+
+
+
+
+
+
+
+
+
+
+