GLPI 11: remove dependências de libs extintas (CodeMirror, jQuery UI) e hack FileVersion
- add_css/add_javascript agora usam strings simples: o core do GLPI 11
interpola o valor uma única vez e acrescenta ?v=<versão> sozinho, o que
neutralizava o truque de __toString duplo do PluginButterflyFileVersion
(classe removida).
- CodeMirror foi removido do GLPI 11 (substituído por Monaco no core);
o init quebrava com ReferenceError. Textarea simples por ora; Monaco
entra na modernização.
- $('#tabs').tabs() removido: jQuery UI não existe mais no GLPI 11 e o
HTML das tabs já estava comentado.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
26127bf736
commit
072547ae8a
3 changed files with 10 additions and 65 deletions
|
|
@ -3,7 +3,6 @@
|
||||||
class PluginButterflyConfig extends CommonDBTM {
|
class PluginButterflyConfig extends CommonDBTM {
|
||||||
|
|
||||||
private static $_cache = null;
|
private static $_cache = null;
|
||||||
private static $_i = 1;
|
|
||||||
|
|
||||||
static function getConfig($name, $defaultValue = null) {
|
static function getConfig($name, $defaultValue = null) {
|
||||||
|
|
||||||
|
|
@ -241,32 +240,13 @@ class PluginButterflyConfig extends CommonDBTM {
|
||||||
Html::parseAttributes([
|
Html::parseAttributes([
|
||||||
'id' => $fullName . '_' . $rand,
|
'id' => $fullName . '_' . $rand,
|
||||||
'name' => $fullName,
|
'name' => $fullName,
|
||||||
'class' => 'butterfly-codemirror',
|
'class' => 'butterfly-css-editor',
|
||||||
|
'rows' => 15,
|
||||||
|
'spellcheck' => 'false',
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
echo rtrim($this->fields[$fullName]);
|
echo rtrim($this->fields[$fullName]);
|
||||||
echo str_repeat("\n", 10);
|
|
||||||
echo '</textarea>';
|
echo '</textarea>';
|
||||||
|
|
||||||
echo Html::scriptBlock('
|
|
||||||
$(function() {
|
|
||||||
var textarea = document.getElementById("' . $fullName . '_' . $rand . '");
|
|
||||||
var editorCode = CodeMirror.fromTextArea(textarea, {
|
|
||||||
mode: "text/x-scss",
|
|
||||||
lineNumbers: true,
|
|
||||||
viewportMargin: Infinity,
|
|
||||||
extraKeys: {
|
|
||||||
"Ctrl-Space": "autocomplete"
|
|
||||||
},
|
|
||||||
foldGutter: true,
|
|
||||||
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
|
|
||||||
});
|
|
||||||
$("#' . $fullName . '_' . $rand . '").data("CodeMirrorInstance", editorCode);
|
|
||||||
|
|
||||||
// Fix bad display of gutter (see https://github.com/codemirror/CodeMirror/issues/3098 )
|
|
||||||
setTimeout(function () {editorCode.refresh();}, ' . (500 + self::$_i++ * 100) . ');
|
|
||||||
});
|
|
||||||
');
|
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
echo "</tr>\n";
|
echo "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
@ -311,9 +291,10 @@ class PluginButterflyConfig extends CommonDBTM {
|
||||||
#tabs$rand .ui-tabs-panel {
|
#tabs$rand .ui-tabs-panel {
|
||||||
margin-left: 0;
|
margin-left: 0;
|
||||||
}
|
}
|
||||||
.CodeMirror {
|
.butterfly-css-editor {
|
||||||
|
width: 100%;
|
||||||
border: 1px solid #eee;
|
border: 1px solid #eee;
|
||||||
height: auto;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
.butterfly-themeselect-container .select2-selection__rendered,
|
.butterfly-themeselect-container .select2-selection__rendered,
|
||||||
.butterfly-themeselect-dropdown .select2-results__option {
|
.butterfly-themeselect-dropdown .select2-results__option {
|
||||||
|
|
@ -598,17 +579,6 @@ class PluginButterflyConfig extends CommonDBTM {
|
||||||
|
|
||||||
// echo "</div>";
|
// echo "</div>";
|
||||||
|
|
||||||
echo Html::scriptBlock("$('#tabs$rand').tabs({
|
|
||||||
activate: function(event, ui) {
|
|
||||||
localStorage['butterfly_last_tab'] = $('#tabs$rand').tabs('option', 'active');
|
|
||||||
var editor = ui.newPanel.find('.butterfly-codemirror').data('CodeMirrorInstance');
|
|
||||||
if (editor) {
|
|
||||||
editor.refresh();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
active: localStorage['butterfly_last_tab']
|
|
||||||
});");
|
|
||||||
|
|
||||||
if ($canedit) {
|
if ($canedit) {
|
||||||
echo "<table class='tab_cadre_fixe'>";
|
echo "<table class='tab_cadre_fixe'>";
|
||||||
echo "<tr class='tab_bg_2'>";
|
echo "<tr class='tab_bg_2'>";
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
class PluginButterflyFileVersion {
|
|
||||||
|
|
||||||
private $_file = "";
|
|
||||||
private $_initialized = false;
|
|
||||||
|
|
||||||
public function __construct($file = "") {
|
|
||||||
$this->_file = $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __toString() {
|
|
||||||
// First call is inside of "file_exists", so it is necessary to return a valid file
|
|
||||||
if (!$this->_initialized) {
|
|
||||||
$this->_initialized = true;
|
|
||||||
return $this->_file;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Second call is inside concatenation
|
|
||||||
|
|
||||||
$timestamp = PluginButterflyToolbox::getTimestamp();
|
|
||||||
|
|
||||||
return $this->_file . "?_=" . $timestamp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -67,11 +67,11 @@ function plugin_init_butterfly()
|
||||||
|
|
||||||
$PLUGIN_HOOKS['display_login']['butterfly'] = "plugin_butterfly_display_login";
|
$PLUGIN_HOOKS['display_login']['butterfly'] = "plugin_butterfly_display_login";
|
||||||
|
|
||||||
// Tip Trick to add version in css output
|
// GLPI 11 appends ?v=<plugin files version> itself; the endpoints
|
||||||
$PLUGIN_HOOKS["add_css"]['butterfly'] = new PluginButterflyFileVersion('front/internal.css.php');
|
// handle config-change cache busting via their own timestamp redirect
|
||||||
$PLUGIN_HOOKS["add_javascript"]['butterfly'] = new PluginButterflyFileVersion('front/internal.js.php');
|
$PLUGIN_HOOKS["add_css"]['butterfly'] = 'front/internal.css.php';
|
||||||
|
$PLUGIN_HOOKS["add_javascript"]['butterfly'] = 'front/internal.js.php';
|
||||||
|
|
||||||
$CFG_GLPI['javascript']['config']['config'][] = 'codemirror';
|
|
||||||
$CFG_GLPI['javascript']['config']['config'][] = 'tinymce';
|
$CFG_GLPI['javascript']['config']['config'][] = 'tinymce';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue