-
Notifications
You must be signed in to change notification settings - Fork 2
/
museesDeFrancePlugin.php
282 lines (242 loc) · 9.68 KB
/
museesDeFrancePlugin.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
<?php
class museesDeFrancePlugin extends BaseApplicationPlugin
{
# -------------------------------------------------------
private $opo_config;
private $ops_plugin_path;
# -------------------------------------------------------
public function __construct($ps_plugin_path)
{
$this->ops_plugin_path = $ps_plugin_path;
$this->description = _t('Fonctionnalités pour les musées labellisés Musées de France par le Ministère de la Culture français.');
parent::__construct();
$ps_plugin_path = __CA_BASE_DIR__ . "/app/plugins/museesDeFrance";
if (file_exists($ps_plugin_path . '/conf/local/museesDeFrance.conf')) {
$this->opo_config = Configuration::load($ps_plugin_path . '/conf/local/museesDeFrance.conf');
} else {
$this->opo_config = Configuration::load($ps_plugin_path . '/conf/museesDeFrance.conf');
}
}
# -------------------------------------------------------
/**
* Override checkStatus() to return true - the ampasFrameImporterPlugin plugin always initializes ok
*/
public function checkStatus()
{
return array(
'description' => $this->getDescription(),
'errors' => array(),
'warnings' => array(),
'available' => ((bool)$this->opo_config->get('enabled'))
);
}
# -------------------------------------------------------
/**
* Insert into ObjectEditor info (side bar)
*/
public function hookAppendToEditorInspector(array $va_params = array())
{
MetaTagManager::addLink('stylesheet', __CA_URL_ROOT__."/app/plugins//museesDeFrance/assets/css/museesDeFrance.css",'text/css');
$t_item = $va_params["t_item"];
// basic zero-level error detection
if (!isset($t_item)) return false;
// fetching content of already filled vs_buf_append to surcharge if present (cumulative plugins)
if (isset($va_params["vs_buf_append"])) {
$vs_buf = $va_params["vs_buf_append"];
} else {
$vs_buf = "";
}
if($va_params["caEditorInspectorAppend"]) {
$vs_buf = $va_params["caEditorInspectorAppend"];
}
$vs_table_name = $t_item->tableName();
$vn_item_id = $t_item->getPrimaryKey();
$vn_code = $t_item->getTypeCode();
if ($vs_table_name == "ca_objects") {
$vs_inventaire_url = caNavUrl($this->getRequest(), "museesDeFrance", "InventaireBiensAffectes", "Transfer", array("id"=>$vn_item_id));
$vs_depot_url = caNavUrl($this->getRequest(), "museesDeFrance", "InventaireBiensDeposes", "Transfer", array("id"=>$vn_item_id));
if (in_array($vn_code, $this->opo_config->get('TypesInventaire'))) {
// biens acquis
$vs_inventaire_link_text_affectes = "Afficher dans l'inventaire";
} elseif (in_array($vn_code, $this->opo_config->get('TypesEnsembleComplexe'))) {
// ensemble complexe
$vs_inventaire_link_text = "Recopier dans l'inventaire";
} elseif (in_array($vn_code, $this->opo_config->get('TypesDepot'))) {
// biens déposés
$vs_inventaire_link_text_deposes = "Afficher dans le registre des biens déposés";
}
if ($vs_inventaire_link_text_affectes)
$vs_buf = "<div style=\"text-align:center;width:100%;margin-top:10px;\">"
. "<a href=\"" . $vs_inventaire_url . "\" class='form-button-gradient'>"
. "<img class='form-button-left' src=\"" . __CA_URL_ROOT__ . "/app/plugins/museesDeFrance/views/images/inventaire_16x16.png\" border='0'>"
. $vs_inventaire_link_text_affectes
. "</a></div>";
if ($vs_inventaire_link_text_deposes)
$vs_buf = "<div style=\"text-align:center;width:100%;margin-top:10px;\">"
. "<a href=\"" . $vs_depot_url . "\" class='form-button-gradient'>"
. "<img class='form-button-left' src=\"" . __CA_URL_ROOT__ . "/app/plugins/museesDeFrance/views/images/inventaire_16x16.png\" border='0'>"
. $vs_inventaire_link_text_deposes
. "</a></div>";
}
if ($vs_table_name == "ca_sets") {
$vs_inventaire_url = caNavUrl($this->getRequest(), "museesDeFrance", "InventaireBiensAffectes", "TransferSet", array("id"=>$vn_item_id));
$vs_depot_url = caNavUrl($this->getRequest(), "museesDeFrance", "InventaireBiensDeposes", "TransferSet", array("id"=>$vn_item_id));
// Check if set content is objects from table_num value, 57 = ca_objects, see ca_models/ca_sets.php L.89
if ($t_item->get("table_num") == "57") {
$vs_action = "updateSet/" . $vn_item_id;
$vs_buf = "<div style=\"text-align:center;width:100%;margin-top:10px;\">"
. "<a href=\"" . $vs_inventaire_url . "\" class='form-button-gradient'>"
. "<img class='form-button-left' src=\"" . __CA_URL_ROOT__ . "/app/plugins/museesDeFrance/views/images/inventaire_16x16.png\" border='0'>"
. "Importer dans l'inventaire<br/> des <b>biens affectés</b>"
. "</a><a href=\"" . $vs_depot_url . "\" class='form-button-gradient'>"
. "<img class='form-button-left' src=\"" . __CA_URL_ROOT__ . "/app/plugins/museesDeFrance/views/images/inventaire_16x16.png\" border='0'>"
. "Importer dans l'inventaire<br/> des <b>biens déposés</b>"
. "</a></div>";
}
}
$va_params["caEditorInspectorAppend"] = $vs_buf;
return $va_params;
}
# -------------------------------------------------------
/**
* Insert activity menu
*/
public function hookRenderMenuBar($pa_menu_bar)
{
if ($o_req = $this->getRequest()) {
if (!$o_req->user->canDoAction('can_use_recolementsmf_plugin')) {
return true;
}
if (isset($pa_menu_bar['recolementsmf_menu'])) {
$va_menu_items = $pa_menu_bar['recolementsmf_menu']['navigation'];
if (!is_array($va_menu_items)) {
$va_menu_items = array();
}
} else {
$va_menu_items = array();
}
$va_menu_items['recolementsmf'] = array(
'displayName' => _t('Suivi du récolement'),
"default" => array(
'module' => 'museesDeFrance',
'controller' => 'Recolement',
'action' => 'Index'
)
);
$va_menu_items['smf2'] = array(
'displayName' => _t("Registre des biens affectés"),
"default" => array(
'module' => 'museesDeFrance',
'controller' => 'InventaireBiensAffectes',
'action' => 'Index'
)
);
$va_menu_items['smf3'] = array(
'displayName' => _t("Registre des biens déposés"),
"default" => array(
'module' => 'museesDeFrance',
'controller' => 'InventaireBiensDeposes',
'action' => 'Index'
)
);
$va_menu_items['smf4'] = array(
'displayName' => _t("Export Joconde"),
"default" => array(
'module' => 'museesDeFrance',
'controller' => 'Joconde',
'action' => 'Index'
)
);
if($this->opo_config->get('installProfileThesaurus')) {
$va_menu_items['smf5'] = array(
'displayName' => _t("Installation"),
"default" => array(
'module' => 'museesDeFrance',
'controller' => 'InstallProfileThesaurus',
'action' => 'Index'
)
);
}
$va_menu_items['smf6'] = array(
'displayName' => _t("A propos"),
"default" => array(
'module' => 'museesDeFrance',
'controller' => 'InventaireBiensAffectes',
'action' => 'About'
)
);
$pa_menu_bar['recolementsmf_menu'] = array(
'displayName' => _t("Procédures<br/>réglementaires"),
'navigation' => $va_menu_items
);
}
print "<script type='text/javascript'>".file_get_contents(__CA_APP_DIR__."/plugins/museesDeFrance/assets/js/delimiteur.js")."</script>";
print "<link rel='stylesheet' href='".__CA_URL_ROOT__."/app/plugins/museesDeFrance/assets/css/delimiteur.css' type='text/css' media='all'> yea";
return $pa_menu_bar;
}
public function hookRenderWidgets($pa_widgets_config)
{
$pa_widgets_config["museesDeFranceRecolementInfo"] = array(
"domain" => array(
"module" => "museesDeFrance",
"controller" => "Recolement"),
"handler" => array(
"module" => "museesDeFrance",
"controller" => "Recolement",
"action" => 'Info',
"isplugin" => true),
"requires" => array(),
"parameters" => array()
);
$pa_widgets_config["museesDeFranceInventaireBiensAffectesInfo"] = array(
"domain" => array(
"module" => "museesDeFrance",
"controller" => "InventaireBiensAffectes"),
"handler" => array(
"module" => "museesDeFrance",
"controller" => "InventaireBiensAffectes",
"action" => 'Info',
"isplugin" => true),
"requires" => array(),
"parameters" => array()
);
$pa_widgets_config["museesDeFranceInventaireBiensDeposesInfo"] = array(
"domain" => array(
"module" => "museesDeFrance",
"controller" => "InventaireBiensDeposes"),
"handler" => array(
"module" => "museesDeFrance",
"controller" => "InventaireBiensDeposes",
"action" => 'Info',
"isplugin" => true),
"requires" => array(),
"parameters" => array()
);
return $pa_widgets_config;
}
# -------------------------------------------------------
/**
* Get plugin user actions
*/
static public function getRoleActionList() {
return array(
'can_use_recolementsmf_plugin' => array(
'label' => "Can use MuseesDeFrance plugin",
'description' => "Can use MuseesDeFrance plugin"
),
);
}
# -------------------------------------------------------
/**
* Add plugin user actions
*/
public function hookGetRoleActionList($pa_role_list) {
$pa_role_list['plugin_museesDeFrancePlugin'] = array(
'label' => _t('Plugin MuseesDeFrance'),
'description' => _t('Actions pour le plugin MuseesDeFrance'),
'actions' => museesDeFrancePlugin::getRoleActionList()
);
return $pa_role_list;
}
}
?>