PEEL Shopping
Open source ecommerce : PEEL Shopping
fonctions.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: fonctions.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
24  $output = '
25  <script><!--//--><![CDATA[//><!--
26  function gotobrand(ident){
27  document.location="' . $GLOBALS['wwwroot'] . '/achat/marque.php?id="+ident;
28  }
29  function gotocategorie(ident){
30  document.location="' . $GLOBALS['wwwroot'] . '/achat/?catid="+ident;
31  }
32  //--><!]]></script>';
33 
34  return $output;
35 }
36 
43 function affiche_select_marque($return_mode = false) {
44  $output = '';
45  $query = query("SELECT id, nom_" . $_SESSION['session_langue'] . " AS marque
46  FROM peel_marques
47  WHERE etat=1 AND " . get_filter_site_cond('marques') . "
48  ORDER BY position ASC, nom_" . $_SESSION['session_langue'] . " ASC");
49  if (num_rows($query) > 0) {
50  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/search_select_marque.tpl');
51  $tpl->assign('STR_SEARCH_BRAND', $GLOBALS['STR_SEARCH_BRAND']);
52  $tpl_options = array();
53  while ($brand = fetch_assoc($query)) {
54  $tpl_id = null;
55  if (check_if_module_active('url_rewriting')) {
56  $tpl_id = rewriting_urlencode($brand['marque']);
57  }
58  $tpl_options[] = array(
59  'id' => $tpl_id,
60  'value' => intval($brand['id']),
61  'name' => String::str_shorten($brand['marque'], 50)
62  );
63  }
64  $tpl->assign('options', $tpl_options);
65  $output .= $tpl->fetch();
66  }
67  if ($return_mode) {
68  return $output;
69  } else {
70  echo $output;
71  }
72 }
73 
74 /*
75  * Affichage des champs select selon le type passé en paramètres (critère par défaut dans peel)
76  *
77  * @param string $categorie
78  * @param array $attribute
79  * @return
80  */
81 function display_select_attribute($categorie, $attribute) {
82  $output = '';
83  // si la requete necessite une autre table pour le controle de l'utilisation de l'attribut
84  if (!empty($attribute['join'])) {
85  $sql = 'SELECT DISTINCT a.`id`, a.`nom_' . $_SESSION['session_langue'] . '` AS `nom`
86  FROM `peel_' . word_real_escape_string($attribute['table']) . '` a
87  INNER JOIN `peel_' . word_real_escape_string($attribute['join']) . '` b ON (a.`id` = b.`' . word_real_escape_string($attribute['join_id']) . '`) ';
88  } else {
89  $sql = 'SELECT DISTINCT `' . word_real_escape_string($attribute['join_id']) . '` AS `id`, `' . word_real_escape_string($attribute['join_id']) . '` AS `nom`
90  FROM `peel_' . word_real_escape_string($attribute['table']) . '`';
91  }
92  $result = query($sql);
93  $option = '';
94  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/search_select_attribute.tpl');
95  $tpl->assign('categorie', $categorie);
96  $tpl->assign('label', $attribute['label']);
97  $tpl_options = array();
98  while ($attrib = fetch_assoc($result)) {
99  $tpl_options[] = array(
100  'value' => $attrib['id'],
101  'issel' => vb($_GET[$categorie]) == $attrib['id'],
102  'name' => $attrib['nom']
103  );
104  }
105  $tpl->assign('options', $tpl_options);
106  $output .= $tpl->fetch();
107  return $output;
108 }
109 
110 /*
111  * Affichage des attributs crées via l'administration du site
112  * A FAIRE : L'affichage des champs est à séparer et à fusionner avec affiche_attributs_form_part
113  *
114  * @param array $selected_attributes
115  * @param string $technical_code identifiant unique d'un attribut
116  * @param boolean $show_all
117  * @return
118  */
119 function display_custom_attribute($selected_attributes = null, $technical_code = null, $show_all = false) {
120  $output = '';
121  if(!empty($technical_code)) {
122  if (is_array($technical_code)) {
123  $sql_technical_code_condition = 'a.technical_code IN "(' . implode('","', real_escape_string($technical_code)) . ')"';
124  } else {
125  $sql_technical_code_condition = 'a.technical_code ="' . real_escape_string($technical_code) . '"';
126  }
127  } else {
128  // On ne prend que les choix multiples
129  $sql_technical_code_condition = 'a.`texte_libre`=0 ';
130  }
131  $sql = 'SELECT DISTINCT o.`id`, a.`id` AS `id_nom_attribut`, a.`nom_' . $_SESSION['session_langue'] . '` AS `attribut`, o.`descriptif_' . $_SESSION['session_langue'] . '` AS `nom`
132  FROM `peel_nom_attributs` a
133  LEFT JOIN `peel_attributs` o ON a.`id` = o.`id_nom_attribut` AND ' . get_filter_site_cond('attributs', 'o') . '
134  '.(!$show_all? 'INNER JOIN `peel_produits_attributs` pa ON o.`id` = pa.`attribut_id`':'').'
135  WHERE '.$sql_technical_code_condition.' AND a.`etat`=1 AND a.technical_code NOT IN ("duration", "categorie_number") AND ' . get_filter_site_cond('nom_attributs', 'a');
136  $result = query($sql);
137  while ($this_attribute = fetch_assoc($result)) {
138  $tpl_attrs[$this_attribute['id_nom_attribut']]['name'] = $this_attribute['attribut'];
139  $tpl_attrs[$this_attribute['id_nom_attribut']]['value'] = vb($selected_attributes[$this_attribute['id_nom_attribut']]);
140  if(!empty($this_attribute['id'])) {
141  $tpl_attrs[$this_attribute['id_nom_attribut']]['options'][] = array(
142  'value' => intval($this_attribute['id']),
143  'issel' => (!empty($selected_attributes) && is_array($selected_attributes) && vb($selected_attributes[$this_attribute['id_nom_attribut']]) == $this_attribute['id']),
144  'name' => $this_attribute['nom']
145  );
146  }
147  }
148  if(!empty($tpl_attrs)) {
149  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/search_custom_attribute.tpl');
150  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
151  $tpl->assign('select_attrib_txt', $GLOBALS['STR_MODULE_SEARCH_SELECT_ATTRIB']);
152  $tpl->assign('attributes', $tpl_attrs);
153  $output .= $tpl->fetch();
154  }
155  return $output;
156 }
157 
$result
display_select_attribute($categorie, $attribute)
Definition: fonctions.php:81
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
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
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
Definition: fonctions.php:19
rewriting_urlencode($string, $convert_string_to_lower=true)
Filtre une chaine de caractères pour insertion dans une URL On essaie de couper proprement, pour une longueur entre 30 et 60 caractères.
Definition: format.php:304
real_escape_string($value)
real_escape_string()
Definition: database.php:374
$tpl_options
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
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
num_rows($query_result)
num_rows()
Definition: database.php:321
display_custom_attribute($selected_attributes=null, $technical_code=null, $show_all=false)
Definition: fonctions.php:119
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
affiche_select_marque($return_mode=false)
affiche_select_marque()
Definition: fonctions.php:43
if(!defined('IN_PEEL')) get_advanced_search_script()
get_advanced_search_script()
Definition: fonctions.php:23
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...
static str_shorten($string, $length_limit, $middle_separator= '', $ending_if_no_middle_separator= '...', $ideal_length_with_clean_cut_if_possible=null)
Raccourcit une chaine de caractère en insérant au milieu ou à la fin un séparateur.
Definition: String.php:233
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:31:03 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.