commit e999f52e867cdabb8715a9be2514d8e7c09f9f98 Author: buttle Date: Mon May 17 21:58:27 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..50b8144 --- /dev/null +++ b/Module.php @@ -0,0 +1,16 @@ + [ + 'template_path_stack' => [ + dirname(__DIR__) . '/view', + ] + ], + 'view_helpers' => [ + 'factories' => [ + 'headerImage' => Service\ViewHelper\HeaderImageViewHelperFactory::class, + ], + ], + 'block_layouts' => [ + 'factories' => [ + 'headerImage' => Service\BlockLayout\HeaderImageFactory::class, + ], + ], + 'form_elements' => [ + 'invokables' => [ + Form\HeaderImageBlockForm::class => Form\HeaderImageBlockForm::class, + ], + ], + 'DefaultSettings' => [ + 'HeaderImageBlockForm' => [ + '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..8cd1a09 --- /dev/null +++ b/config/module.ini @@ -0,0 +1,12 @@ +[info] +name = "arcHIVE theme header image" +description = "Each page displays this image above the main menu" +tags = "" +license = "MIT" +author = "Hangar.org" +author_link = "https://git.hangar.org/chris" +module_link = "https://git.hangar.org/arcHIVE-tech/HeaderImage" +support_link = "https://git.hangar.org/arcHIVE-tech/HeaderImage/issues" +configurable = false +version = "1.0.0" +omeka_version_constraint = "^3.0.1" diff --git a/src/Form/HeaderImageBlockForm.php b/src/Form/HeaderImageBlockForm.php new file mode 100644 index 0000000..d460b0f --- /dev/null +++ b/src/Form/HeaderImageBlockForm.php @@ -0,0 +1,14 @@ +get('FormElementManager'), + $services->get('Config')['DefaultSettings']['HeaderImageBlockForm'] + ); + } +} +?> \ No newline at end of file diff --git a/src/Service/ViewHelper/HeaderImageViewHelperFactory.php b/src/Service/ViewHelper/HeaderImageViewHelperFactory.php new file mode 100644 index 0000000..60689f3 --- /dev/null +++ b/src/Service/ViewHelper/HeaderImageViewHelperFactory.php @@ -0,0 +1,17 @@ +get('Config'); + return new HeaderImageViewHelper($services->get('Omeka\Settings')); + } +} diff --git a/src/Site/BlockLayout/HeaderImage.php b/src/Site/BlockLayout/HeaderImage.php new file mode 100644 index 0000000..d0a3ad4 --- /dev/null +++ b/src/Site/BlockLayout/HeaderImage.php @@ -0,0 +1,62 @@ +formElementManager = $formElementManager; + $this->defaultSettings = $defaultSettings; + } + + public function getLabel() { + return 'Header image'; + } + + public function form(PhpRenderer $view, + SiteRepresentation $site, + SitePageRepresentation $page = null, + SitePageBlockRepresentation $block = null + ) { + $form = $this->formElementManager->get(HeaderImageBlockForm::class); + $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) + { + return ""; + } +} diff --git a/src/View/Helper/HeaderImageViewHelper.php b/src/View/Helper/HeaderImageViewHelper.php new file mode 100644 index 0000000..6666180 --- /dev/null +++ b/src/View/Helper/HeaderImageViewHelper.php @@ -0,0 +1,46 @@ +omekaSettings = $omekaSettings; + } + + /** + * Get the page's meta image url. + * + * @param SitePageRepresentation + * @return string media url + */ + public function getImage($page) + { + foreach ($page->blocks() as $block) { + if ($block->layout() === 'headerImage') { + $attachments = $block->attachments(); + $media = $attachments[0]->item()->media()[0]; + return $media->primaryMedia()->thumbnailUrl('large'); + } + } + $site = $this->currentSite(); + return $this->getView()->getHelperPluginManager()->get('archiveSiteMeta')->getSiteImage($site); + } + + /** + * @return \Omeka\Api\Representation\SiteRepresentation + */ + protected function currentSite() + { + $view = $this->getView(); + return isset($view->site) + ? $view->site + : $view->getHelperPluginManager()->get('Laminas\View\Helper\ViewModel')->getRoot()->getVariable('site'); + } +}