-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathvariable.php
executable file
·179 lines (169 loc) · 7.5 KB
/
variable.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<?php
require_once("pre.php");
require_once("auth.php");
require_once("../fonctions/divers.php");
if (!est_autorise("acces_configuration"))
exit;
$request = Symfony\Component\HttpFoundation\Request::createFromGlobals();
try
{
ActionsAdminVariable::getInstance()->action($request);
} catch(TheliaAdminException $e) {
$errorCode = $e->getCode();
switch ($errorCode)
{
case TheliaAdminException::VARIABLE_ADD_ERROR:
$addError = 1;
$errorData = $e->getData();
break;
}
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<?php require_once("title.php"); ?>
</head>
<body>
<?php
ActionsAdminModules::instance()->inclure_module_admin("variable_top");
$menu = "configuration";
$breadcrumbs = Breadcrumb::getInstance()->getConfigurationList(trad('Gestion_variables', 'admin'));
require_once("entete.php");
?>
<div class="row-fluid">
<div class="span12">
<h3><?php echo trad('LISTE_VARIABLES', 'admin'); ?>
<div class="btn-group">
<a class="btn btn-large" title="<?php echo trad('ajouter', 'admin'); ?>" href="#addVariableModal" data-toggle="modal">
<i class="icon-plus-sign icon-white"></i>
</a>
</div>
</h3>
<?php
ActionsAdminModules::instance()->inclure_module_admin("variable");
?>
<form method="POST" action="variable.php">
<input type="hidden" name="action" value="edit" />
<p>
<button class="btn btn-large btn-block btn-primary" type="submit"><?php echo trad('VALIDER_LES_MODIFICATIONS', 'admin'); ?></button>
</p>
<table class="table table-striped">
<thead>
<tr>
<th class="span3"><?php echo trad('Nom2', 'admin'); ?></th>
<th class="span7"><?php echo trad('Valeur', 'admin'); ?></th>
<th class="span2"></th>
</tr>
</thead>
<tbody>
<?php foreach(VariableAdmin::getInstance()->getList() as $variable){ ?>
<tr>
<td><?php echo $variable["nom"]; ?></td>
<td>
<input class="span11 js-edit" type="text" name="valeur_<?php echo $variable["id"]; ?>" variable-original="<?php echo htmlentities($variable["valeur"], ENT_QUOTES, "UTF-8"); ?>" variable-id="<?php echo $variable["id"]; ?>" id="js_edit_<?php echo $variable["id"]; ?>" value="<?php echo htmlentities($variable["valeur"], ENT_QUOTES, "UTF-8"); ?>" />
</td>
<td>
<div class="btn-group">
<a class="btn btn-mini js-cancel-edit" title="<?php echo trad('undo_changes', 'admin'); ?>" variable-id="<?php echo $variable["id"]; ?>" id="js_cancel_edit_<?php echo $variable["id"]; ?>"><i class="icon-remove"></i></a>
<?php if($variable["protege"] == 0) { ?>
<a class="btn btn-mini js-delete-variable" title="<?php echo trad('supprimer', 'admin'); ?>" href="#deleteVariableModal" data-toggle="modal" variable-id="<?php echo $variable["id"]; ?>" variable-nom="<?php echo $variable["nom"]; ?>"><i class="icon-trash"></i></a>
<?php } ?>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<p>
<button class="btn btn-large btn-block btn-primary" type="submit"><?php echo trad('VALIDER_LES_MODIFICATIONS', 'admin'); ?></button>
</p>
</form>
</div>
</div>
<div class="modal hide fade in" id="deleteVariableModal">
<div class="modal-header"> <a class="close" data-dismiss="modal">×</a>
<h3><?php echo trad('SUPPRESSION_VARIABLE', 'admin'); ?></h3>
</div>
<div class="modal-body">
<p><?php echo trad('DeleteVariableWarning', 'admin'); ?></p>
<p id="variableDelationInfo"></p>
</div>
<div class="modal-footer">
<a class="btn" data-dismiss="modal" aria-hidden="true"><?php echo trad('Non', 'admin'); ?></a>
<a class="btn btn-primary" id="variableDelationLink"><?php echo trad('Oui', 'admin'); ?></a>
</div>
</div>
<div class="modal hide fade in" id="addVariableModal">
<form method="post" action="variable.php">
<input type="hidden" name="action" value="add">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h3><?php echo trad('CREATION_VARIABLE', 'admin'); ?></h3>
</div>
<div class="modal-body">
<?php if($addError){ ?>
<div class="alert alert-block alert-error fade in">
<h4 class="alert-heading"><?php echo trad('Cautious', 'admin'); ?></h4>
<p><?php echo trad('check_information', 'admin'); ?></p>
</div>
<?php } ?>
<table class="table table-striped">
<tbody>
<tr class="<?php if($addError && ($errorData->nom==='' || VariableAdmin::testVariableExists($errorData->nom))){ ?>error<?php } ?>">
<td>
<?php echo trad('Nom2', 'admin'); ?> *
<?php if($addError && VariableAdmin::testVariableExists($errorData->nom)){ ?>
<br /><?php echo trad('variable_already_exists', 'admin'); ?>
<?php } ?>
</td>
<td><input type="text" name="nom" value="<?php echo ($addError)?$errorData->nom:''; ?>"></td>
</tr>
<tr>
<td><?php echo trad('Valeur', 'admin'); ?></td>
<td><input type="text" name="valeur" value="<?php echo ($addError)?$errorData->valeur:''; ?>"></td>
</tr>
</tbody>
</table>
</div>
<div class="modal-footer">
<a class="btn" data-dismiss="modal" aria-hidden="true"><?php echo trad('Cancel', 'admin'); ?></a>
<button type="submit" class="btn btn-primary"><?php echo trad('Ajouter', 'admin'); ?></button>
</div>
</form>
</div>
<?php
ActionsAdminModules::instance()->inclure_module_admin("variable_bottom");
?>
<?php require_once("pied.php"); ?>
<script type="text/javascript">
jQuery(function($)
{
/*cancel edit*/
$('.js-cancel-edit')
.addClass('disabled')
.click(function()
{
if(!$(this).is('.disabled'))
{
$(this).addClass('disabled')
$('#js_edit_' + $(this).attr('variable-id')).val($('#js_edit_' + $(this).attr('variable-id')).attr('variable-original'));
}
});
$('.js-edit').keyup(function(){
$('#js_cancel_edit_' + $(this).attr('variable-id')).removeClass('disabled');
});
/*modal*/
$(document).ready(function(){
$(".js-delete-variable").click(function(){
$("#variableDelationInfo").html($(this).attr("variable-nom"));
$("#variableDelationLink").attr("href","variable.php?action=delete&id=" + $(this).attr("variable-id"));
})
});
<?php if($addError){ ?>
$('#addVariableModal').modal();
<?php } ?>
});
</script>
</body>
</html>