mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Fix suggested values editing
This commit is contained in:
@@ -117,7 +117,7 @@
|
||||
</div>
|
||||
|
||||
<div id="divXml" style="display:none">
|
||||
<textarea nowrap id="txtareaxml" onchange="chgXml();" style=" width:99%;height:380px;white-space:pre" >{{ collection.get_prefs() }}</textarea>
|
||||
<textarea nowrap id="txtareaxml" onchange="chgXml();" style=" width:99%;height:380px;white-space:pre" >{{ collection.get_prefs() | raw }}</textarea>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -135,7 +135,7 @@
|
||||
</table>
|
||||
|
||||
<form method="post" name="chgStructure" action="{{ path('admin_collection_display_suggested_values', { 'bas_id' : app['request'].attributes.get('bas_id') }) }}" onsubmit="return(false);" target="right" style="visibility:hidden;">
|
||||
<textarea nowrap style="visibility:hidden;white-space:pre" name="str" id="idstr">{{ collection.get_prefs() }}</textarea>
|
||||
<textarea nowrap style="visibility:hidden;white-space:pre" name="str" id="idstr">{{ collection.get_prefs() | raw }}</textarea>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
@@ -174,26 +174,6 @@
|
||||
tableLeft.scrollTop(theTable.scrollTop());
|
||||
}
|
||||
|
||||
/*function addEvent(obj, evType, fn, useCapture)
|
||||
{
|
||||
if (obj.addEventListener)
|
||||
{
|
||||
obj.addEventListener(evType, fn, useCapture);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (obj.attachEvent) {
|
||||
var r = obj.attachEvent("on"+evType, fn);
|
||||
|
||||
return r;
|
||||
} else {
|
||||
alert("Handler could not be attached");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
/* Chargement de tt les elements dans un tableau pour un acces plus rapide */
|
||||
function scandom(node, depth)
|
||||
{
|
||||
@@ -432,7 +412,7 @@ function write_valsug()
|
||||
for (i=0; i<pref[o.val()].valsug.length; i++)
|
||||
{
|
||||
if (pref[o.val()].valsug[i]) {
|
||||
x = p.options[p.options.length] = new Option(unescape(pref[o.val()].valsug[i]), pref[o.val()].valsug[i]);
|
||||
x = p.options[p.options.length] = new Option((pref[o.val()].valsug[i]), pref[o.val()].valsug[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -576,7 +556,7 @@ function ajouter()
|
||||
o = $("#nomchamPH");
|
||||
// pref[o.value].valsug.push( UtEncode(o2.value) );
|
||||
// pref[o.value].valsug[pref[o.value].valsug.length]= UtEncode(o2.value);
|
||||
pref[o.val()].valsug[pref[o.val()].valsug.length]= escape(o2.val());
|
||||
pref[o.val()].valsug[pref[o.val()].valsug.length]= (o2.val());
|
||||
o2.val("");
|
||||
}
|
||||
|
||||
@@ -815,7 +795,7 @@ pref["{{ name }}"].empty = true;
|
||||
|
||||
|
||||
{% for value in suggestedValues %}
|
||||
pref["{{ value['key'] }}"].valsug["{{ value['value'] }}"] = unescape('{{ value['name'] }}');
|
||||
pref["{{ value['key']|escapeDoubleQuote|raw }}"].valsug["{{ value['value']|escapeDoubleQuote|raw }}"] = ('{{ value['name']|escapeSimpleQuote|raw }}');
|
||||
{% endfor %}
|
||||
|
||||
|
||||
@@ -829,44 +809,64 @@ pref["{{ value['key'] }}"].valsug["{{ value['value'] }}"] = unescape('{{ value['
|
||||
|
||||
function getSruct()
|
||||
{
|
||||
var lexmlstruct = '<'+ '?xml version="1.0" encoding="UTF-8"?'+'>\n<baseprefs>\n';
|
||||
lexmlstruct += "\t" + statuscoll+"\n";
|
||||
|
||||
if(otherFields!="") {
|
||||
lexmlstruct += "\t" + otherFields+"\n";
|
||||
}
|
||||
|
||||
lexmlstruct +='\t<sugestedValues>\n';
|
||||
var dom = document.implementation.createDocument(null, 'baseprefs');
|
||||
var values = dom.createElement('sugestedValues');
|
||||
|
||||
for (a in pref ) {
|
||||
lexmlstruct2 = "";
|
||||
|
||||
var section = dom.createElement(a);
|
||||
var go = false;
|
||||
for (b in pref[a].valsug ) {
|
||||
// rempl
|
||||
var reg=new RegExp("&", "g");
|
||||
var reg2=new RegExp("<", "g");
|
||||
var reg3=new RegExp(">", "g");
|
||||
|
||||
pref[a].valsug[b] = unescape(pref[a].valsug[b]).replace(reg,"&");
|
||||
pref[a].valsug[b] = pref[a].valsug[b].replace(reg2,"<");
|
||||
pref[a].valsug[b] = pref[a].valsug[b].replace(reg3,">");
|
||||
|
||||
if(pref[a].valsug[b]!="") {
|
||||
lexmlstruct2 += '\t\t\t<value>'+ unescape(pref[a].valsug[b]).replace(reg,"&") + '</value>\n';
|
||||
go = true;
|
||||
var value = dom.createElement('value');
|
||||
value.appendChild(dom.createTextNode(pref[a].valsug[b]));
|
||||
section.appendChild(value);
|
||||
}
|
||||
}
|
||||
|
||||
if(lexmlstruct2 != "") {
|
||||
lexmlstruct += '\t\t<' + a + '>\n';
|
||||
lexmlstruct += lexmlstruct2;
|
||||
lexmlstruct += '\t\t</' + a + '>\n';
|
||||
if (go) {
|
||||
values.appendChild(section);
|
||||
}
|
||||
}
|
||||
dom.getElementsByTagName('baseprefs')[0].appendChild(values);
|
||||
|
||||
lexmlstruct += '\t</sugestedValues>\n';
|
||||
lexmlstruct += '</baseprefs>';
|
||||
var serializer = new XMLSerializer();
|
||||
var xml = '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(dom);
|
||||
|
||||
return(lexmlstruct);
|
||||
xml.replace('<sugestedValues>', statuscoll + otherFields + '<sugestedValues>');
|
||||
|
||||
|
||||
return formatXml(xml);
|
||||
}
|
||||
|
||||
function formatXml(xml) {
|
||||
var formatted = '';
|
||||
var reg = /(>)(<)(\/*)/g;
|
||||
xml = xml.replace(reg, '$1\r\n$2$3');
|
||||
var pad = 0;
|
||||
jQuery.each(xml.split('\r\n'), function(index, node) {
|
||||
var indent = 0;
|
||||
if (node.match( /.+<\/\w[^>]*>$/ )) {
|
||||
indent = 0;
|
||||
} else if (node.match( /^<\/\w/ )) {
|
||||
if (pad != 0) {
|
||||
pad -= 1;
|
||||
}
|
||||
} else if (node.match( /^<\w[^>]*[^\/]>.*$/ )) {
|
||||
indent = 1;
|
||||
} else {
|
||||
indent = 0;
|
||||
}
|
||||
|
||||
var padding = '';
|
||||
for (var i = 0; i < pad; i++) {
|
||||
padding += ' ';
|
||||
}
|
||||
|
||||
formatted += padding + node + '\r\n';
|
||||
pad += indent;
|
||||
});
|
||||
|
||||
return formatted;
|
||||
}
|
||||
|
||||
function view(type)
|
||||
|
Reference in New Issue
Block a user