diff --git a/config/install/layout_builder_browser.layout_builder_browser_block.uw_lbb_profile_list_manual.yml b/config/install/layout_builder_browser.layout_builder_browser_block.uw_lbb_profile_list_manual.yml new file mode 100644 index 0000000000000000000000000000000000000000..c1893bc7a058973e94606fd037f7297ae59516b1 --- /dev/null +++ b/config/install/layout_builder_browser.layout_builder_browser_block.uw_lbb_profile_list_manual.yml @@ -0,0 +1,10 @@ +langcode: en +status: true +dependencies: { } +id: uw_lbb_profile_list_manual +block_id: uw_cbl_profiles_manual +category: uw_bc_listings +label: 'Profile list (manual)' +weight: -3 +image_path: /themes/uw_fdsu_theme_resp/images/layout_builder_browser/profilelist-manual.svg +image_alt: '' diff --git a/config/install/redirect.settings.yml b/config/install/redirect.settings.yml new file mode 100644 index 0000000000000000000000000000000000000000..260b8928b158be6fe2a74f763a4b077a988cd98d --- /dev/null +++ b/config/install/redirect.settings.yml @@ -0,0 +1,7 @@ +auto_redirect: false +default_status_code: 301 +passthrough_querystring: true +warning: false +ignore_admin_path: false +access_check: false +route_normalizer_enabled: true diff --git a/config/install/redirect_404.settings.yml b/config/install/redirect_404.settings.yml new file mode 100644 index 0000000000000000000000000000000000000000..7a823bee20cb00b5db4011ac74a8da177f6d35ff --- /dev/null +++ b/config/install/redirect_404.settings.yml @@ -0,0 +1,3 @@ +row_limit: 10000 +pages: '' +suppress_404: false diff --git a/config/install/user.role.uw_role_site_manager.yml b/config/install/user.role.uw_role_site_manager.yml index 6931fc4e09cdda02ce0f4110469a2f2b506a9eca..7f02fb0f0b866c62df37567710c29a83e5d30d41 100644 --- a/config/install/user.role.uw_role_site_manager.yml +++ b/config/install/user.role.uw_role_site_manager.yml @@ -20,6 +20,7 @@ permissions: - 'access uw_ebr_cta entity browser pages' - 'access uw_ebr_image entity browser pages' - 'administer main menu items' + - 'administer redirects' - 'administer special alert' - 'administer uw-menu-audience-menu menu items' - 'can override my_dashboard dashboard' diff --git a/src/Access/UwNodeAccessCheck.php b/src/Access/UwNodeAccessCheck.php index 0c190d08124f36fd1c0aa2452cc26451742b536e..af8a0b17da5e28f95454ab58baf4bec94ead3d9c 100644 --- a/src/Access/UwNodeAccessCheck.php +++ b/src/Access/UwNodeAccessCheck.php @@ -6,6 +6,8 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Routing\Access\AccessInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Session\AccountInterface; +use Drupal\menu_admin_per_menu\Access\MenuAdminPerMenuAccess; +use Drupal\uw_cfg_common\Service\UWService; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** @@ -21,10 +23,37 @@ class UwNodeAccessCheck implements AccessInterface { * @param \Drupal\Core\Session\AccountInterface $account * Run access checks for this account. * - * @return \Drupal\Core\Access\AccessResultInterface + * @return \Drupal\Core\Access\AccessResult * The access result. */ - public function access(RouteMatchInterface $route_match, AccountInterface $account) { + public function access(RouteMatchInterface $route_match, AccountInterface $account): AccessResult { + $route_name = $route_match->getRouteName(); + + // Menu link edit pages. + if ($route_name === 'menu_ui.link_edit') { + $menu_link_plugin = $route_match->getParameter('menu_link_plugin'); + // Only those with permission may edit home page menu entry. + if ($menu_link_plugin->getPluginId() === 'uw_base_profile.front_page') { + return $account->hasPermission('bypass home page protection') ? AccessResult::allowed() : AccessResult::forbidden(); + } + else { + // Otherwise, default to access set in menu_admin_per_menu. + $menu_admin_per_menu = new MenuAdminPerMenuAccess(); + return $menu_admin_per_menu->menuLinkAccess($account, $menu_link_plugin); + } + } + + // Node delete pages. + if ($route_name === 'entity.node.delete_form') { + $node = $route_match->getParameter('node'); + // Only those with permission may delete the home page. + if ($node && UWService::nodeIsHomePage((int) $node->id())) { + return $account->hasPermission('bypass home page protection') ? AccessResult::allowed() : AccessResult::forbidden(); + } + else { + return AccessResult::allowed(); + } + } // Get the node object, which is in the route match variable. $node = $route_match->getParameter('node'); diff --git a/src/Plugin/Layout/Uw2ColumnLayout.php b/src/Plugin/Layout/Uw2ColumnLayout.php deleted file mode 100644 index eb4916305640466cbfcea96d02df1fa948953d4d..0000000000000000000000000000000000000000 --- a/src/Plugin/Layout/Uw2ColumnLayout.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Drupal\uw_cfg_common\Plugin\Layout; - -use Drupal\Core\Form\FormStateInterface; - -/** - * A UW two column layout. - */ -class Uw2ColumnLayout extends UwColumnLayoutBase { - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - - // Get the config for this layout. - $configuration = $this->getConfiguration(); - - // The options for the column widths. - $options = [ - 'even-split' => $this->t('Even split (50%, 50%)'), - 'larger-left' => $this->t('Larger left (67%, 33%)'), - 'larger-right' => $this->t('Larger right (33%, 67%)'), - ]; - - // The form element for the column widths. - $form['layout_settings']['column_class'] = [ - '#type' => 'select', - '#title' => $this->t('Column widths'), - '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split', - '#options' => $options, - ]; - - return $form; - } - -} diff --git a/src/Plugin/Layout/Uw3ColumnLayout.php b/src/Plugin/Layout/Uw3ColumnLayout.php deleted file mode 100644 index 308cc01ff3c8d570379baf881b6e96bd9472eeb5..0000000000000000000000000000000000000000 --- a/src/Plugin/Layout/Uw3ColumnLayout.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Drupal\uw_cfg_common\Plugin\Layout; - -use Drupal\Core\Form\FormStateInterface; - -/** - * A UW three column layout. - */ -class Uw3ColumnLayout extends UwColumnLayoutBase { - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - - // Get the config for this layout. - $configuration = $this->getConfiguration(); - - // The options for the column widths. - $options = [ - 'even-split' => $this->t('Even split (33%, 34%, 33%)'), - 'larger-left' => $this->t('Larger left (50%, 25%, 25%)'), - 'larger-middle' => $this->t('Larger middle (25%, 50%, 25%)'), - 'larger-right' => $this->t('Larger right (25%, 25%, 50%)'), - 'legacy-38-38-24' => $this->t('Legacy (38%, 38%, 24%)'), - 'legacy-24-38-38' => $this->t('Legacy (24%, 38%, 38%)'), - ]; - - // The form element for the column widths. - $form['layout_settings']['column_class'] = [ - '#type' => 'select', - '#title' => $this->t('Column widths'), - '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split', - '#options' => $options, - ]; - - return $form; - } - -} diff --git a/src/Plugin/Layout/Uw4ColumnLayout.php b/src/Plugin/Layout/Uw4ColumnLayout.php deleted file mode 100644 index c4c655ec5e7c4e957ca3a5fd63e87b9aa0fa7d5a..0000000000000000000000000000000000000000 --- a/src/Plugin/Layout/Uw4ColumnLayout.php +++ /dev/null @@ -1,41 +0,0 @@ -<?php - -namespace Drupal\uw_cfg_common\Plugin\Layout; - -use Drupal\Core\Form\FormStateInterface; - -/** - * A UW four column layout. - */ -class Uw4ColumnLayout extends UwColumnLayoutBase { - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - - // Get the config for this layout. - $configuration = $this->getConfiguration(); - - // The options for the column widths. - $options = [ - 'even-split' => $this->t('Even split (25%, 25%, 25%, 25%)'), - 'larger-left' => $this->t('Larger left (50%, 16.67%, 16.67%, 16.67%)'), - 'larger-second' => $this->t('Larger second (16.67%, 50%, 16.67%, 16.67%)'), - 'larger-third' => $this->t('Larger third (16.67%, 16.67%, 50%, 16.67%)'), - 'larger-right' => $this->t('Larger right (16.67%, 16.67%, 16.67%, 50%)'), - 'legacy-23-27-27-23' => $this->t('Legacy (23%, 27%, 27%, 23%)'), - ]; - - // The form element for the column widths. - $form['layout_settings']['column_class'] = [ - '#type' => 'select', - '#title' => $this->t('Column widths'), - '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split', - '#options' => $options, - ]; - - return $form; - } - -} diff --git a/src/Plugin/Layout/Uw5ColumnLayout.php b/src/Plugin/Layout/Uw5ColumnLayout.php deleted file mode 100644 index 9a64acc1a7fa82498b69ed070e6ed6ea50cc985c..0000000000000000000000000000000000000000 --- a/src/Plugin/Layout/Uw5ColumnLayout.php +++ /dev/null @@ -1,42 +0,0 @@ -<?php - -namespace Drupal\uw_cfg_common\Plugin\Layout; - -use Drupal\Core\Form\FormStateInterface; - -/** - * A UW four column layout. - */ -class Uw5ColumnLayout extends UwColumnLayoutBase { - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - - // Get the config for this layout. - $configuration = $this->getConfiguration(); - - // The options for the column widths. - $options = [ - 'even-split' => $this->t('Even split (20%, 20%, 20%, 20%, 20%)'), - 'larger-left' => $this->t('Larger left (40%, 15%, 15%, 15%, 15%)'), - 'larger-second' => $this->t('Larger second (15%, 40%, 15%, 15%, 15%)'), - 'larger-third' => $this->t('Larger third (15%, 15%, 40%, 15%, 15%)'), - 'larger-fourth' => $this->t('Larger fourth (15%, 15%, 15%, 40%, 15%)'), - 'larger-right' => $this->t('Larger right (15%, 15%, 15%, 15%, 40%)'), - 'legacy-23-19-19-19-20' => $this->t('Legacy (23%, 19%, 19%, 19%, 20%)'), - ]; - - // The form element for the column widths. - $form['layout_settings']['column_class'] = [ - '#type' => 'select', - '#title' => $this->t('Column widths'), - '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split', - '#options' => $options, - ]; - - return $form; - } - -} diff --git a/src/Plugin/Layout/UwColumnLayoutBase.php b/src/Plugin/Layout/UwColumnLayoutBase.php index 06460ba4d740a6c49e53351e75a137bb5b53674f..3d3d3eae4cd6d67a15df3024b772e742e97efcbb 100644 --- a/src/Plugin/Layout/UwColumnLayoutBase.php +++ b/src/Plugin/Layout/UwColumnLayoutBase.php @@ -11,14 +11,42 @@ use Drupal\Core\Plugin\PluginFormInterface; */ class UwColumnLayoutBase extends LayoutDefault implements PluginFormInterface { + /** + * {@inheritdoc} + */ + public function buildConfigurationForm(array $form, FormStateInterface $form_state) { + + // Get Parents configuration form (which by default adds the Admin Label). + $form = parent::buildConfigurationForm($form, $form_state); + + // Get the config for this layout. + $configuration = $this->getConfiguration(); + + // The options for the column widths. + $columnOptions = $this->getColumnOptions(); + + // The form element for the column widths. + $form['column_class'] = [ + '#type' => 'select', + '#title' => $this->t('Column widths'), + '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : $columnOptions['default'], + '#options' => $columnOptions['columns'], + ]; + + return $form; + } + /** * {@inheritdoc} */ public function submitConfigurationForm(array &$form, FormStateInterface $form_state) { + // Call parent and let it do its thing (like set the label). + parent::submitConfigurationForm($form, $form_state); + // Set the column class in the config. $this->configuration['column_class'] = $form_state->getValue( - ['layout_settings', 'column_class'], + ['column_class'], NULL ); } @@ -40,4 +68,14 @@ class UwColumnLayoutBase extends LayoutDefault implements PluginFormInterface { return $build; } + /** + * Helper function to get column options defined in *.layout.yml file. + * + * @return array[] + * an array containing string options and the default column. + */ + public function getColumnOptions() { + return $this->getPluginDefinition()->get('column_options'); + } + } diff --git a/src/Plugin/Layout/UwInvertedLLeftLayout.php b/src/Plugin/Layout/UwInvertedLLeftLayout.php deleted file mode 100644 index 2f3d4c918cdc23643c577b8451bd44b449e76720..0000000000000000000000000000000000000000 --- a/src/Plugin/Layout/UwInvertedLLeftLayout.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Drupal\uw_cfg_common\Plugin\Layout; - -use Drupal\Core\Form\FormStateInterface; - -/** - * A UW Inverted L Left layout. - */ -class UwInvertedLLeftLayout extends UwColumnLayoutBase { - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - - // Get the config for this layout. - $configuration = $this->getConfiguration(); - - // The options for the column widths. - $options = [ - 'even-split' => $this->t('Even split (50%, 50%)'), - 'larger-left' => $this->t('Larger left (33%, 67%)'), - 'larger-right' => $this->t('Larger right (67%, 33%)'), - ]; - - // The form element for the column widths. - $form['layout_settings']['column_class'] = [ - '#type' => 'select', - '#title' => $this->t('Column widths for top row'), - '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split', - '#options' => $options, - ]; - - return $form; - } - -} diff --git a/src/Plugin/Layout/UwInvertedLRightLayout.php b/src/Plugin/Layout/UwInvertedLRightLayout.php deleted file mode 100644 index e0bd1f7a80511325142de12d7dc88aa1d5e604b4..0000000000000000000000000000000000000000 --- a/src/Plugin/Layout/UwInvertedLRightLayout.php +++ /dev/null @@ -1,38 +0,0 @@ -<?php - -namespace Drupal\uw_cfg_common\Plugin\Layout; - -use Drupal\Core\Form\FormStateInterface; - -/** - * A UW Inverted L Right layout. - */ -class UwInvertedLRightLayout extends UwColumnLayoutBase { - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - - // Get the config for this layout. - $configuration = $this->getConfiguration(); - - // The options for the column widths. - $options = [ - 'even-split' => $this->t('Even split (50%, 50%)'), - 'larger-left' => $this->t('Larger left (33%, 67%)'), - 'larger-right' => $this->t('Larger right (67%, 33%)'), - ]; - - // The form element for the column widths. - $form['layout_settings']['column_class'] = [ - '#type' => 'select', - '#title' => $this->t('Column widths for top row'), - '#default_value' => !empty($configuration['column_class']) ? $configuration['column_class'] : 'even-split', - '#options' => $options, - ]; - - return $form; - } - -} diff --git a/src/Routing/UwNodeAccessRouteSubscriber.php b/src/Routing/UwNodeAccessRouteSubscriber.php index d5309c69fe257f4c71aa0fda8cb7e26e726d9c83..d9a15672ab2e67c67fcd608b749e977162509755 100644 --- a/src/Routing/UwNodeAccessRouteSubscriber.php +++ b/src/Routing/UwNodeAccessRouteSubscriber.php @@ -3,6 +3,7 @@ namespace Drupal\uw_cfg_common\Routing; use Drupal\Core\Routing\RouteSubscriberBase; +use Drupal\Core\Routing\RoutingEvents; use Symfony\Component\Routing\RouteCollection; /** @@ -14,10 +15,29 @@ class UwNodeAccessRouteSubscriber extends RouteSubscriberBase { * {@inheritdoc} */ protected function alterRoutes(RouteCollection $collection) { - // Change the route associated with node (/node/{nid}). - if ($route = $collection->get('entity.node.canonical')) { - $route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access'); + $access_route_names = [ + // Node pages (/node/{nid}). + 'entity.node.canonical', + // Menu link edit pages. + 'menu_ui.link_edit', + // Node delete pages. + 'entity.node.delete_form', + ]; + foreach ($access_route_names as $route_name) { + if ($route = $collection->get($route_name)) { + $route->setRequirement('_custom_access', 'Drupal\uw_cfg_common\Access\UwNodeAccessCheck::access'); + } } } + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents(): array { + // Run this implementation of alterRoutes() after menu_admin_per_menu, which + // has priority -220. + $events[RoutingEvents::ALTER] = ['onAlterRoutes', -300]; + return $events; + } + } diff --git a/uw_cfg_common.info.yml b/uw_cfg_common.info.yml index 0838923fad441a21beddb793e83bd8ae295778e3..c259efb41e12a48f8f47da296168b565ddab88db 100644 --- a/uw_cfg_common.info.yml +++ b/uw_cfg_common.info.yml @@ -20,6 +20,7 @@ dependencies: - drupal:language - drupal:layout_builder - drupal:layout_builder_browser + - drupal:layout_builder_expand_collapse - drupal:layout_builder_modal - drupal:layout_builder_restrictions - drupal:layout_builder_styles @@ -31,6 +32,8 @@ dependencies: - drupal:pathauto - drupal:preprocess_event_dispatcher - drupal:realname + - drupal:redirect + - drupal:redirect_404 - drupal:taxonomy - drupal:text - drupal:user diff --git a/uw_cfg_common.layouts.yml b/uw_cfg_common.layouts.yml index e82dbcdd2a12cf101c1cc03869f34d08caf5fd27..cb2413e0a6e88fc98a6dc51181892f7dbc2558d5 100644 --- a/uw_cfg_common.layouts.yml +++ b/uw_cfg_common.layouts.yml @@ -1,117 +1,163 @@ -uw_1_column: - label: 'One column' - category: 'UW layouts' - library: uw_cfg_common/uw_layout_1_col - template: layouts/uw-1-col/layout--uw-1-col - default_region: first - regions: - first: - label: One - icon_map: - - [first] -uw_2_column: - label: 'Two columns' - category: 'UW layouts' - class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw2ColumnLayout' - library: uw_cfg_common/uw_layout_2_col - template: layouts/uw-2-col/layout--uw-2-col - default_region: first - regions: - first: - label: First - second: - label: Second - icon_map: - - [first, second] -uw_3_column: - label: 'Three columns' - category: 'UW layouts' - class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw3ColumnLayout' - library: uw_cfg_common/uw_layout_3_col - template: layouts/uw-3-col/layout--uw-3-col - default_region: first - regions: - first: - label: First - second: - label: Second - third: - label: Third - icon_map: - - [first, second, third] -uw_4_column: - label: 'Four columns' - category: 'UW layouts' - class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw4ColumnLayout' - library: uw_cfg_common/uw_layout_4_col - template: layouts/uw-4-col/layout--uw-4-col - default_region: first - regions: - first: - label: First - second: - label: Second - third: - label: Third - fourth: - label: Fourth - icon_map: - - [first, second, third, fourth] -uw_5_column: - label: 'Five columns' - category: 'UW layouts' - class: '\Drupal\uw_cfg_common\Plugin\Layout\Uw5ColumnLayout' - library: uw_cfg_common/uw_layout_5_col - template: layouts/uw-5-col/layout--uw-5-col - default_region: first - regions: - first: - label: First - second: - label: Second - third: - label: Third - fourth: - label: Fourth - fifth: - label: Fifth - icon_map: - - [first, second, third, fourth, fifth] -uw_inverted_l_right: - label: 'Inverted "L" - right' - category: 'UW layouts' - class: '\Drupal\uw_cfg_common\Plugin\Layout\UwInvertedLRightLayout' - library: uw_cfg_common/uw_layout_inverted_l_right - template: layouts/uw-inverted-l-right/layout--uw-inverted-l-right - default_region: first - regions: - first: - label: First - second: - label: Second - third: - label: Third - fourth: - label: Fourth - icon_map: - - [first, second, fourth] - - [third, third, fourth] -uw_inverted_l_left: - label: 'Inverted "L" - left' - category: 'UW layouts' - class: '\Drupal\uw_cfg_common\Plugin\Layout\UwInvertedLLeftLayout' - library: uw_cfg_common/uw_layout_inverted_l_left - template: layouts/uw-inverted-l-left/layout--uw-inverted-l-left - default_region: first - regions: - first: - label: First - second: - label: Second - third: - label: Third - fourth: - label: Fourth - icon_map: - - [first, second, third] - - [first, fourth, fourth] +uw_1_column: + label: 'One column' + category: 'UW layouts' + library: uw_cfg_common/uw_layout_1_col + template: layouts/uw-1-col/layout--uw-1-col + default_region: first + regions: + first: + label: One + icon_map: + - [first] +uw_2_column: + label: 'Two columns' + category: 'UW layouts' + class: '\Drupal\uw_cfg_common\Plugin\Layout\UwColumnLayoutBase' + library: uw_cfg_common/uw_layout_2_col + template: layouts/uw-2-col/layout--uw-2-col + default_region: first + regions: + first: + label: First + second: + label: Second + icon_map: + - [first, second] + column_options: + columns: + even-split: 'Even split (50%, 50%)' + larger-left: 'Larger left (67%, 33%)' + larger-right: 'Larger right (33%, 67%)' + default: 'even-split' +uw_3_column: + label: 'Three columns' + category: 'UW layouts' + class: '\Drupal\uw_cfg_common\Plugin\Layout\UwColumnLayoutBase' + library: uw_cfg_common/uw_layout_3_col + template: layouts/uw-3-col/layout--uw-3-col + default_region: first + regions: + first: + label: First + second: + label: Second + third: + label: Third + icon_map: + - [first, second, third] + column_options: + columns: + even-split: 'Even split (33%, 34%, 33%)' + larger-left: 'Larger left (50%, 25%, 25%)' + larger-middle: 'Larger middle (25%, 50%, 25%)' + larger-right: 'Larger right (25%, 25%, 50%)' + legacy-38-38-24: 'Legacy (38%, 38%, 24%)' + legacy-24-38-38: 'Legacy (24%, 38%, 38%)' + default: 'even-split' +uw_4_column: + label: 'Four columns' + category: 'UW layouts' + class: '\Drupal\uw_cfg_common\Plugin\Layout\UwColumnLayoutBase' + library: uw_cfg_common/uw_layout_4_col + template: layouts/uw-4-col/layout--uw-4-col + default_region: first + regions: + first: + label: First + second: + label: Second + third: + label: Third + fourth: + label: Fourth + icon_map: + - [first, second, third, fourth] + column_options: + columns: + even-split': 'Even split (25%, 25%, 25%, 25%)' + larger-left': 'Larger left (50%, 16.67%, 16.67%, 16.67%)' + larger-second': 'Larger second (16.67%, 50%, 16.67%, 16.67%)' + larger-third': 'Larger third (16.67%, 16.67%, 50%, 16.67%)' + larger-right': 'Larger right (16.67%, 16.67%, 16.67%, 50%)' + legacy-23-27-27-23': 'Legacy (23%, 27%, 27%, 23%)' + default: 'even-split' +uw_5_column: + label: 'Five columns' + category: 'UW layouts' + class: '\Drupal\uw_cfg_common\Plugin\Layout\UwColumnLayoutBase' + library: uw_cfg_common/uw_layout_5_col + template: layouts/uw-5-col/layout--uw-5-col + default_region: first + regions: + first: + label: First + second: + label: Second + third: + label: Third + fourth: + label: Fourth + fifth: + label: Fifth + icon_map: + - [first, second, third, fourth, fifth] + column_options: + columns: + even-split': 'Even split (20%, 20%, 20%, 20%, 20%)' + larger-left': 'Larger left (40%, 15%, 15%, 15%, 15%)' + larger-second': 'Larger second (15%, 40%, 15%, 15%, 15%)' + larger-third': 'Larger third (15%, 15%, 40%, 15%, 15%)' + larger-fourth': 'Larger fourth (15%, 15%, 15%, 40%, 15%)' + larger-right': 'Larger right (15%, 15%, 15%, 15%, 40%)' + legacy-23-19-19-19-20': 'Legacy (23%, 19%, 19%, 19%, 20%)' + default: 'even-split' +uw_inverted_l_right: + label: 'Inverted "L" - right' + category: 'UW layouts' + class: '\Drupal\uw_cfg_common\Plugin\Layout\UwColumnLayoutBase' + library: uw_cfg_common/uw_layout_inverted_l_right + template: layouts/uw-inverted-l-right/layout--uw-inverted-l-right + default_region: first + regions: + first: + label: First + second: + label: Second + third: + label: Third + fourth: + label: Fourth + icon_map: + - [first, second, fourth] + - [third, third, fourth] + column_options: + columns: + even-split: 'Even split (50%, 50%)' + larger-left: 'Larger left (67%, 33%)' + larger-right: 'Larger right (33%, 67%)' + default: 'even-split' +uw_inverted_l_left: + label: 'Inverted "L" - left' + category: 'UW layouts' + class: '\Drupal\uw_cfg_common\Plugin\Layout\UwColumnLayoutBase' + library: uw_cfg_common/uw_layout_inverted_l_left + template: layouts/uw-inverted-l-left/layout--uw-inverted-l-left + default_region: first + regions: + first: + label: First + second: + label: Second + third: + label: Third + fourth: + label: Fourth + icon_map: + - [first, second, third] + - [first, fourth, fourth] + column_options: + columns: + even-split: 'Even split (50%, 50%)' + larger-left: 'Larger left (67%, 33%)' + larger-right: 'Larger right (33%, 67%)' + default: 'even-split' diff --git a/uw_cfg_common.links.menu.yml b/uw_cfg_common.links.menu.yml index 9b3c02e25dd3793e760a78d1f7db376ee33af505..6616fd6aa127dc026b9a05424df3f865e4934f3a 100644 --- a/uw_cfg_common.links.menu.yml +++ b/uw_cfg_common.links.menu.yml @@ -262,6 +262,12 @@ uw_content_management.content_types.site_footer: url: internal:/node/add/uw_ct_site_footer weight: 0 +uw_content_management.content_types.special_alerts: + title: 'Special Alerts' + parent: uw_content_management.content_types + route_name: uw_custom_blocks.special_alert.settings + weight: 0 + uw_content_management.content_types.web_page: title: 'Web page' parent: uw_content_management.content_types diff --git a/uw_cfg_common.module b/uw_cfg_common.module index 0f5298ec16168079aaa2954d64dcc9ef8a482bcc..3695fbdbcd7cb21b60a73c2fad19231415446ca9 100644 --- a/uw_cfg_common.module +++ b/uw_cfg_common.module @@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\uw_cfg_common\Service\UWService; use Drupal\webform\WebformInterface; use Drupal\webform\WebformSubmissionStorageInterface; @@ -276,3 +277,86 @@ function uw_cfg_common_form_node_type_add_form_alter(&$form, FormStateInterface $form['submission']['preview_mode']['#default_value'] = 0; } + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Node edit form: node/NID/edit. + * + * Prevent certain changes to the home page. + */ +function uw_cfg_common_form_node_uw_ct_web_page_edit_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void { + // No changes for those with access. + if (\Drupal::currentUser()->hasPermission('bypass home page protection')) { + return; + } + + // Do not allow the home page to be parent of any item. + unset($form['menu']['link']['menu_parent']['#options']['main:uw_base_profile.front_page']); + + // Early return if not editing home page. + $nid = (int) \Drupal::routeMatch()->getRawParameter('node'); + if (!UWService::nodeIsHomePage($nid)) { + return; + } + + // Remove access to certain controls. + $form['path']['#access'] = FALSE; + $form['promote']['#access'] = FALSE; + $form['sticky']['#access'] = FALSE; + // For 'menu', setting #access did not work for non-admins. So, also hide the + // sub-components and make it a container so that nothing appears on the page. + $form['menu']['#access'] = FALSE; + $form['menu']['#type'] = 'container'; + $form['menu']['enabled']['#access'] = FALSE; + $form['menu']['link']['#access'] = FALSE; + + // Hide delete link if no access. This should happen by itself, but does not. + if (!$form['actions']['delete']['#url']->access()) { + $form['actions']['delete']['#access'] = FALSE; + } +} + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Menu edit form: admin/structure/menu/manage/main. + * + * Prevent certain changes to the home page. + */ +function uw_cfg_common_form_menu_edit_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void { + // No changes for those with access. + if (\Drupal::currentUser()->hasPermission('bypass home page protection')) { + return; + } + + // Return early if not editing "Main navigation" menu. + if (!isset($form['links']['links']['menu_plugin_id:uw_base_profile.front_page'])) { + return; + } + + // Remove access to home page controls. + $form['links']['links']['menu_plugin_id:uw_base_profile.front_page']['enabled']['#access'] = FALSE; + $form['links']['links']['menu_plugin_id:uw_base_profile.front_page']['operations']['#access'] = FALSE; + $form['links']['links']['menu_plugin_id:uw_base_profile.front_page']['weight']['#access'] = FALSE; + // Make home page not draggable. + $key = array_search('draggable', $form['links']['links']['menu_plugin_id:uw_base_profile.front_page']['#attributes']['class'], TRUE); + unset($form['links']['links']['menu_plugin_id:uw_base_profile.front_page']['#attributes']['class'][$key]); +} + +/** + * Implements hook_form_FORM_ID_alter(). + * + * Menu link edit form: admin/structure/menu/link/LINK/edit. + * + * Do not allow the home page to be parent of any item. + */ +function uw_cfg_common_form_menu_link_edit_alter(array &$form, FormStateInterface $form_state, string $form_id): void { + // No changes for those with access. + if (\Drupal::currentUser()->hasPermission('bypass home page protection')) { + return; + } + + // Do not allow the home page to be parent of any item. + unset($form['menu_parent']['#options']['main:uw_base_profile.front_page']); +}