PEEL Shopping
Open source ecommerce : PEEL Shopping
categories.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: categories.php 47186 2015-10-05 14:54:56Z sdelaporte $
14 define('IN_PEEL_ADMIN', true);
15 include("../configuration.inc.php");
17 necessite_priv('admin_products');
18 
19 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_ADMIN_CATEGORIES_TITLE'];
20 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
21 
22 $frm = $_POST;
24 
25 switch (vb($_REQUEST['mode'])) {
26  case "ajout" :
27  if (!empty($_POST['on_child'])) {
28  // On veut mettre à jour les catégories filles
29  update_category_sons_promotions($_REQUEST['id'], $_POST['promotion_devises'], $_POST['promotion_percent']);
30  }
32  break;
33 
34  case "modif" :
36  break;
37 
38  case "suppr" :
39  supprime_produits_categorie($_REQUEST['id']);
41  break;
42 
43  case "supprfile" :
44  supprime_fichier_categorie(vn($_REQUEST['id']), $_GET['file'], vn($_REQUEST['lang']));
46  break;
47 
48  case "insere" :
49  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
50  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
51  }
52  if (!$form_error_object->count()) {
53  insere_categorie($_POST);
55  } else {
56  if ($form_error_object->has_error('token')) {
57  echo $form_error_object->text('token');
58  }
59  affiche_formulaire_ajout_produits_categorie(vn($_REQUEST['id']), $frm);
60  }
61  break;
62 
63  case "maj" :
64  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
65  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
66  }
67  if (!$form_error_object->count()) {
68  maj_produits_categorie($_REQUEST['id'], $_POST);
69  if (!empty($_POST['on_child'])) {
70  // On veut mettre à jour les catégories filles
71  update_category_sons_promotions($_REQUEST['id'], $_POST['promotion_devises'], $_POST['promotion_percent']);
72  }
73  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_MSG_CHANGES_OK'], $_POST['id'])))->fetch();
75  } else {
76  if ($form_error_object->has_error('token')) {
77  echo $form_error_object->text('token');
78  }
79  affiche_formulaire_modif_produits_categorie($_REQUEST['id'], $frm);
80  }
81  break;
82 
83  case "modif_etat" :
84  if (isset($_GET['position']) && !empty($_GET['id'])) {
85  $qid = query("SELECT *
86  FROM peel_categories
87  WHERE id = " . intval($_GET['id'])." AND " . get_filter_site_cond('categories', null, true) . "");
88  if ($result = fetch_assoc($qid)) {
89  // On intervertit les positions si une autre catégorie a la même position
90  $qid = query('UPDATE peel_categories
91  SET position="' . intval($result['position']) . '"
92  WHERE parent_id="' . intval($result['parent_id']) . '" AND position="' . intval($_GET['position']) . '" AND ' . get_filter_site_cond('categories', null, true) . '');
93  }
94  query('UPDATE peel_categories
95  SET position="' . intval($_GET['position']) . '"
96  WHERE id="' . intval($_GET['id']) . '" AND ' . get_filter_site_cond('categories', null, true) . '');
97  }
99  break;
100 
101  default :
103  break;
104 }
105 
106 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
107 
117 function update_category_sons_promotions($parent_id, $promotion_devises = 0, $promotion_percent = 0)
118 {
119  $sql = "SELECT c.id AS categorie_id
120  FROM peel_categories c
121  WHERE c.parent_id='" . intval($parent_id) . "' AND " . get_filter_site_cond('categories', 'c', true) . "
122  ORDER BY c.id ASC";
123  $qid = query($sql);
124 
125  while ($cat = fetch_assoc($qid)) {
126  $sql = "UPDATE peel_categories
127  SET promotion_devises='" . floatval(get_float_from_user_input($promotion_devises)) . "', promotion_percent='" . floatval(get_float_from_user_input($promotion_percent)) . "'
128  WHERE id=" . intval($cat['categorie_id']." AND " . get_filter_site_cond('categories', null, true) . "");
129  query($sql);
130  update_category_sons_promotions($cat['categorie_id'], $promotion_devises, $promotion_percent);
131  }
132 }
133 
143 function affiche_arbo_categorie(&$sortie, $selectionne, $parent_id = 0, $indent = "", $first_line = 0, $depth = 1)
144 {
145  static $tpl;
146 
147  $sql = "SELECT c.id, c.reference, c.nom_" . $_SESSION['session_langue'] . ", c.etat, c.site_id, c.position, c.nb, c.image_" . $_SESSION['session_langue'] . "";
148  if (check_if_module_active('category_promotion')) {
149  $sql .= ", c.promotion_devises, c.promotion_percent";
150  }
151  $sql .= ' FROM peel_categories c
152  WHERE c.parent_id = "' . intval($parent_id) . '" AND ' . get_filter_site_cond('categories', 'c', true) . '
153  ORDER BY c.position' . (!empty($GLOBALS['site_parameters']['category_primary_order_by'])? ", c." . $GLOBALS['site_parameters']['category_primary_order_by'] : '') . '';
154 
155  $qid = query($sql);
156  while ($cat = fetch_assoc($qid)) {
157  if(empty($tpl)){
158  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_arbo_categorie.tpl');
159  }
160  if ($cat['image_' . $_SESSION['session_langue']] != "") {
161  $this_thumb = thumbs($cat['image_' . $_SESSION['session_langue']], 80, 50, 'fit');
162  $tpl->assign('image', array('src' => $GLOBALS['repertoire_upload'] . '/thumbs/' . $this_thumb,
163  'name' => $cat['image_' . $_SESSION['session_langue']]
164  ));
165  }else{
166  $tpl->assign('image', null);
167  }
168  $tpl->assign('tr_rollover', tr_rollover($first_line, true));
169  $tpl->assign('ajout_cat_href', get_current_url(false) . "?mode=ajout&id=" . $cat['id']);
170  $tpl->assign('ajout_cat_src', $GLOBALS['administrer_url'] . '/images/rubrique-24.gif');
171  $tpl->assign('ajout_prod_href', $GLOBALS['administrer_url'] . '/produits.php?mode=ajout&categories=' . $cat['id']);
172  $tpl->assign('ajout_prod_src', $GLOBALS['administrer_url'] . '/images/prod-cat-24.gif');
173  $tpl->assign('sup_cat_href', get_current_url(false) . "?mode=suppr&id=" . $cat['id']);
174  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
175  $tpl->assign('cat_id', $cat['id']);
176  $tpl->assign('indent', $indent);
177  $tpl->assign('modif_href', get_current_url(false) . "?mode=modif&id=" . $cat['id']);
178  $tpl->assign('cat_nom', (!empty($cat['nom_' . $_SESSION['session_langue']])?$cat['nom_' . $_SESSION['session_langue']]:'['.$cat['id'].']'));
179  $tpl->assign('site_name', get_site_name($cat['site_id']));
180  if (check_if_module_active('category_promotion')) {
181  $tpl->assign('promotion', array('percent' => number_format($cat['promotion_percent'], 2),
182  'prix' => fprix($cat['promotion_devises'], true, $GLOBALS['site_parameters']['code'], false)
183  ));
184  }else{
185  $tpl->assign('promotion', null);
186  }
187 
188  $tpl->assign('depth', $depth);
189  $tpl->assign('up_src', $GLOBALS['administrer_url'] . '/images/up.gif');
190  $tpl->assign('desc_src', $GLOBALS['administrer_url'] . '/images/desc.gif');
191  $tpl->assign('cat_position', $cat['position']);
192  if ($cat['position'] > 1) {
193  $tpl->assign('up_href', get_current_url(false) . '?mode=modif_etat&id=' . $cat['id'] . '&position=' . ($cat['position'] - 1));
194  }else{
195  $tpl->assign('up_href', null);
196  }
197  $tpl->assign('desc_href', get_current_url(false) . '?mode=modif_etat&id=' . $cat['id'] . '&position=' . ($cat['position'] + 1));
198  $tpl->assign('etat_onclick', 'change_status("categories", "' . $cat['id'] . '", this, "'.$GLOBALS['administrer_url'] . '")');
199  $tpl->assign('modif_src', $GLOBALS['administrer_url'] . '/images/' . (empty($cat['etat']) ? 'puce-blanche.gif' : 'puce-verte.gif'));
200  $tpl->assign('STR_ADMIN_LEVEL', $GLOBALS['STR_ADMIN_LEVEL']);
201  $tpl->assign('STR_NUMBER', $GLOBALS['STR_NUMBER']);
202  $tpl->assign('STR_DELETE', $GLOBALS['STR_DELETE']);
203  $tpl->assign('STR_ADMIN_CATEGORIES_ADD_SUBCATEGORY', $GLOBALS['STR_ADMIN_CATEGORIES_ADD_SUBCATEGORY']);
204  $tpl->assign('STR_ADMIN_CATEGORIES_ADD_PRODUCT', $GLOBALS['STR_ADMIN_CATEGORIES_ADD_PRODUCT']);
205  $tpl->assign('STR_ADMIN_CATEGORIES_DELETE_CATEGORY', $GLOBALS['STR_ADMIN_CATEGORIES_DELETE_CATEGORY']);
206  $tpl->assign('STR_ADMIN_DELETE_WARNING', $GLOBALS['STR_ADMIN_DELETE_WARNING']);
207  $sortie .= $tpl->fetch();
208  $first_line++;
209  if ($cat['id'] != $parent_id) {
210  affiche_arbo_categorie($sortie, $selectionne, $cat['id'], $indent . "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", $first_line, $depth + 1);
211  }
212  }
213 }
214 
222 {
223  if(empty($frm)) {
224  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
225  $frm['nom_' . $lng] = "";
226  $frm['description_' . $lng] = "";
227  $frm['meta_titre_' . $lng] = "";
228  $frm['meta_key_' . $lng] = "";
229  $frm['meta_desc_' . $lng] = "";
230  $frm['header_html_' . $lng] = "";
231  $frm['image_' . $lng] = "";
232  $frm['sentence_displayed_on_product_' . $lng] = "";
233  }
234  $frm['position'] = 0;
235  $frm['etat'] = "0";
236  $frm['on_special'] = "";
237  $frm['technical_code'] = "";
238  $frm['on_carrousel'] = "";
239  $frm['background_menu'] = $frm['background_color'] = "#";
240  $frm['type_affichage'] = 0;
241  if (check_if_module_active('category_promotion')) {
242  $frm['promotion_devises'] = 0;
243  $frm['promotion_percent'] = 0;
244  $frm['on_child'] = 0;
245  }
246  }
247  $frm['parent_id'] = $id;
248  $frm['site_id'] = '';
249  $frm['nouveau_mode'] = "insere";
250  $frm['id'] = "";
251  $frm["titre_soumet"] = $GLOBALS['STR_ADMIN_CATEGORIES_FORM_ADD_BUTTON'];
252 
254 }
255 
263 {
264  if(empty($frm)){
265  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
266  $qid = query("SELECT *
267  FROM peel_categories
268  WHERE id = " . intval($id) . " AND " . get_filter_site_cond('categories', null, true) . "");
269  if ($frm = fetch_assoc($qid)) {
270  } else {
271  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CATEGORIES_ERR_NOT_FOUND'], $id)))->fetch();
272  return false;
273  }
274  }
275  $frm["nouveau_mode"] = "maj";
276  $frm["titre_soumet"] = $GLOBALS['STR_ADMIN_CATEGORIES_FORM_MODIFY'];
277 
279 }
280 
288 {
289  $qid = query("SELECT cat.nom_" . $_SESSION['session_langue'] . " AS category_name, cat.parent_id, parent_id.nom_" . $_SESSION['session_langue'] . " AS parent_category_name
290  FROM peel_categories cat
291  LEFT JOIN peel_categories parent_id ON parent_id.id = cat.parent_id
292  WHERE cat.id = " . intval($id) . " AND " . get_filter_site_cond('categories', 'cat', true) . "");
293  if ($cat = fetch_assoc($qid)) {
294  query("UPDATE peel_produits_categories
295  SET categorie_id = '" . intval($cat["parent_id"]) . "'
296  WHERE categorie_id = '" . intval($id) . "'");
297  query("UPDATE peel_categories
298  SET parent_id = '" . $cat["parent_id"] . "'
299  WHERE parent_id = '" . intval($id) . "' AND " . get_filter_site_cond('categories', null, true) . "");
300  $message = $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CATEGORIES_MSG_DELETED'], String::html_entity_decode_if_needed($cat['category_name']), String::html_entity_decode_if_needed($cat["parent_category_name"]))))->fetch();
301  } else {
302  $message = $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CATEGORIES_ERR_NOT_FOUND'], $id)))->fetch();
303  }
304  query("DELETE FROM peel_categories WHERE id = '" . intval($id) . "' AND " . get_filter_site_cond('categories', null, true) . "");
305  echo $message;
306 }
307 
316 {
317  if (!empty($frm['nom_' . $_SESSION['session_langue']])) {
318  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
319  $frm['image_' . $lng] = upload('image_' . $lng, false, 'image_or_pdf', $GLOBALS['site_parameters']['image_max_width'], $GLOBALS['site_parameters']['image_max_height'], null, null, vb($frm['image_' . $lng]));
320  }
321 
322  // Remplit les contenus vides
324 
325  $sql = 'INSERT INTO peel_categories (parent_id
326  , etat
327  , on_special
328  , technical_code
329  , on_carrousel
330  , position
331  , type_affichage
332  , background_menu
333  , background_color
334  , site_id';
335  if (check_if_module_active('category_promotion')) {
336  $sql .= ', promotion_devises
337  , promotion_percent
338  , on_child';
339  }
340  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
341  $sql .= "
342  , alpha_" . $lng . "
343  , nom_" . $lng . "
344  , description_" . $lng . '
345  , meta_titre_' . $lng . '
346  , meta_key_' . $lng . '
347  , meta_desc_' . $lng . '
348  , image_' . $lng . '
349  , header_html_' . $lng . '
350  , sentence_displayed_on_product_' . $lng;
351  }
352  $sql .= ") VALUES (" . intval($frm['parent_id']) . "
353  , '" . intval($frm['etat']) . "'
354  , '" . intval(vn($frm['on_special'])) . "'
355  , '" . nohtml_real_escape_string(vb($frm['technical_code'])) . "'
356  , '" . intval(vn($frm['on_carrousel'])) . "'
357  , '" . intval($frm['position']) . "'
358  , '" . intval($frm['type_affichage']) . "'
359  , '" . nohtml_real_escape_string($frm['background_menu']) . "'
360  , '" . nohtml_real_escape_string($frm['background_color']) . "'
361  , '" . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . "'";
362  if (check_if_module_active('category_promotion')) {
363  $sql .= ", '" . floatval(get_float_from_user_input($frm['promotion_devises'])) . "'
364  , '" . floatval(get_float_from_user_input($frm['promotion_percent'])) . "'
365  , '" . intval($frm['on_child']) . "'";
366  }
367  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
368  $sql .= "
369  , '" . nohtml_real_escape_string(String::substr(String::strtoupper($frm['nom_' . $lng]), 0, 1)) . "'
370  , '" . nohtml_real_escape_string($frm['nom_' . $lng]) . "'
371  , '" . real_escape_string($frm['description_' . $lng]) . "'
372  , '" . nohtml_real_escape_string($frm['meta_titre_' . $lng]) . "'
373  , '" . nohtml_real_escape_string($frm['meta_key_' . $lng]) . "'
374  , '" . nohtml_real_escape_string($frm['meta_desc_' . $lng]) . "'
375  , '" . nohtml_real_escape_string($frm['image_' . $lng]) . "'
376  , '" . real_escape_string($frm['header_html_' . $lng]) . "'
377  , '" . real_escape_string(vb($frm['sentence_displayed_on_product_' . $lng])) . "'";
378  }
379  $sql .= ')';
380  query($sql);
381  $categorie_id = @insert_id();
382  if (!empty($categorie_id)) {
383  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CATEGORIES_MSG_CREATED_OK'], $categorie_id)))->fetch();
384  }
385  // Suppression des caches de catégories
386  $this_cache_object = new Cache(null, array('group' => 'categories'));
387  $this_cache_object->delete_cache_file(true);
388  unset($this_cache_object);
389  } else {
390  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ADMIN_ERR_CHOOSE_TITLE']))->fetch();
391  }
392 }
393 
403 {
404  if (empty($frm['parent_id']) || $frm['parent_id'] == $id) {
405  $frm['parent_id'] = 0;
406  }
407  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
408  $frm['image_' . $lng] = upload('image_' . $lng, false, 'image_or_pdf', $GLOBALS['site_parameters']['image_max_width'], $GLOBALS['site_parameters']['image_max_height'], null, null, vb($frm['image_' . $lng]));
409  }
410 
411  // Remplit les contenus vides
413 
414  $sql = "UPDATE peel_categories
415  SET parent_id = '" . intval($frm['parent_id']) . "'
416  , etat = '" . intval($frm['etat']) . "'
417  , position = '" . intval($frm['position']) . "'
418  , on_special = '" . intval(vn($frm['on_special'])) . "'
419  , technical_code = '" . nohtml_real_escape_string(vb($frm['technical_code'])) . "'
420  , on_carrousel = '" . intval(vn($frm['on_carrousel'])) . "'
421  , type_affichage = '" . intval($frm['type_affichage']) . "'
422  , background_menu = '" . nohtml_real_escape_string($frm['background_menu']) . "'
423  , background_color = '" . nohtml_real_escape_string($frm['background_color']) . "'
424  , site_id = '" . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . "'";
425  if (check_if_module_active('category_promotion')) {
426  $sql .= ", promotion_devises = '" . nohtml_real_escape_string($frm['promotion_devises']) . "'
427  , promotion_percent = '" . nohtml_real_escape_string($frm['promotion_percent']) . "'
428  , on_child = '" . intval($frm['on_child']) . "'";
429  }
430 
431  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
432  $sql .= ", alpha_" . $lng . "='" . nohtml_real_escape_string(String::substr(strtoupper($frm['nom_' . $lng]), 0, 1)) . "'
433  , nom_" . $lng . "='" . real_escape_string($frm['nom_' . $lng]) . "'
434  , image_" . $lng . "='" . real_escape_string($frm['image_' . $lng]) . "'
435  , description_" . $lng . "='" . real_escape_string($frm['description_' . $lng]) . "'
436  , meta_titre_" . $lng . "='" . nohtml_real_escape_string($frm['meta_titre_' . $lng]) . "'
437  , meta_key_" . $lng . "='" . nohtml_real_escape_string($frm['meta_key_' . $lng]) . "'
438  , meta_desc_" . $lng . "='" . nohtml_real_escape_string($frm['meta_desc_' . $lng]) . "'
439  , header_html_" . $lng . " = '" . real_escape_string($frm['header_html_' . $lng]) . "'
440  , sentence_displayed_on_product_" . $lng . " = '" . real_escape_string(vb($frm['sentence_displayed_on_product_' . $lng])) . "'";
441  }
442  $sql .= " WHERE id=" . intval($id). " AND " . get_filter_site_cond('categories', null, true) . "";
443 
444  query($sql);
445  // Suppression des caches de catégories
446  $this_cache_object = new Cache(null, array('group' => 'categories'));
447  $this_cache_object->delete_cache_file(true);
448  unset($this_cache_object);
449 }
450 
458 {
459  $frm["parent_id"] = $id;
460 
462 }
463 
471 {
472  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_liste_categorie.tpl');
473  $tpl->assign('is_category_promotion_module_active', check_if_module_active('category_promotion'));
474  $tpl->assign('add_src', $GLOBALS['administrer_url'] . '/images/add.png');
475  $tpl->assign('add_href', get_current_url(false) . '?mode=ajout');
476  $tpl->assign('cat_src', $GLOBALS['administrer_url'] . '/images/rubrique-24.gif');
477  $tpl->assign('prod_src', $GLOBALS['administrer_url'] . '/images/prod-cat-24.gif');
478  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
479  affiche_arbo_categorie($categorie_output, $parent_id);
480  $tpl->assign('categorie_options', $categorie_output);
481  $tpl->assign('STR_ADMIN_CATEGORIES_LIST_TITLE', $GLOBALS['STR_ADMIN_CATEGORIES_LIST_TITLE']);
482  $tpl->assign('STR_ADMIN_CATEGORIES_CREATE', $GLOBALS['STR_ADMIN_CATEGORIES_CREATE']);
483  $tpl->assign('STR_ADMIN_CATEGORIES_ADD_SUBCATEGORY', $GLOBALS['STR_ADMIN_CATEGORIES_ADD_SUBCATEGORY']);
484  $tpl->assign('STR_ADMIN_CATEGORIES_ADD_PRODUCT', $GLOBALS['STR_ADMIN_CATEGORIES_ADD_PRODUCT']);
485  $tpl->assign('STR_ADMIN_CATEGORIES_DELETE_CATEGORY', $GLOBALS['STR_ADMIN_CATEGORIES_DELETE_CATEGORY']);
486  $tpl->assign('STR_ADMIN_ACTION', $GLOBALS['STR_ADMIN_ACTION']);
487  $tpl->assign('STR_ADMIN_ID', $GLOBALS['STR_ADMIN_ID']);
488  $tpl->assign('STR_IMAGE', $GLOBALS['STR_IMAGE']);
489  $tpl->assign('STR_ADMIN_CATEGORIES', $GLOBALS['STR_ADMIN_CATEGORIES']);
490  $tpl->assign('STR_WEBSITE', $GLOBALS['STR_WEBSITE']);
491  $tpl->assign('STR_PROMOTION', $GLOBALS['STR_PROMOTION']);
492  $tpl->assign('STR_ADMIN_POSITION', $GLOBALS['STR_ADMIN_POSITION']);
493  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
494  $tpl->assign('STR_ADMIN_TECHNICAL_CODE', $GLOBALS['STR_ADMIN_TECHNICAL_CODE']);
495  echo $tpl->fetch();
496 }
497 
504 {
505  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_formulaire_categorie.tpl');
506  $tpl->assign('action', get_current_url(false));
507  $tpl->assign('form_token', get_form_token_input($_SERVER['PHP_SELF'] . $frm['nouveau_mode'] . intval($frm['id'])));
508  $tpl->assign('mode', $frm["nouveau_mode"]);
509  $tpl->assign('id', intval($frm['id']));
510  $tpl->assign('nom', $frm['nom_' . $_SESSION['session_langue']]);
511  if ($frm['nouveau_mode'] == "maj") {
512  $tpl->assign('cat_href', get_product_category_url($frm['id'], $frm['nom_' . $_SESSION['session_langue']]), false, false, vb($frm['site_id']));
513  }
514  $tpl->assign('issel_parent_zero', vb($frm['parent_id']) == 0);
515  $tpl->assign('categorie_options', get_categories_output(null, 'categories', $frm['parent_id'], 'option', '&nbsp;&nbsp;', null, null, true, 80));
516  $tpl->assign('is_on_special', !empty($frm['on_special']));
517  $tpl->assign('technical_code', vb($frm["technical_code"]));
518  $tpl->assign('is_carrousel_module_active', check_if_module_active('carrousel'));
519  $tpl->assign('is_on_carrousel', !empty($frm['on_carrousel']));
520  $tpl->assign('position', $frm['position']);
521  $tpl->assign('etat', $frm['etat']);
522  $tpl->assign('site_id_select_options', get_site_id_select_options(vb($frm['site_id'])));
523  $tpl->assign('site_id_select_multiple', !empty($GLOBALS['site_parameters']['multisite_using_array_for_site_id']));
524  $tpl->assign('type_affichage', $frm['type_affichage']);
525  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
526 
527  $tpl_langs = array();
528  $tpl->assign('is_lot_module_active', check_if_module_active('lot'));
529  if (check_if_module_active('lot')) {
530  if (vb($frm['nouveau_mode']) == "maj") {
531  $tpl->assign('lot_explanation_table', get_lot_explanation_table(null, $frm['id']));
532  $tpl->assign('lot_href', $GLOBALS['wwwroot_in_admin'] . '/modules/lot/administrer/lot.php?cat_id=' . vb($frm['id']));
533  if (num_rows(query("SELECT 1 FROM peel_quantites WHERE cat_id='" . intval($frm['id']) . "' AND " . get_filter_site_cond('quantites'))) > 0) {
534  $tpl->assign('lot_supprime_href', $GLOBALS['wwwroot_in_admin'] . '/modules/lot/administrer/lot.php?cat_id=' . vb($frm['id']) . '&mode=supprime');
535  }
536  }
537  }
538  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
539  $tpl_langs[] = array('lng' => $lng,
540  'nom' => $frm['nom_' . $lng],
541  'description_te' => getTextEditor('description_' . $lng, '100%', 500, String::html_entity_decode_if_needed(vb($frm['description_' . $lng]))),
542  'meta_titre' => $frm['meta_titre_' . $lng],
543  'meta_key' => $frm['meta_key_' . $lng],
544  'meta_desc' => $frm['meta_desc_' . $lng],
545  'header_html' => vb($frm['header_html_' . $lng]),
546  'sentence_displayed_on_product' => vb($frm['sentence_displayed_on_product_' . $lng]),
547  'image' => get_uploaded_file_infos('image_' . $lng, $frm['image_' . $lng], get_current_url(false) . '?mode=supprfile&id=' . vb($frm['id']) . '&file=image&lang=' . $lng),
548  );
549  }
550  $tpl->assign('langs', $tpl_langs);
551 
552  $tpl->assign('enable_categorie_sentence_displayed_on_product', vb($GLOBALS['site_parameters']['enable_categorie_sentence_displayed_on_product']));
553  $tpl->assign('is_category_promotion_module_active', check_if_module_active('category_promotion'));
554  $tpl->assign('promotion_devises', vb($frm["promotion_devises"]));
555  $tpl->assign('site_symbole', vb($GLOBALS['site_parameters']['symbole']));
556  $tpl->assign('promotion_percent', vb($frm["promotion_percent"]));
557  $tpl->assign('on_child', vb($frm["on_child"]));
558  $tpl->assign('background_color', $frm["background_color"]);
559  $tpl->assign('background_menu', $frm["background_menu"]);
560  $tpl->assign('titre_soumet', $frm["titre_soumet"]);
561  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
562  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
563  $tpl->assign('STR_ADMIN_AT_ROOT', $GLOBALS['STR_ADMIN_AT_ROOT']);
564  $tpl->assign('STR_ADMIN_CATEGORIES_FORM_MODIFY', $GLOBALS['STR_ADMIN_CATEGORIES_FORM_MODIFY']);
565  $tpl->assign('STR_ADMIN_SEE_RESULT_IN_REAL', $GLOBALS['STR_ADMIN_SEE_RESULT_IN_REAL']);
566  $tpl->assign('STR_ADMIN_CATEGORIES_FORM_ADD_BUTTON', $GLOBALS['STR_ADMIN_CATEGORIES_FORM_ADD_BUTTON']);
567  $tpl->assign('STR_ADMIN_CATEGORIES_PARENT', $GLOBALS['STR_ADMIN_CATEGORIES_PARENT']);
568  $tpl->assign('STR_ADMIN_DISPLAY_ON_HOMEPAGE', $GLOBALS['STR_ADMIN_DISPLAY_ON_HOMEPAGE']);
569  $tpl->assign('STR_ADMIN_CATEGORIES_DISPLAY_IN_CARROUSEL', $GLOBALS['STR_ADMIN_CATEGORIES_DISPLAY_IN_CARROUSEL']);
570  $tpl->assign('STR_ADMIN_POSITION', $GLOBALS['STR_ADMIN_POSITION']);
571  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
572  $tpl->assign('STR_ADMIN_TECHNICAL_CODE', $GLOBALS['STR_ADMIN_TECHNICAL_CODE']);
573  $tpl->assign('STR_ADMIN_IN_COLUMNS', $GLOBALS['STR_ADMIN_IN_COLUMNS']);
574  $tpl->assign('STR_ADMIN_IN_LINES', $GLOBALS['STR_ADMIN_IN_LINES']);
575  $tpl->assign('STR_ADMIN_CATEGORIES_DISPLAY_MODE', $GLOBALS['STR_ADMIN_CATEGORIES_DISPLAY_MODE']);
576  $tpl->assign('STR_ADMIN_LANGUAGES_SECTION_HEADER', $GLOBALS['STR_ADMIN_LANGUAGES_SECTION_HEADER']);
577  $tpl->assign('STR_ADMIN_NAME', $GLOBALS['STR_ADMIN_NAME']);
578  $tpl->assign('STR_ADMIN_DESCRIPTION', $GLOBALS['STR_ADMIN_DESCRIPTION']);
579  $tpl->assign('STR_ADMIN_HEADER_HTML_TEXT', $GLOBALS['STR_ADMIN_HEADER_HTML_TEXT']);
580  $tpl->assign('STR_IMAGE', $GLOBALS['STR_IMAGE']);
581  $tpl->assign('STR_ADMIN_CUSTOMIZE_APPEARANCE', $GLOBALS['STR_ADMIN_CUSTOMIZE_APPEARANCE']);
582  $tpl->assign('STR_ADMIN_BACKGROUND_COLOR', $GLOBALS['STR_ADMIN_BACKGROUND_COLOR']);
583  $tpl->assign('STR_ADMIN_BACKGROUND_COLOR_FOR_MENU', $GLOBALS['STR_ADMIN_BACKGROUND_COLOR_FOR_MENU']);
584  $tpl->assign('STR_ADMIN_ONLINE', $GLOBALS['STR_ADMIN_ONLINE']);
585  $tpl->assign('STR_ADMIN_OFFLINE', $GLOBALS['STR_ADMIN_OFFLINE']);
586  $tpl->assign('STR_ADMIN_META_TITLE', $GLOBALS['STR_ADMIN_META_TITLE']);
587  $tpl->assign('STR_ADMIN_META_KEYWORDS', $GLOBALS['STR_ADMIN_META_KEYWORDS']);
588  $tpl->assign('STR_ADMIN_SEPARATE_KEYWORDS_EXPLAIN', $GLOBALS['STR_ADMIN_SEPARATE_KEYWORDS_EXPLAIN']);
589  $tpl->assign('STR_ADMIN_META_DESCRIPTION', $GLOBALS['STR_ADMIN_META_DESCRIPTION']);
590  $tpl->assign('STR_ADMIN_META_TITLE', $GLOBALS['STR_ADMIN_META_TITLE']);
591  $tpl->assign('STR_ADMIN_META_KEYWORDS', $GLOBALS['STR_ADMIN_META_KEYWORDS']);
592  $tpl->assign('STR_ADMIN_SEPARATE_KEYWORDS_EXPLAIN', $GLOBALS['STR_ADMIN_SEPARATE_KEYWORDS_EXPLAIN']);
593  $tpl->assign('STR_ADMIN_META_DESCRIPTION', $GLOBALS['STR_ADMIN_META_DESCRIPTION']);
594  $tpl->assign('STR_ADMIN_VARIOUS_INFORMATION_HEADER', $GLOBALS['STR_ADMIN_VARIOUS_INFORMATION_HEADER']);
595  $tpl->assign('STR_ADMIN_CATEGORIES_DISCOUNT_IN_CATEGORY', $GLOBALS['STR_ADMIN_CATEGORIES_DISCOUNT_IN_CATEGORY']);
596  $tpl->assign('STR_ADMIN_CATEGORIES_LOT_PRICE', $GLOBALS['STR_ADMIN_CATEGORIES_LOT_PRICE']);
597  $tpl->assign('STR_ADMIN_PRODUITS_LOT_PRICE_HANDLE', $GLOBALS['STR_ADMIN_PRODUITS_LOT_PRICE_HANDLE']);
598  $tpl->assign('STR_ADMIN_PRODUITS_LOT_PRICE_HANDLE_EXPLAIN', $GLOBALS['STR_ADMIN_PRODUITS_LOT_PRICE_HANDLE_EXPLAIN']);
599  $tpl->assign('STR_ADMIN_DELETE_WARNING', $GLOBALS['STR_ADMIN_DELETE_WARNING']);
600  $tpl->assign('STR_DELETE', $GLOBALS['STR_DELETE']);
601  $tpl->assign('STR_DELETE_THIS_FILE', $GLOBALS['STR_DELETE_THIS_FILE']);
602  $tpl->assign('STR_TTC', $GLOBALS['STR_TTC']);
603  $tpl->assign('STR_YES', $GLOBALS['STR_YES']);
604  $tpl->assign('STR_NO', $GLOBALS['STR_NO']);
605  $tpl->assign('STR_ADMIN_CATEGORIES_DISCOUNT_APPLY_TO_SONS', $GLOBALS['STR_ADMIN_CATEGORIES_DISCOUNT_APPLY_TO_SONS']);
606  $tpl->assign('STR_ADMIN_CATEGORIES_DISCOUNT_APPLY_TO_SONS_EXPLAIN', $GLOBALS['STR_ADMIN_CATEGORIES_DISCOUNT_APPLY_TO_SONS_EXPLAIN']);
607  $tpl->assign('STR_ADMIN_DELETE_IMAGE', $GLOBALS['STR_ADMIN_DELETE_IMAGE']);
608  $tpl->assign('STR_ADMIN_FILE_NAME', $GLOBALS['STR_ADMIN_FILE_NAME']);
609  $tpl->assign('STR_ADMIN_SENTENCE_DISPLAYED_ON_PRODUCT', $GLOBALS['STR_ADMIN_SENTENCE_DISPLAYED_ON_PRODUCT']);
610  echo $tpl->fetch();
611 }
612 
622 {
623  /* Charge les infos du produit. */
624  switch ($file) {
625  case "image":
626  $sql = "SELECT image_" . word_real_escape_string($lang) . "
627  FROM peel_categories
628  WHERE id = '" . intval($id) . "' AND " . get_filter_site_cond('categories', null, true) . "";
629  $res = query($sql);
630  $file = fetch_assoc($res);
631  query("UPDATE peel_categories
632  SET image_" . word_real_escape_string($lang) . " = ''
633  WHERE id = '" . intval($id) . "' AND " . get_filter_site_cond('categories', null, true) . "");
634  break;
635  }
636  delete_uploaded_file_and_thumbs($file['image_' . $lang]);
637  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_FILE_DELETED'], $file['image_' . $lang])))->fetch();
638 }
639 
static strtoupper($string)
Returns string with all alphabetic characters converted to uppercase.
Definition: String.php:154
get_site_name($site_ids, $skip_rights_check=false)
Retourne le nom d'un ou de plusieurs sites à partir de l'id.
Definition: fonctions.php:4763
getTextEditor($instance_name, $width, $height, $default_text, $default_path=null, $type_html_editor=0, $compter_char_max_if_enabled=255, $placeholder= '')
getTextEditor()
Definition: fonctions.php:4055
$lang
Definition: spellchecker.php:9
$result
affiche_liste_produits_categorie($parent_id)
affiche_liste_produits_categorie()
Definition: categories.php:470
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
supprime_produits_categorie($id)
supprime_produits_categorie()
Definition: categories.php:287
upload($field_name, $rename_file=true, $file_kind=null, $image_max_width=null, $image_max_height=null, $path=null, $new_file_name_without_extension=null, $default_return_value=null)
Fonction d'upload de fichiers.
Definition: fonctions.php:3302
fill_other_language_content($frm)
Retourne les contenus remplis si vide.
supprime_fichier_categorie($id, $file, $lang)
Supprime l'image de la catégorie spécifiée par $id.
Definition: categories.php:621
$tpl_langs
maj_produits_categorie($id, $frm)
maj_produits_categorie()
Definition: categories.php:402
get_site_id_select_options($selected_site_id=null, $selected_site_name=null, $display_first_option=null, $select_current_site_id_by_default=false)
Créer les options pour le select qui liste les noms de sites configurés en back office.
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
Definition: String.php:533
word_real_escape_string($value)
Applique real_escape_string dans le cas où on n'insère qu'un seul mot, de moins de 30 caractères...
Definition: database.php:424
insert_id($database_object=null)
insert_id()
Definition: database.php:339
$frm
Definition: categories.php:22
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
Definition: database.php:400
affiche_formulaire_produits_categorie(&$frm)
affiche_formulaire_produits_categorie()
Definition: categories.php:503
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
affiche_arbo_categorie(&$sortie, $selectionne, $parent_id=0, $indent="", $first_line=0, $depth=1)
affiche_arbo_categorie()
Definition: categories.php:143
get_float_from_user_input($string, $from_currency_rate=1)
Transforme tout nombre formaté en un float au format PHP Exemples : 12 004,34 ou 12,324.50.
Definition: format.php:196
if(!defined('IN_PEEL')) thumbs($source_filename, $width, $height, $method= 'fit', $source_folder=null, $thumb_folder=null, $thumb_rename=true, $return_absolute_path=false)
Charge l'image dont le nom est $source_filename dans le répertoire d'upload, et crée une vignette pou...
Definition: fonctions.php:33
real_escape_string($value)
real_escape_string()
Definition: database.php:374
necessite_priv($priv, $demo_allowed=true, $configuration_modification=false)
Cette fonction vérifie si l'utilisateur a les privilèges de $priv.
Definition: fonctions.php:1575
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
Definition: fonctions.php:4643
update_category_sons_promotions($parent_id, $promotion_devises=0, $promotion_percent=0)
FONCTIONS.
Definition: categories.php:117
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
Definition: database.php:158
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
get_uploaded_file_infos($field_name, $file, $delete_url, $logo_width=100, $logo_height=100)
Remplit un tableau d'informations pour le template d'upload HTML.
Definition: fonctions.php:3601
necessite_identification()
Si l'utilisateur n'est pas connecté à un compte, on affiche une page d'identification et arrête le sc...
Definition: fonctions.php:1596
num_rows($query_result)
num_rows()
Definition: database.php:321
affiche_formulaire_modif_produits_categorie($id, &$frm)
affiche_formulaire_modif_produits_categorie()
Definition: categories.php:262
delete_uploaded_file_and_thumbs($filename)
delete_uploaded_file_and_thumbs()
Definition: fonctions.php:3417
$form_error_object
Definition: categories.php:23
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
affiche_formulaire_ajout_produits_categorie($id, &$frm)
affiche_formulaire_ajout_produits_categorie()
Definition: categories.php:221
get_form_token_input($name= 'general', $use_existing_token=true, $return_as_input_form=true)
get_form_token_input()
Definition: fonctions.php:94
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
get_site_id_sql_set_value($site_ids)
Retourne la valeur SQL d'un champ INT ou SET suivant que ce soit un entier ou un tableau.
Definition: fonctions.php:4747
verify_token($name= 'general', $delay_in_minutes=60, $check_referer_if_set_by_server=true, $cancel_token=true, $minimum_wait_in_seconds_before_use=0)
Vérification de la validité d'un token Par défaut, un token est valide 1h, et utilisable 1 seule fois...
Definition: fonctions.php:118
$id
Definition: articles.php:22
fprix($price, $display_currency=false, $currency_code_or_default=null, $convertion_needed_into_currency=true, $currency_rate=null, $display_iso_currency_code=false, $format=true, $force_format_separator=null, $add_rdfa_properties=false, $round_even_if_no_format=false)
fprix formatte le prix donné en le convertissant si nécessaire au préalable et en ajoutant éventuelle...
Definition: fonctions.php:242
insere_categorie(&$frm)
insere_categorie()
Definition: categories.php:315
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
Definition: String.php:112
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...
affiche_formulaire_liste_produits_categorie($id)
Affiche un formulaire de catégorie vide.
Definition: categories.php:457
Definition: Cache.php:27
$GLOBALS['DOC_TITLE']
Definition: categories.php:19
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:28:58 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.