Изменения документа LDAP Admin sheet

Редактировал(а) Dmitriy Rybakov 04.10.2024, 00:20

От версии 2.1
отредактировано superadmin
на 04.10.2024, 00:09
Изменить комментарий: Migrated property [scope] from class [XWiki.ConfigurableClass]
К версии 3.1
отредактировано Dmitriy Rybakov
на 04.10.2024, 00:20
Изменить комментарий: Install extension [org.xwiki.contrib.ldap:ldap-ui/9.15.5]

Сводка

Подробности

Свойства страницы
Автор документа
... ... @@ -1,1 +1,1 @@
1 -XWiki.superadmin
1 +XWiki.rybakovds
XWiki.ConfigurableClass[0]
configureGlobally
... ... @@ -1,0 +1,1 @@
1 +1
XWiki.JavaScriptExtension[0]
Код
... ... @@ -11,6 +11,7 @@
11 11   options: {
12 12   separator: ","
13 13   , mapsToString: " \u2192 "
14 + , escapeChar: '\\'
14 14   , newEntryMessage: "New entry"
15 15   },
16 16  
... ... @@ -21,6 +21,8 @@
21 21   initialize:function(input, options) {
22 22   this.input = $(input);
23 23   this.options = Object.extend(Object.clone(this.options), options || {});
25 + this.options.newEntryMessage = this.input.getAttribute("data-add-entry-text") || this.options.newEntryMessage;
26 + this.options.escapeChar = this.input.getAttribute("data-escape-character") || this.options.escapeChar;
24 24  
25 25   (this.input.up("dd") || this.input).addClassName("hidden");
26 26   this.inputContainer = (this.input.up("dd") || this.input).up();
... ... @@ -52,17 +52,42 @@
52 52   * Initializes a collection of existing properties based on the original input value, and displays them as a pair of two input elements.
53 53   */
54 54   initializeAndDisplayExistingProperties: function() {
55 - var props = this.value == "" ? [] : this.value.split(this.options.separator);
56 - for (var i=0;i<props.length;i++) {
57 - var key = props[i].substring(0, props[i].indexOf("=")),
58 - value = props[i].substring(props[i].indexOf("=") + 1) || "";
59 - this.properties.push( [key, value] );
58 + var propStr = this.value
59 + var props = []
60 + var escaped = false
61 + var currentProp = ''
62 + for (var i=0;i<propStr.length;i++) {
63 + var c = propStr[i]
64 + if (escaped) {
65 + currentProp += c
66 + escaped = false
67 + } else {
68 + if (c == this.options.escapeChar) {
69 + escaped = true
70 + } else if (c == this.options.separator) {
71 + this._addProp(currentProp)
72 + currentProp = ''
73 + } else {
74 + currentProp += c
75 + }
76 + }
60 60   }
78 + if (currentProp.length > 0) {
79 + this._addProp(currentProp)
80 + }
81 +
61 61   for (var i=this.properties.length-1;i>=0;i--) {
62 62   (this.input.up("dd") || this.input).insert({'after': this.createPropertyEntry(this.properties[i][0], this.properties[i][1]) });
63 63   }
64 64   },
65 65  
87 + _addProp: function(prop) {
88 + // note: we do not handle escaped '=' in keys; currently there should be no need for this
89 + var key = prop.substring(0, prop.indexOf("=")),
90 + value = prop.substring(prop.indexOf("=") + 1) || "";
91 + this.properties.push( [key, value] );
92 + },
93 +
66 66   /**
67 67   * Creates and returns the DOM fragment for an property entry for this widget
68 68   */
... ... @@ -117,11 +117,24 @@
117 117   * Computes the new value for the original underlaying input element (textarea or input text), and updates its value with the result.
118 118   */
119 119   updateValue: function() {
148 + var that = this
120 120   var value = this.inputContainer.select("." + this.id + " .key[value!='']").collect(function(key){
121 121   if (key.value == key.defaultValue) {
122 122   return ""
123 123   }
124 124   return key.value + "=" + key.next("input").value;
154 + }).filter(function(value) {
155 + return value != '' && value != '=';
156 + }).map(function(value) {
157 + var escapedValue = ''
158 + for (var i=0;i<value.length;i++) {
159 + var c = value[i]
160 + if (c == that.options.separator || c == that.options.escapeChar) {
161 + escapedValue += that.options.escapeChar
162 + }
163 + escapedValue += c
164 + }
165 + return escapedValue
125 125   }).join(this.options.separator);
126 126  
127 127   if (this.input.tagName.toLowerCase() === "textarea") {
XWiki.JavaScriptExtension[1]
Код
... ... @@ -4,11 +4,14 @@
4 4  
5 5   groupMapping.setAttribute("data-key-tip", "${escapetool.javascript($services.localization.render('ldap.xwikiGroupTip'))}")
6 6   groupMapping.setAttribute("data-value-tip", "${escapetool.javascript($services.localization.render('ldap.ldapGroupTip'))}")
7 + groupMapping.setAttribute("data-add-entry-text", "$!{escapetool.javascript($services.localization.render('ldap.addNewEntry'))}")
7 7   groupMapping.setAttribute("data-separator", "|")
9 + groupMapping.setAttribute("data-escape-character", "\\")
8 8   groupMapping.addClassName("properties-editor");
9 9  
10 10   fieldMapping.setAttribute("data-key-tip", "${escapetool.javascript($services.localization.render('ldap.xwikiUserField'))}")
11 11   fieldMapping.setAttribute("data-value-tip", "${escapetool.javascript($services.localization.render('ldap.ldapUserField'))}")
14 + fieldMapping.setAttribute("data-add-entry-text", "$!{escapetool.javascript($services.localization.render('ldap.addNewEntry'))}")
12 12   fieldMapping.addClassName("properties-editor");
13 13  
14 14  });
XWiki.StyleSheetExtension[0]
Content Type
... ... @@ -1,0 +1,1 @@
1 +CSS