- core-recommended/scaffold/project-message ^11.4, platform php 8.3.37, symfony/runtime allow-plugin - drush ^13, toutes les contraintes modules montées vers D11 (racine + profil starterkit) - modules abandonnés D11 pris en custom: path_alias_xt, content_type_clone, bulkdelete, imagestyleflush (flush_single_image), audiofield (annotations -> attributs PHP 8), adminimal_theme (theme) - decoupled + theme caravane: core_version_requirement || ^11 - .gitmodules du profil -> gitea (gogs mort) - patch page_manager 3438993 retiré (ne s'applique plus sur 4.1.0, refactor upstream) - sync: retrait ban/actions_permissions/seven (modules core supprimés en D11) + normalisation cex D11 - config_pages: conflit intro_partenaire résolu Tests local (docker php 8.3.37): updb OK, cim OK, getChangeList vide, 6 pages clés hash-identiques avant/après, watchdog sans erreur nouvelle. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
132 lines
4.3 KiB
PHP
132 lines
4.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Functions to support theming in the Adminimal theme.
|
|
*/
|
|
|
|
use Drupal\Core\Form\FormStateInterface;
|
|
use Drupal\Core\Template\Attribute;
|
|
use Drupal\Core\File\FileSystemInterface;
|
|
|
|
/**
|
|
* Implements hook_preprocess_HOOK() for HTML document templates.
|
|
*/
|
|
function adminimal_theme_preprocess_html(&$variables) {
|
|
// Add adminimal class to the body.
|
|
if ($variables['attributes'] instanceof Attribute) {
|
|
$variables['attributes']->addClass('adminimal');
|
|
}
|
|
else {
|
|
$variables['attributes']['class'][] = 'adminimal';
|
|
}
|
|
|
|
// Add library with custom CSS.
|
|
if (theme_get_setting('custom_css')) {
|
|
$variables['#attached']['library'][] = 'adminimal_theme/custom-styling';
|
|
}
|
|
// Add Open Sans font styles based on the theme setting.
|
|
if (!theme_get_setting('disable_google_fonts')) {
|
|
$variables['#attached']['library'][] = 'adminimal_theme/google-fonts';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements hook_form_system_theme_settings_alter().
|
|
*/
|
|
function adminimal_theme_form_system_theme_settings_alter(&$form, FormStateInterface &$form_state, $form_id = NULL) {
|
|
// Work-around for a core bug affecting admin themes. See issue #943212.
|
|
if (isset($form_id)) {
|
|
return;
|
|
}
|
|
|
|
// Get adminimal theme path.
|
|
global $base_url;
|
|
$adminimal_path = \Drupal::service('extension.list.theme')->getPath('adminimal_theme');
|
|
$old_css_path = $adminimal_path . '/css/custom.css';
|
|
$custom_css_path = 'public://adminimal-custom.css';
|
|
$custom_css_dir = str_replace($base_url . '/', "", \Drupal::service('file_url_generator')->generateAbsoluteString($custom_css_path));
|
|
|
|
// Try to create the adminimal-custom.css file automatically.
|
|
if (!file_exists($custom_css_path)) {
|
|
|
|
/** @var \Drupal\Core\File\FileSystemInterface $file_system */
|
|
$file_system = \Drupal::service('file_system');
|
|
// Try to migrate from the old css.
|
|
if (file_exists($old_css_path)) {
|
|
$file_system->copy($old_css_path, $custom_css_path, FileSystemInterface::EXISTS_ERROR);
|
|
}
|
|
// Else create a new blank css file.
|
|
else {
|
|
$file_system->saveData("", $custom_css_path, FileSystemInterface::EXISTS_ERROR);
|
|
}
|
|
|
|
}
|
|
|
|
// Notify user to remove his old css file.
|
|
if (file_exists($old_css_path)) {
|
|
\Drupal::messenger()->addWarning(t('Please delete the old @css_location file, as its no longer used.', ['@css_location file' => $old_css_path]));
|
|
}
|
|
|
|
$form['adminimal_custom'] = [
|
|
'#type' => 'fieldset',
|
|
'#title' => t('Adminimal Customization'),
|
|
'#weight' => -10,
|
|
];
|
|
|
|
$form['adminimal_custom']['custom_css'] = [
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Use "adminimal-custom.css"'),
|
|
'#description' => t('Include adminimal-custom.css file to override or add custom css code without subthememing/hacking Adminimal Theme.'),
|
|
'#default_value' => theme_get_setting('custom_css'),
|
|
];
|
|
|
|
$form['adminimal_custom']['adminimal_custom_check'] = [
|
|
'#type' => 'fieldset',
|
|
'#title' => t('Custom CSS file check'),
|
|
'#weight' => 50,
|
|
'#states' => [
|
|
// Hide the settings when the cancel notify checkbox is disabled.
|
|
'visible' => [
|
|
':input[name="custom_css"]' => ['checked' => TRUE],
|
|
],
|
|
],
|
|
];
|
|
|
|
if (file_exists($custom_css_path)) {
|
|
$form['adminimal_custom']['adminimal_custom_check']['custom_css_description'] = [
|
|
'#type' => 'container',
|
|
'#attributes' => [
|
|
'class' => ['messages', 'messages--status'],
|
|
],
|
|
'message' => [
|
|
'#markup' => t('Custom CSS file Found in: @css', ['@css' => $custom_css_dir]),
|
|
],
|
|
];
|
|
}
|
|
else {
|
|
$form['adminimal_custom']['adminimal_custom_check']['custom_css_not_found'] = [
|
|
'#type' => 'container',
|
|
'#attributes' => [
|
|
'class' => ['messages', 'messages--error'],
|
|
],
|
|
'message' => [
|
|
'#markup' => t('Custom CSS file not found. You must create the @css file manually.', ['@css' => $custom_css_dir]),
|
|
],
|
|
];
|
|
}
|
|
|
|
$form['adminimal_theme_settings'] = [
|
|
'#type' => 'details',
|
|
'#title' => t('Adminimal theme settings'),
|
|
'#open' => TRUE,
|
|
];
|
|
|
|
$form['adminimal_theme_settings']['disable_google_fonts'] = [
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Avoid using "Open Sans" font'),
|
|
'#default_value' => theme_get_setting('disable_google_fonts'),
|
|
'#description' => t('Useful for languages that are not well supported by the "Open sans" font. Like Japanese for example.'),
|
|
];
|
|
}
|