Skip to content

Commit

Permalink
Change to fallback; implement in resource-values
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Oct 2, 2023
1 parent f533b85 commit f66d781
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 85 deletions.
6 changes: 3 additions & 3 deletions application/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@
'Omeka\Settings' => Service\Settings\SettingsFactory::class,
'Omeka\Settings\Site' => Service\Settings\SiteSettingsFactory::class,
'Omeka\Settings\User' => Service\Settings\UserSettingsFactory::class,
'Omeka\Settings\Multi' => Service\Settings\MultiSettingsFactory::class,
'Omeka\Settings\Fallback' => Service\Settings\FallbackSettingsFactory::class,
'Omeka\Job\Dispatcher' => Service\Job\DispatcherFactory::class,
'Omeka\Job\DispatchStrategy\PhpCli' => Service\Job\DispatchStrategy\PhpCliFactory::class,
'Omeka\Job\DispatchStrategy\Synchronous' => Service\Job\DispatchStrategy\SynchronousFactory::class,
Expand Down Expand Up @@ -384,7 +384,7 @@
'settings' => Service\ControllerPlugin\SettingsFactory::class,
'siteSettings' => Service\ControllerPlugin\SiteSettingsFactory::class,
'userSettings' => Service\ControllerPlugin\UserSettingsFactory::class,
'multiSettings' => Service\ControllerPlugin\MultiSettingsFactory::class,
'fallbackSettings' => Service\ControllerPlugin\FallbackSettingsFactory::class,
'status' => Service\ControllerPlugin\StatusFactory::class,
'viewHelpers' => Service\ControllerPlugin\ViewHelpersFactory::class,
'browse' => Service\ControllerPlugin\BrowseFactory::class,
Expand Down Expand Up @@ -467,7 +467,7 @@
'setting' => Service\ViewHelper\SettingFactory::class,
'userSetting' => Service\ViewHelper\UserSettingFactory::class,
'siteSetting' => Service\ViewHelper\SiteSettingFactory::class,
'multiSetting' => Service\ViewHelper\MultiSettingFactory::class,
'fallbackSetting' => Service\ViewHelper\FallbackSettingFactory::class,
'themeSetting' => Service\ViewHelper\ThemeSettingFactory::class,
'trigger' => Service\ViewHelper\TriggerFactory::class,
'userIsAllowed' => Service\ViewHelper\UserIsAllowedFactory::class,
Expand Down
36 changes: 18 additions & 18 deletions application/src/Form/SiteSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,6 @@ public function init()
'value' => $settings->get('show_page_pagination', true),
],
]);
$this->add([
'name' => 'property_label_information',
'type' => 'Select',
'options' => [
'element_group' => 'general',
'label' => 'Property label information', // @translate
'info' => 'The additional information that accompanies labels on resource pages.', // @translate
'value_options' => [
'none' => 'None', // @translate
'vocab' => 'Show Vocabulary', // @translate
'term' => 'Show Term', // @translate
],
],
'attributes' => [
'id' => 'property_label_information',
'value' => $settings->get('property_label_information', 'none'),
],
]);
$this->add([
'name' => 'show_user_bar',
'type' => 'radio',
Expand Down Expand Up @@ -265,6 +247,24 @@ public function init()
'value' => (bool) $settings->get('show_attached_pages', true),
],
]);
$this->add([
'name' => 'property_label_information',
'type' => 'Select',
'options' => [
'element_group' => 'show',
'label' => 'Property label information', // @translate
'info' => 'The additional information that accompanies labels on resource pages.', // @translate
'value_options' => [
'none' => 'None', // @translate
'vocab' => 'Show Vocabulary', // @translate
'term' => 'Show Term', // @translate
],
],
'attributes' => [
'id' => 'property_label_information',
'value' => $settings->get('property_label_information', 'none'),
],
]);
$this->add([
'name' => 'show_value_annotations',
'type' => 'select',
Expand Down
20 changes: 20 additions & 0 deletions application/src/Mvc/Controller/Plugin/FallbackSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
namespace Omeka\Mvc\Controller\Plugin;

use Omeka\Settings\FallbackSettings as FallbackSettingsService;
use Laminas\Mvc\Controller\Plugin\AbstractPlugin;

class FallbackSettings extends AbstractPlugin
{
protected $fallbackSettings;

public function __construct(FallbackSettingsService $fallbackSettings)
{
$this->fallbackSettings = $fallbackSettings;
}

public function __invoke()
{
return $this->fallbackSettings;
}
}
20 changes: 0 additions & 20 deletions application/src/Mvc/Controller/Plugin/MultiSettings.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
namespace Omeka\Service\ControllerPlugin;

use Interop\Container\ContainerInterface;
use Omeka\Mvc\Controller\Plugin\MultiSettings;
use Omeka\Mvc\Controller\Plugin\FallbackSettings;
use Laminas\ServiceManager\Factory\FactoryInterface;

class MultiSettingsFactory implements FactoryInterface
class FallbackSettingsFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $services, $requestedName, array $options = null)
{
return new MultiSettings($services->get('Omeka\Settings\Multi'));
return new FallbackSettings($services->get('Omeka\Settings\Fallback'));
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php
namespace Omeka\Service\Settings;

use Omeka\Settings\MultiSettings;
use Omeka\Settings\FallbackSettings;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Interop\Container\ContainerInterface;

class MultiSettingsFactory implements FactoryInterface
class FallbackSettingsFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $serviceLocator, $requestedName, array $options = null)
{
return new MultiSettings(
return new FallbackSettings(
$serviceLocator->get('Omeka\Settings'),
$serviceLocator->get('Omeka\Settings\Site'),
$serviceLocator->get('Omeka\Settings\User')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Omeka\Service\ViewHelper;

use Omeka\View\Helper\MultiSetting;
use Omeka\View\Helper\FallbackSetting;
use Laminas\ServiceManager\Factory\FactoryInterface;
use Interop\Container\ContainerInterface;

class MultiSettingFactory implements FactoryInterface
class FallbackSettingFactory implements FactoryInterface
{
public function __invoke(ContainerInterface $services, $requestedName, array $options = null)
{
return new MultiSetting($services->get('Omeka\Settings\Multi'));
return new FallbackSetting($services->get('Omeka\Settings\Fallback'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Omeka\Settings\SiteSettings;
use Omeka\Settings\UserSettings;

class MultiSettings
class FallbackSettings
{
protected $settings;
protected $siteSettings;
Expand All @@ -24,7 +24,7 @@ public function __construct(Settings $settings, SiteSettings $siteSettings, User
* Can select from the following sources: global, site, user.
*
* @param string $id The setting ID
* @param array $sources An array of setting sources in priority order
* @param array $sources An array of setting sources in fallback order
* @param mixed $default The default value
* @return mixed
*/
Expand Down
20 changes: 20 additions & 0 deletions application/src/View/Helper/FallbackSetting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
namespace Omeka\View\Helper;

use Omeka\Settings\FallbackSettings as FallbackSettingsService;
use Laminas\View\Helper\AbstractHelper;

class FallbackSetting extends AbstractHelper
{
protected $fallbackSettings;

public function __construct(FallbackSettingsService $fallbackSettings)
{
$this->fallbackSettings = $fallbackSettings;
}

public function __invoke($id, array $sources, $default = null)
{
return $this->fallbackSettings->get($id, $sources, $default);
}
}
20 changes: 0 additions & 20 deletions application/src/View/Helper/MultiSetting.php

This file was deleted.

19 changes: 6 additions & 13 deletions application/view/common/resource-values.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,12 @@
$translate = $this->plugin('translate');
$escape = $this->plugin('escapeHtml');

if ($this->status()->isSiteRequest()) {
$labelInfo = $this->siteSetting('property_label_information');
$showLocale = (bool) $this->siteSetting('show_locale_label', true);
$filterLocale = $this->siteSetting('filter_locale_values');
$lang = $this->lang();
$showValueAnnotations = $this->siteSetting('show_value_annotations');
} else {
$labelInfo = $this->setting('property_label_information');
$showLocale = true;
$filterLocale = false;
$lang = null;
$showValueAnnotations = true;
}
$labelInfo = $this->fallbackSetting('property_label_information', ['site', 'global'], 'none');
$showLocale = (bool) $this->fallbackSetting('show_locale_label', ['site'], true);
$filterLocale = (bool) $this->fallbackSetting('filter_locale_values', ['site'], false);
$showValueAnnotations = (bool) $this->fallbackSetting('show_value_annotations', ['site'], true);
$lang = $this->lang();

$filterLocaleCallback = function ($value) use ($lang) {
$valueLang = $value->lang();
return $valueLang == '' || strcasecmp($valueLang, $lang) === 0;
Expand Down

0 comments on commit f66d781

Please sign in to comment.