Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wcms/uw_cfg_common
1 result
Show changes
Commits on Source (22)
langcode: en
status: true
dependencies: { }
id: waterloo_news
block_id: uw_cbl_waterloo_news
category: uw_bc_listings
label: 'Waterloo News'
image_path: images/layout_builder_browser/waterloonewslist.svg
image_path_base: 'theme:uw_fdsu_theme_resp'
image_alt: 'Waterloo News'
weight: 0
services:
uw_cfg_common.commands:
class: Drupal\uw_cfg_common\Commands\UwDrushCommands
arguments: ['@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@module_handler', '@module_installer']
arguments: ['@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@module_handler', '@module_installer', '@uw_multilingual.setup_new_language']
tags:
- { name: drush.command }
......@@ -8,7 +8,7 @@
use Drupal\taxonomy\Entity\Term;
/**
* Function to get the class for the term.
* Function to get the class for the term form the object.
*
* @param \Drupal\taxonomy\Entity\Term $term
* The term object.
......@@ -17,35 +17,54 @@ use Drupal\taxonomy\Entity\Term;
* The class for the term.
*/
function uw_get_org_class_from_term(Term $term): string {
return uw_get_org_class_from_name($term->label());
}
/**
* Function to get the class for the term using the name.
*
* @param string $name
* The term object.
*
* @return string
* The class for the term.
*/
function uw_get_org_class_from_name(string $name): string {
// Get the class name from the term label.
switch ($term->label()) {
switch ($name) {
case 'Conrad Grebel University College':
$class = 'org-cgc';
break;
case 'Faculty of Arts':
case 'Arts':
$class = 'org-art';
break;
case 'Faculty of Engineering':
case 'Engineering':
$class = 'org-eng';
break;
case 'Faculty of Environment':
case 'Environment':
$class = 'org-env';
break;
case 'Faculty of Health':
case 'Health':
$class = 'org-ahs';
break;
case 'Faculty of Mathematics':
case 'Math':
$class = 'org-mat';
break;
case 'Faculty of Science':
case 'Science':
$class = 'org-sci';
break;
......@@ -82,3 +101,121 @@ function uw_get_short_faculty_tag(string $label): string {
return str_replace('Faculty of ', '', $label);
}
/**
* Function to get the content type list that use tags and their links.
*
* @return string[]
* Array of content types with tags and their links.
*/
function uw_get_content_type_list_for_tags(): array {
// The list of content types and their listing page url.
return [
'uw_ct_blog' => 'blog',
'uw_ct_event' => 'events',
'uw_ct_news_item' => 'news',
'uw_ct_opportunity' => 'opportunities',
'uw_ct_profile' => 'profiles',
'uw_ct_project' => 'projects/search',
'uw_ct_service' => 'services',
];
}
/**
* Function to get the tag field names and their links.
*
* @return string[]
* Array to get the field names and their links.
*/
function uw_get_tag_field_names_and_links(): array {
// The tag field names to use in the parameters.
return [
'field_uw_audience' => 'audience',
'field_uw_event_type' => 'type',
'field_uw_opportunity_type' => 'opportunity_type',
'field_uw_opportunity_employment' => 'employment_type',
'field_uw_opportunity_pay_type' => 'rate_of_pay',
'field_uw_ct_profile_type' => 'type',
'field_uw_project_status' => 'status',
'field_uw_project_topics' => 'topics',
'field_uw_service_audience' => 'audience',
'field_uw_service_category' => 'categories',
];
}
/**
* Function to fix the array for tags.
*
* @param array $tags
* The array of tags.
* @param string $content_type
* The content type.
*
* @return array
* Array of fixed tags.
*/
function uw_fix_tags_array(array $tags, string $content_type): array {
// The tag field names to use in the parameters.
$tag_field_names = uw_get_tag_field_names_and_links();
// Get the content type list for tags.
$content_type_list = uw_get_content_type_list_for_tags();
// Step through each of the tags and get the
// correct url.
foreach ($tags as $index => $tag) {
// Start the url to the content type listing page, service
// category does not require the content type after the /.
if ($tag['field_name'] !== 'field_uw_service_category') {
$new_url = '/' . $content_type_list[$content_type];
}
else {
$new_url = '';
}
// If the tag is in the list of field names to convert,
// then convert them using the url provided, if not use
// the field name with tags.
if (array_key_exists($tag['field_name'], $tag_field_names)) {
// If this is not a service tag, add the query parameters.
// Services require a special url, so we will take care
// of that later.
if (
$tag['field_name'] !== 'field_uw_service_audience' &&
$tag['field_name'] !== 'field_uw_service_category'
) {
$new_url .= '?' . $tag_field_names[$tag['field_name']];
}
}
else {
$new_url .= '?tags';
}
// Add the tid to the new url, projects status requires
// the non array for tid.
if ($tag['field_name'] == 'field_uw_project_status') {
$new_url .= '=' . $tag['tid'];
}
// If this is a service, just use the url to the term.
elseif (
$tag['field_name'] == 'field_uw_service_audience' ||
$tag['field_name'] == 'field_uw_service_category'
) {
$new_url .= $tag['url'];
}
// Add the array tid query parameter.
else {
$new_url .= '[' . $tag['tid'] . ']=' . $tag['tid'];
}
// Set the new url.
$tags[$index]['url'] = $new_url;
}
return $tags;
}
......@@ -9,6 +9,7 @@ use Drupal\Core\ProxyClass\Extension\ModuleInstaller;
use Drupal\uw_cfg_common\Service\UWMissingBlocks;
use Drupal\uw_cfg_common\UwPermissions\UwPermissions;
use Drupal\uw_cfg_common\UwRoles\UwRoles;
use Drupal\uw_multilingual\Service\UwMultiLingualSetupInterface;
use Drush\Commands\DrushCommands;
use Drush\Utils\StringUtils;
......@@ -54,6 +55,13 @@ class UwDrushCommands extends DrushCommands {
*/
protected $moduleInstaller;
/**
* Uw Multi-Lingual service.
*
* @var \Drupal\uw_multilingual\Service\UwMultiLingualSetupInterface
*/
protected $uwMultiLingualService;
/**
* {@inheritDoc}
*/
......@@ -62,13 +70,15 @@ class UwDrushCommands extends DrushCommands {
UWMissingBlocks $missingBlocks,
ConfigFactoryInterface $configFactory,
ModuleHandlerInterface $moduleHandler,
ModuleInstaller $moduleInstaller
ModuleInstaller $moduleInstaller,
UwMultiLingualSetupInterface $uwMultiLingualService
) {
$this->entityTypeManager = $entityTypeManager;
$this->missingBlocks = $missingBlocks;
$this->configFactory = $configFactory;
$this->moduleHandler = $moduleHandler;
$this->moduleInstaller = $moduleInstaller;
$this->uwMultiLingualService = $uwMultiLingualService;
}
/**
......@@ -288,4 +298,29 @@ class UwDrushCommands extends DrushCommands {
}
}
/**
* Call service of multi-lingual module to set up language settings.
*
* @param string $language_code
* The language code to update the entities to.
*
* @command uw:update-language
* @aliases uwul
* @usage uw:update-language fr
* - Create the FR language and configure all settings.
*
* @throws \Exception
*/
public function updateLanguage(string $language_code) {
try {
$this->uwMultiLingualService->setupSiteConfiguration([
'language' => $language_code,
]);
drush_backend_batch_process();
}
catch (\Exception $exception) {
$this->logger()->error($exception->getMessage());
}
}
}
<?php
namespace Drupal\uw_cfg_common\Form;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Form\FormStateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class DefaultForm.
*/
class UwVideoBannerConfigForm extends ConfigFormBase {
/**
* Drupal\Core\Entity\EntityTypeManagerInterface definition.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->entityTypeManager = $container->get('entity_type.manager');
$instance->currentUser = $container->get('current_user');
return $instance;
}
/**
* {@inheritdoc}
*/
protected function getEditableConfigNames() {
return [
'uw_cfg_common_video_banner.settings',
];
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'video_banner_settings';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('uw_cfg_common_video_banner.settings');
$form['settings']['video_banner_enabled'] = [
'#type' => 'checkbox',
'#title' => $this->t('Enable third-party video banners using a paid Vimeo account'),
'#description' => $this->t('ONLY enable this if you will be using a video from a paid Vimeo account. Videos from free accounts will display the video player and other Vimeo interface elements over the video.'),
'#default_value' => $config->get('video_banner_enabled'),
];
return parent::buildForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
parent::submitForm($form, $form_state);
$config = $this->config('uw_cfg_common_video_banner.settings');
$config->set('video_banner_enabled', $form_state->getValue('video_banner_enabled'));
$config->save();
}
}
......@@ -701,7 +701,20 @@ class UwNodeFieldValue {
// Step through each of the terms and add to array.
foreach ($field_name as $field) {
$tags = array_merge($tags, $this->getTermsFromEntityField($node->$field, 'tags'));
$tags = array_merge($tags, $this->getTermsFromEntityField($node->$field, 'tags', $field));
}
// If the content type is in the list to convert,
// then perform the url conversion.
if (
array_key_exists(
$node->getType(),
uw_get_content_type_list_for_tags()
)
) {
// Fix the array of tags with correct urls.
$tags = uw_fix_tags_array($tags, $node->getType());
}
// Return array of terms.
......@@ -855,13 +868,19 @@ class UwNodeFieldValue {
* List of values for the provided field.
* @param string|null $type
* The type of terms to get, if none provided just term name returned.
* @param string|null $field_name
* The name of the field.
*
* @return array
* List of terms with name and link.
*
* @throws \Drupal\Core\Entity\EntityMalformedException
*/
public function getTermsFromEntityField(EntityReferenceFieldItemListInterface $values, string $type = NULL): array {
public function getTermsFromEntityField(
EntityReferenceFieldItemListInterface $values,
string $type = NULL,
string $field_name = NULL
): array {
// Array to hold the terms, need to set to
// null in case there are no terms to be
......@@ -907,6 +926,8 @@ class UwNodeFieldValue {
$terms[] = [
'title' => $term_entity->getName(),
'url' => $url,
'tid' => $term_entity->id(),
'field_name' => $field_name,
];
}
else {
......
......@@ -49,5 +49,6 @@ permissions:
- 'customize shortcut links'
- 'edit users role expire'
- 'enable disable ofis profiles'
- 'enable disable third-party video settings'
- 'publish own pdfs'
- 'view UW CSV reports'
......@@ -66,3 +66,4 @@ dependencies:
- 'subpathauto:subpathauto'
- 'transliterate_filenames:transliterate_filenames'
- 'uw_media:uw_media'
- 'uw_multilingual:uw_multilingual'
......@@ -727,3 +727,7 @@ uw_site_management.uw_menu_report_csv:
menu_name: uw-menu-site-management
route_name: uw_cfg_common.uw_menu_report_csv
weight: 0
uw_site_management.third_party_video_banner_settings:
title: 'Third-party video banner settings'
menu_name: uw-menu-site-management
route_name: uw_cfg_common.video_banner_settings_form
......@@ -1217,11 +1217,6 @@ function uw_cfg_common_form_user_register_form_alter(array &$form, FormStateInte
*/
function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state, string $form_id): void {
// Hide hide_branding field in simple sitemap settings.
if ($form_id == 'simple_sitemap_settings_form' && isset($form['settings']['hide_branding'])) {
unset($form['settings']['hide_branding']);
}
// Only blog, event and news item has 'Image' option.
$hero_image_form_ids = [
'node_uw_ct_blog_form',
......@@ -1289,6 +1284,15 @@ function uw_cfg_common_form_alter(array &$form, FormStateInterface $form_state,
// Add custom validation for blank summaries.
$form['#validate'][] = '_uw_cfg_common_blank_summaries_validation';
}
// Get the vimeo banner settings.
$config = \Drupal::config('uw_cfg_common_video_banner.settings');
// If the vimeo video banner is not enabled, remove the
// option from the dropdown for banners.
if (!$config->get('video_banner_enabled')) {
unset($form['field_uw_banner']['widget']['add_more']['add_more_button_uw_para_vimeo_video_banner']);
}
}
// ISTWCMS-4648: removing revisions from layout builder page.
......
......@@ -24,3 +24,6 @@
'view UW CSV reports':
title: 'View UW CSV reports'
description: 'Allows access to UW CSV reports.'
'enable disable third-party video settings':
title: 'Access third-party video settings'
description: 'Allows access to configure third-party video settings.'
......@@ -62,3 +62,12 @@ bibcite_import.populate:
_title: 'Populate publication reference values'
requirements:
_permission: 'bibcite populate+administer bibcite'
uw_cfg_common.video_banner_settings_form:
path: '/admin/third-party-video-banner-settings'
defaults:
_form: '\Drupal\uw_cfg_common\Form\UwVideoBannerConfigForm'
_title: 'Third-party video banner settings'
requirements:
_permission: 'enable disable third-party video settings'
options:
_admin_route: TRUE
services:
uw_cfg_common.drush_commands:
class: Drupal\uw_cfg_common\Commands\UwDrushCommands
arguments: [ '@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@module_handler', '@module_installer' ]
arguments: [ '@entity_type.manager', '@uw_cfg_common.missing_blocks', '@config.factory', '@module_handler', '@module_installer', '@uw_multilingual.setup_new_language' ]
tags:
- { name: drush.command }
uw_cfg_common.uw_ldap:
......