Issue #3270899 by Spokje, quietone, q0rban, longwave, ravi.shankar, dww, andypost, bbrala, Wim Leers: Remove Color module from core
|
@ -14,9 +14,6 @@
|
||||||
"../**/LICENSE.txt",
|
"../**/LICENSE.txt",
|
||||||
"modules/**/Migrate*Test.php",
|
"modules/**/Migrate*Test.php",
|
||||||
"modules/ckeditor5/js/build/*",
|
"modules/ckeditor5/js/build/*",
|
||||||
"modules/color/preview.html",
|
|
||||||
"modules/color/tests/fixtures/drupal7.php",
|
|
||||||
"modules/color/tests/modules/color_test/themes/color_test_theme/color/preview.html",
|
|
||||||
"modules/media/tests/fixtures/oembed/*",
|
"modules/media/tests/fixtures/oembed/*",
|
||||||
"modules/migrate_drupal/tests/fixtures/drupal6.php",
|
"modules/migrate_drupal/tests/fixtures/drupal6.php",
|
||||||
"modules/migrate_drupal/tests/fixtures/drupal7.php",
|
"modules/migrate_drupal/tests/fixtures/drupal7.php",
|
||||||
|
|
|
@ -129,9 +129,6 @@ Claro
|
||||||
Classy
|
Classy
|
||||||
- David Hernandez 'davidhernandez' https://www.drupal.org/u/davidhernandez
|
- David Hernandez 'davidhernandez' https://www.drupal.org/u/davidhernandez
|
||||||
|
|
||||||
Color
|
|
||||||
- ?
|
|
||||||
|
|
||||||
Comment
|
Comment
|
||||||
- Lee Rowlands 'larowlan' https://www.drupal.org/u/larowlan
|
- Lee Rowlands 'larowlan' https://www.drupal.org/u/larowlan
|
||||||
- Andrey Postnikov 'andypost' https://www.drupal.org/u/andypost
|
- Andrey Postnikov 'andypost' https://www.drupal.org/u/andypost
|
||||||
|
|
|
@ -446,7 +446,6 @@ fakepath
|
||||||
falsey
|
falsey
|
||||||
falsish
|
falsish
|
||||||
fapi
|
fapi
|
||||||
farb
|
|
||||||
farbtastic
|
farbtastic
|
||||||
fatals
|
fatals
|
||||||
favourite
|
favourite
|
||||||
|
@ -491,7 +490,6 @@ fodg
|
||||||
fodp
|
fodp
|
||||||
fods
|
fods
|
||||||
fodt
|
fodt
|
||||||
fontsizer
|
|
||||||
fooalert
|
fooalert
|
||||||
foobarbaz
|
foobarbaz
|
||||||
foobargorilla
|
foobargorilla
|
||||||
|
|
|
@ -1,338 +0,0 @@
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Attaches the behaviors for the Color module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function ($, Drupal) {
|
|
||||||
/**
|
|
||||||
* Displays farbtastic color selector and initialize color administration UI.
|
|
||||||
*
|
|
||||||
* @type {Drupal~behavior}
|
|
||||||
*
|
|
||||||
* @prop {Drupal~behaviorAttach} attach
|
|
||||||
* Attach color selection behavior to relevant context.
|
|
||||||
*/
|
|
||||||
Drupal.behaviors.color = {
|
|
||||||
attach(context, settings) {
|
|
||||||
let i;
|
|
||||||
let j;
|
|
||||||
let colors;
|
|
||||||
// This behavior attaches by ID, so is only valid once on a page.
|
|
||||||
const form = $(
|
|
||||||
once('color', '#system-theme-settings .color-form', context),
|
|
||||||
);
|
|
||||||
if (form.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const inputs = [];
|
|
||||||
const hooks = [];
|
|
||||||
const locks = [];
|
|
||||||
let focused = null;
|
|
||||||
|
|
||||||
// Add Farbtastic.
|
|
||||||
$(once('color', $('<div class="color-placeholder"></div>'))).prependTo(
|
|
||||||
form,
|
|
||||||
);
|
|
||||||
const farb = $.farbtastic('.color-placeholder');
|
|
||||||
|
|
||||||
// Decode reference colors to HSL.
|
|
||||||
const reference = settings.color.reference;
|
|
||||||
Object.keys(reference || {}).forEach((color) => {
|
|
||||||
reference[color] = farb.RGBToHSL(farb.unpack(reference[color]));
|
|
||||||
});
|
|
||||||
|
|
||||||
// Build a preview.
|
|
||||||
const height = [];
|
|
||||||
const width = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders the preview.
|
|
||||||
*/
|
|
||||||
function preview() {
|
|
||||||
Drupal.color.callback(context, settings, form, farb, height, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Resets the color scheme selector.
|
|
||||||
*/
|
|
||||||
function resetScheme() {
|
|
||||||
form.find('#edit-scheme').each(function () {
|
|
||||||
this.selectedIndex = this.options.length - 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shifts a given color, using a reference pair (ref in HSL).
|
|
||||||
*
|
|
||||||
* This algorithm ensures relative ordering on the saturation and
|
|
||||||
* luminance axes is preserved, and performs a simple hue shift.
|
|
||||||
*
|
|
||||||
* It is also symmetrical. If: shiftColor(c, a, b) === d, then
|
|
||||||
* shiftColor(d, b, a) === c.
|
|
||||||
*
|
|
||||||
* @function Drupal.color~shiftColor
|
|
||||||
*
|
|
||||||
* @param {string} given
|
|
||||||
* A hex color code to shift.
|
|
||||||
* @param {Array.<number>} ref1
|
|
||||||
* First HSL color reference.
|
|
||||||
* @param {Array.<number>} ref2
|
|
||||||
* Second HSL color reference.
|
|
||||||
*
|
|
||||||
* @return {string}
|
|
||||||
* A hex color, shifted.
|
|
||||||
*/
|
|
||||||
function shiftColor(given, ref1, ref2) {
|
|
||||||
let d;
|
|
||||||
// Convert to HSL.
|
|
||||||
given = farb.RGBToHSL(farb.unpack(given));
|
|
||||||
|
|
||||||
// Hue: apply delta.
|
|
||||||
given[0] += ref2[0] - ref1[0];
|
|
||||||
|
|
||||||
// Saturation: interpolate.
|
|
||||||
if (ref1[1] === 0 || ref2[1] === 0) {
|
|
||||||
given[1] = ref2[1];
|
|
||||||
} else {
|
|
||||||
d = ref1[1] / ref2[1];
|
|
||||||
if (d > 1) {
|
|
||||||
given[1] /= d;
|
|
||||||
} else {
|
|
||||||
given[1] = 1 - (1 - given[1]) * d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Luminance: interpolate.
|
|
||||||
if (ref1[2] === 0 || ref2[2] === 0) {
|
|
||||||
given[2] = ref2[2];
|
|
||||||
} else {
|
|
||||||
d = ref1[2] / ref2[2];
|
|
||||||
if (d > 1) {
|
|
||||||
given[2] /= d;
|
|
||||||
} else {
|
|
||||||
given[2] = 1 - (1 - given[2]) * d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return farb.pack(farb.HSLToRGB(given));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for Farbtastic when a new color is chosen.
|
|
||||||
*
|
|
||||||
* @param {HTMLElement} input
|
|
||||||
* The input element where the color is chosen.
|
|
||||||
* @param {string} color
|
|
||||||
* The color that was chosen through the input.
|
|
||||||
* @param {bool} propagate
|
|
||||||
* Whether or not to propagate the color to a locked pair value
|
|
||||||
* @param {bool} colorScheme
|
|
||||||
* Flag to indicate if the user is using a color scheme when changing
|
|
||||||
* the color.
|
|
||||||
*/
|
|
||||||
function callback(input, color, propagate, colorScheme) {
|
|
||||||
let matched;
|
|
||||||
// Set background/foreground colors.
|
|
||||||
$(input).css({
|
|
||||||
backgroundColor: color,
|
|
||||||
color: farb.RGBToHSL(farb.unpack(color))[2] > 0.5 ? '#000' : '#fff',
|
|
||||||
});
|
|
||||||
|
|
||||||
// Change input value.
|
|
||||||
if (input.value && input.value !== color) {
|
|
||||||
input.value = color;
|
|
||||||
|
|
||||||
// Update locked values.
|
|
||||||
if (propagate) {
|
|
||||||
i = input.i;
|
|
||||||
for (j = i + 1; ; ++j) {
|
|
||||||
if (!locks[j - 1] || $(locks[j - 1]).is('.is-unlocked')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
matched = shiftColor(
|
|
||||||
color,
|
|
||||||
reference[input.key],
|
|
||||||
reference[inputs[j].key],
|
|
||||||
);
|
|
||||||
callback(inputs[j], matched, false);
|
|
||||||
}
|
|
||||||
for (j = i - 1; ; --j) {
|
|
||||||
if (!locks[j] || $(locks[j]).is('.is-unlocked')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
matched = shiftColor(
|
|
||||||
color,
|
|
||||||
reference[input.key],
|
|
||||||
reference[inputs[j].key],
|
|
||||||
);
|
|
||||||
callback(inputs[j], matched, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update preview.
|
|
||||||
preview();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reset colorScheme selector.
|
|
||||||
if (!colorScheme) {
|
|
||||||
resetScheme();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through all defined gradients.
|
|
||||||
Object.keys(settings.gradients || {}).forEach((i) => {
|
|
||||||
// Add element to display the gradient.
|
|
||||||
$(once('color', '.color-preview')).append(
|
|
||||||
`<div id="gradient-${i}"></div>`,
|
|
||||||
);
|
|
||||||
const gradient = $(`.color-preview #gradient-${i}`);
|
|
||||||
// Add height of current gradient to the list (divided by 10).
|
|
||||||
height.push(parseInt(gradient.css('height'), 10) / 10);
|
|
||||||
// Add width of current gradient to the list (divided by 10).
|
|
||||||
width.push(parseInt(gradient.css('width'), 10) / 10);
|
|
||||||
// Add rows (or columns for horizontal gradients).
|
|
||||||
// Each gradient line should have a height (or width for horizontal
|
|
||||||
// gradients) of 10px (because we divided the height/width by 10
|
|
||||||
// above).
|
|
||||||
for (
|
|
||||||
j = 0;
|
|
||||||
j <
|
|
||||||
(settings.gradients[i].direction === 'vertical'
|
|
||||||
? height[i]
|
|
||||||
: width[i]);
|
|
||||||
++j
|
|
||||||
) {
|
|
||||||
gradient.append('<div class="gradient-line"></div>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set up colorScheme selector.
|
|
||||||
form.find('#edit-scheme').on('change', function () {
|
|
||||||
const schemes = settings.color.schemes;
|
|
||||||
const colorScheme = this.options[this.selectedIndex].value;
|
|
||||||
if (colorScheme !== '' && schemes[colorScheme]) {
|
|
||||||
// Get colors of active scheme.
|
|
||||||
colors = schemes[colorScheme];
|
|
||||||
Object.keys(colors || {}).forEach((fieldName) => {
|
|
||||||
callback(
|
|
||||||
$(`#edit-palette-${fieldName}`),
|
|
||||||
colors[fieldName],
|
|
||||||
false,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
});
|
|
||||||
preview();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Focuses Farbtastic on a particular field.
|
|
||||||
*
|
|
||||||
* @param {jQuery.Event} e
|
|
||||||
* The focus event on the field.
|
|
||||||
*/
|
|
||||||
function focus(e) {
|
|
||||||
const input = e.target;
|
|
||||||
// Remove old bindings.
|
|
||||||
if (focused) {
|
|
||||||
$(focused)
|
|
||||||
.off('keyup', farb.updateValue)
|
|
||||||
.off('keyup', preview)
|
|
||||||
.off('keyup', resetScheme)
|
|
||||||
.parent()
|
|
||||||
.removeClass('item-selected');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add new bindings.
|
|
||||||
focused = input;
|
|
||||||
farb.linkTo((color) => {
|
|
||||||
callback(input, color, true, false);
|
|
||||||
});
|
|
||||||
farb.setColor(input.value);
|
|
||||||
$(focused)
|
|
||||||
.on('keyup', farb.updateValue)
|
|
||||||
.on('keyup', preview)
|
|
||||||
.on('keyup', resetScheme)
|
|
||||||
.parent()
|
|
||||||
.addClass('item-selected');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Initialize color fields.
|
|
||||||
form
|
|
||||||
.find('.js-color-palette input.form-text')
|
|
||||||
.each(function () {
|
|
||||||
// Extract palette field name.
|
|
||||||
this.key = this.id.substring(13);
|
|
||||||
|
|
||||||
// Link to color picker temporarily to initialize.
|
|
||||||
farb
|
|
||||||
.linkTo(() => {})
|
|
||||||
.setColor('#000')
|
|
||||||
.linkTo(this);
|
|
||||||
|
|
||||||
// Add lock.
|
|
||||||
const i = inputs.length;
|
|
||||||
if (inputs.length) {
|
|
||||||
let toggleClick = true;
|
|
||||||
const lock = $(
|
|
||||||
`<button class="color-palette__lock">${Drupal.t(
|
|
||||||
'Unlock',
|
|
||||||
)}</button>`,
|
|
||||||
).on('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
if (toggleClick) {
|
|
||||||
$(this).addClass('is-unlocked').html(Drupal.t('Lock'));
|
|
||||||
$(hooks[i - 1]).attr(
|
|
||||||
'class',
|
|
||||||
locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)')
|
|
||||||
? 'color-palette__hook is-up'
|
|
||||||
: 'color-palette__hook',
|
|
||||||
);
|
|
||||||
$(hooks[i]).attr(
|
|
||||||
'class',
|
|
||||||
locks[i] && $(locks[i]).is(':not(.is-unlocked)')
|
|
||||||
? 'color-palette__hook is-down'
|
|
||||||
: 'color-palette__hook',
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$(this).removeClass('is-unlocked').html(Drupal.t('Unlock'));
|
|
||||||
$(hooks[i - 1]).attr(
|
|
||||||
'class',
|
|
||||||
locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)')
|
|
||||||
? 'color-palette__hook is-both'
|
|
||||||
: 'color-palette__hook is-down',
|
|
||||||
);
|
|
||||||
$(hooks[i]).attr(
|
|
||||||
'class',
|
|
||||||
locks[i] && $(locks[i]).is(':not(.is-unlocked)')
|
|
||||||
? 'color-palette__hook is-both'
|
|
||||||
: 'color-palette__hook is-up',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
toggleClick = !toggleClick;
|
|
||||||
});
|
|
||||||
$(this).after(lock);
|
|
||||||
locks.push(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add hook.
|
|
||||||
const hook = $('<div class="color-palette__hook"></div>');
|
|
||||||
$(this).after(hook);
|
|
||||||
hooks.push(hook);
|
|
||||||
|
|
||||||
$(this).parent().find('.color-palette__lock').trigger('click');
|
|
||||||
this.i = i;
|
|
||||||
inputs.push(this);
|
|
||||||
})
|
|
||||||
.on('focus', focus);
|
|
||||||
|
|
||||||
form.find('.js-color-palette label');
|
|
||||||
|
|
||||||
// Focus first color.
|
|
||||||
inputs[0].focus();
|
|
||||||
|
|
||||||
// Render preview.
|
|
||||||
preview();
|
|
||||||
},
|
|
||||||
};
|
|
||||||
})(jQuery, Drupal);
|
|
|
@ -1,7 +0,0 @@
|
||||||
name: Color
|
|
||||||
type: module
|
|
||||||
description: 'Allows users to change the color scheme of compatible themes.'
|
|
||||||
lifecycle: deprecated
|
|
||||||
lifecycle_link: https://www.drupal.org/node/3223395#s-color
|
|
||||||
package: Core
|
|
||||||
version: VERSION
|
|
|
@ -1,39 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Install, update and uninstall functions for the color module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_requirements().
|
|
||||||
*/
|
|
||||||
function color_requirements($phase) {
|
|
||||||
$requirements = [];
|
|
||||||
|
|
||||||
if ($phase == 'runtime') {
|
|
||||||
// Check for the PHP GD library.
|
|
||||||
if (function_exists('imagegd2')) {
|
|
||||||
$info = gd_info();
|
|
||||||
$requirements['color_gd'] = [
|
|
||||||
'value' => $info['GD Version'],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Check for PNG support.
|
|
||||||
if (!function_exists('imagecreatefrompng')) {
|
|
||||||
$requirements['color_gd']['severity'] = REQUIREMENT_WARNING;
|
|
||||||
$requirements['color_gd']['description'] = t('The GD library for PHP is enabled, but was compiled without PNG support. Check the <a href="http://php.net/manual/ref.image.php">PHP image documentation</a> for information on how to correct this.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$requirements['color_gd'] = [
|
|
||||||
'value' => t('Not installed'),
|
|
||||||
'severity' => REQUIREMENT_ERROR,
|
|
||||||
'description' => t('The GD library for PHP is missing or outdated. Check the <a href="http://php.net/manual/book.image.php">PHP image documentation</a> for information on how to correct this.'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
$requirements['color_gd']['title'] = t('GD library PNG support');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $requirements;
|
|
||||||
}
|
|
|
@ -1,192 +0,0 @@
|
||||||
/**
|
|
||||||
* DO NOT EDIT THIS FILE.
|
|
||||||
* See the following change record for more information,
|
|
||||||
* https://www.drupal.org/node/2815083
|
|
||||||
* @preserve
|
|
||||||
**/
|
|
||||||
|
|
||||||
(function ($, Drupal) {
|
|
||||||
Drupal.behaviors.color = {
|
|
||||||
attach(context, settings) {
|
|
||||||
let i;
|
|
||||||
let j;
|
|
||||||
let colors;
|
|
||||||
const form = $(once('color', '#system-theme-settings .color-form', context));
|
|
||||||
|
|
||||||
if (form.length === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const inputs = [];
|
|
||||||
const hooks = [];
|
|
||||||
const locks = [];
|
|
||||||
let focused = null;
|
|
||||||
$(once('color', $('<div class="color-placeholder"></div>'))).prependTo(form);
|
|
||||||
const farb = $.farbtastic('.color-placeholder');
|
|
||||||
const reference = settings.color.reference;
|
|
||||||
Object.keys(reference || {}).forEach(color => {
|
|
||||||
reference[color] = farb.RGBToHSL(farb.unpack(reference[color]));
|
|
||||||
});
|
|
||||||
const height = [];
|
|
||||||
const width = [];
|
|
||||||
|
|
||||||
function preview() {
|
|
||||||
Drupal.color.callback(context, settings, form, farb, height, width);
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetScheme() {
|
|
||||||
form.find('#edit-scheme').each(function () {
|
|
||||||
this.selectedIndex = this.options.length - 1;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function shiftColor(given, ref1, ref2) {
|
|
||||||
let d;
|
|
||||||
given = farb.RGBToHSL(farb.unpack(given));
|
|
||||||
given[0] += ref2[0] - ref1[0];
|
|
||||||
|
|
||||||
if (ref1[1] === 0 || ref2[1] === 0) {
|
|
||||||
given[1] = ref2[1];
|
|
||||||
} else {
|
|
||||||
d = ref1[1] / ref2[1];
|
|
||||||
|
|
||||||
if (d > 1) {
|
|
||||||
given[1] /= d;
|
|
||||||
} else {
|
|
||||||
given[1] = 1 - (1 - given[1]) * d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ref1[2] === 0 || ref2[2] === 0) {
|
|
||||||
given[2] = ref2[2];
|
|
||||||
} else {
|
|
||||||
d = ref1[2] / ref2[2];
|
|
||||||
|
|
||||||
if (d > 1) {
|
|
||||||
given[2] /= d;
|
|
||||||
} else {
|
|
||||||
given[2] = 1 - (1 - given[2]) * d;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return farb.pack(farb.HSLToRGB(given));
|
|
||||||
}
|
|
||||||
|
|
||||||
function callback(input, color, propagate, colorScheme) {
|
|
||||||
let matched;
|
|
||||||
$(input).css({
|
|
||||||
backgroundColor: color,
|
|
||||||
color: farb.RGBToHSL(farb.unpack(color))[2] > 0.5 ? '#000' : '#fff'
|
|
||||||
});
|
|
||||||
|
|
||||||
if (input.value && input.value !== color) {
|
|
||||||
input.value = color;
|
|
||||||
|
|
||||||
if (propagate) {
|
|
||||||
i = input.i;
|
|
||||||
|
|
||||||
for (j = i + 1;; ++j) {
|
|
||||||
if (!locks[j - 1] || $(locks[j - 1]).is('.is-unlocked')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
matched = shiftColor(color, reference[input.key], reference[inputs[j].key]);
|
|
||||||
callback(inputs[j], matched, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (j = i - 1;; --j) {
|
|
||||||
if (!locks[j] || $(locks[j]).is('.is-unlocked')) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
matched = shiftColor(color, reference[input.key], reference[inputs[j].key]);
|
|
||||||
callback(inputs[j], matched, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
preview();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!colorScheme) {
|
|
||||||
resetScheme();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.keys(settings.gradients || {}).forEach(i => {
|
|
||||||
$(once('color', '.color-preview')).append(`<div id="gradient-${i}"></div>`);
|
|
||||||
const gradient = $(`.color-preview #gradient-${i}`);
|
|
||||||
height.push(parseInt(gradient.css('height'), 10) / 10);
|
|
||||||
width.push(parseInt(gradient.css('width'), 10) / 10);
|
|
||||||
|
|
||||||
for (j = 0; j < (settings.gradients[i].direction === 'vertical' ? height[i] : width[i]); ++j) {
|
|
||||||
gradient.append('<div class="gradient-line"></div>');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
form.find('#edit-scheme').on('change', function () {
|
|
||||||
const schemes = settings.color.schemes;
|
|
||||||
const colorScheme = this.options[this.selectedIndex].value;
|
|
||||||
|
|
||||||
if (colorScheme !== '' && schemes[colorScheme]) {
|
|
||||||
colors = schemes[colorScheme];
|
|
||||||
Object.keys(colors || {}).forEach(fieldName => {
|
|
||||||
callback($(`#edit-palette-${fieldName}`), colors[fieldName], false, true);
|
|
||||||
});
|
|
||||||
preview();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function focus(e) {
|
|
||||||
const input = e.target;
|
|
||||||
|
|
||||||
if (focused) {
|
|
||||||
$(focused).off('keyup', farb.updateValue).off('keyup', preview).off('keyup', resetScheme).parent().removeClass('item-selected');
|
|
||||||
}
|
|
||||||
|
|
||||||
focused = input;
|
|
||||||
farb.linkTo(color => {
|
|
||||||
callback(input, color, true, false);
|
|
||||||
});
|
|
||||||
farb.setColor(input.value);
|
|
||||||
$(focused).on('keyup', farb.updateValue).on('keyup', preview).on('keyup', resetScheme).parent().addClass('item-selected');
|
|
||||||
}
|
|
||||||
|
|
||||||
form.find('.js-color-palette input.form-text').each(function () {
|
|
||||||
this.key = this.id.substring(13);
|
|
||||||
farb.linkTo(() => {}).setColor('#000').linkTo(this);
|
|
||||||
const i = inputs.length;
|
|
||||||
|
|
||||||
if (inputs.length) {
|
|
||||||
let toggleClick = true;
|
|
||||||
const lock = $(`<button class="color-palette__lock">${Drupal.t('Unlock')}</button>`).on('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
if (toggleClick) {
|
|
||||||
$(this).addClass('is-unlocked').html(Drupal.t('Lock'));
|
|
||||||
$(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)') ? 'color-palette__hook is-up' : 'color-palette__hook');
|
|
||||||
$(hooks[i]).attr('class', locks[i] && $(locks[i]).is(':not(.is-unlocked)') ? 'color-palette__hook is-down' : 'color-palette__hook');
|
|
||||||
} else {
|
|
||||||
$(this).removeClass('is-unlocked').html(Drupal.t('Unlock'));
|
|
||||||
$(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.is-unlocked)') ? 'color-palette__hook is-both' : 'color-palette__hook is-down');
|
|
||||||
$(hooks[i]).attr('class', locks[i] && $(locks[i]).is(':not(.is-unlocked)') ? 'color-palette__hook is-both' : 'color-palette__hook is-up');
|
|
||||||
}
|
|
||||||
|
|
||||||
toggleClick = !toggleClick;
|
|
||||||
});
|
|
||||||
$(this).after(lock);
|
|
||||||
locks.push(lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
const hook = $('<div class="color-palette__hook"></div>');
|
|
||||||
$(this).after(hook);
|
|
||||||
hooks.push(hook);
|
|
||||||
$(this).parent().find('.color-palette__lock').trigger('click');
|
|
||||||
this.i = i;
|
|
||||||
inputs.push(this);
|
|
||||||
}).on('focus', focus);
|
|
||||||
form.find('.js-color-palette label');
|
|
||||||
inputs[0].focus();
|
|
||||||
preview();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
})(jQuery, Drupal);
|
|
|
@ -1,26 +0,0 @@
|
||||||
drupal.color:
|
|
||||||
version: VERSION
|
|
||||||
js:
|
|
||||||
color.js: {}
|
|
||||||
dependencies:
|
|
||||||
- core/jquery
|
|
||||||
- core/drupal
|
|
||||||
- core/once
|
|
||||||
- core/jquery.farbtastic
|
|
||||||
- color/drupal.color.preview
|
|
||||||
|
|
||||||
drupal.color.preview:
|
|
||||||
version: VERSION
|
|
||||||
js:
|
|
||||||
preview.js: {}
|
|
||||||
dependencies:
|
|
||||||
- core/jquery
|
|
||||||
- core/drupal
|
|
||||||
- core/drupalSettings
|
|
||||||
- core/once
|
|
||||||
|
|
||||||
admin:
|
|
||||||
version: VERSION
|
|
||||||
css:
|
|
||||||
theme:
|
|
||||||
css/color.admin.css: {}
|
|
|
@ -1,852 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Allows users to change the color scheme of themes.
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Drupal\Core\Url;
|
|
||||||
use Drupal\Component\Utility\Bytes;
|
|
||||||
use Drupal\Component\Utility\Color;
|
|
||||||
use Drupal\Component\Utility\Environment;
|
|
||||||
use Drupal\Core\Asset\CssOptimizer;
|
|
||||||
use Drupal\Core\Block\BlockPluginInterface;
|
|
||||||
use Drupal\Core\File\Exception\FileException;
|
|
||||||
use Drupal\Core\File\FileSystemInterface;
|
|
||||||
use Drupal\Core\Form\FormStateInterface;
|
|
||||||
use Drupal\Core\Language\LanguageInterface;
|
|
||||||
use Drupal\Core\Render\Element\Textfield;
|
|
||||||
use Drupal\Core\Routing\RouteMatchInterface;
|
|
||||||
use Drupal\color\ColorSystemBrandingBlockAlter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_help().
|
|
||||||
*/
|
|
||||||
function color_help($route_name, RouteMatchInterface $route_match) {
|
|
||||||
switch ($route_name) {
|
|
||||||
case 'help.page.color':
|
|
||||||
$output = '<h3>' . t('About') . '</h3>';
|
|
||||||
$output .= '<p>' . t('The Color module allows users with the <em>Administer site configuration</em> permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the <a href=":color_do">online documentation for the Color module</a>.', [':color_do' => 'https://www.drupal.org/documentation/modules/color']) . '</p>';
|
|
||||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
|
||||||
$output .= '<dl>';
|
|
||||||
$output .= '<dt>' . t('Changing colors') . '</dt>';
|
|
||||||
$output .= '<dd><p>' . t('To change the color settings, select the <em>Settings</em> link for your theme on the <a href=":appearance">Appearance</a> page. If the color picker does not appear then the theme is not compatible with the Color module.', [':appearance' => Url::fromRoute('system.themes_page')->toString()]) . '</p>';
|
|
||||||
$output .= '<p>' . t("The Color module saves a modified copy of the theme's specified stylesheets in the files directory. If you make any manual changes to your theme's stylesheet, <em>you must save your color settings again, even if you haven't changed the colors</em>. This step is required because the module stylesheets in the files directory need to be recreated to reflect your changes.") . '</p></dd>';
|
|
||||||
$output .= '</dl>';
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_theme().
|
|
||||||
*/
|
|
||||||
function color_theme() {
|
|
||||||
return [
|
|
||||||
'color_scheme_form' => [
|
|
||||||
'render element' => 'form',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_form_FORM_ID_alter().
|
|
||||||
*/
|
|
||||||
function color_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
|
|
||||||
$build_info = $form_state->getBuildInfo();
|
|
||||||
if (isset($build_info['args'][0]) && ($theme = $build_info['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
|
|
||||||
$form['color'] = [
|
|
||||||
'#type' => 'details',
|
|
||||||
'#title' => t('Color scheme'),
|
|
||||||
'#open' => TRUE,
|
|
||||||
'#weight' => -1,
|
|
||||||
'#attributes' => ['id' => 'color_scheme_form'],
|
|
||||||
'#theme' => 'color_scheme_form',
|
|
||||||
];
|
|
||||||
$form['color'] += color_scheme_form($form, $form_state, $theme);
|
|
||||||
$form['#validate'][] = 'color_scheme_form_validate';
|
|
||||||
// Ensure color submission happens first so we can unset extra values.
|
|
||||||
array_unshift($form['#submit'], 'color_scheme_form_submit');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_library_info_alter().
|
|
||||||
*
|
|
||||||
* Replaces style sheets declared in libraries with color-altered style sheets.
|
|
||||||
*/
|
|
||||||
function color_library_info_alter(&$libraries, $extension) {
|
|
||||||
$themes = array_keys(\Drupal::service('theme_handler')->listInfo());
|
|
||||||
if (in_array($extension, $themes)) {
|
|
||||||
$color_paths = \Drupal::config('color.theme.' . $extension)->get('stylesheets');
|
|
||||||
if (!empty($color_paths)) {
|
|
||||||
foreach (array_keys($libraries) as $name) {
|
|
||||||
if (isset($libraries[$name]['css'])) {
|
|
||||||
// Override stylesheets.
|
|
||||||
foreach ($libraries[$name]['css'] as $category => $css_assets) {
|
|
||||||
foreach ($css_assets as $path => $metadata) {
|
|
||||||
// Loop over the path array with recolored CSS files to find matching
|
|
||||||
// paths which could replace the non-recolored paths.
|
|
||||||
foreach ($color_paths as $color_path) {
|
|
||||||
// Color module currently requires unique file names to be used,
|
|
||||||
// which allows us to compare different file paths.
|
|
||||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
|
||||||
$file_system = \Drupal::service('file_system');
|
|
||||||
if ($file_system->basename($path) == $file_system->basename($color_path)) {
|
|
||||||
// Replace the path to the new css file.
|
|
||||||
// This keeps the order of the stylesheets intact.
|
|
||||||
$index = array_search($path, array_keys($libraries[$name]['css'][$category]));
|
|
||||||
$preceding_css_assets = array_slice($libraries[$name]['css'][$category], 0, $index);
|
|
||||||
$succeeding_css_assets = array_slice($libraries[$name]['css'][$category], $index + 1);
|
|
||||||
$libraries[$name]['css'][$category] = array_merge(
|
|
||||||
$preceding_css_assets,
|
|
||||||
[$color_path => $metadata],
|
|
||||||
$succeeding_css_assets
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_block_view_BASE_BLOCK_ID_alter().
|
|
||||||
*/
|
|
||||||
function color_block_view_system_branding_block_alter(array &$build, BlockPluginInterface $block) {
|
|
||||||
$build['#pre_render'][] = [ColorSystemBrandingBlockAlter::class, 'preRender'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the Color module information for a particular theme.
|
|
||||||
*/
|
|
||||||
function color_get_info($theme) {
|
|
||||||
static $theme_info = [];
|
|
||||||
|
|
||||||
if (isset($theme_info[$theme])) {
|
|
||||||
return $theme_info[$theme];
|
|
||||||
}
|
|
||||||
|
|
||||||
$path = \Drupal::service('extension.list.theme')->getPath($theme);
|
|
||||||
$file = \Drupal::root() . '/' . $path . '/color/color.inc';
|
|
||||||
if ($path && file_exists($file)) {
|
|
||||||
$info = [];
|
|
||||||
include $file;
|
|
||||||
// Add in default values.
|
|
||||||
$info += [
|
|
||||||
// CSS files (excluding @import) to rewrite with new color scheme.
|
|
||||||
'css' => [],
|
|
||||||
// Files to copy.
|
|
||||||
'copy' => [],
|
|
||||||
// Gradient definitions.
|
|
||||||
'gradients' => [],
|
|
||||||
// Color areas to fill (x, y, width, height).
|
|
||||||
'fill' => [],
|
|
||||||
// Coordinates of all the theme slices (x, y, width, height) with their
|
|
||||||
// filename as used in the stylesheet.
|
|
||||||
'slices' => [],
|
|
||||||
// Reference color used for blending.
|
|
||||||
'blend_target' => '#ffffff',
|
|
||||||
];
|
|
||||||
$theme_info[$theme] = $info;
|
|
||||||
return $info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the color palette for a particular theme.
|
|
||||||
*/
|
|
||||||
function color_get_palette($theme, $default = FALSE) {
|
|
||||||
// Fetch and expand default palette.
|
|
||||||
$info = color_get_info($theme);
|
|
||||||
$palette = $info['schemes']['default']['colors'];
|
|
||||||
|
|
||||||
if ($default) {
|
|
||||||
return $palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load variable.
|
|
||||||
// @todo Default color config should be moved to yaml in the theme.
|
|
||||||
// Getting a mutable override-free object because this function is only used
|
|
||||||
// in forms. Color configuration is used to write CSS to the file system
|
|
||||||
// making configuration overrides pointless.
|
|
||||||
return \Drupal::configFactory()->getEditable('color.theme.' . $theme)->get('palette') ?: $palette;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form constructor for the color configuration form for a particular theme.
|
|
||||||
*
|
|
||||||
* @param $theme
|
|
||||||
* The machine name of the theme whose color settings are being configured.
|
|
||||||
*
|
|
||||||
* @see color_scheme_form_validate()
|
|
||||||
* @see color_scheme_form_submit()
|
|
||||||
*/
|
|
||||||
function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) {
|
|
||||||
$info = color_get_info($theme);
|
|
||||||
|
|
||||||
$info['schemes'][''] = ['title' => t('Custom'), 'colors' => []];
|
|
||||||
$color_sets = [];
|
|
||||||
$schemes = [];
|
|
||||||
foreach ($info['schemes'] as $key => $scheme) {
|
|
||||||
$color_sets[$key] = $scheme['title'];
|
|
||||||
$schemes[$key] = $scheme['colors'];
|
|
||||||
$schemes[$key] += $info['schemes']['default']['colors'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// See if we're using a predefined scheme.
|
|
||||||
// Note: we use the original theme when the default scheme is chosen.
|
|
||||||
// Note: we use configuration without overrides since this information is used
|
|
||||||
// in a form and therefore without doing this would bleed overrides into
|
|
||||||
// active configuration. Furthermore, color configuration is used to write
|
|
||||||
// CSS to the file system making configuration overrides pointless.
|
|
||||||
$current_scheme = \Drupal::configFactory()->getEditable('color.theme.' . $theme)->get('palette');
|
|
||||||
foreach ($schemes as $key => $scheme) {
|
|
||||||
if ($current_scheme == $scheme) {
|
|
||||||
$scheme_name = $key;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($scheme_name)) {
|
|
||||||
if (empty($current_scheme)) {
|
|
||||||
$scheme_name = 'default';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$scheme_name = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add scheme selector.
|
|
||||||
$default_palette = color_get_palette($theme, TRUE);
|
|
||||||
$form['scheme'] = [
|
|
||||||
'#type' => 'select',
|
|
||||||
'#title' => t('Color set'),
|
|
||||||
'#options' => $color_sets,
|
|
||||||
'#default_value' => $scheme_name,
|
|
||||||
'#attached' => [
|
|
||||||
'library' => [
|
|
||||||
'color/drupal.color',
|
|
||||||
'color/admin',
|
|
||||||
],
|
|
||||||
// Add custom JavaScript.
|
|
||||||
'drupalSettings' => [
|
|
||||||
'color' => [
|
|
||||||
'reference' => $default_palette,
|
|
||||||
'schemes' => $schemes,
|
|
||||||
],
|
|
||||||
'gradients' => $info['gradients'],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Add palette fields. Use the configuration if available.
|
|
||||||
$palette = $current_scheme ?: $default_palette;
|
|
||||||
$names = $info['fields'];
|
|
||||||
$form['palette']['#tree'] = TRUE;
|
|
||||||
foreach ($palette as $name => $value) {
|
|
||||||
if (isset($names[$name])) {
|
|
||||||
$form['palette'][$name] = [
|
|
||||||
'#type' => 'textfield',
|
|
||||||
'#title' => $names[$name],
|
|
||||||
'#value_callback' => 'color_palette_color_value',
|
|
||||||
'#default_value' => $value,
|
|
||||||
'#size' => 8,
|
|
||||||
'#attributes' => ['dir' => LanguageInterface::DIRECTION_LTR],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$form['theme'] = ['#type' => 'value', '#value' => $theme];
|
|
||||||
if (isset($info['#attached'])) {
|
|
||||||
$form['#attached'] = $info['#attached'];
|
|
||||||
unset($info['#attached']);
|
|
||||||
}
|
|
||||||
$form['info'] = ['#type' => 'value', '#value' => $info];
|
|
||||||
|
|
||||||
return $form;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prepares variables for color scheme form templates.
|
|
||||||
*
|
|
||||||
* Default template: color-scheme-form.html.twig.
|
|
||||||
*
|
|
||||||
* @param array $variables
|
|
||||||
* An associative array containing:
|
|
||||||
* - form: A render element representing the form.
|
|
||||||
*/
|
|
||||||
function template_preprocess_color_scheme_form(&$variables) {
|
|
||||||
$form = &$variables['form'];
|
|
||||||
|
|
||||||
$theme = $form['theme']['#value'];
|
|
||||||
$info = $form['info']['#value'];
|
|
||||||
|
|
||||||
if (isset($info['preview_library'])) {
|
|
||||||
$form['scheme']['#attached']['library'][] = $info['preview_library'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attempt to load preview HTML if the theme provides it.
|
|
||||||
$preview_html_path = \Drupal::root() . '/';
|
|
||||||
if (isset($info['preview_html'])) {
|
|
||||||
$preview_html_path .= \Drupal::service('extension.list.theme')->getPath($theme) . '/' . $info['preview_html'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$preview_html_path .= \Drupal::service('extension.list.module')->getPath('color') . '/preview.html';
|
|
||||||
}
|
|
||||||
$variables['html_preview']['#markup'] = file_get_contents($preview_html_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines the value for a palette color field.
|
|
||||||
*
|
|
||||||
* @param array $element
|
|
||||||
* The form element whose value is being populated.
|
|
||||||
* @param string|bool $input
|
|
||||||
* The incoming input to populate the form element. If this is FALSE,
|
|
||||||
* the element's default value should be returned.
|
|
||||||
* @param \Drupal\Core\Form\FormStateInterface $form_state
|
|
||||||
* The current state of the form.
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* The data that will appear in the $form_state->getValues() collection for this
|
|
||||||
* element. Return nothing to use the default.
|
|
||||||
*/
|
|
||||||
function color_palette_color_value($element, $input, FormStateInterface $form_state) {
|
|
||||||
// If we suspect a possible cross-site request forgery attack, only accept
|
|
||||||
// hexadecimal CSS color strings from user input, to avoid problems when this
|
|
||||||
// value is used in the JavaScript preview.
|
|
||||||
if ($input !== FALSE) {
|
|
||||||
// Start with the provided value for this textfield, and validate that if
|
|
||||||
// necessary, falling back on the default value.
|
|
||||||
$value = Textfield::valueCallback($element, $input, $form_state);
|
|
||||||
$complete_form = $form_state->getCompleteForm();
|
|
||||||
if (!$value || !isset($complete_form['#token']) || color_valid_hexadecimal_string($value) || \Drupal::csrfToken()->validate($form_state->getValue('form_token'), $complete_form['#token'])) {
|
|
||||||
return $value;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return $element['#default_value'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determines if a hexadecimal CSS color string is valid.
|
|
||||||
*
|
|
||||||
* @param string $color
|
|
||||||
* The string to check.
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* TRUE if the string is a valid hexadecimal CSS color string, or FALSE if it
|
|
||||||
* isn't.
|
|
||||||
*/
|
|
||||||
function color_valid_hexadecimal_string($color) {
|
|
||||||
return (bool) preg_match('/^#([a-f0-9]{3}){1,2}$/iD', $color);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form validation handler for color_scheme_form().
|
|
||||||
*
|
|
||||||
* @see color_scheme_form_submit()
|
|
||||||
*/
|
|
||||||
function color_scheme_form_validate($form, FormStateInterface $form_state) {
|
|
||||||
// Only accept hexadecimal CSS color strings to avoid XSS upon use.
|
|
||||||
foreach ($form_state->getValue('palette') as $key => $color) {
|
|
||||||
if (!color_valid_hexadecimal_string($color)) {
|
|
||||||
$form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', ['%name' => $form['color']['palette'][$key]['#title']]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Form submission handler for color_scheme_form().
|
|
||||||
*
|
|
||||||
* @see color_scheme_form_validate()
|
|
||||||
*/
|
|
||||||
function color_scheme_form_submit($form, FormStateInterface $form_state) {
|
|
||||||
|
|
||||||
// Avoid color settings spilling over to theme settings.
|
|
||||||
$color_settings = ['theme', 'palette', 'scheme'];
|
|
||||||
if ($form_state->hasValue('info')) {
|
|
||||||
$color_settings[] = 'info';
|
|
||||||
}
|
|
||||||
foreach ($color_settings as $setting_name) {
|
|
||||||
${$setting_name} = $form_state->getValue($setting_name);
|
|
||||||
$form_state->unsetValue($setting_name);
|
|
||||||
}
|
|
||||||
if (!isset($info)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$config = \Drupal::configFactory()->getEditable('color.theme.' . $theme);
|
|
||||||
|
|
||||||
// Resolve palette.
|
|
||||||
if ($scheme != '') {
|
|
||||||
foreach ($palette as $key => $color) {
|
|
||||||
if (isset($info['schemes'][$scheme]['colors'][$key])) {
|
|
||||||
$palette[$key] = $info['schemes'][$scheme]['colors'][$key];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$palette += $info['schemes']['default']['colors'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Make sure enough memory is available.
|
|
||||||
if (isset($info['base_image'])) {
|
|
||||||
// Fetch source image dimensions.
|
|
||||||
$source = \Drupal::service('extension.list.theme')->getPath($theme) . '/' . $info['base_image'];
|
|
||||||
[$width, $height] = getimagesize($source);
|
|
||||||
|
|
||||||
// We need at least a copy of the source and a target buffer of the same
|
|
||||||
// size (both at 32bpp).
|
|
||||||
$required = $width * $height * 8;
|
|
||||||
// We intend to prevent color scheme changes if there isn't enough memory
|
|
||||||
// available. memory_get_usage(TRUE) returns a more accurate number than
|
|
||||||
// memory_get_usage(), therefore we won't inadvertently reject a color
|
|
||||||
// scheme change based on a faulty memory calculation.
|
|
||||||
$usage = memory_get_usage(TRUE);
|
|
||||||
$memory_limit = ini_get('memory_limit');
|
|
||||||
$size = Bytes::toNumber($memory_limit);
|
|
||||||
if (!Environment::checkMemoryLimit($usage + $required, $memory_limit)) {
|
|
||||||
\Drupal::messenger()->addError(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the <a href="http://php.net/manual/ini.core.php#ini.sect.resource-limits">PHP documentation</a> for more information.', ['%size' => format_size($usage + $required - $size)]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$file_system = \Drupal::service('file_system');
|
|
||||||
// Delete old files.
|
|
||||||
$files = $config->get('files');
|
|
||||||
if (isset($files)) {
|
|
||||||
foreach ($files as $file) {
|
|
||||||
@$file_system->unlink($file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isset($file) && $file = dirname($file)) {
|
|
||||||
@\Drupal::service('file_system')->rmdir($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
// No change in color config, use the standard theme from color.inc.
|
|
||||||
if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)) {
|
|
||||||
$config->delete();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prepare target locations for generated files.
|
|
||||||
$id = $theme . '-' . substr(hash('sha256', serialize($palette) . microtime()), 0, 8);
|
|
||||||
$paths['color'] = 'public://color';
|
|
||||||
$paths['target'] = $paths['color'] . '/' . $id;
|
|
||||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
|
||||||
$file_system = \Drupal::service('file_system');
|
|
||||||
foreach ($paths as $path) {
|
|
||||||
$file_system->prepareDirectory($path, FileSystemInterface::CREATE_DIRECTORY);
|
|
||||||
}
|
|
||||||
$paths['target'] = $paths['target'] . '/';
|
|
||||||
$paths['id'] = $id;
|
|
||||||
$paths['source'] = \Drupal::service('extension.list.theme')->getPath($theme) . '/';
|
|
||||||
$paths['files'] = $paths['map'] = [];
|
|
||||||
|
|
||||||
// Save palette and logo location.
|
|
||||||
$config
|
|
||||||
->set('palette', $palette)
|
|
||||||
->set('logo', $paths['target'] . 'logo.svg')
|
|
||||||
->save();
|
|
||||||
|
|
||||||
// Copy over neutral images.
|
|
||||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
|
||||||
$file_system = \Drupal::service('file_system');
|
|
||||||
foreach ($info['copy'] as $file) {
|
|
||||||
$base = $file_system->basename($file);
|
|
||||||
$source = $paths['source'] . $file;
|
|
||||||
try {
|
|
||||||
$filepath = $file_system->copy($source, $paths['target'] . $base);
|
|
||||||
}
|
|
||||||
catch (FileException $e) {
|
|
||||||
$filepath = FALSE;
|
|
||||||
}
|
|
||||||
$paths['map'][$file] = $base;
|
|
||||||
$paths['files'][] = $filepath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render new images, if image has been provided.
|
|
||||||
if (isset($info['base_image'])) {
|
|
||||||
_color_render_images($theme, $info, $paths, $palette);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rewrite theme stylesheets.
|
|
||||||
$css = [];
|
|
||||||
foreach ($info['css'] as $stylesheet) {
|
|
||||||
// Build a temporary array with CSS files.
|
|
||||||
$files = [];
|
|
||||||
if (file_exists($paths['source'] . $stylesheet)) {
|
|
||||||
$files[] = $stylesheet;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($files as $file) {
|
|
||||||
$css_optimizer = new CssOptimizer(\Drupal::service('file_url_generator'));
|
|
||||||
// Aggregate @imports recursively for each configured top level CSS file
|
|
||||||
// without optimization. Aggregation and optimization will be
|
|
||||||
// handled by drupal_build_css_cache() only.
|
|
||||||
$style = $css_optimizer->loadFile($paths['source'] . $file, FALSE);
|
|
||||||
|
|
||||||
// Return the path to where this CSS file originated from, stripping
|
|
||||||
// off the name of the file at the end of the path.
|
|
||||||
$css_optimizer->rewriteFileURIBasePath = base_path() . dirname($paths['source'] . $file) . '/';
|
|
||||||
|
|
||||||
// Prefix all paths within this CSS file, ignoring absolute paths.
|
|
||||||
$style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', [$css_optimizer, 'rewriteFileURI'], $style);
|
|
||||||
|
|
||||||
// Rewrite stylesheet with new colors.
|
|
||||||
$style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
|
|
||||||
$base_file = $file_system->basename($file);
|
|
||||||
$css[] = $paths['target'] . $base_file;
|
|
||||||
_color_save_stylesheet($paths['target'] . $base_file, $style, $paths);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Maintain list of files.
|
|
||||||
$config
|
|
||||||
->set('stylesheets', $css)
|
|
||||||
->set('files', $paths['files'])
|
|
||||||
->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Rewrites the stylesheet to match the colors in the palette.
|
|
||||||
*/
|
|
||||||
function _color_rewrite_stylesheet($theme, &$info, &$paths, $palette, $style) {
|
|
||||||
// Prepare color conversion table.
|
|
||||||
$conversion = $palette;
|
|
||||||
foreach ($conversion as $k => $v) {
|
|
||||||
$v = mb_strtolower($v);
|
|
||||||
$conversion[$k] = Color::normalizeHexLength($v);
|
|
||||||
}
|
|
||||||
$default = color_get_palette($theme, TRUE);
|
|
||||||
|
|
||||||
// Split off the "Don't touch" section of the stylesheet.
|
|
||||||
$split = "Color Module: Don't touch";
|
|
||||||
if (strpos($style, $split) !== FALSE) {
|
|
||||||
[$style, $fixed] = explode($split, $style);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find all colors in the stylesheet and the chunks in between.
|
|
||||||
$style = preg_split('/(#[0-9a-f]{6}|#[0-9a-f]{3})/i', $style, -1, PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
$is_color = FALSE;
|
|
||||||
$output = '';
|
|
||||||
$base = 'base';
|
|
||||||
|
|
||||||
// Iterate over all the parts.
|
|
||||||
foreach ($style as $chunk) {
|
|
||||||
if ($is_color) {
|
|
||||||
$chunk = mb_strtolower($chunk);
|
|
||||||
$chunk = Color::normalizeHexLength($chunk);
|
|
||||||
// Check if this is one of the colors in the default palette.
|
|
||||||
if ($key = array_search($chunk, $default)) {
|
|
||||||
$chunk = $conversion[$key];
|
|
||||||
}
|
|
||||||
// Not a pre-set color. Extrapolate from the base.
|
|
||||||
else {
|
|
||||||
$chunk = _color_shift($palette[$base], $default[$base], $chunk, $info['blend_target']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Determine the most suitable base color for the next color.
|
|
||||||
|
|
||||||
// 'a' declarations. Use link.
|
|
||||||
if (preg_match('@[^a-z0-9_-](a)[^a-z0-9_-][^/{]*{[^{]+$@i', $chunk)) {
|
|
||||||
$base = 'link';
|
|
||||||
}
|
|
||||||
// 'color:' styles. Use text.
|
|
||||||
elseif (preg_match('/(?<!-)color[^{:]*:[^{#]*$/i', $chunk)) {
|
|
||||||
$base = 'text';
|
|
||||||
}
|
|
||||||
// Reset back to base.
|
|
||||||
else {
|
|
||||||
$base = 'base';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$output .= $chunk;
|
|
||||||
$is_color = !$is_color;
|
|
||||||
}
|
|
||||||
// Append fixed colors segment.
|
|
||||||
if (isset($fixed)) {
|
|
||||||
$output .= $fixed;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace paths to images.
|
|
||||||
foreach ($paths['map'] as $before => $after) {
|
|
||||||
$before = base_path() . $paths['source'] . $before;
|
|
||||||
$before = preg_replace('`(^|/)(?!../)([^/]+)/../`', '$1', $before);
|
|
||||||
$output = str_replace($before, $after, $output);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $output;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the rewritten stylesheet to disk.
|
|
||||||
*/
|
|
||||||
function _color_save_stylesheet($file, $style, &$paths) {
|
|
||||||
$filepath = \Drupal::service('file_system')->saveData($style, $file, FileSystemInterface::EXISTS_REPLACE);
|
|
||||||
$paths['files'][] = $filepath;
|
|
||||||
|
|
||||||
// Set standard file permissions for webserver-generated files.
|
|
||||||
\Drupal::service('file_system')->chmod($file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders images that match a given palette.
|
|
||||||
*/
|
|
||||||
function _color_render_images($theme, &$info, &$paths, $palette) {
|
|
||||||
// Prepare template image.
|
|
||||||
$source = $paths['source'] . '/' . $info['base_image'];
|
|
||||||
$source = imagecreatefrompng($source);
|
|
||||||
$width = imagesx($source);
|
|
||||||
$height = imagesy($source);
|
|
||||||
|
|
||||||
// Prepare target buffer.
|
|
||||||
$target = imagecreatetruecolor($width, $height);
|
|
||||||
imagealphablending($target, TRUE);
|
|
||||||
|
|
||||||
// Fill regions of solid color.
|
|
||||||
foreach ($info['fill'] as $color => $fill) {
|
|
||||||
imagefilledrectangle($target, $fill[0], $fill[1], $fill[0] + $fill[2], $fill[1] + $fill[3], _color_gd($target, $palette[$color]));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render gradients.
|
|
||||||
foreach ($info['gradients'] as $gradient) {
|
|
||||||
// Get direction of the gradient.
|
|
||||||
if (isset($gradient['direction']) && $gradient['direction'] == 'horizontal') {
|
|
||||||
// Horizontal gradient.
|
|
||||||
for ($x = 0; $x < $gradient['dimension'][2]; $x++) {
|
|
||||||
$color = _color_blend($target, $palette[$gradient['colors'][0]], $palette[$gradient['colors'][1]], $x / ($gradient['dimension'][2] - 1));
|
|
||||||
imagefilledrectangle($target, ($gradient['dimension'][0] + $x), $gradient['dimension'][1], ($gradient['dimension'][0] + $x + 1), ($gradient['dimension'][1] + $gradient['dimension'][3]), $color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Vertical gradient.
|
|
||||||
for ($y = 0; $y < $gradient['dimension'][3]; $y++) {
|
|
||||||
$color = _color_blend($target, $palette[$gradient['colors'][0]], $palette[$gradient['colors'][1]], $y / ($gradient['dimension'][3] - 1));
|
|
||||||
imagefilledrectangle($target, $gradient['dimension'][0], $gradient['dimension'][1] + $y, $gradient['dimension'][0] + $gradient['dimension'][2], $gradient['dimension'][1] + $y + 1, $color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Blend over template.
|
|
||||||
imagecopy($target, $source, 0, 0, 0, 0, $width, $height);
|
|
||||||
|
|
||||||
// Clean up template image.
|
|
||||||
imagedestroy($source);
|
|
||||||
|
|
||||||
// Cut out slices.
|
|
||||||
foreach ($info['slices'] as $file => $coord) {
|
|
||||||
[$x, $y, $width, $height] = $coord;
|
|
||||||
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
|
||||||
$file_system = \Drupal::service('file_system');
|
|
||||||
$base = $file_system->basename($file);
|
|
||||||
$image = $file_system->realpath($paths['target'] . $base);
|
|
||||||
|
|
||||||
// Cut out slice.
|
|
||||||
if ($file == 'screenshot.png') {
|
|
||||||
$slice = imagecreatetruecolor(150, 90);
|
|
||||||
imagecopyresampled($slice, $target, 0, 0, $x, $y, 150, 90, $width, $height);
|
|
||||||
\Drupal::configFactory()->getEditable('color.theme.' . $theme)
|
|
||||||
->set('screenshot', $image)
|
|
||||||
->save();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$slice = imagecreatetruecolor($width, $height);
|
|
||||||
imagecopy($slice, $target, 0, 0, $x, $y, $width, $height);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save image.
|
|
||||||
imagepng($slice, $image);
|
|
||||||
imagedestroy($slice);
|
|
||||||
$paths['files'][] = $image;
|
|
||||||
|
|
||||||
// Set standard file permissions for webserver-generated files.
|
|
||||||
$file_system->chmod($image);
|
|
||||||
|
|
||||||
// Build before/after map of image paths.
|
|
||||||
$paths['map'][$file] = $base;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clean up target buffer.
|
|
||||||
imagedestroy($target);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Shifts a given color, using a reference pair and a target blend color.
|
|
||||||
*
|
|
||||||
* Note: this function is significantly different from the JS version, as it
|
|
||||||
* is written to match the blended images perfectly.
|
|
||||||
*
|
|
||||||
* Constraint: if (ref2 == target + (ref1 - target) * delta) for some fraction
|
|
||||||
* delta then (return == target + (given - target) * delta).
|
|
||||||
*
|
|
||||||
* Loose constraint: Preserve relative positions in saturation and luminance
|
|
||||||
* space.
|
|
||||||
*/
|
|
||||||
function _color_shift($given, $ref1, $ref2, $target) {
|
|
||||||
// We assume that ref2 is a blend of ref1 and target and find
|
|
||||||
// delta based on the length of the difference vectors.
|
|
||||||
|
|
||||||
// delta = 1 - |ref2 - ref1| / |white - ref1|
|
|
||||||
$target = _color_unpack($target, TRUE);
|
|
||||||
$ref1 = _color_unpack($ref1, TRUE);
|
|
||||||
$ref2 = _color_unpack($ref2, TRUE);
|
|
||||||
$numerator = 0;
|
|
||||||
$denominator = 0;
|
|
||||||
for ($i = 0; $i < 3; ++$i) {
|
|
||||||
$numerator += ($ref2[$i] - $ref1[$i]) * ($ref2[$i] - $ref1[$i]);
|
|
||||||
$denominator += ($target[$i] - $ref1[$i]) * ($target[$i] - $ref1[$i]);
|
|
||||||
}
|
|
||||||
$delta = ($denominator > 0) ? (1 - sqrt($numerator / $denominator)) : 0;
|
|
||||||
|
|
||||||
// Calculate the color that ref2 would be if the assumption was true.
|
|
||||||
for ($i = 0; $i < 3; ++$i) {
|
|
||||||
$ref3[$i] = $target[$i] + ($ref1[$i] - $target[$i]) * $delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the assumption is not true, there is a difference between ref2 and ref3.
|
|
||||||
// We measure this in HSL space. Notation: x' = hsl(x).
|
|
||||||
$ref2 = _color_rgb2hsl($ref2);
|
|
||||||
$ref3 = _color_rgb2hsl($ref3);
|
|
||||||
for ($i = 0; $i < 3; ++$i) {
|
|
||||||
$shift[$i] = $ref2[$i] - $ref3[$i];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Take the given color, and blend it towards the target.
|
|
||||||
$given = _color_unpack($given, TRUE);
|
|
||||||
for ($i = 0; $i < 3; ++$i) {
|
|
||||||
$result[$i] = $target[$i] + ($given[$i] - $target[$i]) * $delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, we apply the extra shift in HSL space.
|
|
||||||
// Note: if ref2 is a pure blend of ref1 and target, then |shift| = 0.
|
|
||||||
$result = _color_rgb2hsl($result);
|
|
||||||
for ($i = 0; $i < 3; ++$i) {
|
|
||||||
$result[$i] = min(1, max(0, $result[$i] + $shift[$i]));
|
|
||||||
}
|
|
||||||
$result = _color_hsl2rgb($result);
|
|
||||||
|
|
||||||
// Return hex color.
|
|
||||||
return _color_pack($result, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a hex triplet into a GD color.
|
|
||||||
*/
|
|
||||||
function _color_gd($img, $hex) {
|
|
||||||
$c = array_merge([$img], _color_unpack($hex));
|
|
||||||
return call_user_func_array('imagecolorallocate', $c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Blends two hex colors and returns the GD color.
|
|
||||||
*/
|
|
||||||
function _color_blend($img, $hex1, $hex2, $alpha) {
|
|
||||||
$in1 = _color_unpack($hex1);
|
|
||||||
$in2 = _color_unpack($hex2);
|
|
||||||
$out = [$img];
|
|
||||||
for ($i = 0; $i < 3; ++$i) {
|
|
||||||
$out[] = $in1[$i] + ($in2[$i] - $in1[$i]) * $alpha;
|
|
||||||
}
|
|
||||||
|
|
||||||
return call_user_func_array('imagecolorallocate', $out);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts a hex color into an RGB triplet.
|
|
||||||
*/
|
|
||||||
function _color_unpack($hex, $normalize = FALSE) {
|
|
||||||
$hex = substr($hex, 1);
|
|
||||||
if (strlen($hex) == 3) {
|
|
||||||
$hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
|
|
||||||
}
|
|
||||||
$c = hexdec($hex);
|
|
||||||
for ($i = 16; $i >= 0; $i -= 8) {
|
|
||||||
$out[] = (($c >> $i) & 0xFF) / ($normalize ? 255 : 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an RGB triplet to a hex color.
|
|
||||||
*/
|
|
||||||
function _color_pack($rgb, $normalize = FALSE) {
|
|
||||||
$out = 0;
|
|
||||||
foreach ($rgb as $k => $v) {
|
|
||||||
$out |= ((int) ($v * ($normalize ? 255 : 1)) << (16 - $k * 8));
|
|
||||||
}
|
|
||||||
|
|
||||||
return '#' . str_pad(dechex($out), 6, 0, STR_PAD_LEFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an HSL triplet into RGB.
|
|
||||||
*/
|
|
||||||
function _color_hsl2rgb($hsl) {
|
|
||||||
$h = $hsl[0];
|
|
||||||
$s = $hsl[1];
|
|
||||||
$l = $hsl[2];
|
|
||||||
$m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l * $s;
|
|
||||||
$m1 = $l * 2 - $m2;
|
|
||||||
|
|
||||||
return [
|
|
||||||
_color_hue2rgb($m1, $m2, $h + 0.33333),
|
|
||||||
_color_hue2rgb($m1, $m2, $h),
|
|
||||||
_color_hue2rgb($m1, $m2, $h - 0.33333),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function for _color_hsl2rgb().
|
|
||||||
*/
|
|
||||||
function _color_hue2rgb($m1, $m2, $h) {
|
|
||||||
$h = ($h < 0) ? $h + 1 : (($h > 1) ? $h - 1 : $h);
|
|
||||||
if ($h * 6 < 1) {
|
|
||||||
return $m1 + ($m2 - $m1) * $h * 6;
|
|
||||||
}
|
|
||||||
if ($h * 2 < 1) {
|
|
||||||
return $m2;
|
|
||||||
}
|
|
||||||
if ($h * 3 < 2) {
|
|
||||||
return $m1 + ($m2 - $m1) * (0.66666 - $h) * 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $m1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an RGB triplet to HSL.
|
|
||||||
*/
|
|
||||||
function _color_rgb2hsl($rgb) {
|
|
||||||
$r = $rgb[0];
|
|
||||||
$g = $rgb[1];
|
|
||||||
$b = $rgb[2];
|
|
||||||
$min = min($r, min($g, $b));
|
|
||||||
$max = max($r, max($g, $b));
|
|
||||||
$delta = $max - $min;
|
|
||||||
$l = ($min + $max) / 2;
|
|
||||||
$s = 0;
|
|
||||||
|
|
||||||
if ($l > 0 && $l < 1) {
|
|
||||||
$s = $delta / ($l < 0.5 ? (2 * $l) : (2 - 2 * $l));
|
|
||||||
}
|
|
||||||
|
|
||||||
$h = 0;
|
|
||||||
if ($delta > 0) {
|
|
||||||
if ($max == $r && $max != $g) {
|
|
||||||
$h += ($g - $b) / $delta;
|
|
||||||
}
|
|
||||||
if ($max == $g && $max != $b) {
|
|
||||||
$h += (2 + ($b - $r) / $delta);
|
|
||||||
}
|
|
||||||
if ($max == $b && $max != $r) {
|
|
||||||
$h += (4 + ($r - $g) / $delta);
|
|
||||||
}
|
|
||||||
$h /= 6;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [$h, $s, $l];
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
services:
|
|
||||||
color.config_cache_invalidator:
|
|
||||||
class: Drupal\color\EventSubscriber\ColorConfigCacheInvalidator
|
|
||||||
arguments: ['@cache_tags.invalidator']
|
|
||||||
tags:
|
|
||||||
- { name: event_subscriber }
|
|
|
@ -1,20 +0,0 @@
|
||||||
color.theme.*:
|
|
||||||
type: config_object
|
|
||||||
label: 'Color theme settings'
|
|
||||||
mapping:
|
|
||||||
palette:
|
|
||||||
type: sequence
|
|
||||||
label: 'Palette settings'
|
|
||||||
sequence:
|
|
||||||
type: color_hex
|
|
||||||
logo:
|
|
||||||
type: path
|
|
||||||
label: 'Logo path'
|
|
||||||
stylesheets:
|
|
||||||
type: sequence
|
|
||||||
sequence:
|
|
||||||
type: path
|
|
||||||
files:
|
|
||||||
type: sequence
|
|
||||||
sequence:
|
|
||||||
type: path
|
|
|
@ -1,153 +0,0 @@
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Stylesheet for the administration pages of the Color module.
|
|
||||||
*/
|
|
||||||
.color-form {
|
|
||||||
max-width: 50em;
|
|
||||||
}
|
|
||||||
.farbtastic {
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
.color-form .form-item {
|
|
||||||
height: 2em;
|
|
||||||
margin: 0.5em 0;
|
|
||||||
padding: 0.5em;
|
|
||||||
}
|
|
||||||
.color-form label {
|
|
||||||
clear: left; /* LTR */
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-form label {
|
|
||||||
clear: right;
|
|
||||||
}
|
|
||||||
.color-form .form-text {
|
|
||||||
float: left; /* LTR */
|
|
||||||
width: 86%;
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-form .form-text {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
.color-palette__hook {
|
|
||||||
float: left; /* LTR */
|
|
||||||
width: 16px;
|
|
||||||
height: 16px;
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-palette__hook {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
.color-palette__hook.is-down,
|
|
||||||
.color-palette__hook.is-up,
|
|
||||||
.color-palette__hook.is-both {
|
|
||||||
background: url(../images/hook.png) no-repeat 100% 0; /* LTR */
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-palette__hook.is-down,
|
|
||||||
[dir="rtl"] .color-palette__hook.is-up,
|
|
||||||
[dir="rtl"] .color-palette__hook.is-both {
|
|
||||||
background: url(../images/hook-rtl.png) no-repeat 0 0;
|
|
||||||
}
|
|
||||||
.color-palette__hook.is-up {
|
|
||||||
background-position: 100% -27px; /* LTR */
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-palette__hook.is-up {
|
|
||||||
background-position: 0 -27px;
|
|
||||||
}
|
|
||||||
.color-palette__hook.is-both {
|
|
||||||
background-position: 100% -54px; /* LTR */
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-palette__hook.is-both {
|
|
||||||
background-position: 0 -54px;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* The button also inherits from .link, which hides the background. Use a more
|
|
||||||
* specific selector to overwrite.
|
|
||||||
*/
|
|
||||||
button.color-palette__lock,
|
|
||||||
.color-palette__lock {
|
|
||||||
position: relative;
|
|
||||||
top: -1.7em;
|
|
||||||
left: -10px;
|
|
||||||
float: left; /* LTR */
|
|
||||||
width: 20px;
|
|
||||||
height: 19px;
|
|
||||||
cursor: pointer;
|
|
||||||
text-indent: -9999px;
|
|
||||||
direction: ltr;
|
|
||||||
border: 0;
|
|
||||||
outline: 0;
|
|
||||||
background: url(../images/lock.png) no-repeat 50% 0;
|
|
||||||
}
|
|
||||||
[dir="rtl"] button.color-palette__lock,
|
|
||||||
[dir="rtl"] .color-palette__lock {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
/* Same as above .color-palette__lock rule. */
|
|
||||||
button.is-unlocked,
|
|
||||||
.is-unlocked {
|
|
||||||
background-position: 50% -22px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* wide viewport. */
|
|
||||||
@media screen and (min-width: 37.5625em) { /* 601px */
|
|
||||||
.color-placeholder {
|
|
||||||
float: right; /* LTR */
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-placeholder {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
.color-form .form-item {
|
|
||||||
margin: 0.5em 195px 0.5em 0; /* LTR */
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-form .form-item {
|
|
||||||
margin: 0.5em 0 0.5em 195px;
|
|
||||||
}
|
|
||||||
.color-form label {
|
|
||||||
float: left; /* LTR */
|
|
||||||
clear: left; /* LTR */
|
|
||||||
width: 15em;
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-form label {
|
|
||||||
float: right;
|
|
||||||
clear: right;
|
|
||||||
}
|
|
||||||
.color-form .form-text,
|
|
||||||
.color-form .form-select {
|
|
||||||
float: left; /* LTR */
|
|
||||||
width: auto;
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-form .form-text,
|
|
||||||
[dir="rtl"] .color-form .form-select {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
.color-palette__hook {
|
|
||||||
float: left; /* LTR */
|
|
||||||
margin-top: 3px;
|
|
||||||
}
|
|
||||||
[dir="rtl"] .color-palette__hook {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.item-selected {
|
|
||||||
background: #eee;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Preview */
|
|
||||||
.color-preview {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.js .color-preview {
|
|
||||||
position: relative;
|
|
||||||
display: block;
|
|
||||||
float: left; /* LTR */
|
|
||||||
}
|
|
||||||
.js[dir="rtl"] .color-preview {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 30em) { /* 480px */
|
|
||||||
.color-form .color-preview-sidebar,
|
|
||||||
.color-form .color-preview-content {
|
|
||||||
width: auto;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
label: 'Changing the color palette of a theme'
|
|
||||||
related:
|
|
||||||
- core.appearance
|
|
||||||
---
|
|
||||||
{% set appearance = render_var(url('system.themes_page')) %}
|
|
||||||
<h2>{% trans %}Goal{% endtrans %}</h2>
|
|
||||||
<p>{% trans %}Change the colors for links, backgrounds, and text in a theme that supports the Color module. Color-specific stylesheets will be generated and saved; you will need to follow these steps again to regenerate the stylesheets if you make any changes to the base stylesheets of your theme.{% endtrans %}</p>
|
|
||||||
<h2>{% trans %}Steps{% endtrans %}</h2>
|
|
||||||
<ol>
|
|
||||||
<li>{% trans %}In the Manage administrative menu, navigate to <a href="{{ appearance }}">Appearance</a>.{% endtrans %}</li>
|
|
||||||
<li>{% trans %}Click the <em>Settings</em> link for the theme you want to change the colors of.{% endtrans %}</li>
|
|
||||||
<li>{% trans %}In the <em>Color scheme</em> section, choose new colors for the backgrounds, text, and links that your theme defines colors for. However, if you do not see color settings, then your theme does not support the Color module.{% endtrans %}</li>
|
|
||||||
<li>{% trans %}Click <em>Save configuration</em>. Color-specific stylesheets will be generated and saved in the file system.{% endtrans %}</li>
|
|
||||||
</ol>
|
|
||||||
|
|
||||||
<h2>{% trans %}Additional resources{% endtrans %}</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://www.drupal.org/docs/8/core/modules/color/overview">{% trans %}Color module overview{% endtrans %}</a></li>
|
|
||||||
</ul>
|
|
|
@ -1,54 +0,0 @@
|
||||||
id: d7_color
|
|
||||||
label: Color
|
|
||||||
migration_tags:
|
|
||||||
- Drupal 7
|
|
||||||
- Configuration
|
|
||||||
source:
|
|
||||||
plugin: d7_color
|
|
||||||
constants:
|
|
||||||
config_prefix: 'color.theme.'
|
|
||||||
process:
|
|
||||||
# Skip if theme not installed on destination.
|
|
||||||
theme_installed:
|
|
||||||
plugin: skip_on_empty
|
|
||||||
source: theme_installed
|
|
||||||
method: row
|
|
||||||
element_name:
|
|
||||||
-
|
|
||||||
plugin: explode
|
|
||||||
source: name
|
|
||||||
delimiter: _
|
|
||||||
-
|
|
||||||
plugin: extract
|
|
||||||
index:
|
|
||||||
- 2
|
|
||||||
# Skip if the variable name ends in 'screenshot'.
|
|
||||||
screenshot:
|
|
||||||
-
|
|
||||||
plugin: static_map
|
|
||||||
source: '@element_name'
|
|
||||||
bypass: true
|
|
||||||
map:
|
|
||||||
screenshot: false
|
|
||||||
-
|
|
||||||
plugin: skip_on_empty
|
|
||||||
method: row
|
|
||||||
# Build the configuration name from the variable name, i.e.
|
|
||||||
# 'color_themename_element' becomes 'color.theme.themename'
|
|
||||||
theme_name:
|
|
||||||
-
|
|
||||||
plugin: explode
|
|
||||||
source: name
|
|
||||||
delimiter: _
|
|
||||||
-
|
|
||||||
plugin: extract
|
|
||||||
index:
|
|
||||||
- 1
|
|
||||||
configuration_name:
|
|
||||||
plugin: concat
|
|
||||||
source:
|
|
||||||
- constants/config_prefix
|
|
||||||
- '@theme_name'
|
|
||||||
value: value
|
|
||||||
destination:
|
|
||||||
plugin: color
|
|
|
@ -1,3 +0,0 @@
|
||||||
finished:
|
|
||||||
7:
|
|
||||||
color: color
|
|
|
@ -1,93 +0,0 @@
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Attaches preview-related behavior for the Color module.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function ($, Drupal) {
|
|
||||||
/**
|
|
||||||
* Namespace for color-related functionality for Drupal.
|
|
||||||
*
|
|
||||||
* @namespace
|
|
||||||
*/
|
|
||||||
Drupal.color = {
|
|
||||||
/**
|
|
||||||
* The callback for when the color preview has been attached.
|
|
||||||
*
|
|
||||||
* @param {Element} context
|
|
||||||
* The context to initiate the color behavior.
|
|
||||||
* @param {object} settings
|
|
||||||
* Settings for the color functionality.
|
|
||||||
* @param {HTMLFormElement} form
|
|
||||||
* The form to initiate the color behavior on.
|
|
||||||
* @param {object} farb
|
|
||||||
* The farbtastic object.
|
|
||||||
* @param {number} height
|
|
||||||
* Height of gradient.
|
|
||||||
* @param {number} width
|
|
||||||
* Width of gradient.
|
|
||||||
*/
|
|
||||||
callback(context, settings, form, farb, height, width) {
|
|
||||||
let accum;
|
|
||||||
let delta;
|
|
||||||
// Solid background.
|
|
||||||
form
|
|
||||||
.find('.color-preview')
|
|
||||||
.css(
|
|
||||||
'backgroundColor',
|
|
||||||
form.find('.color-palette input[name="palette[base]"]').val(),
|
|
||||||
);
|
|
||||||
|
|
||||||
// Text preview.
|
|
||||||
form
|
|
||||||
.find('#text')
|
|
||||||
.css(
|
|
||||||
'color',
|
|
||||||
form.find('.color-palette input[name="palette[text]"]').val(),
|
|
||||||
);
|
|
||||||
form
|
|
||||||
.find('#text a, #text h2')
|
|
||||||
.css(
|
|
||||||
'color',
|
|
||||||
form.find('.color-palette input[name="palette[link]"]').val(),
|
|
||||||
);
|
|
||||||
|
|
||||||
function gradientLineColor(i, element) {
|
|
||||||
Object.keys(accum || {}).forEach((k) => {
|
|
||||||
accum[k] += delta[k];
|
|
||||||
});
|
|
||||||
element.style.backgroundColor = farb.pack(accum);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up gradients if there are some.
|
|
||||||
let colorStart;
|
|
||||||
let colorEnd;
|
|
||||||
Object.keys(settings.gradients || {}).forEach((i) => {
|
|
||||||
colorStart = farb.unpack(
|
|
||||||
form
|
|
||||||
.find(
|
|
||||||
`.color-palette input[name="palette[${settings.gradients[i].colors[0]}]"]`,
|
|
||||||
)
|
|
||||||
.val(),
|
|
||||||
);
|
|
||||||
colorEnd = farb.unpack(
|
|
||||||
form
|
|
||||||
.find(
|
|
||||||
`.color-palette input[name="palette[${settings.gradients[i].colors[1]}]"]`,
|
|
||||||
)
|
|
||||||
.val(),
|
|
||||||
);
|
|
||||||
if (colorStart && colorEnd) {
|
|
||||||
delta = [];
|
|
||||||
Object.keys(colorStart || {}).forEach((colorStartKey) => {
|
|
||||||
delta[colorStartKey] =
|
|
||||||
(colorEnd[colorStartKey] - colorStart[colorStartKey]) /
|
|
||||||
(settings.gradients[i].vertical ? height[i] : width[i]);
|
|
||||||
});
|
|
||||||
accum = colorStart;
|
|
||||||
// Render gradient lines.
|
|
||||||
form.find(`#gradient-${i} > div`).each(gradientLineColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
})(jQuery, Drupal);
|
|
|
@ -1,7 +0,0 @@
|
||||||
<div class="color-preview">
|
|
||||||
<div id="text">
|
|
||||||
<h2>Lorem ipsum dolor</h2>
|
|
||||||
<p>Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud <a href="#">exercitation ullamco</a> laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
||||||
</div>
|
|
||||||
<div id="img"></div>
|
|
||||||
</div>
|
|
|
@ -1,42 +0,0 @@
|
||||||
/**
|
|
||||||
* DO NOT EDIT THIS FILE.
|
|
||||||
* See the following change record for more information,
|
|
||||||
* https://www.drupal.org/node/2815083
|
|
||||||
* @preserve
|
|
||||||
**/
|
|
||||||
|
|
||||||
(function ($, Drupal) {
|
|
||||||
Drupal.color = {
|
|
||||||
callback(context, settings, form, farb, height, width) {
|
|
||||||
let accum;
|
|
||||||
let delta;
|
|
||||||
form.find('.color-preview').css('backgroundColor', form.find('.color-palette input[name="palette[base]"]').val());
|
|
||||||
form.find('#text').css('color', form.find('.color-palette input[name="palette[text]"]').val());
|
|
||||||
form.find('#text a, #text h2').css('color', form.find('.color-palette input[name="palette[link]"]').val());
|
|
||||||
|
|
||||||
function gradientLineColor(i, element) {
|
|
||||||
Object.keys(accum || {}).forEach(k => {
|
|
||||||
accum[k] += delta[k];
|
|
||||||
});
|
|
||||||
element.style.backgroundColor = farb.pack(accum);
|
|
||||||
}
|
|
||||||
|
|
||||||
let colorStart;
|
|
||||||
let colorEnd;
|
|
||||||
Object.keys(settings.gradients || {}).forEach(i => {
|
|
||||||
colorStart = farb.unpack(form.find(`.color-palette input[name="palette[${settings.gradients[i].colors[0]}]"]`).val());
|
|
||||||
colorEnd = farb.unpack(form.find(`.color-palette input[name="palette[${settings.gradients[i].colors[1]}]"]`).val());
|
|
||||||
|
|
||||||
if (colorStart && colorEnd) {
|
|
||||||
delta = [];
|
|
||||||
Object.keys(colorStart || {}).forEach(colorStartKey => {
|
|
||||||
delta[colorStartKey] = (colorEnd[colorStartKey] - colorStart[colorStartKey]) / (settings.gradients[i].vertical ? height[i] : width[i]);
|
|
||||||
});
|
|
||||||
accum = colorStart;
|
|
||||||
form.find(`#gradient-${i} > div`).each(gradientLineColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
})(jQuery, Drupal);
|
|
|
@ -1,34 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\color;
|
|
||||||
|
|
||||||
use Drupal\Core\Cache\CacheableMetadata;
|
|
||||||
use Drupal\Core\Render\Element\RenderCallbackInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Provides a trusted callback to alter the system branding block.
|
|
||||||
*
|
|
||||||
* @see color_block_view_system_branding_block_alter()
|
|
||||||
*/
|
|
||||||
class ColorSystemBrandingBlockAlter implements RenderCallbackInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* #pre_render callback: Sets color preset logo.
|
|
||||||
*/
|
|
||||||
public static function preRender($build) {
|
|
||||||
$theme_key = \Drupal::theme()->getActiveTheme()->getName();
|
|
||||||
$config = \Drupal::config('color.theme.' . $theme_key);
|
|
||||||
CacheableMetadata::createFromRenderArray($build)
|
|
||||||
->addCacheableDependency($config)
|
|
||||||
->applyTo($build);
|
|
||||||
|
|
||||||
// Override logo.
|
|
||||||
$logo = $config->get('logo');
|
|
||||||
if ($logo && $build['content']['site_logo'] && preg_match('!' . $theme_key . '/logo.svg$!', $build['content']['site_logo']['#uri'])) {
|
|
||||||
$build['content']['site_logo']['#uri'] = \Drupal::service('file_url_generator')->generateString($logo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $build;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,56 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\color\EventSubscriber;
|
|
||||||
|
|
||||||
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
|
|
||||||
use Drupal\Core\Config\ConfigCrudEvent;
|
|
||||||
use Drupal\Core\Config\ConfigEvents;
|
|
||||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A subscriber invalidating cache tags when color config objects are saved.
|
|
||||||
*/
|
|
||||||
class ColorConfigCacheInvalidator implements EventSubscriberInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The cache tags invalidator.
|
|
||||||
*
|
|
||||||
* @var \Drupal\Core\Cache\CacheTagsInvalidatorInterface
|
|
||||||
*/
|
|
||||||
protected $cacheTagsInvalidator;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a ColorConfigCacheInvalidator object.
|
|
||||||
*
|
|
||||||
* @param \Drupal\Core\Cache\CacheTagsInvalidatorInterface $cache_tags_invalidator
|
|
||||||
* The cache tags invalidator.
|
|
||||||
*/
|
|
||||||
public function __construct(CacheTagsInvalidatorInterface $cache_tags_invalidator) {
|
|
||||||
$this->cacheTagsInvalidator = $cache_tags_invalidator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Invalidate cache tags when a color theme config object changes.
|
|
||||||
*
|
|
||||||
* @param \Drupal\Core\Config\ConfigCrudEvent $event
|
|
||||||
* The Event to process.
|
|
||||||
*/
|
|
||||||
public function onChange(ConfigCrudEvent $event) {
|
|
||||||
// Changing a theme's color settings causes the theme's asset library
|
|
||||||
// containing the color CSS file to be altered to use a different file.
|
|
||||||
if (strpos($event->getConfig()->getName(), 'color.theme.') === 0) {
|
|
||||||
$this->cacheTagsInvalidator->invalidateTags(['library_info']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public static function getSubscribedEvents(): array {
|
|
||||||
$events[ConfigEvents::SAVE][] = ['onChange'];
|
|
||||||
$events[ConfigEvents::DELETE][] = ['onChange'];
|
|
||||||
|
|
||||||
return $events;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,90 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\color\Plugin\migrate\destination;
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
|
||||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
|
||||||
use Drupal\migrate\Plugin\MigrationInterface;
|
|
||||||
use Drupal\migrate\Row;
|
|
||||||
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Persist color data to the config system.
|
|
||||||
*
|
|
||||||
* @MigrateDestination(
|
|
||||||
* id = "color"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
class Color extends DestinationBase implements ContainerFactoryPluginInterface {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The configuration factory.
|
|
||||||
*
|
|
||||||
* @var \Drupal\Core\Config\ConfigFactoryInterface
|
|
||||||
*/
|
|
||||||
protected $configFactory;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a Color object.
|
|
||||||
*
|
|
||||||
* @param array $configuration
|
|
||||||
* Plugin configuration.
|
|
||||||
* @param string $plugin_id
|
|
||||||
* The plugin ID.
|
|
||||||
* @param mixed $plugin_definition
|
|
||||||
* The plugin definition.
|
|
||||||
* @param \Drupal\migrate\Plugin\MigrationInterface $migration
|
|
||||||
* The current migration.
|
|
||||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
|
||||||
* The configuration factory.
|
|
||||||
*/
|
|
||||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ConfigFactoryInterface $config_factory) {
|
|
||||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
|
||||||
$this->configFactory = $config_factory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
|
||||||
return new static(
|
|
||||||
$configuration,
|
|
||||||
$plugin_id,
|
|
||||||
$plugin_definition,
|
|
||||||
$migration,
|
|
||||||
$container->get('config.factory')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function import(Row $row, array $old_destination_id_values = []) {
|
|
||||||
$imported = FALSE;
|
|
||||||
$value = $row->getDestinationProperty('value');
|
|
||||||
if (isset($value)) {
|
|
||||||
$this->configFactory->getEditable($row->getDestinationProperty('configuration_name'))
|
|
||||||
->set($row->getDestinationProperty('element_name'), $row->getDestinationProperty('value'))
|
|
||||||
->save();
|
|
||||||
$imported = TRUE;
|
|
||||||
}
|
|
||||||
return $imported;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function getIds() {
|
|
||||||
$ids['name']['type'] = 'string';
|
|
||||||
return $ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function fields() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,103 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\color\Plugin\migrate\source\d7;
|
|
||||||
|
|
||||||
use Drupal\Core\Extension\ThemeHandler;
|
|
||||||
use Drupal\migrate\Row;
|
|
||||||
use Drupal\migrate_drupal\Plugin\migrate\source\VariableMultiRow;
|
|
||||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
|
||||||
use Drupal\Core\State\StateInterface;
|
|
||||||
use Drupal\migrate\Plugin\MigrationInterface;
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Drupal 7 color source from database.
|
|
||||||
*
|
|
||||||
* For available configuration keys, refer to the parent classes.
|
|
||||||
*
|
|
||||||
* @see \Drupal\migrate\Plugin\migrate\source\SqlBase
|
|
||||||
* @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase
|
|
||||||
*
|
|
||||||
* @MigrateSource(
|
|
||||||
* id = "d7_color",
|
|
||||||
* source_module = "color"
|
|
||||||
* )
|
|
||||||
*/
|
|
||||||
class Color extends VariableMultiRow {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The theme handler.
|
|
||||||
*
|
|
||||||
* @var \Drupal\Core\Extension\ThemeHandler
|
|
||||||
*/
|
|
||||||
protected $themeHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager, ThemeHandler $theme_handler) {
|
|
||||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager);
|
|
||||||
$this->themeHandler = $theme_handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
|
||||||
return new static(
|
|
||||||
$configuration,
|
|
||||||
$plugin_id,
|
|
||||||
$plugin_definition,
|
|
||||||
$migration,
|
|
||||||
$container->get('state'),
|
|
||||||
$container->get('entity_type.manager'),
|
|
||||||
$container->get('theme_handler')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function query() {
|
|
||||||
// Get color data for all themes.
|
|
||||||
$query = $this->select('variable', 'v')
|
|
||||||
->fields('v', ['name', 'value'])
|
|
||||||
->condition('name', 'color_%', 'LIKE');
|
|
||||||
return $query;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function prepareRow(Row $row) {
|
|
||||||
$themes = $this->themeHandler->listInfo();
|
|
||||||
$themes_installed = [];
|
|
||||||
/** @var \Drupal\Core\Extension\Extension $theme */
|
|
||||||
foreach ($themes as $theme) {
|
|
||||||
if ($theme->status) {
|
|
||||||
$themes_installed[] = $theme->getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// The name is of the form 'color_theme_variable'.
|
|
||||||
$name = explode('_', $row->getSourceProperty('name'));
|
|
||||||
|
|
||||||
// Set theme_installed if this source theme is installed.
|
|
||||||
if (in_array($name[1], $themes_installed)) {
|
|
||||||
$row->setSourceProperty('theme_installed', TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::prepareRow($row);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function fields() {
|
|
||||||
return [
|
|
||||||
'name' => $this->t('A color variable for a theme.'),
|
|
||||||
'value' => $this->t('The value of a color variable.'),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
{#
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Default theme implementation for a theme's color form.
|
|
||||||
*
|
|
||||||
* Available variables:
|
|
||||||
* - form: Form elements for the color scheme form, including:
|
|
||||||
* - scheme: A color scheme form element. For example: a select element with
|
|
||||||
* color theme presets, or a color picker widget.
|
|
||||||
* - palette: Color fields that can be changed by entering in a new hex value.
|
|
||||||
* - html_preview: A HTML preview of the theme's current color scheme.
|
|
||||||
*
|
|
||||||
* @see template_preprocess_color_scheme_form()
|
|
||||||
*
|
|
||||||
* @ingroup themeable
|
|
||||||
*/
|
|
||||||
#}
|
|
||||||
<div class="color-form clearfix">
|
|
||||||
{{ form.scheme }}
|
|
||||||
<div class="clearfix color-palette js-color-palette">
|
|
||||||
{{ form.palette }}
|
|
||||||
</div>
|
|
||||||
{{ form|without('scheme', 'palette') }}
|
|
||||||
<h2>{{ 'Preview'|t }}</h2>
|
|
||||||
{{ html_preview }}
|
|
||||||
</div>
|
|
|
@ -1,5 +0,0 @@
|
||||||
name: 'Color test'
|
|
||||||
type: module
|
|
||||||
description: 'Provides test helpers for color module.'
|
|
||||||
package: Testing
|
|
||||||
version: VERSION
|
|
|
@ -1 +0,0 @@
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="57" height="66" viewBox="471.5 467 57 66" enable-background="new 471.5 467 57 66"><path opacity=".2" fill="#303030" d="M528.5 504.965c0 16.634-13.123 27.615-28.24 27.615-10.29 0-19.894-5.523-24.978-14.167l.605-.027c1.313 1.192 3.39 2.58 7.404 2.515 4.77-.064 5.645-.875 9.855-2.756 22.716-10.17 26.925-19.457 27.736-21.59s2.013-5.587.756-9.415c-.242-.737-.42-1.333-.54-1.808-3.018-3.372-6.017-5.225-6.92-5.784-.14-.093-.29-.177-.43-.26l.44.26c2.01 1.247 14.314 8.782 14.314 25.417z"/><path fill="#fff" d="M509.09 518.507c1.006 0 2.077.065 2.83.568.756.503 1.193 1.63 1.445 2.263.25.634 0 1.006-.503 1.258-.438.25-.503.12-.94-.69-.44-.81-.82-1.63-3.01-1.63s-2.887.755-3.948 1.63c-1.062.876-1.443 1.193-1.825.69s-.253-1.006.437-1.63 1.825-1.63 2.888-2.077c1.06-.45 1.62-.383 2.625-.383zm-10.413 7.152c1.257 1.005 3.14 1.825 7.153 1.825 4.015 0 6.836-1.137 8.094-2.077.568-.438.82-.065.875.187.056.25.186.624-.252 1.07-.316.317-3.194 2.33-6.594 2.636-3.4.31-7.964.504-10.73-2.01-.438-.44-.316-1.07 0-1.323.317-.25.568-.438.94-.438.374.008.317.008.513.13z"/><path opacity=".2" fill="#aaa" d="M520.89 496.545c-.81 2.133-5.02 11.42-27.735 21.59-4.21 1.88-5.085 2.69-9.854 2.756-4.013.066-6.09-1.32-7.403-2.514l-.605.028h-.01c-2.393-4.042-3.78-8.783-3.78-13.952 0-7.852 2.97-13.654 6.287-17.687.11-.13.213-.26.325-.382 2.683-3.148 5.55-5.17 7.218-6.203.038-.028.075-.047.112-.065.42-.25.754-.447.987-.568 2.757-1.51 4.77-2.263 7.963-4.77.12-.092.242-.186.354-.288l.008-.01c.875-.754 1.64-1.76 2.18-3.4v-.008c.325-.97.567-2.16.716-3.65l.02.018c2.253 2.69 4.954 5.886 6.89 7.144.69.447 1.38.848 2.068 1.202l.3.15c2.243 1.126 4.507 1.945 6.807 3.333l.428.26c.903.56 3.902 2.412 6.92 5.784.12.475.298 1.07.54 1.807 1.274 3.837.073 7.292-.737 9.425z"/><path opacity=".5" fill="#333" d="M514.176 479.538c-3.26-2.077-6.464-2.887-9.603-4.955-1.938-1.267-4.64-4.47-6.893-7.162-.438 4.332-1.686 6.148-3.26 7.35-3.195 2.515-5.207 3.26-7.963 4.77-2.338 1.256-14.958 8.726-14.958 24.913 0 5.17 1.387 9.91 3.77 13.96 5.077 8.635 14.68 14.158 24.97 14.158 15.126 0 28.24-10.98 28.24-27.614 0-9.127-3.707-15.526-7.386-19.633-3.016-3.382-6.015-5.217-6.918-5.785zm7.627 7.34c4.117 5.15 6.213 11.23 6.213 18.077 0 3.968-.755 7.712-2.245 11.148-1.414 3.25-3.444 6.13-6.053 8.56-5.15 4.806-12.062 7.45-19.475 7.45-3.67 0-7.265-.698-10.692-2.086-3.372-1.36-6.398-3.297-9.016-5.774-5.532-5.225-8.57-12.257-8.57-19.8 0-6.716 2.18-12.695 6.483-17.753 3.288-3.865 6.836-6.007 8.196-6.743.67-.363 1.285-.69 1.89-.997 1.892-.97 3.68-1.89 6.14-3.818 1.312-.997 2.71-2.58 3.305-6.585 2.077 2.468 4.48 5.234 6.314 6.426 1.63 1.08 3.307 1.835 4.918 2.562 1.527.69 3.11 1.406 4.676 2.403l.056.037c4.62 2.84 7.06 5.896 7.86 6.892z"/><path opacity=".5" fill="#fff" d="M497.98 468.678c.874 2.58.753 3.893.753 4.452 0 .56-.307 2.077-1.313 2.832-.438.317-.568.568-.568.624 0 .25.568.438.568 1.006 0 .69-.317 2.077-3.642 5.393-3.325 3.316-8.103 6.278-11.8 8.103-3.698 1.826-5.468 1.686-5.97.81s.185-2.83 2.514-5.392l9.667-6.278 9.164-6.398.503-2.44"/><path fill="#fff" d="M497.98 468.613c-.57 4.145-1.826 5.393-3.512 6.715-2.83 2.133-5.588 3.446-6.212 3.763-1.63.82-7.535 4.08-10.608 8.784-.94 1.444 0 2.012.186 2.133.187.12 2.33.372 6.9-2.385 4.574-2.757 6.595-4.387 9.175-7.078 1.377-1.444 1.573-2.263 1.573-2.636 0-.438-.316-.624-.82-.754-.25-.065-.316-.187 0-.373.317-.186 1.622-.82 1.938-1.07.318-.25 1.827-1.257 1.882-2.887.065-1.63-.056-2.766-.503-4.21zm-14.112 45.628c.065-4.898 4.648-9.472 10.422-9.536 7.348-.065 12.424 7.283 16.13 7.208 3.14-.064 9.166-6.212 12.118-6.212 3.14 0 4.014 3.26 4.014 5.206 0 1.938-.623 5.458-2.133 7.656-1.51 2.198-2.44 3.008-4.2 2.888-2.264-.187-6.78-7.21-9.67-7.35-3.64-.12-11.547 7.6-17.75 7.6-3.763 0-4.9-.567-6.147-1.378-1.92-1.312-2.85-3.315-2.785-6.08z"/></svg>
|
|
Before Width: | Height: | Size: 3.7 KiB |
|
@ -1,44 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Lists available colors and color schemes for the Color test theme.
|
|
||||||
*/
|
|
||||||
|
|
||||||
$info = [
|
|
||||||
'fields' => [
|
|
||||||
'bg' => t('Main background'),
|
|
||||||
'text' => t('Text color'),
|
|
||||||
],
|
|
||||||
'schemes' => [
|
|
||||||
'default' => [
|
|
||||||
'title' => t('Default'),
|
|
||||||
'colors' => [
|
|
||||||
'bg' => '#ff0000',
|
|
||||||
'text' => '#0000ff',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'custom' => [
|
|
||||||
'title' => t('Custom'),
|
|
||||||
'colors' => [
|
|
||||||
'bg' => '#ff0000',
|
|
||||||
'text' => '#3b3b3b',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
'css' => [
|
|
||||||
'css/colors.css',
|
|
||||||
],
|
|
||||||
'copy' => [
|
|
||||||
'logo.svg',
|
|
||||||
],
|
|
||||||
'preview_html' => 'color/preview.html',
|
|
||||||
'#attached' => [
|
|
||||||
'drupalSettings' => [
|
|
||||||
'color' => [
|
|
||||||
// Put the logo path into JavaScript for the live preview.
|
|
||||||
'logo' => theme_get_setting('logo.url', 'color_test_theme'),
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
|
|
@ -1,8 +0,0 @@
|
||||||
<div class="color-preview">
|
|
||||||
<div id="text">
|
|
||||||
<h2>TEST COLOR PREVIEW</h2>
|
|
||||||
<p>Sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud <a href="#">exercitation ullamco</a> laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
|
||||||
</div>
|
|
||||||
<div id="img"></div>
|
|
||||||
</div>
|
|
||||||
<script>alert("security filter test");</script>
|
|
|
@ -1,7 +0,0 @@
|
||||||
name: 'Color test theme'
|
|
||||||
type: theme
|
|
||||||
base theme: stable
|
|
||||||
description: 'Theme for testing the color module'
|
|
||||||
version: VERSION
|
|
||||||
libraries:
|
|
||||||
- color_test_theme/base
|
|
|
@ -1,12 +0,0 @@
|
||||||
base:
|
|
||||||
version: VERSION
|
|
||||||
css:
|
|
||||||
theme:
|
|
||||||
css/colors.css: {}
|
|
||||||
|
|
||||||
fontsizer:
|
|
||||||
version: VERSION
|
|
||||||
js:
|
|
||||||
js/color_test_theme-fontsize.js: {}
|
|
||||||
dependencies:
|
|
||||||
- core/jquery
|
|
|
@ -1,5 +0,0 @@
|
||||||
# Schema for the configuration files of the Color test theme.
|
|
||||||
|
|
||||||
color_test_theme.settings:
|
|
||||||
type: theme_settings
|
|
||||||
label: 'Color test theme settings'
|
|
|
@ -1,7 +0,0 @@
|
||||||
html {
|
|
||||||
color: #00f;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
color: #f00;
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Adds javascript functions for font resizing.
|
|
||||||
*/
|
|
||||||
(function ($) {
|
|
||||||
$(document).ready(() => {});
|
|
||||||
})(jQuery);
|
|
|
@ -1,10 +0,0 @@
|
||||||
/**
|
|
||||||
* DO NOT EDIT THIS FILE.
|
|
||||||
* See the following change record for more information,
|
|
||||||
* https://www.drupal.org/node/2815083
|
|
||||||
* @preserve
|
|
||||||
**/
|
|
||||||
|
|
||||||
(function ($) {
|
|
||||||
$(document).ready(() => {});
|
|
||||||
})(jQuery);
|
|
|
@ -1,57 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\color\Functional;
|
|
||||||
|
|
||||||
use Drupal\Tests\BrowserTestBase;
|
|
||||||
use Drupal\user\UserInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensures the color config schema is correct.
|
|
||||||
*
|
|
||||||
* @group color
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class ColorConfigSchemaTest extends BrowserTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modules to install.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected static $modules = ['color'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $defaultTheme = 'color_test_theme';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A user with administrative permissions.
|
|
||||||
*
|
|
||||||
* @var \Drupal\user\UserInterface
|
|
||||||
*/
|
|
||||||
protected UserInterface $adminUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setUp(): void {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
// Create user.
|
|
||||||
$this->adminUser = $this->drupalCreateUser(['administer themes']);
|
|
||||||
$this->drupalLogin($this->adminUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the color config schema is valid.
|
|
||||||
*/
|
|
||||||
public function testValidColorConfigSchema(): void {
|
|
||||||
$settings_path = 'admin/appearance/settings/color_test_theme';
|
|
||||||
$edit['scheme'] = '';
|
|
||||||
$edit['palette[bg]'] = '#123456';
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,63 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\color\Functional;
|
|
||||||
|
|
||||||
use Drupal\Core\Url;
|
|
||||||
use Drupal\Tests\BrowserTestBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests sanitizing color preview loaded from theme.
|
|
||||||
*
|
|
||||||
* @group color
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class ColorSafePreviewTest extends BrowserTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modules to enable.
|
|
||||||
*
|
|
||||||
* @var string[]
|
|
||||||
*/
|
|
||||||
protected static $modules = ['color', 'color_test'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $defaultTheme = 'stark';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A user with administrative permissions.
|
|
||||||
*
|
|
||||||
* @var \Drupal\user\UserInterface
|
|
||||||
*/
|
|
||||||
protected $bigUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setUp(): void {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
// Create user.
|
|
||||||
$this->bigUser = $this->drupalCreateUser(['administer themes']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ensures color preview.html is sanitized.
|
|
||||||
*/
|
|
||||||
public function testColorPreview() {
|
|
||||||
// Install the color test theme.
|
|
||||||
\Drupal::service('theme_installer')->install(['color_test_theme']);
|
|
||||||
$this->drupalLogin($this->bigUser);
|
|
||||||
|
|
||||||
// Markup is being printed from an HTML file located in:
|
|
||||||
// core/modules/color/tests/modules/color_test/themes/color_test_theme/color/preview.html
|
|
||||||
$url = Url::fromRoute('system.theme_settings_theme', ['theme' => 'color_test_theme']);
|
|
||||||
$this->drupalGet($url);
|
|
||||||
$this->assertSession()->pageTextContains('TEST COLOR PREVIEW');
|
|
||||||
|
|
||||||
$this->assertSession()->responseNotContains('<script>alert("security filter test");</script>');
|
|
||||||
$this->assertSession()->responseContains('<h2>TEST COLOR PREVIEW</h2>');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,204 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\color\Functional;
|
|
||||||
|
|
||||||
use Drupal\Tests\BrowserTestBase;
|
|
||||||
use Drupal\user\UserInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modify theme colors and make sure the changes are reflected on the frontend.
|
|
||||||
*
|
|
||||||
* @group color
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class ColorTest extends BrowserTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Modules to install.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
protected static $modules = ['color', 'color_test', 'block', 'file'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected $defaultTheme = 'color_test_theme';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A user with administrative permissions.
|
|
||||||
*
|
|
||||||
* @var \Drupal\user\UserInterface
|
|
||||||
*/
|
|
||||||
protected UserInterface $bigUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setUp(): void {
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
// Create user.
|
|
||||||
$this->bigUser = $this->drupalCreateUser(['administer themes']);
|
|
||||||
|
|
||||||
// Set 'color_test_theme' as the default theme.
|
|
||||||
$this->config('system.theme')
|
|
||||||
->set('default', 'color_test_theme')
|
|
||||||
->save();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests the Color module functionality.
|
|
||||||
*/
|
|
||||||
public function testColor(): void {
|
|
||||||
$settings_path = 'admin/appearance/settings/color_test_theme';
|
|
||||||
$assert_session = $this->assertSession();
|
|
||||||
|
|
||||||
$this->drupalLogin($this->bigUser);
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$assert_session->statusCodeEquals(200);
|
|
||||||
$assert_session->pageTextContainsOnce('Color set');
|
|
||||||
$edit['scheme'] = '';
|
|
||||||
$edit['palette[bg]'] = '#123456';
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
|
|
||||||
$this->drupalGet('<front>');
|
|
||||||
$stylesheets = $this->config('color.theme.color_test_theme')
|
|
||||||
->get('stylesheets');
|
|
||||||
/** @var \Drupal\Core\File\FileUrlGeneratorInterface $file_url_generator */
|
|
||||||
$file_url_generator = \Drupal::service('file_url_generator');
|
|
||||||
// Make sure the color stylesheet is included in the content.
|
|
||||||
foreach ($stylesheets as $stylesheet) {
|
|
||||||
$assert_session->responseMatches('|' . $file_url_generator->generateString($stylesheet) . '|');
|
|
||||||
$stylesheet_content = implode("\n", file($stylesheet));
|
|
||||||
$this->assertStringContainsString('color: #123456', $stylesheet_content, 'Make sure the color we changed is in the color stylesheet.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$edit['scheme'] = 'custom';
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
|
|
||||||
$this->drupalGet('<front>');
|
|
||||||
$stylesheets = $this->config('color.theme.color_test_theme')
|
|
||||||
->get('stylesheets');
|
|
||||||
foreach ($stylesheets as $stylesheet) {
|
|
||||||
$stylesheet_content = implode("\n", file($stylesheet));
|
|
||||||
$this->assertStringContainsString('color: #3b3b3b', $stylesheet_content, 'Make sure the color we changed is in the color stylesheet.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test with aggregated CSS turned on.
|
|
||||||
$config = $this->config('system.performance');
|
|
||||||
$config->set('css.preprocess', 1);
|
|
||||||
$config->save();
|
|
||||||
$this->drupalGet('<front>');
|
|
||||||
$stylesheets = \Drupal::state()->get('drupal_css_cache_files', []);
|
|
||||||
$stylesheet_content = '';
|
|
||||||
foreach ($stylesheets as $uri) {
|
|
||||||
$stylesheet_content .= implode("\n", file(\Drupal::service('file_system')
|
|
||||||
->realpath($uri)));
|
|
||||||
}
|
|
||||||
$this->assertStringNotContainsString('public://', $stylesheet_content, 'Make sure the color paths have been translated to local paths.');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the provided color is valid.
|
|
||||||
*/
|
|
||||||
public function testValidColor(): void {
|
|
||||||
$settings_path = 'admin/appearance/settings/color_test_theme';
|
|
||||||
$assert_session = $this->assertSession();
|
|
||||||
|
|
||||||
// Array filled with valid and not valid color values.
|
|
||||||
$colorTests = [
|
|
||||||
'#000' => TRUE,
|
|
||||||
'#123456' => TRUE,
|
|
||||||
'#abcdef' => TRUE,
|
|
||||||
'#0' => FALSE,
|
|
||||||
'#00' => FALSE,
|
|
||||||
'#0000' => FALSE,
|
|
||||||
'#00000' => FALSE,
|
|
||||||
'123456' => FALSE,
|
|
||||||
'#00000g' => FALSE,
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->drupalLogin($this->bigUser);
|
|
||||||
$edit['scheme'] = '';
|
|
||||||
|
|
||||||
foreach ($colorTests as $color => $is_valid) {
|
|
||||||
$edit['palette[bg]'] = $color;
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
|
|
||||||
if ($is_valid) {
|
|
||||||
$assert_session->pageTextContains('The configuration options have been saved.');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$assert_session->pageTextContains('You must enter a valid hexadecimal color value for Main background.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the custom logo is used in the color preview.
|
|
||||||
*/
|
|
||||||
public function testLogoSettingOverride(): void {
|
|
||||||
$this->drupalLogin($this->bigUser);
|
|
||||||
$edit = [
|
|
||||||
'default_logo' => FALSE,
|
|
||||||
'logo_path' => 'core/misc/druplicon.png',
|
|
||||||
];
|
|
||||||
$this->drupalGet('admin/appearance/settings');
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
|
|
||||||
// Ensure that the overridden logo is present in color_test_theme, which is
|
|
||||||
// colorable.
|
|
||||||
$this->drupalGet('admin/appearance/settings/color_test_theme');
|
|
||||||
$this->assertSame($GLOBALS['base_path'] . 'core/misc/druplicon.png', $this->getDrupalSettings()['color']['logo']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests whether the scheme can be set, viewed anonymously and reset.
|
|
||||||
*/
|
|
||||||
public function testOverrideAndResetScheme(): void {
|
|
||||||
$settings_path = 'admin/appearance/settings/color_test_theme';
|
|
||||||
$assert_session = $this->assertSession();
|
|
||||||
|
|
||||||
// Place branding block with site name and slogan into header region.
|
|
||||||
$this->drupalPlaceBlock('system_branding_block', ['region' => 'header']);
|
|
||||||
|
|
||||||
$this->drupalGet('');
|
|
||||||
// Make sure the color logo is not being used.
|
|
||||||
$assert_session->responseNotContains('files/color/color_test_theme-');
|
|
||||||
// Make sure the original color_test_theme logo exists.
|
|
||||||
$assert_session->responseContains('color_test_theme/logo.svg');
|
|
||||||
|
|
||||||
// Log in and set the color scheme to 'custom'.
|
|
||||||
$this->drupalLogin($this->bigUser);
|
|
||||||
$edit['scheme'] = 'custom';
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
|
|
||||||
// Visit the homepage and ensure color changes.
|
|
||||||
$this->drupalLogout();
|
|
||||||
$this->drupalGet('');
|
|
||||||
// Make sure the color logo is being used.
|
|
||||||
$assert_session->responseContains('files/color/color_test_theme-');
|
|
||||||
// Make sure the original color_test_theme logo does not exist.
|
|
||||||
$assert_session->responseNotContains('color_test_theme/logo.svg');
|
|
||||||
|
|
||||||
// Log in and set the color scheme back to default (delete config).
|
|
||||||
$this->drupalLogin($this->bigUser);
|
|
||||||
$edit['scheme'] = 'default';
|
|
||||||
$this->drupalGet($settings_path);
|
|
||||||
$this->submitForm($edit, 'Save configuration');
|
|
||||||
|
|
||||||
// Log out and ensure there is no color and we have the original logo.
|
|
||||||
$this->drupalLogout();
|
|
||||||
$this->drupalGet('');
|
|
||||||
// Make sure the color logo is not being used.
|
|
||||||
$assert_session->responseNotContains('files/color/color_test_theme-');
|
|
||||||
// Make sure the original color_test_theme logo exists.
|
|
||||||
$assert_session->responseContains('color_test_theme/logo.svg');
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\color\Functional\Migrate;
|
|
||||||
|
|
||||||
use Drupal\Tests\migrate_drupal_ui\Functional\NoMultilingualReviewPageTestBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests review page.
|
|
||||||
*
|
|
||||||
* The test method is provided by the MigrateUpgradeTestBase class.
|
|
||||||
*
|
|
||||||
* @group color
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected static $modules = ['color'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setUp(): void {
|
|
||||||
parent::setUp();
|
|
||||||
$this->loadFixture($this->getModulePath('color') . '/tests/fixtures/drupal7.php');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests that Color is displayed in the will be upgraded list.
|
|
||||||
*/
|
|
||||||
public function testMigrateUpgradeReviewPage() {
|
|
||||||
$this->prepare();
|
|
||||||
// Start the upgrade process.
|
|
||||||
$this->submitCredentialForm();
|
|
||||||
|
|
||||||
$session = $this->assertSession();
|
|
||||||
$this->submitForm([], 'I acknowledge I may lose data. Continue anyway.');
|
|
||||||
$session->statusCodeEquals(200);
|
|
||||||
|
|
||||||
// Confirm that Color will be upgraded.
|
|
||||||
$session->elementExists('xpath', "//td[contains(@class, 'checked') and text() = 'Color']");
|
|
||||||
$session->elementNotExists('xpath', "//td[contains(@class, 'error') and text() = 'Color']");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getSourceBasePath() {
|
|
||||||
return __DIR__;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getAvailablePaths() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getIncompletePaths() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function getMissingPaths() {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,69 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\color\Kernel\Migrate\d7;
|
|
||||||
|
|
||||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests migration of Color variables to configuration.
|
|
||||||
*
|
|
||||||
* @group color
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class MigrateColorTest extends MigrateDrupal7TestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected static $modules = ['color'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected function setUp(): void {
|
|
||||||
parent::setUp();
|
|
||||||
// Install the themes used for this test.
|
|
||||||
$this->container->get('theme_installer')->install(['bartik']);
|
|
||||||
$this->executeMigration('d7_color');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the path to the fixture file.
|
|
||||||
*/
|
|
||||||
protected function getFixtureFilePath() {
|
|
||||||
return __DIR__ . '/../../../../fixtures/drupal7.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests migration of color's variables to configuration.
|
|
||||||
*/
|
|
||||||
public function testMigrateColor() {
|
|
||||||
// Test Bartik migration.
|
|
||||||
$config = $this->config('color.theme.bartik');
|
|
||||||
$files = [
|
|
||||||
'public://color/bartik-e0e23ad7/logo.png',
|
|
||||||
'public://color/bartik-e0e23ad7/colors.css',
|
|
||||||
];
|
|
||||||
$this->assertSame($files, $config->get('files'));
|
|
||||||
$this->assertSame('public://color/bartik-e0e23ad7/logo.png', $config->get('logo'));
|
|
||||||
$palette = [
|
|
||||||
'top' => '#d0d0d0',
|
|
||||||
'bottom' => '#c2c4c5',
|
|
||||||
'bg' => '#ffffff',
|
|
||||||
'sidebar' => '#ffffff',
|
|
||||||
'sidebarborders' => '#cccccc',
|
|
||||||
'footer' => '#24272c',
|
|
||||||
'titleslogan' => '#000000',
|
|
||||||
'text' => '#4a4a4a',
|
|
||||||
'link' => '#019dbf',
|
|
||||||
];
|
|
||||||
$this->assertSame($palette, $config->get('palette'));
|
|
||||||
$this->assertSame(['public://color/bartik-e0e23ad7/colors.css'], $config->get('stylesheets'));
|
|
||||||
// Test that the screenshot was not migrated.
|
|
||||||
$this->assertNull($config->get('screenshot'));
|
|
||||||
|
|
||||||
// Test that garland was not migrated.
|
|
||||||
$this->assertEmpty(\Drupal::config('color.theme.garland')->get());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,131 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\Tests\color\Kernel\Plugin\migrate\source\d7;
|
|
||||||
|
|
||||||
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tests D7 color source plugin.
|
|
||||||
*
|
|
||||||
* @covers \Drupal\color\Plugin\migrate\source\d7\Color
|
|
||||||
*
|
|
||||||
* @group color
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
class ColorTest extends MigrateSqlSourceTestBase {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
protected static $modules = ['color', 'migrate_drupal'];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritdoc}
|
|
||||||
*/
|
|
||||||
public function providerSource() {
|
|
||||||
$tests = [];
|
|
||||||
|
|
||||||
// The source data.
|
|
||||||
$tests[0]['database']['variable'] = [
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_palette',
|
|
||||||
'value' => [
|
|
||||||
'top' => '#cd2d2d',
|
|
||||||
'bottom' => '#d64e4e',
|
|
||||||
'bg' => '#ffffff',
|
|
||||||
'sidebar' => '#f1f4f0',
|
|
||||||
'sidebarborders' => '#ededed',
|
|
||||||
'footer' => '#1f1d1c',
|
|
||||||
'titleslogan' => '#fffeff',
|
|
||||||
'text' => '#888888',
|
|
||||||
'link' => '#d6121f',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_logo',
|
|
||||||
'value' => 'public://color/bartik-e0e23ad7/logo.png',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_stylesheets',
|
|
||||||
'value' => ['public://color/bartik-1d249313/colors.css'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_files',
|
|
||||||
'value' => [
|
|
||||||
'public://color/bartik-e0e23ad7/logo.png',
|
|
||||||
'public://color/bartik-e0e23ad7/colors.css',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_screenshot',
|
|
||||||
'value' => ['public:://color/bartik-b69cfcec/screenshot.png'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_custom_stylesheets',
|
|
||||||
// cspell:ignore beadedff
|
|
||||||
'value' => ['public:://color/custom-beadedff/colors.css'],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($tests[0]['database']['variable'] as $key => $expected) {
|
|
||||||
$tests[0]['database']['variable'][$key]['value'] = serialize($expected['value']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tests[0]['database']['system'] = [
|
|
||||||
[
|
|
||||||
'name' => 'bartik',
|
|
||||||
'type' => 'theme',
|
|
||||||
'status' => '1',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'custom',
|
|
||||||
'type' => 'theme',
|
|
||||||
'status' => '0',
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
// Expected results are the same as the source.
|
|
||||||
$tests[0]['expected_results'] = [
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_palette',
|
|
||||||
'value' => [
|
|
||||||
'top' => '#cd2d2d',
|
|
||||||
'bottom' => '#d64e4e',
|
|
||||||
'bg' => '#ffffff',
|
|
||||||
'sidebar' => '#f1f4f0',
|
|
||||||
'sidebarborders' => '#ededed',
|
|
||||||
'footer' => '#1f1d1c',
|
|
||||||
'titleslogan' => '#fffeff',
|
|
||||||
'text' => '#888888',
|
|
||||||
'link' => '#d6121f',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_logo',
|
|
||||||
'value' => 'public://color/bartik-e0e23ad7/logo.png',
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_stylesheets',
|
|
||||||
'value' => ['public://color/bartik-1d249313/colors.css'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_files',
|
|
||||||
'value' => [
|
|
||||||
'public://color/bartik-e0e23ad7/logo.png',
|
|
||||||
'public://color/bartik-e0e23ad7/colors.css',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_bartik_screenshot',
|
|
||||||
'value' => ['public:://color/bartik-b69cfcec/screenshot.png'],
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'name' => 'color_custom_stylesheets',
|
|
||||||
'value' => ['public:://color/custom-beadedff/colors.css'],
|
|
||||||
],
|
|
||||||
];
|
|
||||||
|
|
||||||
return $tests;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -9,7 +9,6 @@ finished:
|
||||||
# The following do not have an upgrade path.
|
# The following do not have an upgrade path.
|
||||||
blogapi: core
|
blogapi: core
|
||||||
calendarsignup: core
|
calendarsignup: core
|
||||||
color: core
|
|
||||||
content_copy: core
|
content_copy: core
|
||||||
content_multigroup: core
|
content_multigroup: core
|
||||||
content_permissions: core
|
content_permissions: core
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate;
|
namespace Drupal\Tests\migrate_drupal\Kernel\Plugin\migrate;
|
||||||
|
|
||||||
use Drupal\ban\Plugin\migrate\destination\BlockedIp;
|
use Drupal\ban\Plugin\migrate\destination\BlockedIp;
|
||||||
use Drupal\color\Plugin\migrate\destination\Color;
|
|
||||||
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
|
use Drupal\KernelTests\FileSystemModuleDiscoveryDataProviderTrait;
|
||||||
use Drupal\migrate\Plugin\migrate\destination\ComponentEntityDisplayBase;
|
use Drupal\migrate\Plugin\migrate\destination\ComponentEntityDisplayBase;
|
||||||
use Drupal\migrate\Plugin\migrate\destination\Config;
|
use Drupal\migrate\Plugin\migrate\destination\Config;
|
||||||
|
@ -100,7 +99,6 @@ class DestinationCategoryTest extends MigrateDrupalTestBase {
|
||||||
*/
|
*/
|
||||||
protected function getConfigurationClasses() {
|
protected function getConfigurationClasses() {
|
||||||
return [
|
return [
|
||||||
Color::class,
|
|
||||||
Config::class,
|
Config::class,
|
||||||
EntityConfigBase::class,
|
EntityConfigBase::class,
|
||||||
ThemeSettings::class,
|
ThemeSettings::class,
|
||||||
|
|
|
@ -40,8 +40,6 @@ class StateFileExistsTest extends MigrateDrupalTestBase {
|
||||||
'block',
|
'block',
|
||||||
'block_content',
|
'block_content',
|
||||||
'book',
|
'book',
|
||||||
// @todo Remove Color in https://www.drupal.org/project/drupal/issues/3270899
|
|
||||||
'color',
|
|
||||||
'comment',
|
'comment',
|
||||||
'config_translation',
|
'config_translation',
|
||||||
'contact',
|
'contact',
|
||||||
|
|
|
@ -65,8 +65,6 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
|
||||||
'Book',
|
'Book',
|
||||||
'CCK translation',
|
'CCK translation',
|
||||||
'Calendar Signup',
|
'Calendar Signup',
|
||||||
// @todo Remove Color in https://www.drupal.org/project/drupal/issues/3270899
|
|
||||||
'Color',
|
|
||||||
'Comment',
|
'Comment',
|
||||||
'Contact',
|
'Contact',
|
||||||
'Content',
|
'Content',
|
||||||
|
@ -151,6 +149,7 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
|
||||||
'Aggregator',
|
'Aggregator',
|
||||||
// Block is set not_finished in migrate_state_not_finished_test.
|
// Block is set not_finished in migrate_state_not_finished_test.
|
||||||
'Block',
|
'Block',
|
||||||
|
'Color',
|
||||||
'Devel',
|
'Devel',
|
||||||
'Devel generate',
|
'Devel generate',
|
||||||
'Devel node access',
|
'Devel node access',
|
||||||
|
|
|
@ -59,8 +59,6 @@ class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
|
||||||
'Blog API',
|
'Blog API',
|
||||||
'Book',
|
'Book',
|
||||||
'Calendar Signup',
|
'Calendar Signup',
|
||||||
// @todo Remove Color in https://www.drupal.org/project/drupal/issues/3270899
|
|
||||||
'Color',
|
|
||||||
'Comment',
|
'Comment',
|
||||||
'Contact',
|
'Contact',
|
||||||
'Content',
|
'Content',
|
||||||
|
@ -146,6 +144,7 @@ class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
|
||||||
'Block',
|
'Block',
|
||||||
'Block translation',
|
'Block translation',
|
||||||
'CCK translation',
|
'CCK translation',
|
||||||
|
'Color',
|
||||||
'Content type translation',
|
'Content type translation',
|
||||||
'Devel',
|
'Devel',
|
||||||
'Devel generate',
|
'Devel generate',
|
||||||
|
|
|
@ -153,7 +153,6 @@ class MultilingualReviewPageTest extends MultilingualReviewPageTestBase {
|
||||||
// Block is set not_finished in migrate_state_not_finished_test.
|
// Block is set not_finished in migrate_state_not_finished_test.
|
||||||
'Block',
|
'Block',
|
||||||
'Breakpoints',
|
'Breakpoints',
|
||||||
// @todo Remove Color in https://www.drupal.org/project/drupal/issues/3270899
|
|
||||||
'Color',
|
'Color',
|
||||||
'Contact translation',
|
'Contact translation',
|
||||||
'Entity Translation Menu',
|
'Entity Translation Menu',
|
||||||
|
|
|
@ -158,7 +158,6 @@ class NoMultilingualReviewPageTest extends NoMultilingualReviewPageTestBase {
|
||||||
return [
|
return [
|
||||||
'Aggregator',
|
'Aggregator',
|
||||||
'Breakpoints',
|
'Breakpoints',
|
||||||
// @todo Remove Color in https://www.drupal.org/project/drupal/issues/3270899
|
|
||||||
'Color',
|
'Color',
|
||||||
'Contact translation',
|
'Contact translation',
|
||||||
'Entity Translation Menu',
|
'Entity Translation Menu',
|
||||||
|
|
|
@ -205,7 +205,6 @@ class Upgrade7Test extends MigrateUpgradeExecuteTestBase {
|
||||||
protected function getMissingPaths() {
|
protected function getMissingPaths() {
|
||||||
return [
|
return [
|
||||||
'Aggregator',
|
'Aggregator',
|
||||||
// @todo Remove Color in https://www.drupal.org/project/drupal/issues/3270899
|
|
||||||
'Color',
|
'Color',
|
||||||
// @todo Remove RDF in https://www.drupal.org/node/3267515
|
// @todo Remove RDF in https://www.drupal.org/node/3267515
|
||||||
'RDF',
|
'RDF',
|
||||||
|
|
|
@ -344,7 +344,6 @@ class UpdatePathTestBaseFilledTest extends UpdatePathTestBaseTest {
|
||||||
'book',
|
'book',
|
||||||
'breakpoint',
|
'breakpoint',
|
||||||
'ckeditor',
|
'ckeditor',
|
||||||
'color',
|
|
||||||
'comment',
|
'comment',
|
||||||
'config',
|
'config',
|
||||||
'config_translation',
|
'config_translation',
|
||||||
|
|
|
@ -690,11 +690,6 @@ parameters:
|
||||||
count: 2
|
count: 2
|
||||||
path: modules/ckeditor5/ckeditor5.module
|
path: modules/ckeditor5/ckeditor5.module
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Function color_palette_color_value\\(\\) should return string but return statement is missing\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: modules/color/color.module
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
|
message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:10\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
|
@ -39,12 +39,12 @@
|
||||||
.color-palette__hook.is-down,
|
.color-palette__hook.is-down,
|
||||||
.color-palette__hook.is-up,
|
.color-palette__hook.is-up,
|
||||||
.color-palette__hook.is-both {
|
.color-palette__hook.is-both {
|
||||||
background: url(../../../../modules/color/images/hook.png) no-repeat 100% 0; /* LTR */
|
background: url(../../images/color/hook.png) no-repeat 100% 0; /* LTR */
|
||||||
}
|
}
|
||||||
[dir="rtl"] .color-palette__hook.is-down,
|
[dir="rtl"] .color-palette__hook.is-down,
|
||||||
[dir="rtl"] .color-palette__hook.is-up,
|
[dir="rtl"] .color-palette__hook.is-up,
|
||||||
[dir="rtl"] .color-palette__hook.is-both {
|
[dir="rtl"] .color-palette__hook.is-both {
|
||||||
background: url(../../../../modules/color/images/hook-rtl.png) no-repeat 0 0;
|
background: url(../../images/color/hook-rtl.png) no-repeat 0 0;
|
||||||
}
|
}
|
||||||
.color-palette__hook.is-up {
|
.color-palette__hook.is-up {
|
||||||
background-position: 100% -27px; /* LTR */
|
background-position: 100% -27px; /* LTR */
|
||||||
|
@ -75,7 +75,7 @@ button.color-palette__lock,
|
||||||
direction: ltr;
|
direction: ltr;
|
||||||
border: 0;
|
border: 0;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
background: url(../../../../modules/color/images/lock.png) no-repeat 50% 0;
|
background: url(../../images/color/lock.png) no-repeat 50% 0;
|
||||||
}
|
}
|
||||||
[dir="rtl"] button.color-palette__lock,
|
[dir="rtl"] button.color-palette__lock,
|
||||||
[dir="rtl"] .color-palette__lock {
|
[dir="rtl"] .color-palette__lock {
|
||||||
|
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
Before Width: | Height: | Size: 230 B After Width: | Height: | Size: 230 B |