Compare commits

..

No commits in common. "a0e79a272e954762990ecdd7ca1742b7377f25c7" and "9a4d3e282220ce3275b6c3ead30e445e34c14bd4" have entirely different histories.

5 changed files with 28 additions and 28 deletions

View File

@ -8,7 +8,6 @@ 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 = "Archive site meta" name = "Archove 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('Omeka\SiteSettings'), //$services->get('Config')['DefaultSettings']['ArchiveSiteMetaBlockForm'],
//$services->get('Omeka\SiteSettings'), //$settings->get('sitemeta_collections')
); );
} }
} }

View File

@ -7,8 +7,6 @@ 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;
@ -35,15 +33,11 @@ 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() {
@ -60,15 +54,14 @@ 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);
$key = str_replace(array("\r", "\n"), '', $key_value[1]); $collection_options[$key_value[1]] = $key_value[0];
$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' => "Collection", 'label' => "Collections",
'value_options' => $collection_options, 'value_options' => $collection_options,
], ],
]); ]);
@ -79,7 +72,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]' => trim($data['collection']), 'o:block[__blockIndex__][o:data][collection]' => $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) #, $siteSettings) public function __construct($omekaSettings)
{ {
$this->omekaSettings = $omekaSettings; $this->omekaSettings = $omekaSettings;
} }
@ -55,19 +55,27 @@ class ArchiveSiteMetaViewHelper extends AbstractHelper
return null; return null;
} }
public function getCollections(){ public function getCollections($sites){
$sitemeta_collections = $this->omekaSettings->get('sitemeta_collections'); $collections = $this->omekaSettings->get('sitemeta_collections');
$collections = []; $collection_options = [];
foreach ( explode("\n", $sitemeta_collections) as $value ) {
if ($value == "") { foreach ( explode("\n", $collections) as $value ) {
continue; $key_value = explode("=", str_replace(array("\r", "\n"), '',$value));
} $collection_options[trim($key_value[1])] = trim($key_value[0]);
$key_value = explode("=", str_replace(array("\r", "\n"), '', $value)); }
if ($key_value) { //return $collections;
$collections[trim($key_value[1])] = trim($key_value[0]); //$site = $sites[0]->setting('sitemeta_collections');
//$collections = [];
$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 $collections; return $result;
} }
public function getPages() public function getPages()