mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
924 lines
25 KiB
Twig
924 lines
25 KiB
Twig
<form method="post" action="{{ path('admin_users_search') }}" target="_self" style="visibility:hidden; display:none" >
|
||
<input type="text" name="ord" value="" />
|
||
<input type="text" name="srt" value="" />
|
||
<input type="text" name="act" value="?" />
|
||
<input type="text" name="p0" value="" />
|
||
<input type="text" name="p1" value="" />
|
||
<input type="text" name="p2" value="5" />
|
||
<input type="text" name="p3" value="?" />
|
||
<input type="submit">
|
||
</form>
|
||
|
||
<div class="page-header">
|
||
<h1>{{ 'Suggested values' | trans }}</h1>
|
||
</div>
|
||
|
||
|
||
{% if app['request'].query.get('success') == '1' %}
|
||
<div class="alert alert-success">
|
||
<a class="close" data-dismiss="alert" href="#">×</a>
|
||
{{ 'Successful update' | trans }}
|
||
</div>
|
||
{% elseif app['request'].query.get('success') == '0' %}
|
||
<div class="alert alert-error">
|
||
<a class="close" data-dismiss="alert" href="#">×</a>
|
||
<strong>{{ 'An error occured' | trans }}</strong>
|
||
</div>
|
||
{% endif %}
|
||
|
||
<div id="iddivloading" style="border:#ff0000 3px solid;position:absolute; width:94%;height:80%; top:95px; left:10px;z-index:99;text-align:center">
|
||
<table style='width:100%;height:100%; text-align:center;vertical-align: middle; color:#FF0000; font-size:16px'>
|
||
<tr>
|
||
<td>
|
||
<div style='background-color:#FFFFFF'>
|
||
<b>{{ 'phraseanet::chargement' | trans }}</b>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<span id="spanref" style="position:absolute; bottom:0px; left:5px; background-color:#0f00cc; visibility:hidden">
|
||
</span>
|
||
|
||
<div id="divref" > </div>
|
||
|
||
<table id="presentUser" style="table-layout:fixed; width:100%;border:none;" border="0" cellpadding="0" cellspacing="0">
|
||
|
||
<tr style="height:30px; " >
|
||
<td style="height:30px; width:20px; font-size:12px; border:0px; background-position: left top;background-repeat: no-repeat">
|
||
|
||
</td>
|
||
|
||
<td style="text-align:center;height:30px;font-size:12px; border:0px;background-position: 0px 0px;background-repeat: repeat-x" nowrap>
|
||
{{ 'admin::sugval: Valeurs suggerees/Preferences de la collection' | trans }} {{ app['request'].attributes.get('bas_id')|bas_labels(app) }}
|
||
</td>
|
||
|
||
<td style="height:30px;width:20px;font-size:12px;border:0px; text-align:right">
|
||
|
||
</td>
|
||
|
||
</tr>
|
||
|
||
<tr style="background-color:#aaaaaa; border:#cccccc 1px solid;" >
|
||
<td colspan="3" style=" border:#aaaaaa 1px solid;padding-left:3px;text-align:right">
|
||
<a href="#" id="linkviewxml" onClick="view('XML');return(false);" class='btn btn-mini'>{{ 'boutton::vue xml' | trans }}</a>
|
||
<a href="#" id="linkviewgraph" onClick="view('GRAPH');return(false);" class='btn btn-mini' style="display:none">{{ 'boutton::vue graphique' | trans }}</a>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr style="background-color:#c9c9c9; border:#cccccc 1px solid;" >
|
||
<td colspan="3" style=" border:#c9c9c9 1px solid;padding-left:3px;text-align:center">
|
||
|
||
<div id="divGraph" style="background-color:#c9c9c9; border:none; width:100%; height:100%;overflow:hidden;" >
|
||
|
||
<table border="0" id="tabsgv" style="width:100%; background-color:#c9c9c9;">
|
||
<tr>
|
||
<td valign="top" style="text-align:center;">
|
||
{{ 'admin::sugval: champs' | trans }}
|
||
<select name=usrbases id="nomchamPH" onKeyUp="javascript:write_valsug();" onChange="javascript:savenomaff();makeRestrict();maketextaffich();makeEmpty();write_valsug();" onclick="javascript: makeRestrict();desactivall4VS(); write_valsug();" >
|
||
{% for field in databox.get_meta_structure() %}
|
||
{% if not field.is_readonly %}
|
||
<option value='{{ field.get_name() }}'> {{ field.get_label(app['locale.I18n']) }} </option>
|
||
{% endif %}
|
||
{% endfor %}
|
||
</select>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td valign="top" style="text-align:center;">
|
||
<div class="btn-group">
|
||
<input class='btn' type="submit" value="{{ 'admin::base:collorder: monter' | trans }}" disabled onclick="javascript:modifordre(true);" id="bout_mont" name="bout_mont">
|
||
<input class='btn' type="submit" value="{{ 'admin::base:collorder: descendre' | trans }}" disabled onclick="javascript:modifordre(false);" id="bout_desc" name="bout_desc">
|
||
<input class='btn' type="submit" value="{{ 'boutton::supprimer' | trans }}" disabled onclick="javascript:supprimer();" ondblclick="javascript:supprimer();" id="bout_supp" name="bout_supp">
|
||
<input class='btn' type="submit" value="{{ 'admin::base:collorder: reinitialiser en ordre alphabetique' | trans }}" onclick="javascript:trialph();" ondblclick="javascript:trialph();" id="bout_trialph" name="bout_trialph">
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
<tr>
|
||
<td valign="top">
|
||
<span id="valsug">
|
||
<select size="12" name=valsug2 id="valsug2" onFocus="activ4VS();" onClick="desactiver();activ4VS();" onChange="desactiv4VS();" style="width:100%;font-size:11px;height:380px;"></select>
|
||
</span>
|
||
</td>
|
||
|
||
</tr>
|
||
<tr id="trajout" style="height:50px">
|
||
<td valign="top" style="height:50px; border:none">
|
||
<table style="width:100%;">
|
||
<tr>
|
||
<td style="width:100%"><input type="text" id="valajout" onKeyUp="verifAndactiv();" onclick="desactivall4VS();" style="width:99%"></td>
|
||
<td style="width:100px" ><input class='btn' type="submit" value="{{ 'boutton::ajouter' | trans }}" disabled style="width:100px" onclick="javascript:ajouter();" id="bout_add" name="bout_add"></td>
|
||
</tr>
|
||
</table>
|
||
</td>
|
||
</tr>
|
||
</table>
|
||
</div>
|
||
|
||
<div id="divXml" style="display:none">
|
||
<textarea nowrap id="txtareaxml" onchange="chgXml();" style=" width:99%;height:380px;white-space:pre" >{{ collection.get_prefs() | raw }}</textarea>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr style="height:30px;" >
|
||
<td style="height:30px; width:20px; background-position: 0px 0px; background-repeat:no-repeat">
|
||
|
||
</td>
|
||
<td style="height:30px; background-position: 0px 0px; background-repeat: repeat-x; font-size:12px;text-align:center;">
|
||
<b><a class='btn' href="javascript:void();" onclick="valid();return(false);" id="genevalid" style="color:#000000; text-decoration:none">{{ 'boutton::valider' | trans }}</a></b>
|
||
</td>
|
||
<td style="height:30px;width:20px;font-size:12px; background-position:left ;">
|
||
</td>
|
||
</tr>
|
||
</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() | raw }}</textarea>
|
||
</form>
|
||
|
||
<script type="text/javascript">
|
||
|
||
var allgetID = new Array ;
|
||
var total = 0;
|
||
var statuscoll="";
|
||
var changeInXml = false ;
|
||
var avantModif="";
|
||
|
||
function chgXml()
|
||
{
|
||
inxml = $("#txtareaxml").val();
|
||
inxml2="";
|
||
for(i=0; i<inxml.length;i++)
|
||
{
|
||
if(inxml.charCodeAt(i)!=13)
|
||
inxml2+=inxml.substr(i,1);
|
||
|
||
}
|
||
|
||
if( avantModif!= inxml2 )
|
||
changeInXml = true ;
|
||
|
||
}
|
||
|
||
function tableScroll(theTable)
|
||
{
|
||
var TableId = theTable.id.replace("_center", "");
|
||
var tableTop = $("#"+TableId+"_top");
|
||
var tableLeft = $("#"+TableId+"_left");
|
||
|
||
$("#imgtopinclin").width("700px");
|
||
|
||
tableTop.scrollLeft(theTable.scrollLeft());
|
||
tableLeft.scrollTop(theTable.scrollTop());
|
||
}
|
||
|
||
/* Chargement de tt les elements dans un tableau pour un acces plus rapide */
|
||
function scandom(node, depth)
|
||
{
|
||
var n;
|
||
if(!node)
|
||
|
||
return;
|
||
|
||
if(node.id)
|
||
{
|
||
allgetID[node.id] = node;
|
||
//node.style.visibility = "hidden";
|
||
total++;
|
||
}
|
||
|
||
for(n=node.firstChild; n; n=n.nextSibling)
|
||
{
|
||
if(n.nodeType && n.nodeType == 1)
|
||
scandom(n, depth+1);
|
||
}
|
||
}
|
||
|
||
function scan()
|
||
{
|
||
if(document.all)
|
||
scandom(document.documentElement, 0);
|
||
else
|
||
{
|
||
allccuser = document.getElementsByName("ccuser");
|
||
for (var i=0; i<allccuser.length;i++)
|
||
{
|
||
allgetID[allccuser[i].id] = allccuser[i];
|
||
total++ ;
|
||
}
|
||
}
|
||
|
||
}
|
||
|
||
function view(typeDiv)
|
||
{
|
||
|
||
switch (typeDiv)
|
||
{
|
||
case "RIGHTS":
|
||
if( $("#divGraph").length > 0 )
|
||
{
|
||
$("#divGraph").show();
|
||
}
|
||
if( oo=returnElement("genecancel") )
|
||
oo.style.visibility = "visible" ;
|
||
if( oo=returnElement("genevalid") )
|
||
oo.style.visibility = "visible" ;
|
||
break;
|
||
}
|
||
}
|
||
|
||
var pass = false;
|
||
|
||
function redrawme()
|
||
{
|
||
wb = $("#divref").outerWidth(true);
|
||
|
||
if(wb<150) {
|
||
wb= 150;
|
||
}
|
||
|
||
$("#presentUser").width((wb-10)+"px");
|
||
|
||
/***************************************************/
|
||
if(document.all)
|
||
{
|
||
if (document.documentElement.clientHeight) { // no jquery equivalent for clientHeight
|
||
bodyH = document.documentElement.clientHeight - 5 ;
|
||
} else {
|
||
bodyH = document.body.clientHeight - 5 ;
|
||
}
|
||
|
||
scrollLeft = null;
|
||
|
||
if (document.documentElement.scrollLeft) {
|
||
scrollLeft = document.documentElement.scrollLeft;
|
||
} else {
|
||
scrollLeft = document.body.scrollLeft;
|
||
}
|
||
|
||
scrolltop = null;
|
||
|
||
if (document.documentElement.scrollTop)
|
||
{
|
||
scrolltop = document.documentElement.scrollTop;
|
||
document.documentElement.scrollTop = 0 ;
|
||
}
|
||
else
|
||
{
|
||
scrolltop = document.body.scrollTop;
|
||
document.body.scrollTop=0;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
bodyH = window.document.clientHeight;
|
||
|
||
if (!bodyH) {
|
||
if (document.documentElement.clientHeight) {
|
||
bodyH = document.documentElement.clientHeight - 5 ;
|
||
}
|
||
} else {
|
||
bodyH = document.body.clientHeight - 5 ;
|
||
}
|
||
|
||
scrollLeft = null;
|
||
|
||
if (document.documentElement.scrollLeft) {
|
||
scrollLeft = document.documentElement.scrollLeft;
|
||
} else {
|
||
scrollLeft = document.body.scrollLeft;
|
||
}
|
||
|
||
scrolltop = null;
|
||
|
||
if (document.documentElement.scrollTop) {
|
||
scrolltop = document.documentElement.scrollTop;
|
||
document.documentElement.scrollTop = 0;
|
||
} else {
|
||
scrolltop = document.body.scrollTop;
|
||
document.body.scrollTop=0;
|
||
}
|
||
}
|
||
|
||
/***************************************************/
|
||
hauteur = $("#spanref").offset().top;
|
||
hauteur = bodyH-10;
|
||
|
||
if (hauteur<10)
|
||
{
|
||
hauteur = document.getElementById("spanref").clientHeight;
|
||
}
|
||
|
||
if (hauteur<350) {
|
||
hauteur= 350;
|
||
}
|
||
|
||
$("#divGraph").height((hauteur-160)+"px");
|
||
$("#tabsgv").height((hauteur-100)+"px");
|
||
$("#trajout").height("150px");
|
||
|
||
if ((hauteur-280) > 10) {
|
||
$("#valsug2").height((hauteur-280)+"px");
|
||
} else {
|
||
$("#valsug2").height("10px");
|
||
}
|
||
|
||
$("#txtareaxml").height((hauteur-160)+"px");
|
||
|
||
if (o = returnElement("iddivloading") )
|
||
{
|
||
o.style.width = (wb-18)+"px";
|
||
o.style.left = "10px";
|
||
o.style.top = "95px";
|
||
o.style.height = (hauteur-160)+"px";
|
||
}
|
||
}
|
||
|
||
|
||
function returnElement(unId)
|
||
{
|
||
if (! allgetID[unId] )
|
||
{
|
||
if ( document.getElementById(unId) )
|
||
{
|
||
allgetID[unId] = document.getElementById(unId);
|
||
}
|
||
}
|
||
|
||
return allgetID[unId];
|
||
}
|
||
|
||
var pref = new Array(0);
|
||
var lastpref=null;
|
||
|
||
function loaded()
|
||
{
|
||
self.focus();
|
||
write_valsug();
|
||
makeRestrict();
|
||
maketextaffich();
|
||
makeEmpty();
|
||
redrawme();
|
||
scan();
|
||
$("#iddivloading").hide();
|
||
}
|
||
|
||
function Roll(im, x)
|
||
{
|
||
var s=document[im].src;
|
||
var d=s.substr(0,s.length-5)
|
||
document[im].src = d + x + ".gif";
|
||
}
|
||
|
||
function valeursPref(nomaff,valsug)
|
||
{
|
||
this.nomaff = nomaff;
|
||
this.Type = "text";
|
||
this.content = "none" ;
|
||
this.empty = true;
|
||
this.valsug = new Array(0);
|
||
|
||
return(this);
|
||
}
|
||
|
||
function savenomaff()
|
||
{
|
||
o = $("#namAff");
|
||
|
||
if (o.length > 0 && lastpref!=null) {
|
||
pref[lastpref].nomaff = o.val();
|
||
}
|
||
}
|
||
// ecrit le select des valsug
|
||
function write_valsug()
|
||
{
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 )
|
||
{
|
||
o2 = $("#valsug");
|
||
|
||
if ( o2.length > 0 )
|
||
{
|
||
lastpref = o.val();
|
||
|
||
p = document.getElementById("valsug2");
|
||
|
||
p.options.length = 0;
|
||
|
||
for (i=0; i<pref[o.val()].valsug.length; i++)
|
||
{
|
||
if (pref[o.val()].valsug[i]) {
|
||
x = p.options[p.options.length] = new Option((pref[o.val()].valsug[i]), pref[o.val()].valsug[i]);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
function desactivall4VS()
|
||
{
|
||
activer_bout('bout_supp',true);
|
||
activer_bout('bout_mont',true);
|
||
activer_bout('bout_desc',true);
|
||
|
||
o2 = $("#valsug2");
|
||
|
||
if( o2.length > 0 ) {
|
||
o2.prop("selectedIndex",-1);
|
||
}
|
||
}
|
||
|
||
|
||
function desactiv4VS()
|
||
{
|
||
o2 = $("#valsug2");
|
||
|
||
if( o2.length > 0 )
|
||
{
|
||
var optionLength = o2.find("options").length;
|
||
if ( optionLength > 1) {
|
||
|
||
if ((o2.prop("selectedIndex")+1) != optionLength) {
|
||
activer_bout('bout_desc',false);
|
||
} else {
|
||
activer_bout('bout_desc',true);
|
||
}
|
||
|
||
if (o2.prop("selectedIndex")!=0 && optionLength>1) {
|
||
activer_bout('bout_mont',false);
|
||
} else {
|
||
activer_bout('bout_mont',true);
|
||
}
|
||
} else {
|
||
activer_bout('bout_desc',true);
|
||
activer_bout('bout_mont',true);
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
function activ4VS()
|
||
{
|
||
o2 = $("#valsug2");
|
||
|
||
if( o2.length > 0 ) {
|
||
|
||
if(o2.prop("selectedIndex") ==-1)
|
||
|
||
return;
|
||
}
|
||
|
||
desactiv4VS();
|
||
activer_bout('bout_supp',false);
|
||
}
|
||
|
||
// supprime une valsug
|
||
function supprimer()
|
||
{
|
||
|
||
lastIdx = null;
|
||
o2 = $("#valsug2");
|
||
|
||
if( o2.length > 0 )
|
||
{
|
||
var o = $("#nomchamPH");
|
||
var ancienfocus = o2.prop("selectedIndex");
|
||
// pref[o.value].valsug.splice(o2.selectedIndex,1);
|
||
var bb =0;
|
||
lastIdx = (pref[o.val()].valsug.length)-1;
|
||
for ( aa in pref[o.val()].valsug)
|
||
{
|
||
if(aa != o2.prop("selectedIndex")) {
|
||
pref[o.val()].valsug[bb]=pref[o.val()].valsug[aa];
|
||
if(aa+1 == pref[o.val()].valsug.length) {
|
||
pref[o.val()].valsug[bb]=null;
|
||
}
|
||
bb++;
|
||
}
|
||
}
|
||
|
||
pref[o.val()].valsug[bb]="";
|
||
|
||
if (lastIdx!=null && lastIdx>=0) {
|
||
delete(pref[o.val()].valsug[lastIdx]);
|
||
pref[o.val()].valsug.length--;
|
||
}
|
||
|
||
|
||
write_valsug();
|
||
o2 = $("#valsug2");
|
||
|
||
var i = o2.find("options").length ; // au depart i=1 et ancienfocus=1
|
||
o2.prop("selectedIndex",-1);
|
||
|
||
while( i>-1 )
|
||
{
|
||
if (o2.find("options").length>= ancienfocus+1) {
|
||
o2.prop("selectedIndex",ancienfocus);
|
||
i==0;
|
||
} else {
|
||
ancienfocus--;
|
||
}
|
||
|
||
i--;
|
||
}
|
||
|
||
if(o2.prop("selectedIndex")<0) {
|
||
activer_bout('bout_supp',true);
|
||
}
|
||
|
||
desactiv4VS();
|
||
}
|
||
}
|
||
|
||
// ajoute une valsug
|
||
function ajouter()
|
||
{
|
||
o2 = $("#valajout");
|
||
var test = false;
|
||
|
||
for (var k=0; k<o2.val().length; k++) {
|
||
if(o2.val().charAt(k)!=" ") {
|
||
test=true;
|
||
}
|
||
}
|
||
|
||
if(!test) {
|
||
o2.val("");
|
||
verifAndactiv();
|
||
o2.focus();
|
||
} else {
|
||
if(o2.val()!="" && o2.val()!=null) {
|
||
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]= (o2.val());
|
||
o2.val("");
|
||
}
|
||
|
||
write_valsug();
|
||
|
||
o2 = $("#valsug2");
|
||
if( test && o2.length > 0) {
|
||
o2.prop("selectedIndex", o2.find("options").length-1);
|
||
activer_bout('bout_add',true);
|
||
activ4VS();
|
||
desactiv4VS();
|
||
}
|
||
}
|
||
}
|
||
|
||
function UtEncode(expr)
|
||
{
|
||
var expretour = "";
|
||
|
||
for (i=0; i<expr.length; i++) {
|
||
|
||
if( (expr.charCodeAt(i) >= 65 && expr.charCodeAt(i) <=90) || (expr.charCodeAt(i) >= 97 && expr.charCodeAt(i) <=122) ) {
|
||
expretour += expr.substring(i,i+1);
|
||
} else {
|
||
expretour += "&#" + expr.charCodeAt(i)+";";
|
||
}
|
||
}
|
||
|
||
return (expretour);
|
||
}
|
||
|
||
function verifAndactiv()
|
||
{
|
||
o = $("#valajout");
|
||
if ( o.length > 0 ) {
|
||
if(o.val().length>0) {
|
||
activer_bout('bout_add',false);
|
||
} else {
|
||
activer_bout('bout_add',true);
|
||
}
|
||
}
|
||
}
|
||
|
||
function desactiver()
|
||
{
|
||
o = $("#valajout");
|
||
// desactivation du bouton ajouter
|
||
if( o.length > 0) {
|
||
o.val("");
|
||
activer_bout("bout_add",true);
|
||
}
|
||
}
|
||
|
||
function valid()
|
||
{
|
||
savenomaff();
|
||
var lexmlstruct = '';
|
||
|
||
if($('#divGraph').length > 0 && $('#divGraph').is(':visible')) {
|
||
lexmlstruct = getSruct();
|
||
} else if( $('#divXml').length >0 && $('#divXml').is(':visible') ) {
|
||
lexmlstruct = $('#txtareaxml').val();
|
||
}
|
||
|
||
if($("#idstr").length > 0) {
|
||
$("#idstr").val(lexmlstruct);
|
||
|
||
var form = $("form[name=chgStructure]");
|
||
|
||
$.ajax({
|
||
dataType:'json',
|
||
type: form.attr('method'),
|
||
url: form.attr('action'),
|
||
data: form.serializeArray(),
|
||
success: function(data) {
|
||
if(data.success) {
|
||
$('#tree li.selected a').trigger('click');
|
||
} else {
|
||
$(".page-header").after(
|
||
'<div class="alert alert-error">'
|
||
+'<button class="close" data-dismiss="alert">×</button>'
|
||
+ data.msg
|
||
+ '</div>');
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
function modifordre(bool)
|
||
{
|
||
o2 = $("#valsug2");
|
||
//bool : true pour monter -- false pour descendre
|
||
if(o2.length > 0) {
|
||
o = $("#nomchamPH");
|
||
if ( o.length > 0) {
|
||
var ancienind = o2.prop('selectedIndex');
|
||
var tmp = pref[o.val()].valsug[o2.prop('selectedIndex')];
|
||
|
||
if (bool) {
|
||
pref[o.val()].valsug[o2.prop('selectedIndex')] = pref[o.val()].valsug[o2.prop('selectedIndex')-1] ;
|
||
pref[o.val()].valsug[o2.prop('selectedIndex')-1] = tmp ;
|
||
ancienind--;
|
||
} else {
|
||
pref[o.val()].valsug[o2.prop('selectedIndex')] = pref[o.val()].valsug[o2.prop('selectedIndex')+1] ;
|
||
pref[o.val()].valsug[o2.prop('selectedIndex')+1] = tmp ;
|
||
ancienind++;
|
||
}
|
||
|
||
write_valsug();
|
||
o2 = $("#valsug2");
|
||
o2.prop('selectedIndex', ancienind);
|
||
desactiv4VS();
|
||
}
|
||
}
|
||
}
|
||
|
||
function trialph()
|
||
{
|
||
o2 = $("#valsug2");
|
||
|
||
if(o2.length > 0) {
|
||
o = $("#nomchamPH");
|
||
if ( o.length > 0 ) {
|
||
pref[o.val()].valsug.sort();
|
||
write_valsug();
|
||
desactiv4VS();
|
||
desactivall4VS()
|
||
}
|
||
}
|
||
}
|
||
|
||
function maketextaffich()
|
||
{
|
||
return false;
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 ) {
|
||
var tmp = "idtext";
|
||
|
||
if(pref[o.val()].Type != null ) {
|
||
tmp = "id" + pref[o.val()].Type;
|
||
}
|
||
|
||
o3 = $("#"+tmp);
|
||
|
||
if ( o3.length > 0 ) {
|
||
o3.attr("checked", true);
|
||
}
|
||
}
|
||
}
|
||
|
||
function makeRestrict()
|
||
{
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 ) {
|
||
var tmp = "none";
|
||
|
||
if(pref[o.val()].content != null ) {
|
||
tmp = pref[o.val()].content;
|
||
}
|
||
|
||
o3 = $("#"+tmp);
|
||
|
||
if ( o3.length > 0 ) {
|
||
o3.attr("checked", true);
|
||
}
|
||
}
|
||
}
|
||
|
||
function makeEmpty()
|
||
{
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 ) {
|
||
var tmp = "empty";
|
||
if(!pref[o.val()].empty) {
|
||
tmp = "no"+tmp;
|
||
}
|
||
|
||
o3 = $("#"+tmp);
|
||
|
||
if ( o3.length > 0 ) {
|
||
o3.attr("checked", true);
|
||
}
|
||
}
|
||
}
|
||
|
||
function chgEmpty(bool)
|
||
{
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 ) {
|
||
pref[o.val()].empty = bool;
|
||
}
|
||
}
|
||
|
||
function chgType(type)
|
||
{
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 ) {
|
||
pref[o.val()].Type = type;
|
||
}
|
||
}
|
||
|
||
function chgrestrict(nomRestrict)
|
||
{
|
||
o = $("#nomchamPH");
|
||
|
||
if ( o.length > 0 ) {
|
||
pref[o.val()].content=nomRestrict;
|
||
}
|
||
}
|
||
|
||
function activer_bout(idBout,val)
|
||
{
|
||
o = $("#"+idBout);
|
||
|
||
if( o.length > 0 ) {
|
||
o.attr("disabled", val);
|
||
}
|
||
}
|
||
|
||
otherFields = "";
|
||
|
||
|
||
{% for name, meta in structFields %}
|
||
pref["{{ name }}"] = new valeursPref("{{ name }}");
|
||
pref["{{ name }}"].nomaff = "{{ name }}>";
|
||
pref["{{ name }}"].Type = "text";
|
||
pref["{{ name }}"].content = "none";
|
||
pref["{{ name }}"].empty = true;
|
||
{% endfor %}
|
||
|
||
|
||
{% for value in suggestedValues %}
|
||
pref["{{ value['key']|escapeDoubleQuote|raw }}"].valsug["{{ value['value']|escapeDoubleQuote|raw }}"] = ('{{ value['name']|escapeSimpleQuote|raw }}');
|
||
{% endfor %}
|
||
|
||
|
||
{% for pref in basePrefs %}
|
||
{% if pref['status'] is not none %}
|
||
statuscoll = "<status>{{ pref['status'] }}</status>";
|
||
{% elseif pref['xml'] is not none %}
|
||
otherFields += "{{ pref['xml'] | e('js') }}";
|
||
{% endif%}
|
||
{% endfor %}
|
||
|
||
function getSruct()
|
||
{
|
||
var dom = document.implementation.createDocument(null, 'baseprefs');
|
||
var values = dom.createElement('sugestedValues');
|
||
|
||
for (a in pref ) {
|
||
var section = dom.createElement(a);
|
||
var go = false;
|
||
for (b in pref[a].valsug ) {
|
||
if(pref[a].valsug[b]!="") {
|
||
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;
|
||
}
|
||
|
||
var padding = '';
|
||
for (var i = 0; i < pad; i++) {
|
||
padding += ' ';
|
||
}
|
||
|
||
formatted += padding + node + '\r\n';
|
||
pad += indent;
|
||
});
|
||
|
||
return formatted;
|
||
}
|
||
|
||
function view(type)
|
||
{
|
||
switch(type)
|
||
{
|
||
case 'XML':
|
||
if($('#divGraph').length > 0 )
|
||
$('#divGraph').hide();
|
||
|
||
if($('#divXml').length > 0 )
|
||
$('#divXml').show();
|
||
|
||
if($('#linkviewgraph').length >0 )
|
||
$('#linkviewgraph').show();
|
||
|
||
if( $('#linkviewxml'))
|
||
$('#linkviewxml').hide();
|
||
|
||
newStr=getSruct();
|
||
|
||
console.log(newStr);
|
||
if($('#txtareaxml').length > 0 && newStr!=null )
|
||
{
|
||
avantModif = newStr;
|
||
$('#txtareaxml').val(newStr);
|
||
}
|
||
|
||
|
||
break;
|
||
case 'GRAPH':
|
||
if( !changeInXml || confirm("{{ 'admin::sugval: Attention, passer en mode graphique implique la perte des modifications du xml si vous n\'appliquez pas les changements avant.\nContinuer quand meme'|trans | e('js') }}"))
|
||
{
|
||
if($('#divGraph').length > 0 )
|
||
$('#divGraph').show();
|
||
|
||
if($('#divXml').length > 0 )
|
||
$('#divXml').hide();
|
||
|
||
if($('#linkviewgraph').length > 0 )
|
||
$('#linkviewgraph').hide();
|
||
if($('#linkviewxml').length >0 )
|
||
$('#linkviewxml').show();
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
|
||
$(document).ready(function(){
|
||
scan();
|
||
$("#iddivloading").hide();
|
||
});
|
||
|
||
</script>
|