diff --git a/CHANGELOG.md b/CHANGELOG.md index d7ca08a..fe86bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- ### Adds search frontend and settings + This update: + - Adds a search modal which appears when clicking on the search icon in the top bar. + - Adds a new "Pages and search" tab to CU Boulder site settings (`/admin/config/cu-boulder/pages`). This tab contains settings accessible to Architect, Developer, and Site Manager: + - The home page setting (moved from "General"). + - Options to enable site search, all of Colorado.edu search (default), both, or neither. + - Configuration for the site search label, placeholder, and URL. + - Renames "Appearance" to "Appearance and layout" and alters the descriptions of menu items. + - Adds the [Google Programmable Search Engine](https://www.drupal.org/project/google_cse) module, which allows creating custom search pages to use with site search. + + CuBoulder/tiamat-theme#266 + + Sister PR in: [tiamat-theme](https://github.com/CuBoulder/tiamat-theme/pull/527), [tiamat10-profile](https://github.com/CuBoulder/tiamat10-profile/pull/43), [tiamat10-project-template](https://github.com/CuBoulder/tiamat10-project-template/pull/17) +--- + - ### Adds home page setting to CU Boulder site settings This update to CU Boulder Site Configuration: - Adds a new home page setting to CU Boulder site settings. Resolves CuBoulder/tiamat-theme#506 diff --git a/config/install/ucb_site_configuration.configuration.yml b/config/install/ucb_site_configuration.configuration.yml index 69701fc..3dd86dc 100644 --- a/config/install/ucb_site_configuration.configuration.yml +++ b/config/install/ucb_site_configuration.configuration.yml @@ -162,6 +162,17 @@ site_affiliation_options: label: 'A CU Boulder Sport Club' type_restricted: true +site_search_options: + custom: + url: '' + label: 'This site' + placeholder: 'Search this site' + default: + url: 'https://www.colorado.edu/search' + label: 'All of Colorado.edu' + placeholder: 'Search Colorado.edu' + parameter: 'cse' + external_services: mainstay: label: Mainstay diff --git a/config/install/ucb_site_configuration.settings.yml b/config/install/ucb_site_configuration.settings.yml index 7391f01..ce626af 100644 --- a/config/install/ucb_site_configuration.settings.yml +++ b/config/install/ucb_site_configuration.settings.yml @@ -4,6 +4,10 @@ site_type: '' site_affiliation: '' site_affiliation_label: '' site_affiliation_url: '' +site_search_enabled: + - default +site_search_label: '' +site_search_url: '' related_articles_enabled_by_default: FALSE related_articles_exclude_categories: [] diff --git a/src/Controller/SiteSettingsAccessController.php b/src/Controller/SiteSettingsAccessController.php deleted file mode 100644 index 4aa5270..0000000 --- a/src/Controller/SiteSettingsAccessController.php +++ /dev/null @@ -1,29 +0,0 @@ -hasPermission('edit ucb site general') || $account->hasPermission('edit ucb site pages')); - } - -} diff --git a/src/Form/GeneralForm.php b/src/Form/GeneralForm.php index 90cb1c4..1e1e3b0 100644 --- a/src/Form/GeneralForm.php +++ b/src/Form/GeneralForm.php @@ -5,43 +5,14 @@ use Drupal\Core\Config\ConfigFactoryInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; -use Drupal\Core\Path\PathValidatorInterface; -use Drupal\Core\Routing\RequestContext; -use Drupal\Core\Session\AccountInterface; -use Drupal\path_alias\AliasManagerInterface; use Drupal\ucb_site_configuration\SiteConfiguration; use Symfony\Component\DependencyInjection\ContainerInterface; /** * The form for the "General" tab in CU Boulder site settings. - * - * While "Pages" could eventually be split off into its own tab, the settings - * are found under "General", at least for now. "General" and "Pages" require - * different permissions to access. */ class GeneralForm extends ConfigFormBase { - /** - * The current user. - * - * @var \Drupal\Core\Session\AccountInterface - */ - protected $user; - - /** - * The path alias manager. - * - * @var \Drupal\path_alias\AliasManagerInterface - */ - protected $aliasManager; - - /** - * The path validator. - * - * @var \Drupal\Core\Path\PathValidatorInterface - */ - protected $pathValidator; - /** * The request context. * @@ -61,23 +32,11 @@ class GeneralForm extends ConfigFormBase { * * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory * The config factory. - * @param \Drupal\Core\Session\AccountInterface $user - * The current user. - * @param \Drupal\path_alias\AliasManagerInterface $alias_manager - * The path alias manager. - * @param \Drupal\Core\Path\PathValidatorInterface $path_validator - * The path validator. - * @param \Drupal\Core\Routing\RequestContext $request_context - * The request context. * @param \Drupal\ucb_site_configuration\SiteConfiguration $service * The site configuration service defined in this module. */ - public function __construct(ConfigFactoryInterface $config_factory, AccountInterface $user, AliasManagerInterface $alias_manager, PathValidatorInterface $path_validator, RequestContext $request_context, SiteConfiguration $service) { + public function __construct(ConfigFactoryInterface $config_factory, SiteConfiguration $service) { parent::__construct($config_factory); - $this->user = $user; - $this->aliasManager = $alias_manager; - $this->pathValidator = $path_validator; - $this->requestContext = $request_context; $this->service = $service; } @@ -92,10 +51,6 @@ public function __construct(ConfigFactoryInterface $config_factory, AccountInter public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), - $container->get('current_user'), - $container->get('path_alias.manager'), - $container->get('path.validator'), - $container->get('router.request_context'), $container->get('ucb_site_configuration') ); } @@ -116,131 +71,93 @@ public function getFormId() { /** * {@inheritdoc} - * - * @see \Drupal\system\Form\SiteInformationForm::buildForm - * Contains the definition of a home page field. */ public function buildForm(array $form, FormStateInterface $form_state) { $configuration = $this->service->getConfiguration(); $settings = $this->service->getSettings(); $systemSiteSettings = $this->config('system.site'); - if ($this->user->hasPermission('edit ucb site general')) { - $siteTypeOptions = $configuration->get('site_type_options'); - $siteAffiliationOptions = array_filter($configuration->get('site_affiliation_options'), function ($value) { - return !$value['type_restricted']; - }); - $form['site_name'] = [ - '#type' => 'textfield', - '#title' => $this->t('Site name'), - '#default_value' => $systemSiteSettings->get('name'), - '#required' => TRUE, - ]; - $form['site_type'] = [ + $siteTypeOptions = $configuration->get('site_type_options'); + $siteAffiliationOptions = array_filter($configuration->get('site_affiliation_options'), function ($value) { + return !$value['type_restricted']; + }); + $form['site_name'] = [ + '#type' => 'textfield', + '#title' => $this->t('Site name'), + '#default_value' => $systemSiteSettings->get('name'), + '#required' => TRUE, + ]; + $form['site_type'] = [ + '#type' => 'select', + '#title' => $this->t('Type'), + '#default_value' => $settings->get('site_type'), + '#options' => array_merge(['' => $this->t('- None -')], array_map(function ($value) { + return $value['label']; + }, $siteTypeOptions)), + '#required' => FALSE, + ]; + $affiliationHidesOn = []; + foreach ($siteTypeOptions as $siteTypeId => $siteType) { + if (isset($siteType['affiliation'])) { + array_push($affiliationHidesOn, [':input[name="site_type"]' => ['value' => $siteTypeId]]); + } + } + $form['site_affiliation_container'] = [ + '#type' => 'container', + '#states' => [ + 'invisible' => $affiliationHidesOn, + ], + 'site_affiliation' => [ '#type' => 'select', - '#title' => $this->t('Type'), - '#default_value' => $settings->get('site_type'), + '#title' => $this->t('Affiliation'), + '#default_value' => $settings->get('site_affiliation'), '#options' => array_merge(['' => $this->t('- None -')], array_map(function ($value) { - return $value['label']; - }, $siteTypeOptions)), + return $value['label']; + }, $siteAffiliationOptions), ['custom' => $this->t('Custom')]), '#required' => FALSE, - ]; - $affiliationHidesOn = []; - foreach ($siteTypeOptions as $siteTypeId => $siteType) { - if (isset($siteType['affiliation'])) { - array_push($affiliationHidesOn, [':input[name="site_type"]' => ['value' => $siteTypeId]]); - } - } - $form['site_affiliation_container'] = [ - '#type' => 'container', + ], + 'site_affiliation_custom' => [ + '#type' => 'fieldset', + '#description' => $this->t('Define a title and optional URL for the custom affiliation.'), '#states' => [ - 'invisible' => $affiliationHidesOn, + 'visible' => [[':input[name="site_affiliation"]' => ['value' => 'custom']]], ], - 'site_affiliation' => [ - '#type' => 'select', - '#title' => $this->t('Affiliation'), - '#default_value' => $settings->get('site_affiliation'), - '#options' => array_merge(['' => $this->t('- None -')], array_map(function ($value) { - return $value['label']; - }, $siteAffiliationOptions), ['custom' => $this->t('Custom')]), + 'site_affiliation_label' => [ + '#type' => 'textfield', + '#title' => $this->t('Title'), + '#default_value' => $settings->get('site_affiliation_label'), '#required' => FALSE, + '#maxlength' => 255, ], - 'site_affiliation_custom' => [ - '#type' => 'fieldset', - '#description' => $this->t('Define a title and optional URL for the custom affiliation.'), - '#states' => [ - 'visible' => [[':input[name="site_affiliation"]' => ['value' => 'custom']]], - ], - 'site_affiliation_label' => [ - '#type' => 'textfield', - '#title' => $this->t('Title'), - '#default_value' => $settings->get('site_affiliation_label'), - '#required' => FALSE, - '#maxlength' => 255, - ], - 'site_affiliation_url' => [ - '#type' => 'textfield', - '#title' => $this->t('URL'), - '#default_value' => $settings->get('site_affiliation_url'), - '#required' => FALSE, - '#maxlength' => 255, - ], + 'site_affiliation_url' => [ + '#type' => 'textfield', + '#title' => $this->t('URL'), + '#default_value' => $settings->get('site_affiliation_url'), + '#required' => FALSE, + '#maxlength' => 255, ], - ]; - } - if ($this->user->hasPermission('edit ucb site pages')) { - $form['site_frontpage'] = [ - '#type' => 'textfield', - '#title' => $this->t('Home page'), - '#default_value' => $this->aliasManager->getAliasByPath($systemSiteSettings->get('page.front')), - '#required' => TRUE, - '#size' => 40, - '#description' => $this->t('Specify a relative URL to display as the home page.'), - '#field_prefix' => $this->requestContext->getCompleteBaseUrl(), - ]; - } + ], + ]; return parent::buildForm($form, $form_state); } - /** - * {@inheritdoc} - * - * @see \Drupal\system\Form\SiteInformationForm::validateForm - * Contains the validation of a home page path. - */ - public function validateForm(array &$form, FormStateInterface $form_state) { - if ($this->user->hasPermission('edit ucb site pages')) { - if (($value = $form_state->getValue('site_frontpage')) && $value[0] !== '/') { - $form_state->setErrorByName('site_frontpage', $this->t("The path '%path' has to start with a slash.", ['%path' => $form_state->getValue('site_frontpage')])); - } - if (!$this->pathValidator->isValid($form_state->getValue('site_frontpage'))) { - $form_state->setErrorByName('site_frontpage', $this->t("The path '%path' is invalid.", ['%path' => $form_state->getValue('site_frontpage')])); - } - } - } - /** * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $configuration = $this->service->getConfiguration(); - if ($this->user->hasPermission('edit ucb site general')) { - $siteTypeOptions = $configuration->get('site_type_options'); - $this->config('system.site')->set('name', $form_state->getValue('site_name'))->save(); - $siteTypeId = $form_state->getValue('site_type'); - $siteAffiliationId = $form_state->getValue('site_affiliation'); - if ($siteTypeId && isset($siteTypeOptions[$siteTypeId]) && isset($siteTypeOptions[$siteTypeId]['affiliation'])) { - $siteAffiliationId = $siteTypeOptions[$siteTypeId]['affiliation']; - } - $this->config('ucb_site_configuration.settings') - ->set('site_type', $siteTypeId) - ->set('site_affiliation', $siteAffiliationId) - ->set('site_affiliation_label', $form_state->getValue('site_affiliation_label')) - ->set('site_affiliation_url', $form_state->getValue('site_affiliation_url')) - ->save(); - } - if ($this->user->hasPermission('edit ucb site pages')) { - $this->config('system.site')->set('page.front', $form_state->getValue('site_frontpage'))->save(); + $siteTypeOptions = $configuration->get('site_type_options'); + $this->config('system.site')->set('name', $form_state->getValue('site_name'))->save(); + $siteTypeId = $form_state->getValue('site_type'); + $siteAffiliationId = $form_state->getValue('site_affiliation'); + if ($siteTypeId && isset($siteTypeOptions[$siteTypeId]) && isset($siteTypeOptions[$siteTypeId]['affiliation'])) { + $siteAffiliationId = $siteTypeOptions[$siteTypeId]['affiliation']; } + $this->config('ucb_site_configuration.settings') + ->set('site_type', $siteTypeId) + ->set('site_affiliation', $siteAffiliationId) + ->set('site_affiliation_label', $form_state->getValue('site_affiliation_label')) + ->set('site_affiliation_url', $form_state->getValue('site_affiliation_url')) + ->save(); parent::submitForm($form, $form_state); } diff --git a/src/Form/PagesForm.php b/src/Form/PagesForm.php new file mode 100644 index 0000000..ae1ca34 --- /dev/null +++ b/src/Form/PagesForm.php @@ -0,0 +1,218 @@ +aliasManager = $alias_manager; + $this->pathValidator = $path_validator; + $this->requestContext = $request_context; + $this->service = $service; + } + + /** + * {@inheritdoc} + * + * @param \Symfony\Component\DependencyInjection\ContainerInterface $container + * The container that allows getting any needed services. + * + * @link https://www.drupal.org/node/2133171 For more on dependency injection + */ + public static function create(ContainerInterface $container) { + return new static( + $container->get('config.factory'), + $container->get('path_alias.manager'), + $container->get('path.validator'), + $container->get('router.request_context'), + $container->get('ucb_site_configuration') + ); + } + + /** + * {@inheritdoc} + */ + protected function getEditableConfigNames() { + return ['system.site', 'ucb_site_configuration.settings']; + } + + /** + * {@inheritdoc} + */ + public function getFormId() { + return 'ucb_site_configuration_pages_form'; + } + + /** + * {@inheritdoc} + * + * @see \Drupal\system\Form\SiteInformationForm::buildForm + * Contains the definition of a home page field. + */ + public function buildForm(array $form, FormStateInterface $form_state) { + $configuration = $this->service->getConfiguration(); + $settings = $this->service->getSettings(); + $systemSiteSettings = $this->config('system.site'); + $siteSearchOptions = $configuration->get('site_search_options'); + $siteSearchEnabled = $settings->get('site_search_enabled'); + $form['site_frontpage'] = [ + '#type' => 'textfield', + '#title' => $this->t('Home page'), + '#default_value' => $this->aliasManager->getAliasByPath($systemSiteSettings->get('page.front')), + '#required' => TRUE, + '#size' => 40, + '#description' => $this->t('Specify a relative URL to display as the site home page.'), + '#field_prefix' => $this->requestContext->getCompleteBaseUrl(), + ]; + $form['site_search_enabled'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Enable searching'), + ]; + foreach ($siteSearchOptions as $key => $value) { + $form['site_search_enabled']['site_search_enabled_' . $key] = [ + '#type' => 'checkbox', + '#title' => $value['label'], + '#default_value' => in_array($key, $siteSearchEnabled), + ]; + } + $form['site_search'] = [ + '#type' => 'fieldset', + '#title' => $this->t('Site search'), + '#states' => [ + 'visible' => [[':input[name="site_search_enabled_custom"]' => ['checked' => TRUE]]], + ], + ]; + $form['site_search']['site_search_label'] = [ + '#type' => 'textfield', + '#title' => $this->t('Label'), + '#default_value' => $settings->get('site_search_label'), + '#placeholder' => $siteSearchOptions['custom']['label'], + '#required' => FALSE, + '#size' => 32, + '#description' => $this->t('Leave blank to use the default label.'), + ]; + $form['site_search']['site_search_placeholder'] = [ + '#type' => 'textfield', + '#title' => $this->t('Placeholder'), + '#default_value' => $settings->get('site_search_placeholder'), + '#placeholder' => $siteSearchOptions['custom']['placeholder'], + '#required' => FALSE, + '#size' => 32, + '#description' => $this->t('Leave blank to use the default placeholder.'), + ]; + $form['site_search']['site_search_url'] = [ + '#type' => 'textfield', + '#title' => $this->t('Search page'), + '#default_value' => $settings->get('site_search_url') ? $this->aliasManager->getAliasByPath($settings->get('site_search_url')) : '', + '#states' => [ + 'required' => [[':input[name="site_search_enabled_custom"]' => ['checked' => TRUE]]], + ], + '#size' => 40, + '#description' => $this->t('Specify a relative URL to use as the site search page.'), + '#field_prefix' => $this->requestContext->getCompleteBaseUrl(), + ]; + return parent::buildForm($form, $form_state); + } + + /** + * {@inheritdoc} + * + * @see \Drupal\system\Form\SiteInformationForm::validateForm + * Contains the validation of a home page path. + */ + public function validateForm(array &$form, FormStateInterface $form_state) { + if (($value = $form_state->getValue('site_frontpage')) && $value[0] !== '/') { + $form_state->setErrorByName('site_frontpage', $this->t("The path '%path' has to start with a slash.", ['%path' => $form_state->getValue('site_frontpage')])); + } + if (!$this->pathValidator->isValid($form_state->getValue('site_frontpage'))) { + $form_state->setErrorByName('site_frontpage', $this->t("The path '%path' is invalid.", ['%path' => $form_state->getValue('site_frontpage')])); + } + if ($form_state->getValues('site_search_enabled')['site_search_enabled_custom']) { + if (($value = $form_state->getValue('site_search_url')) && $value[0] !== '/') { + $form_state->setErrorByName('site_search_url', $this->t("The path '%path' has to start with a slash.", ['%path' => $form_state->getValue('site_search_url')])); + } + if (!$this->pathValidator->isValid($form_state->getValue('site_search_url'))) { + $form_state->setErrorByName('site_search_url', $this->t("The path '%path' is invalid.", ['%path' => $form_state->getValue('site_search_url')])); + } + } + } + + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + $configuration = $this->service->getConfiguration(); + $siteSearchEnabled = []; + $siteSearchEnabledFormValues = $form_state->getValues('site_search_enabled'); + $siteSearchFormValues = $form_state->getValues('site_search'); + foreach ($configuration->get('site_search_options') as $key => $value) { + if ($siteSearchEnabledFormValues['site_search_enabled_' . $key]) { + $siteSearchEnabled[] = $key; + } + } + $this->config('ucb_site_configuration.settings') + ->set('site_search_enabled', $siteSearchEnabled) + ->set('site_search_label', $siteSearchFormValues['site_search_label']) + ->set('site_search_placeholder', $siteSearchFormValues['site_search_placeholder']) + ->set('site_search_url', $siteSearchFormValues['site_search_url']) + ->save(); + $this->config('system.site')->set('page.front', $form_state->getValue('site_frontpage'))->save(); + parent::submitForm($form, $form_state); + } + +} diff --git a/src/SiteConfiguration.php b/src/SiteConfiguration.php index 7b9b45b..0fd67a1 100644 --- a/src/SiteConfiguration.php +++ b/src/SiteConfiguration.php @@ -348,6 +348,28 @@ public function attachSiteInformation(array &$variables) { 'url' => '', ]); $variables['site_affiliation'] = array_merge(['id' => $siteAffiliationId], $siteAffiliationAttribs); + $siteSearchOptions = $configuration->get('site_search_options'); + $siteSearchEnabled = $settings->get('site_search_enabled'); + $variables['site_search'] = []; + foreach ($siteSearchEnabled as $name) { + $siteSearchOption = $siteSearchOptions[$name]; + $siteSearchOption['name'] = $name; + if ('custom' == $name) { + $searchLabel = $settings->get('site_search_label'); + if ($searchLabel) { + $siteSearchOption['label'] = $searchLabel; + } + $searchPlaceholder = $settings->get('site_search_placeholder'); + if ($searchPlaceholder) { + $siteSearchOption['placeholder'] = $searchPlaceholder; + } + $searchUrl = $settings->get('site_search_url'); + if ($searchUrl) { + $siteSearchOption['url'] = $searchUrl; + } + } + $variables['site_search'][] = $siteSearchOption; + } } /** diff --git a/ucb_site_configuration.info.yml b/ucb_site_configuration.info.yml index 47965bd..c6f657f 100644 --- a/ucb_site_configuration.info.yml +++ b/ucb_site_configuration.info.yml @@ -2,7 +2,7 @@ name: CU Boulder Site Configuration description: 'Allows CU Boulder site administrators to configure site-specific settings.' core_version_requirement: ^9 || ^10 type: module -version: '2.4' +version: '2.5' package: CU Boulder dependencies: - block diff --git a/ucb_site_configuration.install b/ucb_site_configuration.install index 1c98d70..7c6fa1c 100644 --- a/ucb_site_configuration.install +++ b/ucb_site_configuration.install @@ -8,21 +8,62 @@ use Symfony\Component\Yaml\Yaml; /** - * V2.1 – Adds configuration and settings for the site type and affiliation (CuBoulder/tiamat-theme#210, CuBoulder/tiamat-theme#211). + * Updates the configuration. + * + * @param string[] $configKeys + * The configuration to update. */ -function ucb_site_configuration_update_9502() { - $config = \Drupal::configFactory()->getEditable('ucb_site_configuration.configuration'); - $settings = \Drupal::configFactory()->getEditable('ucb_site_configuration.settings'); - $yaml = Yaml::parse(file_get_contents(drupal_get_path('module', 'ucb_site_configuration') . '/config/install/ucb_site_configuration.configuration.yml')); - if (!is_array($yaml)) { - throw new \RuntimeException('Oh no! Failed to get or parse site type and affiliation configuration YAML.'); +function _ucb_site_configuration_update_config(array $configKeys) { + $modulePath = Drupal::getContainer()->get('extension.path.resolver')->getPath('module', 'ucb_site_configuration'); + $configYaml = Yaml::parse(file_get_contents($modulePath . '/config/install/ucb_site_configuration.configuration.yml')); + $configEditable = \Drupal::configFactory()->getEditable('ucb_site_configuration.configuration'); + foreach ($configKeys as $configKey) { + $configEditable->set($configKey, $configYaml[$configKey]); + } + $configEditable->save(); +} + +/** + * Updates the settings. + * + * Important: This will override any user-defined settings. Recommended only + * for adding previously non-existent settings. + * + * @param string[] $settingKeys + * The settings to update. + */ +function _ucb_site_configuration_update_settings(array $settingKeys) { + $modulePath = Drupal::getContainer()->get('extension.path.resolver')->getPath('module', 'ucb_site_configuration'); + $settingsYaml = Yaml::parse(file_get_contents($modulePath . '/config/install/ucb_site_configuration.settings.yml')); + $settingsEditable = \Drupal::configFactory()->getEditable('ucb_site_configuration.settings'); + foreach ($settingKeys as $settingKey) { + $settingsEditable->set($settingKey, $settingsYaml[$settingKey]); } - $config->set('site_type_options', $yaml['site_type_options'])->set('site_affiliation_options', $yaml['site_affiliation_options'])->save(); - $settings->set('site_type', '')->set('site_affiliation', '')->set('site_affiliation_label', '')->set('site_affiliation_url', '')->save(); + $settingsEditable->save(); +} + +/** + * Adds configuration and settings for the site type and affiliation. + * + * Introduced in version 2.1 to address tiamat-theme#210, tiamat-theme#211. + */ +function ucb_site_configuration_update_9502() { + _ucb_site_configuration_update_config([ + 'site_type_options', + 'site_affiliation_options', + ]); + _ucb_site_configuration_update_settings([ + 'site_type', + 'site_affiliation', + 'site_affiliation_label', + 'site_affiliation_url', + ]); } /** - * V2.1.1 – Removes "Be Boulder slogan" from Appearance settings (CuBoulder/tiamat-theme#230). + * Removes "Be Boulder slogan" from Appearance settings. + * + * Introduced in version 2.1.1 to address tiamat-theme#230. */ function ucb_site_configuration_update_9503() { $config = \Drupal::configFactory()->getEditable('ucb_site_configuration.configuration'); @@ -35,14 +76,18 @@ function ucb_site_configuration_update_9503() { } /** - * V2.2 – Admin Helpscout Beacon moved to ucb_admin_menus (CuBoulder/ucb_admin_menus#2). + * Admin Helpscout Beacon moved to ucb_admin_menus. + * + * Introduced in version 2.2 to address ucb_admin_menus#2. */ function ucb_site_configuration_update_9504() { \Drupal::configFactory()->getEditable('ucb_site_configuration.configuration')->clear('admin_helpscout_beacon_id')->save(); } /** - * V2.3 – Modififies contact info settings (CuBoulder/tiamat-theme#269). + * Modifies contact info settings. + * + * Introduced in version 2.3 to address tiamat-theme#269. */ function ucb_site_configuration_update_9505() { \Drupal::configFactory()->getEditable('ucb_site_configuration.contact_info') @@ -58,3 +103,20 @@ function ucb_site_configuration_update_9505() { ]) ->save(); } + +/** + * Adds configuration and settings for the site search. + * + * Introduced in version 2.5 to address tiamat-theme#266. + */ +function ucb_site_configuration_update_9506() { + _ucb_site_configuration_update_config([ + 'site_search_options', + ]); + _ucb_site_configuration_update_settings([ + 'site_search_enabled', + 'site_search_label', + 'site_search_placeholder', + 'site_search_url', + ]); +} diff --git a/ucb_site_configuration.links.menu.yml b/ucb_site_configuration.links.menu.yml index f0c38f9..485fdff 100644 --- a/ucb_site_configuration.links.menu.yml +++ b/ucb_site_configuration.links.menu.yml @@ -7,31 +7,37 @@ ucb_site_configuration: ucb_site_configuration.general_form: title: General - description: 'Modify general settings and information such as the site name, type, and affiliation.' + description: 'Modify the site name, type, or affiliation.' route_name: ucb_site_configuration.general_form parent: ucb_site_configuration weight: 0 ucb_site_configuration.appearance_form: - title: Appearance - description: 'Change the appearance, layout, and formatting of the site theme.' + title: Appearance and layout + description: 'Change the appearance, layout, or formatting options of the site.' route_name: ucb_site_configuration.appearance_form parent: ucb_site_configuration weight: 1 +ucb_site_configuration.pages_form: + title: Pages and search + description: 'Change the site home page or search options.' + route_name: ucb_site_configuration.pages_form + parent: ucb_site_configuration + weight: 2 ucb_site_configuration.contact_info_form: title: Contact info description: 'Modify the contact info for the site as it appears in the site footer.' route_name: ucb_site_configuration.contact_info_form parent: ucb_site_configuration - weight: 2 + weight: 3 ucb_site_configuration.related_articles_form: title: Related articles description: 'Exclude categories or tags from related articles.' route_name: ucb_site_configuration.related_articles_form parent: ucb_site_configuration - weight: 3 + weight: 4 ucb_site_configuration.external_services: title: Third-party services description: 'Configure third-party services to be used on the site.' route_name: entity.ucb_external_service_include.collection parent: ucb_site_configuration - weight: 4 + weight: 5 diff --git a/ucb_site_configuration.links.task.yml b/ucb_site_configuration.links.task.yml index 2e6fe57..e643296 100644 --- a/ucb_site_configuration.links.task.yml +++ b/ucb_site_configuration.links.task.yml @@ -5,21 +5,26 @@ ucb_site_configuration.general_form: weight: 0 ucb_site_configuration.appearance_form: route_name: ucb_site_configuration.appearance_form - title: 'Appearance' + title: 'Appearance and layout' base_route: ucb_site_configuration weight: 1 +ucb_site_configuration.pages_form: + route_name: ucb_site_configuration.pages_form + title: 'Pages and search' + base_route: ucb_site_configuration + weight: 2 ucb_site_configuration.contact_info_form: route_name: ucb_site_configuration.contact_info_form title: 'Contact info' base_route: ucb_site_configuration - weight: 2 + weight: 3 ucb_site_configuration.related_articles_form: route_name: ucb_site_configuration.related_articles_form title: 'Related articles' base_route: ucb_site_configuration - weight: 3 + weight: 4 ucb_site_configuration.external_services: route_name: entity.ucb_external_service_include.collection title: 'Third-party services' base_route: ucb_site_configuration - weight: 4 + weight: 5 diff --git a/ucb_site_configuration.routing.yml b/ucb_site_configuration.routing.yml index 0b142b5..3b233cc 100644 --- a/ucb_site_configuration.routing.yml +++ b/ucb_site_configuration.routing.yml @@ -16,7 +16,7 @@ ucb_site_configuration.general_form: _form: '\Drupal\ucb_site_configuration\Form\GeneralForm' _title: General requirements: - _custom_access: '\Drupal\ucb_site_configuration\Controller\SiteSettingsAccessController::accessGeneral' + _permission: edit ucb site general options: _admin_route: true @@ -24,12 +24,22 @@ ucb_site_configuration.appearance_form: path: '/admin/config/cu-boulder/appearance' defaults: _form: '\Drupal\ucb_site_configuration\Form\AppearanceForm' - _title: Appearance + _title: Appearance and layout requirements: _permission: edit ucb site appearance options: _admin_route: true +ucb_site_configuration.pages_form: + path: '/admin/config/cu-boulder/pages' + defaults: + _form: '\Drupal\ucb_site_configuration\Form\PagesForm' + _title: Pages and search + requirements: + _permission: edit ucb site pages + options: + _admin_route: true + ucb_site_configuration.contact_info_form: path: '/admin/config/cu-boulder/contact-info' defaults: