diff --git a/hook.php b/hook.php
index 230d1bf..5f26111 100644
--- a/hook.php
+++ b/hook.php
@@ -17,10 +17,16 @@ function plugin_butterfly_display_login() {
$themeInfo = \GlpiPlugin\Butterfly\Theme::getThemeInfo($theme);
}
- $loginPicture = \GlpiPlugin\Butterfly\Config::getConfig('login_picture');
+ // Logo do login: custom (imagem enviada ou do tema) / original / hide
+ $logoDisplay = \GlpiPlugin\Butterfly\Config::getConfig('login_logo_display', 'custom');
- if (!$loginPicture && $themeInfo && !empty($themeInfo['login-logo'])) {
- $loginPicture = $themeInfo['login-logo'] . '&theme=' . $themeInfo['id'];
+ $loginPicture = null;
+ if ($logoDisplay === 'custom') {
+ $loginPicture = \GlpiPlugin\Butterfly\Config::getConfig('login_picture');
+
+ if (!$loginPicture && $themeInfo && !empty($themeInfo['login-logo'])) {
+ $loginPicture = $themeInfo['login-logo'] . '&theme=' . $themeInfo['id'];
+ }
}
$loginCss = \GlpiPlugin\Butterfly\Scss::getLoginCSS($requestedTheme);
@@ -29,6 +35,14 @@ function plugin_butterfly_display_login() {
}
?>
+
+
+
'',
'page_footer_display' => 'original',
'page_footer_text' => '',
+ 'login_logo_display' => 'custom',
'login_picture' => '',
'login_picture_max_width' => '240px',
'login_picture_max_height' => '130px',
@@ -237,45 +238,49 @@ class Config extends \CommonDBTM {
echo "
";
$rand = mt_rand();
+ $textareaId = $fullName . '_' . $rand;
$containerId = $fullName . '_editor_' . $rand;
$value = rtrim($this->fields[$fullName]);
- // Editor Monaco do core (GLPI 11) com fallback: o textarea escondido
- // mantém o name/valor e é sincronizado no submit via evento formdata
+ // Caixa de texto longa sempre visível; o Monaco do core (GLPI 11) só
+ // assume se a lib estiver carregada — aí esconde o textarea e passa a
+ // sincronizar o valor no submit via evento formdata
echo sprintf(
'';
- echo '';
+ echo '';
echo \Html::scriptBlock('
$(function() {
if (window.GLPI === undefined || window.GLPI.Monaco === undefined) {
- $("#' . $fullName . '_' . $rand . '").removeClass("d-none").attr({rows: 15, spellcheck: false});
- $("#' . $containerId . '").remove();
- return;
+ return; // sem Monaco nesta página — fica o textarea
}
- window.GLPI.Monaco.createEditor(
- ' . json_encode($containerId, JSON_HEX_TAG | JSON_HEX_AMP) . ',
- "scss",
- ' . json_encode($value, JSON_UNESCAPED_UNICODE | JSON_HEX_TAG | JSON_HEX_AMP) . ',
- []
- ).then(() => {
- $("#' . $containerId . '").closest("form").on("formdata", (e) => {
+ var taId = ' . json_encode($textareaId, JSON_HEX_TAG | JSON_HEX_AMP) . ';
+ var containerId = ' . json_encode($containerId, JSON_HEX_TAG | JSON_HEX_AMP) . ';
+ var fieldName = ' . json_encode($fullName, JSON_HEX_TAG | JSON_HEX_AMP) . ';
+ window.GLPI.Monaco.createEditor(containerId, "scss", $("#" + taId).val(), []).then(() => {
+ $("#" + containerId).removeClass("d-none");
+ $("#" + taId).addClass("d-none").prop("disabled", true);
+ $("#" + containerId).closest("form").on("formdata", (e) => {
const editors = window.monaco.editor.getEditors().filter(
- (editor) => editor._domElement.id === ' . json_encode($containerId, JSON_HEX_TAG | JSON_HEX_AMP) . '
+ (editor) => editor._domElement.id === containerId
);
if (editors.length) {
- e.originalEvent.formData.delete(' . json_encode($fullName, JSON_HEX_TAG | JSON_HEX_AMP) . ');
- e.originalEvent.formData.append(' . json_encode($fullName, JSON_HEX_TAG | JSON_HEX_AMP) . ', editors[0].getValue());
+ e.originalEvent.formData.delete(fieldName);
+ e.originalEvent.formData.append(fieldName, editors[0].getValue());
}
});
+ }).catch(() => {
+ // editor falhou — mantém o textarea funcional
});
});
');
@@ -534,6 +539,17 @@ class Config extends \CommonDBTM {
}
}
+ echo " | ";
+ echo "| " . t_butterfly('Logo') . " | ";
+ echo "";
+ \Dropdown::showFromArray('login_logo_display', [
+ 'custom' => t_butterfly('Custom (uploaded picture or theme logo)'),
+ 'original' => __('Original'),
+ 'hide' => t_butterfly('Hide'),
+ ], ['value' => $this->fields['login_logo_display']]);
+ echo " | ";
+ echo "
\n";
+
echo "";
echo "| " . __('Picture') . " | ";
$this->buildPictureLine('login_picture', '145px x 80px');