mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-24 02:13:15 +00:00
Fix suggested values editing
This commit is contained in:
@@ -604,6 +604,14 @@ class Application extends SilexApplication
|
|||||||
$twig->addFilter('formatOctets', new \Twig_Filter_Function('p4string::format_octets'));
|
$twig->addFilter('formatOctets', new \Twig_Filter_Function('p4string::format_octets'));
|
||||||
$twig->addFilter('base_from_coll', new \Twig_Filter_Function('phrasea::baseFromColl'));
|
$twig->addFilter('base_from_coll', new \Twig_Filter_Function('phrasea::baseFromColl'));
|
||||||
$twig->addFilter('AppName', new \Twig_Filter_Function('Alchemy\Phrasea\Controller\Admin\ConnectedUsers::appName'));
|
$twig->addFilter('AppName', new \Twig_Filter_Function('Alchemy\Phrasea\Controller\Admin\ConnectedUsers::appName'));
|
||||||
|
$twig->addFilter(new \Twig_SimpleFilter('escapeSimpleQuote', function ($value) {
|
||||||
|
$ret = str_replace("'", "\'", $value);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}));
|
||||||
|
$twig->addFilter(new \Twig_SimpleFilter('escapeDoubleQuote', function ($value) {
|
||||||
|
return str_replace('"', '\"', $value);
|
||||||
|
}));
|
||||||
|
|
||||||
return $twig;
|
return $twig;
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1163,7 +1163,7 @@ class Collection implements ControllerProviderInterface
|
|||||||
if ($vi && isset($structFields[$ki])) {
|
if ($vi && isset($structFields[$ki])) {
|
||||||
foreach ($vi->value as $oneValue) {
|
foreach ($vi->value as $oneValue) {
|
||||||
$suggestedValues[] = array(
|
$suggestedValues[] = array(
|
||||||
'key' => $ki, 'value' => $f, 'name' => $oneValue
|
'key' => $ki, 'value' => $f, 'name' => (string) $oneValue
|
||||||
);
|
);
|
||||||
$f++;
|
$f++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,7 +117,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="divXml" style="display:none">
|
<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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -135,7 +135,7 @@
|
|||||||
</table>
|
</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;">
|
<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>
|
</form>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@@ -174,26 +174,6 @@
|
|||||||
tableLeft.scrollTop(theTable.scrollTop());
|
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 */
|
/* Chargement de tt les elements dans un tableau pour un acces plus rapide */
|
||||||
function scandom(node, depth)
|
function scandom(node, depth)
|
||||||
{
|
{
|
||||||
@@ -432,7 +412,7 @@ function write_valsug()
|
|||||||
for (i=0; i<pref[o.val()].valsug.length; i++)
|
for (i=0; i<pref[o.val()].valsug.length; i++)
|
||||||
{
|
{
|
||||||
if (pref[o.val()].valsug[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");
|
o = $("#nomchamPH");
|
||||||
// pref[o.value].valsug.push( UtEncode(o2.value) );
|
// pref[o.value].valsug.push( UtEncode(o2.value) );
|
||||||
// pref[o.value].valsug[pref[o.value].valsug.length]= 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("");
|
o2.val("");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,7 +795,7 @@ pref["{{ name }}"].empty = true;
|
|||||||
|
|
||||||
|
|
||||||
{% for value in suggestedValues %}
|
{% 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 %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
@@ -829,44 +809,64 @@ pref["{{ value['key'] }}"].valsug["{{ value['value'] }}"] = unescape('{{ value['
|
|||||||
|
|
||||||
function getSruct()
|
function getSruct()
|
||||||
{
|
{
|
||||||
var lexmlstruct = '<'+ '?xml version="1.0" encoding="UTF-8"?'+'>\n<baseprefs>\n';
|
var dom = document.implementation.createDocument(null, 'baseprefs');
|
||||||
lexmlstruct += "\t" + statuscoll+"\n";
|
var values = dom.createElement('sugestedValues');
|
||||||
|
|
||||||
if(otherFields!="") {
|
|
||||||
lexmlstruct += "\t" + otherFields+"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
lexmlstruct +='\t<sugestedValues>\n';
|
|
||||||
|
|
||||||
for (a in pref ) {
|
for (a in pref ) {
|
||||||
lexmlstruct2 = "";
|
var section = dom.createElement(a);
|
||||||
|
var go = false;
|
||||||
for (b in pref[a].valsug ) {
|
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]!="") {
|
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 (go) {
|
||||||
|
values.appendChild(section);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dom.getElementsByTagName('baseprefs')[0].appendChild(values);
|
||||||
|
|
||||||
|
var serializer = new XMLSerializer();
|
||||||
|
var xml = '<?xml version="1.0" encoding="UTF-8"?>' + serializer.serializeToString(dom);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if(lexmlstruct2 != "") {
|
var padding = '';
|
||||||
lexmlstruct += '\t\t<' + a + '>\n';
|
for (var i = 0; i < pad; i++) {
|
||||||
lexmlstruct += lexmlstruct2;
|
padding += ' ';
|
||||||
lexmlstruct += '\t\t</' + a + '>\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lexmlstruct += '\t</sugestedValues>\n';
|
formatted += padding + node + '\r\n';
|
||||||
lexmlstruct += '</baseprefs>';
|
pad += indent;
|
||||||
|
});
|
||||||
|
|
||||||
return(lexmlstruct);
|
return formatted;
|
||||||
}
|
}
|
||||||
|
|
||||||
function view(type)
|
function view(type)
|
||||||
|
|||||||
Reference in New Issue
Block a user