Compare commits

..

2 Commits

Author SHA1 Message Date
buttle a0e79a272e exposes custom collection meta 2021-05-08 11:46:36 +02:00
buttle 3671b05828 removes unnecessary site iteration 2021-05-04 13:07:56 +02:00
5 changed files with 28 additions and 28 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,27 +55,19 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
return null; return null;
} }
public function getCollections($sites){ public function getCollections(){
$collections = $this->omekaSettings->get('sitemeta_collections'); $sitemeta_collections = $this->omekaSettings->get('sitemeta_collections');
$collection_options = []; $collections = [];
foreach ( explode("\n", $sitemeta_collections) as $value ) {
foreach ( explode("\n", $collections) as $value ) { if ($value == "") {
$key_value = explode("=", str_replace(array("\r", "\n"), '',$value)); continue;
$collection_options[trim($key_value[1])] = trim($key_value[0]);
} }
//return $collections; $key_value = explode("=", str_replace(array("\r", "\n"), '', $value));
//$site = $sites[0]->setting('sitemeta_collections'); if ($key_value) {
//$collections = []; $collections[trim($key_value[1])] = trim($key_value[0]);
$result = [];
foreach ($sites as $site) {
$settings = $this->getSiteMetaValues($site);
if ($settings && !in_array($settings['collection'], $result)) {
$name = $collection_options[$settings['collection']];
$result[$settings['collection']] = $name;
//array_push($collections, $settings['collection']);
} }
} }
return $result; return $collections;
} }
public function getPages() public function getPages()