exposes custom collection meta

This commit is contained in:
buttle 2021-05-08 11:46:36 +02:00
parent 3671b05828
commit a0e79a272e
5 changed files with 18 additions and 10 deletions

View File

@ -8,6 +8,7 @@ return [
], ],
'template_map' => [ 'template_map' => [
'omeka/index/index' => __DIR__ . '/../../../themes/archive/view/omeka/site/index.phtml', 'omeka/index/index' => __DIR__ . '/../../../themes/archive/view/omeka/site/index.phtml',
'omeka/search/results' => __DIR__ . '/../../../themes/archive/view/omeka/search/results.phtml',
], ],
], ],
'view_helpers' => [ 'view_helpers' => [

View File

@ -1,5 +1,5 @@
[info] [info]
name = "Archove site meta" name = "Archive site meta"
description = "Add some meta vaule to pages" description = "Add some meta vaule to pages"
tags = "" tags = ""
license = "MIT" license = "MIT"

View File

@ -15,9 +15,9 @@ class ArchiveSiteMetaFactory implements FactoryInterface
return new ArchiveSiteMeta( return new ArchiveSiteMeta(
$services->get('FormElementManager'), $services->get('FormElementManager'),
$services->get('Config')['DefaultSettings']['ArchiveSiteMetaBlockForm'], $services->get('Config')['DefaultSettings']['ArchiveSiteMetaBlockForm'],
$settings->get('sitemeta_collections'), $settings->get('sitemeta_collections')
//$services->get('Config')['DefaultSettings']['ArchiveSiteMetaBlockForm'], //$services->get('Omeka\SiteSettings'),
//$settings->get('sitemeta_collections') //$services->get('Omeka\SiteSettings'),
); );
} }
} }

View File

@ -7,6 +7,8 @@ use Omeka\Api\Representation\SitePageBlockRepresentation;
use Omeka\Site\BlockLayout\AbstractBlockLayout; use Omeka\Site\BlockLayout\AbstractBlockLayout;
use Laminas\View\Renderer\PhpRenderer; use Laminas\View\Renderer\PhpRenderer;
use ArchiveSiteMeta\Site\BlockLayout\ContainerInterface;
use Laminas\Form\Element; use Laminas\Form\Element;
use Laminas\Form\FormElementManager; use Laminas\Form\FormElementManager;
@ -33,11 +35,15 @@ class ArchiveSiteMeta extends AbstractBlockLayout
*/ */
public function __construct(FormElementManager $formElementManager, public function __construct(FormElementManager $formElementManager,
array $defaultSettings, array $defaultSettings,
string $sitemeta_collections) string $sitemeta_collections
//ContainerInterface $site_settings
)
{ {
$this->formElementManager = $formElementManager; $this->formElementManager = $formElementManager;
$this->defaultSettings = $defaultSettings; $this->defaultSettings = $defaultSettings;
$this->sitemeta_collections = $sitemeta_collections; $this->sitemeta_collections = $sitemeta_collections;
//$this->services = $services;
} }
public function getLabel() { public function getLabel() {
@ -54,14 +60,15 @@ class ArchiveSiteMeta extends AbstractBlockLayout
$collection_options = []; $collection_options = [];
foreach ( explode("\n", $this->sitemeta_collections) as $value ) { foreach ( explode("\n", $this->sitemeta_collections) as $value ) {
$key_value = explode("=", $value); $key_value = explode("=", $value);
$collection_options[$key_value[1]] = $key_value[0]; $key = str_replace(array("\r", "\n"), '', $key_value[1]);
$collection_options[trim($key)] = $key_value[0];
} }
$form->add([ $form->add([
'name' => 'o:block[__blockIndex__][o:data][collection]', 'name' => 'o:block[__blockIndex__][o:data][collection]',
'type' => Element\Select::class, 'type' => Element\Select::class,
'options' => [ 'options' => [
'label' => "Collections", 'label' => "Collection",
'value_options' => $collection_options, 'value_options' => $collection_options,
], ],
]); ]);
@ -72,7 +79,7 @@ class ArchiveSiteMeta extends AbstractBlockLayout
$form->setData([ $form->setData([
'o:block[__blockIndex__][o:data][currator]' => $data['currator'], 'o:block[__blockIndex__][o:data][currator]' => $data['currator'],
'o:block[__blockIndex__][o:data][project_date]' => $data['project_date'], 'o:block[__blockIndex__][o:data][project_date]' => $data['project_date'],
'o:block[__blockIndex__][o:data][collection]' => $data['collection'], 'o:block[__blockIndex__][o:data][collection]' => trim($data['collection']),
]); ]);
$form->prepare(); $form->prepare();
//$form->collections = $this->sitemeta_collections; //$form->collections = $this->sitemeta_collections;

View File

@ -16,7 +16,7 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
{ {
public function __construct($omekaSettings) public function __construct($omekaSettings) #, $siteSettings)
{ {
$this->omekaSettings = $omekaSettings; $this->omekaSettings = $omekaSettings;
} }
@ -55,7 +55,7 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
return null; return null;
} }
public function getCollections($sites){ public function getCollections(){
$sitemeta_collections = $this->omekaSettings->get('sitemeta_collections'); $sitemeta_collections = $this->omekaSettings->get('sitemeta_collections');
$collections = []; $collections = [];
foreach ( explode("\n", $sitemeta_collections) as $value ) { foreach ( explode("\n", $sitemeta_collections) as $value ) {