commit 5b1f1a0239aebd10a320e30421d374c936b58bf8 Author: Chris Date: Tue Aug 10 13:32:24 2021 +0200 first commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9bd6b00 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Neo-Inspiration + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/Module.php b/Module.php new file mode 100644 index 0000000..532ffbe --- /dev/null +++ b/Module.php @@ -0,0 +1,29 @@ + '25 %', + '50' => '50 %', + '75' => '75 %', + '100' => '100 %', + ]; + + const ZOOM_TYPE = [ + '' => '', + 'zoom' => 'Touch / grab', + 'wheelzoom' => 'Deep zooming', + ]; + + public function getConfig() + { + return include __DIR__ . '/config/module.config.php'; + } +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..b74d7f4 --- /dev/null +++ b/README.md @@ -0,0 +1,20 @@ +# PDFLink media for Omeka S + +[PDFLink] is a module for [Omeka S] that adds PDF links with description text. + +## Install + +``` +cd ./modules +https://git.hangar.org/arcHIVE-tech/PDFLink/archive/main.zip +unzip main.zip +mv pdflink-omeka-module/ PDFLink +rm main.zip +``` + +## LISENCE +The module is released under the [MIT] License. + +[Omeka S]: https://omeka.org/s +[PDFLink]: https://git.hangar.org/arcHIVE-tech/PDFLink +[MIT]: http://opensource.org/licenses/MIT diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000..3077414 --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,29 @@ + [ + 'template_path_stack' => [ + dirname(__DIR__) . '/view', + ] + ], + 'block_layouts' => [ + 'factories' => [ + 'pDFLink' => Service\BlockLayout\PDFLinkFactory::class, + ], + ], + 'form_elements' => [ + 'invokables' => [ + Form\PDFLinkBlockForm::class => Form\PDFLinkBlockForm::class, + ], + ], + 'DefaultSettings' => [ + 'PDFLinkBlockForm' => [ + 'title' => '', + 'renderSourceLink' => true, + 'width' => 600, + 'zoom_type' => '', + 'wrapStyle' => 'overflow-y: hidden;display: flex;flex-direction: column;justify-content: center;', + ] + ] +]; diff --git a/config/module.ini b/config/module.ini new file mode 100644 index 0000000..328a002 --- /dev/null +++ b/config/module.ini @@ -0,0 +1,12 @@ +[info] +name = "Image viewer" +description = "View and optionally zoom images" +tags = "" +license = "MIT" +author = "Hangar.org" +author_link = "https://git.hangar.org/chris" +module_link = "https://git.hangar.org/arcHIVE-tech/PDFLink" +support_link = "https://git.hangar.org/arcHIVE-tech/PDFLink/issues" +configurable = false +version = "1.0.0" +omeka_version_constraint = "^3.0.1" diff --git a/src/Form/PDFLinkBlockForm.php b/src/Form/PDFLinkBlockForm.php new file mode 100644 index 0000000..8316c26 --- /dev/null +++ b/src/Form/PDFLinkBlockForm.php @@ -0,0 +1,50 @@ +add([ + 'name' => 'o:block[__blockIndex__][o:data][width]', + 'type' => Element\Select::class, + 'options' => [ + 'label' => 'Width', + 'value_options' => Module::IMAGE_WIDTH, + ], + ]); + + $this->add([ + 'name' => 'o:block[__blockIndex__][o:data][zoom_type]', + 'type' => Element\Select::class, + 'options' => [ + 'label' => 'Zooming', + 'value_options' => Module::ZOOM_TYPE, + ], + ]); + + $this->add([ + 'type' => Element\Checkbox::class, + 'name' => 'o:block[__blockIndex__][o:data][renderSourceLink]', + 'options' => [ + '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/Service/BlockLayout/PDFLinkFactory.php b/src/Service/BlockLayout/PDFLinkFactory.php new file mode 100644 index 0000000..4951c64 --- /dev/null +++ b/src/Service/BlockLayout/PDFLinkFactory.php @@ -0,0 +1,18 @@ +get('FormElementManager'), + $services->get('Config')['DefaultSettings']['PDFLinkBlockForm'] + ); + } +} +?> \ No newline at end of file diff --git a/src/Site/BlockLayout/PDFLink.php b/src/Site/BlockLayout/PDFLink.php new file mode 100644 index 0000000..018d42c --- /dev/null +++ b/src/Site/BlockLayout/PDFLink.php @@ -0,0 +1,88 @@ +formElementManager = $formElementManager; + $this->defaultSettings = $defaultSettings; + } + + public function getLabel() { + return 'Image viewer'; + } + + public function form(PhpRenderer $view, + SiteRepresentation $site, + SitePageRepresentation $page = null, + SitePageBlockRepresentation $block = null + ) { + $form = $this->formElementManager->get(PDFLinkBlockForm::class); + $data = $block + ? $block->data() + $this->defaultSettings + : $this->defaultSettings; + $form->setData([ + '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][renderSourceLink]' => $data['renderSourceLink'], + ]); + $form->prepare(); + + $html = ''; + $html .= $view->blockAttachmentsForm($block); + $html .= '

'; + $html .= $view->translate('Options'). '

'; + $html .= '
'; + $html .= $view->formCollection($form); + $html .= '
'; + return $html; + } + + public function render(PhpRenderer $view, SitePageBlockRepresentation $block) + { + $attachments = $block->attachments(); + if (!$attachments) { + return ''; + } + + $thumbnails = []; + static $id = 0; + + $media = $attachments[0]->item()->media()[0]; + return $view->partial('common/block-layout/pDFLink', [ + '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/pDFLink.phtml b/view/common/block-layout/pDFLink.phtml new file mode 100644 index 0000000..f4ee1e2 --- /dev/null +++ b/view/common/block-layout/pDFLink.phtml @@ -0,0 +1,68 @@ + + +headScript()->appendFile($this->assetUrl('vendor/wheelzoom/wheelzoom.js', + 'PDFLink')); + } + if ($zoom_type == "zoom") { + $this->headScript()->appendFile($this->assetUrl('vendor/zoom/jquery.zoom.min.js', + 'PDFLink')); + } + if ($zoom_type == "zoom" || $zoom_type == "wheelzoom") { + $this->headLink()->appendStylesheet($this->assetUrl('css/zoom.css', + 'PDFLink')); + } +?> + + + + + + + +
+ <?= $title ?> +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + + + + + + + + +