Commit 791a2784 authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into prod/1.0.x

parents 9dc51be6 e15f4865
langcode: en
status: true
dependencies:
module:
- node
- options
id: node.field_uw_type_of_media
field_name: field_uw_type_of_media
entity_type: node
type: list_string
settings:
allowed_values:
-
value: image
label: Image
allowed_values_function: ''
module: options
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
......@@ -21,7 +21,7 @@ filters:
status: true
weight: -46
settings:
allowed_html: '<a class data-entity-substitution data-entity-type data-entity-uuid download href hreflang id name rel rev> <abbr title> <acronym title> <address> <b> <blockquote> <br> <caption> <cite> <code> <col span width> <colgroup span width> <dd> <del> <dfn> <div class id lang> <dl> <dt> <em> <h2 class id> <h3 class id> <h4 class id> <h5 class id> <h6 class id> <hr> <i> <img alt height longdesc src width> <ins> <kbd> <li value> <ol start> <p class> <pre> <s> <samp> <span class> <strike> <strong> <sub> <sup> <table class id width> <tbody> <td abbr axis colspan headers rowspan scope width> <tfoot> <th abbr axis colspan headers rowspan scope width> <thead> <tr> <ul> <var>'
allowed_html: '<a class data-entity-substitution data-entity-type data-entity-uuid download href hreflang id name rel rev> <abbr title> <acronym title> <address> <b> <blockquote> <br> <caption> <cite> <code> <col span width> <colgroup span width> <dd> <del> <dfn> <div class id lang> <dl> <dt> <em> <h2 class id> <h3 class id> <h4 class id> <h5 class id> <h6 class id> <hr> <i> <img alt height longdesc src width> <ins> <kbd> <li value> <ol class start> <p class> <pre> <s> <samp> <span class> <strike> <strong> <sub> <sup> <table class id width> <tbody> <td abbr axis colspan headers rowspan scope width> <tfoot> <th abbr axis colspan headers rowspan scope width> <thead> <tr> <ul class> <var>'
filter_html_help: true
filter_html_nofollow: false
editor_file_reference:
......
......@@ -17,7 +17,7 @@ filters:
status: true
weight: -48
settings:
allowed_html: '<a class data-entity-substitution data-entity-type data-entity-uuid download href hreflang id name rel rev> <abbr title> <acronym title> <address> <b> <blockquote> <br> <caption> <cite> <code> <col span width> <colgroup span width> <dd> <del> <dfn> <div class id lang> <dl> <drupal-media alt data-align data-caption data-entity-type data-entity-uuid data-height data-view-mode data-width title> <dt> <em> <footer> <h2 class id> <h3 class id> <h4 class id> <h5 class id> <h6 class id> <hr> <i> <img alt height longdesc src width> <ins> <kbd> <li value> <ol start> <p class> <pre> <s> <samp> <span class> <strike> <strong> <sub> <sup> <table class id width> <tbody> <td abbr axis colspan headers rowspan scope width> <tfoot> <th abbr axis colspan headers rowspan scope width> <thead> <tr> <ul> <var>'
allowed_html: '<a class data-entity-substitution data-entity-type data-entity-uuid download href hreflang id name rel rev> <abbr title> <acronym title> <address> <b> <blockquote> <br> <caption> <cite> <code> <col span width> <colgroup span width> <dd> <del> <dfn> <div class id lang> <dl> <drupal-media alt data-align data-caption data-entity-type data-entity-uuid data-height data-view-mode data-width title> <dt> <em> <footer> <h2 class id> <h3 class id> <h4 class id> <h5 class id> <h6 class id> <hr> <i> <img alt height longdesc src width> <ins> <kbd> <li value> <ol class start> <p class> <pre> <s> <samp> <span class> <strike> <strong> <sub> <sup> <table class id width> <tbody> <td abbr axis colspan headers rowspan scope width> <tfoot> <th abbr axis colspan headers rowspan scope width> <thead> <tr> <ul class> <var>'
filter_html_help: true
filter_html_nofollow: false
filter_htmlcorrector:
......
langcode: en
status: true
dependencies: { }
id: uw_lbb_opportunity_list
block_id: 'views_block:uw_view_opportunities-block_1'
category: uw_bc_listings
label: 'Opportunity list'
weight: null
image_path: images/layout_builder_browser/opportunitylist.svg
image_path_base: 'theme:uw_fdsu_theme_resp'
image_alt: 'Opportunity list'
langcode: en
status: true
dependencies: { }
id: uw_lbb_opportunity_teaser
block_id: uw_cbl_opportunity_teaser
category: uw_bc_teasers
label: 'Opportunity teaser'
weight: null
image_path: images/layout_builder_browser/opportunityteaser.svg
image_path_base: 'theme:uw_fdsu_theme_resp'
image_alt: 'Opportunity teaser'
......@@ -5,7 +5,7 @@ id: uw_lbb_service_teaser
block_id: uw_cbl_service_teaser
category: uw_bc_teasers
label: 'Service teaser'
weight: -100
weight: 0
image_path: images/layout_builder_browser/serviceteaser.svg
image_path_base: 'theme:uw_fdsu_theme_resp'
image_alt: 'Service teaser'
......@@ -4,8 +4,8 @@ dependencies: { }
id: uw_lbb_services_list
block_id: 'inline_block:uw_cbl_services_list'
category: uw_bc_listings
label: 'Services list'
label: 'Service list'
weight: 0
image_path: images/layout_builder_browser/servicelist.svg
image_path_base: 'theme:uw_fdsu_theme_resp'
image_alt: 'Services listing'
image_alt: 'Service list'
......@@ -4,8 +4,8 @@ dependencies: { }
id: uw_lbb_services_search
block_id: uw_cbl_services_search
category: uw_bc_searches
label: 'Services search'
label: 'Service search'
weight: 0
image_path: images/layout_builder_browser/servicesearch.svg
image_path_base: 'theme:uw_fdsu_theme_resp'
image_alt: 'Services search'
image_alt: 'Service search'
<?php
namespace Drupal\uw_cfg_common\Helpers;
use Drupal\features\FeaturesManagerInterface;
use Drupal\features\ConfigurationItem;
use Drupal\features\Package;
use Drupal\config_update\ConfigRevertInterface;
/**
* Class to perform feature revert.
*/
class UwFeatureRevert {
/**
* Features manager.
*
* @var \Drupal\features\FeaturesManagerInterface
*/
private $featuresManager;
/**
* Config update revert.
*
* @var \Drupal\config_update\ConfigRevertInterface
*/
private $configRevert;
/**
* Default constructor.
*
* @param \Drupal\features\FeaturesManagerInterface $featuresManager
* Features manager.
* @param Drupal\config_update\ConfigRevertInterface $configRevert
* The config update revert.
*/
public function __construct(
FeaturesManagerInterface $featuresManager,
ConfigRevertInterface $configRevert
) {
$this->featuresManager = $featuresManager;
$this->configRevert = $configRevert;
}
/**
* Load the features from the module.
*
* @param string $module
* Array of modules.
* @param bool $any
* Flag for all modules.
*
* @return \Drupal\features\Package
* The list of packages.
*/
private function drushFeaturesLoadFeature(string $module, bool $any = FALSE): Package {
// Get the features manager.
$manager = $this->featuresManager;
// Get teh feature.
$feature = $manager->getPackage($module);
// Check if this get any or not a feature module.
if ($any && !isset($feature)) {
// See if this is a non-features module.
$module_handler = \Drupal::moduleHandler();
$modules = $module_handler->getModuleList();
// If it is not a feature module, set it up as one.
if (!empty($modules[$module])) {
$extension = $modules[$module];
$feature = $manager->initPackageFromExtension($extension);
$config = $manager->listExtensionConfig($extension);
$feature->setConfig($config);
$feature->setStatus(FeaturesManagerInterface::STATUS_INSTALLED);
}
}
return $feature;
}
/**
* Copy from file features.drush.inc.
*/
public function import($args) {
// Determine if revert should be forced.
$force = TRUE;
// Determine if -y was supplied. If so, we can filter out needless output
// from this command.
$skip_confirmation = TRUE;
// Get the feature manager.
$manager = $this->featuresManager;
// Get the config update revert.
$config_revert = $this->configRevert;
// Parse list of arguments.
$modules = [];
foreach ($args as $arg) {
$arg = explode(':', $arg);
$module = array_shift($arg);
$component = array_shift($arg);
if (isset($module)) {
if (empty($component)) {
// If we received just a feature name, this means that we need all of
// its components.
$modules[$module] = TRUE;
}
elseif ($modules[$module] !== TRUE) {
if (!isset($modules[$module])) {
$modules[$module] = [];
}
$modules[$module][] = $component;
}
}
}
// Process modules.
foreach ($modules as $module => $components_needed) {
// Setup the modules array.
$dt_args['@module'] = $module;
// Get the feature information.
$feature = $this->drushFeaturesLoadFeature($module, TRUE);
// If the feature is empty, throw an error and exit.
if (empty($feature)) {
\Drupal::logger('UwFeatureRevert')
->error('No such feature is available: @module', $dt_args);
return;
}
// If the feature status is not set as active, throw error and exit.
if ($feature->getStatus() != FeaturesManagerInterface::STATUS_INSTALLED) {
\Drupal::logger('UwFeatureRevert')
->error('No such feature is installed: @module', $dt_args);
return;
}
// Forcefully revert all components of a feature.
if ($force) {
$components = $feature->getConfigOrig();
}
// Only revert components that are detected to be Overridden.
else {
$components = $manager->detectOverrides($feature);
$missing = $manager->reorderMissing($manager->detectMissing($feature));
// Be sure to import missing components first.
$components = array_merge($missing, $components);
}
if (!empty($components_needed) && is_array($components_needed)) {
$components = array_intersect($components, $components_needed);
}
if (empty($components)) {
\Drupal::logger('UwFeatureRevert')
->notice('Current state already matches active config, aborting.');
}
else {
$config = $manager->getConfigCollection();
foreach ($components as $component) {
$dt_args['@component'] = $component;
if ($skip_confirmation) {
// If there is no config for this present, import it.
if (!isset($config[$component])) {
// Import missing component.
$item = $manager->getConfigType($component);
$type = ConfigurationItem::fromConfigStringToConfigType($item['type']);
$config_revert->import($type, $item['name_short']);
\Drupal::logger('d_application_api')
->notice('Import @module : @component.', $dt_args);
}
else {
// Revert existing component.
$item = $config[$component];
$type = ConfigurationItem::fromConfigStringToConfigType($item->getType());
$config_revert->revert($type, $item->getShortName());
\Drupal::logger('UwFeatureRevert')
->notice('Reverted @module : @component.', $dt_args);
}
}
else {
\Drupal::logger('UwFeatureRevert')
->notice('Skipping @module : @component.', $dt_args);
}
}
}
}
}
}
<?php
namespace Drupal\uw_cfg_common\Plugin\CKEditorPlugin;
use Drupal\ckeditor\CKEditorPluginBase;
use Drupal\Core\Asset\LibrariesDirectoryFileFinder;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\editor\Entity\Editor;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Defines the "link" plugin.
*
* @CKEditorPlugin(
* id = "link",
* label = @Translation("link")
* )
*/
class LinkPlugin extends CKEditorPluginBase implements ContainerFactoryPluginInterface {
/**
* Library file finder.
*
* @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder
*/
protected $libFileFinder;
/**
* Constructs a BlockComponentRenderArray object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin ID for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Asset\LibrariesDirectoryFileFinder $libFileFinder
* The library file finder.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, LibrariesDirectoryFileFinder $libFileFinder) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->libFileFinder = $libFileFinder;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('library.libraries_directory_file_finder'));
}
/**
* {@inheritdoc}
*/
public function getDependencies(Editor $editor) {
return [
'fakeobjects',
];
}
/**
* {@inheritdoc}
*/
public function getLibraries(Editor $editor) {
return [];
}
/**
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
return [];
}
/**
* {@inheritdoc}
*/
public function getButtons() {
$libraryUrl = $this->libFileFinder->find('ckeditor.link');
return [
'Link' => [
'label' => $this->t('Link'),
'image' => $libraryUrl . '/icons/link.png',
],
'Unlink' => [
'label' => $this->t('Unlink'),
'image' => $libraryUrl . '/icons/unlink.png',
],
'Anchor' => [
'label' => $this->t('Anchor'),
'image' => $libraryUrl . '/icons/anchor.png',
],
];
}
/**
* {@inheritdoc}
*/
public function getFile() {
return $this->libFileFinder->find('ckeditor.link') . '/plugin.js';
}
/**
* {@inheritdoc}
*/
public function isInternal() {
return FALSE;
}
}
<?php
namespace Drupal\uw_cfg_common\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
/**
* Checks that the submitted value is a unique integer.
*
* @Constraint(
* id = "UwMedia",
* label = @Translation("Media constraint", context = "Validation"),
* type = "string"
* )
*/
class UwMedia extends Constraint {
/**
* Variable for missing media.
*
* @var string
*/
public $mediaMissing = '%value needs to have a media item.';
}
<?php
namespace Drupal\uw_cfg_common\Plugin\Validation\Constraint;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
/**
* Validates the Uw Media constraint.
*/
class UwMediaValidator extends ConstraintValidator {
/**
* {@inheritdoc}
*/
public function validate($items, Constraint $constraint) {
// If the node has a type of media field, then continue
// to check that it has some media.
if ($uw_type_of_media = $items->field_uw_type_of_media) {
// Switch on the type of media select list.
switch ($uw_type_of_media->value) {
// If its a hero image, ensure that an image is selected.
case 'image':
// If there is no hero image, add the violation.
if (!$items->field_uw_hero_image->getValue()) {
$this->context->addViolation($constraint->mediaMissing, ['%value' => 'Hero Image']);
}
break;
}
}
}
}
......@@ -190,6 +190,7 @@ class UWService implements UWServiceInterface {
'uw_ct_contact',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_opportunity',
'uw_ct_profile',
'uw_ct_web_page',
'uw_ct_service',
......@@ -202,6 +203,7 @@ class UWService implements UWServiceInterface {
'uw_ct_contact',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_opportunity',
'uw_ct_profile',
'uw_ct_catalog_item',
'uw_ct_service',
......@@ -215,16 +217,17 @@ class UWService implements UWServiceInterface {
'uw_ct_contact',
'uw_ct_event',
'uw_ct_news_item',
'uw_ct_opportunity',
'uw_ct_profile',
'uw_ct_web_page',
];
break;
case 'featured_image':
case 'media':
$preprocess = [
'uw_ct_blog' => 'field_uw_hero_image',
'uw_ct_event' => 'field_uw_hero_image',
'uw_ct_news_item' => 'field_uw_hero_image',
'uw_ct_blog',
'uw_ct_event',
'uw_ct_news_item',
];
break;
}
......@@ -235,35 +238,34 @@ class UWService implements UWServiceInterface {
/**
* {@inheritDoc}
*/
public function uwCheckNodeForFeaturedImage(Node $node): string {
public function uwCheckNodeForMedia(Node $node): string {
// Set the node type.
$node_type = $node->getType();
// Get the list of content types that are allowed to have
// feature images from our service.
$featured_image = $this->uwGetNodePreprocessing('featured_image');
// hero from our service.
$media = $this->uwGetNodePreprocessing('media');
// If node is allowed to have a featured image, make sure that
// node actually has an image.
if (in_array($node_type, array_keys($featured_image))) {
// If node is allowed to have a media, make sure that
// node actually has a media.
if (in_array($node_type, $media)) {
// Get the field name.
$field_name = $featured_image[$node_type];
// Ensure that the node has the type of media field.
if ($node->hasField('field_uw_type_of_media')) {
// Get the image object values from the node.
$image = $node->$field_name->getValue();
// Get the type of media value from the node.
$value = $node->field_uw_type_of_media->value;
// If there is an image present, set the variable so that
// the page title will not be displayed.
if ($image) {
return 'yes';
}
else {
return 'no';
// If there is a media present, set the variable so that
// the page title will not be displayed.
if ($value) {
return 'yes';
}
}
}
// Return a no by default.
return 'no';
}
......
......@@ -68,7 +68,7 @@ interface UWServiceInterface {
* @return string
* Yes or no.
*/
public function uwCheckNodeForFeaturedImage(Node $node): string;
public function uwCheckNodeForMedia(Node $node): string;
/**
* A function to get or check the attached sidebar.
......
......@@ -84,6 +84,10 @@ class UwNodeContent {
case 'uw_ct_service':
$content_data = $this->getServiceContent($node_flags);
break;
case 'uw_ct_opportunity':
$content_data = $this->getOpportunityContent($node_flags, $view_mode);
break;
}
return $this->uwNodeData->getNodeData($node, $view_mode, $content_data);
......@@ -124,7 +128,8 @@ class UwNodeContent {
$node_flags['get_image'] = FALSE;
$node_flags['get_content'] = FALSE;
$node_flags['get_title'] = FALSE;
$node_flags['get_hero'] = FALSE;
$node_flags['get_media'