-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.php
129 lines (116 loc) · 5.58 KB
/
config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php if(!defined('PLX_ROOT')) exit; ?>
<?php
# Control du token du formulaire
plxToken::validateFormToken($_POST);
# Liste des langues disponibles et prises en charge par le plugin
$aLangs = array($plxAdmin->aConf['default_lang']);
if(!empty($_POST)) {
$plxPlugin->setParam('format', $_POST['format'], 'cdata');
$plxPlugin->setParam('format_group', $_POST['format_group'], 'cdata');
$plxPlugin->setParam('breadcrumbs', $_POST['breadcrumbs'], 'numeric');
$plxPlugin->setParam('interlink', $_POST['interlink'], 'numeric');
$plxPlugin->setParam('sisters', $_POST['sisters'], 'numeric');
$expert_array=array();
foreach($_POST['expertNum'] as $expert_num) {
$key_name= 'pregkey-'.$expert_num;
if($_POST[$key_name] !='') {
$expert_array[$_POST[$key_name]]=$_POST['pregval-'.$expert_num];
}
}
if(count($expert_array)>0) $plxPlugin->setParam('expert', json_encode($expert_array), 'cdata');
else $plxPlugin->setParam('expert', '', 'cdata');
$plxPlugin->saveParams();
header('Location: parametres_plugin.php?p='.basename(__DIR__));
exit;
}
$var = array();
# initialisation des variables propres à chaque lanque
$langs = array();
# initialisation des variables communes à chaque langue
$var['format'] = $plxPlugin->getParam('format')=='' ? '<li class="#static_class #static_status" id="#static_id"><a href="#static_url" title="#static_name">#static_name</a></li>' : $plxPlugin->getParam('format');
$var['format_group'] = $plxPlugin->getParam('format_group')=='' ? '<span class="#group_class #group_status">#group_name</span>' : $plxPlugin->getParam('format_group');
$var['breadcrumbs'] = $plxPlugin->getParam('breadcrumbs')=='' ? 0 : $plxPlugin->getParam('breadcrumbs');
$var['interlink'] = $plxPlugin->getParam('interlink')=='' ? 0 : $plxPlugin->getParam('interlink');
$var['expert'] = $plxPlugin->getParam('expert')==$plxPlugin->defaultExpert ? '' : $plxPlugin->getParam('expert');
$var['sisters'] = $plxPlugin->getParam('sisters')=='' ? 0 : $plxPlugin->getParam('sisters');
# fermeture du wizard
if (isset($_SESSION['justactivated'.basename(__DIR__)])) {unset($_SESSION['justactivated'.basename(__DIR__)]);}
# affichage du wizard à la demande
if(isset($_GET['wizard'])) {$_SESSION['justactivated'.basename(__DIR__)] = true;}
?>
<style>
textarea {vertical-align:top;}
</style>
<p><a href="parametres_plugin.php?p=<?= basename(__DIR__) ?>&wizard" class="aWizard"><img src="<?= PLX_PLUGINS.basename(__DIR__)?>/img/icon.png" style="height:2em;vertical-align:middle"> Wizard</a></p>
<p class="alert blue"><?php echo $plxPlugin->lang('L_HELP') ?> <a href="https://wiki.pluxml.org/docs/develop/plxshow.html#staticlist">DOC staticList()</a>.</p>
<form class="inline-form" id="form_<?= basename(__DIR__) ?>" name="form_<?= basename(__DIR__) ?>" action="parametres_plugin.php?p=<?= basename(__DIR__) ?>" method="post">
<fieldset>
<legend>Format</legend>
<p>
<label for="format_group"><?php echo $plxPlugin->lang('L_FORMAT_GROUP') ?> :</label>
<textarea id="format_group" name="format_group" cols="100" rows="1" ><?= $var['format_group']?></textarea>
</p>
<p>
<label for="format"><?php $plxPlugin->lang('L_FORMAT') ?> :</label>
<textarea id="format" name="format" cols="100" rows="1" ><?= $var['format']?></textarea>
</p>
</fieldset>
<fieldset>
<legend><?php $plxPlugin->lang('L_STAT_NAVS') ?></legend>
<p>
<label for="breadcrumbs" ><?php $plxPlugin->lang('L_SHOW_BREADCRUMBS') ?> :</label>
<?php plxUtils::printSelect('breadcrumbs',array('1'=>L_YES,'0'=>L_NO),$var['breadcrumbs']); ?>
</p>
<p>
<label for="interlink" ><?php $plxPlugin->lang('L_SHOW_INTERLINK') ?> :</label>
<?php plxUtils::printSelect('interlink',array('1'=>L_YES,'0'=>L_NO),$var['interlink']); ?>
</p>
<p>
<label for="sisters" ><?php $plxPlugin->lang('L_SHOW_LEVEL') ?> :</label>
<?php plxUtils::printSelect('sisters',array('1'=>L_YES,'0'=>L_NO),$var['sisters']); ?>
</p>
</fieldset>
<hr class="alert warning">
<fieldset>
<legend class="alert red"><?php $plxPlugin->lang('L_CONFIG_EXPERT') ?></legend>
<table data-rows-num='name$="_ordre"' id="pregR">
<thead>
<tr>
<th>rechercher</th><td>=></td><th>Remplacer par</th>
</tr>
</thead>
<tbody>
<?php
$i=0;
foreach($plxPlugin->defaultExpert as $k => $v) {
$i++;
echo "<tr>
<td><input type='hidden' name='expertNum[]' value='$i'><input id='pregkey-$i' name='pregkey-$i' value='$k' type='text' class='reset' ></td>
<td>=></td>
<td><input id='pregval-$i' name='pregval-$i' value='$v' type='text' class='reset' ></td>
</tr>".PHP_EOL;
}
?>
</tbody>
<tfoot>
<tr>
<td><input type='hidden' name='expertNum[]' value='<?= $i + 1 ?>'><input id='pregkey-<?= $i + 1 ?>' name='pregkey-<?= $i + 1 ?>' placeholder='Rechercher'></td><td>=></td><td><input id='pregval-<?= $i + 1 ?>' name='pregval-<?= $i + 1 ?>' placeholder='Remplacer par'></td>
</tr>
</tfoot>
</table>
<span class="btn-reset" tabindex="-1" onclick="restoreToDefault()">réinitialiser</span>
</fieldset>
<p class="in-action-bar">
<?php echo plxToken::getTokenPostMethod() ?>
<input type="submit" name="btnsubmit" value="<?php $plxPlugin->lang('L_SAVE') ?>" />
</p>
</form>
<script>
function restoreToDefault() {
let iptreset =document.querySelectorAll('input.reset');
for (let i = 0; i < iptreset.length; i++) {
iptreset[i].value='';
}
document.getElementById("form_<?= basename(__DIR__) ?>").submit();
}
</script>