PEEL Shopping
Open source ecommerce : PEEL Shopping
produit.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-2013 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: produit.php 46935 2015-09-18 08:49:48Z gboussin $
14 
15 define('LOAD_NO_OPTIONAL_MODULE', true);
16 include('../../configuration.inc.php');
17 
18 if (!check_if_module_active('search')) {
19  // This module is not activated => we redirect to the homepage
20  redirect_and_die(get_url('/'));
21 }
22 // Javascript
26 $results_array = array();
27 $labels_array = array();
28 $maxRows = 10;
29 
30 if (vb($_POST['type']) == "update_session_add") {
31  $_SESSION['session_search_product_list'][$_POST['id']] = $_POST['quantite'];
32 } elseif (vb($_POST['type']) == "update_session_delete") {
33  unset($_SESSION['session_search_product_list'][$_POST['id']]);
34 } else {
35  $form_add_search_product_list = vb($_POST['type']) == "search_product_list";
36  $search = trim(vb($_POST['search']));
37  $search_category = intval(vb($_POST['search_category']));
38 
39  if (String::strlen($search)>0 || !empty($search_category)) {
40  if(String::strpos($search, vb($GLOBALS['site_parameters']['product_reference_prefix'])) !== false) {
41  // Si les références ont un préfix commun, on peut insérer plusieurs régérence d'un seul coup.
42  $search_array = explode($GLOBALS['site_parameters']['product_reference_prefix'], $search);
43  $result_array=array();
44  foreach($search_array as $this_result) {
45  if (!empty($this_result)) {
46  $result_array[] = $GLOBALS['site_parameters']['product_reference_prefix'].$this_result;
47  }
48  }
49  $search = $result_array;
50  }
51  $queries_results_array = get_quick_search_results($search, $maxRows, true, $search_category);
52  if(!empty($queries_results_array)) {
53  $cat_search_sql = "SELECT pc.produit_id, c.id as categorie_id, c.nom_" . $_SESSION['session_langue'] . " as categorie
54  FROM peel_produits_categories pc
55  LEFT JOIN peel_categories c ON c.id = pc.categorie_id AND " . get_filter_site_cond('categories', 'c') . "
56  WHERE pc.produit_id IN (" . implode(', ', array_keys($queries_results_array)) . ")";
57  $query = query($cat_search_sql);
58  while ($result = fetch_assoc($query)) {
59  $queries_results_array[$result['produit_id']]->categorie_id = $result['categorie_id'];
60  $queries_results_array[$result['produit_id']]->categorie = $result['categorie'];
61  }
62  foreach($queries_results_array as $result) {
63  $product_object = new Product($result->id, null, false, null, true, !check_if_module_active('micro_entreprise'));
64  // Prix hors ecotaxe
65  $display_picture = $product_object->get_product_main_picture(false);
66  if ($display_picture) {
67  $product_picture = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($display_picture, 75, 75, 'fit');
68  } elseif(!empty($GLOBALS['site_parameters']['default_picture'])) {
69  $product_picture = $GLOBALS['repertoire_upload'] . '/thumbs/' . thumbs($GLOBALS['site_parameters']['default_picture'], 75, 75, 'fit');
70  } else {
71  $product_picture = null;
72  }
73  $this_label = (!empty($GLOBALS['site_parameters']['autocomplete_hide_images'])?'<div>':'<div class="autocomplete_image"><img src="'.$product_picture.'" /></div><div style="display:table-cell; vertical-align:middle; height:45px;">') . highlight_found_text(String::html_entity_decode($result->nom), $search, $found_words_array) . (!empty($GLOBALS['site_parameters']['autocomplete_show_references']) && String::strlen($result->reference) ? ' - <span class="autocomplete_reference_result">' . highlight_found_text(String::html_entity_decode($result->reference), $search, $found_words_array) . '</span>' : '') . '</div><div class="clearfix" />';
74  if(!in_array($this_label, $labels_array)) {
75  $results_array[] = array(
76  'id' => $result->id,
77  'reference' => $result->reference,
78  'urlprod' => get_product_url($result->id, $result->nom, $result->categorie_id, $result->categorie),
79  'label' => $this_label,
80  'name' => $result->nom,
81  'category_name' => $product_object->categorie,
82  'nom_produit' => $product_object->name,
83  'href_produit' => $product_object->get_product_url(),
84  'brand_link_html' => (!empty($product_object->id_marque)? get_brand_link_html($product_object->id_marque, false, false, null, "_blank") : ''),
85  'href_category' => get_product_category_url($product_object->categorie_id, $product_object->categorie),
86  'photo_src' => vb($product_picture),
87  'prix' => $product_object->get_original_price(display_prices_with_taxes_active(), check_if_module_active('reseller') && is_reseller(), false),
88  'ean_code' => $product_object->ean_code,
89  'barcode_image_src'=> $product_object->barcode_image_src(),
90  'reference' => $product_object->reference,
91  'minimal_price' => $product_object->get_minimal_price(false),
92  'product_id' => $product_object->id
93  );
94  $labels_array[] = $this_label;
95  }
96  unset($product_object);
97  }
98  }
99  if (check_if_module_active('annonces')) {
100  $sql = get_ad_search_select($_POST, 10);
101  $query = query($sql);
102  while ($result = fetch_assoc($query)) {
103  $ad_object = new Annonce($result['ref'], $result);
104  $product_picture = $ad_object->get_annonce_picture(true, 75, 75);
105  $this_title = $ad_object->get_titre();
106  $this_label = (!empty($GLOBALS['site_parameters']['autocomplete_hide_images']) || empty($product_picture)?'<div>':'<div class="autocomplete_image"><img src="'.$product_picture.'" /></div><div style="display:table-cell; vertical-align:middle; height:45px;">') . highlight_found_text(String::html_entity_decode($this_title), $search, $found_words_array) . (!empty($GLOBALS['site_parameters']['autocomplete_show_references']) && String::strlen(vb($ad_object->reference)) ? ' - <span class="autocomplete_reference_result">' . highlight_found_text(String::html_entity_decode($ad_object->reference), $search, $found_words_array) . '</span>' : '') . '</div><div class="clearfix" />';
107  $results_array[] = array(
108  'id' => $ad_object->ref,
109  'reference' => vb($ad_object->reference),
110  'urlprod' => $ad_object->get_annonce_url(),
111  'label' => $this_label,
112  'name' => $this_title
113  );
114  }
115  }
116 }
117  if (!empty($_POST['return_json_array_with_raw_information'])) {
118  $output = json_encode($results_array);
119  } else {
120  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/search_produit.tpl');
121  $tpl->assign('STR_AUCUN_RESULTAT', $GLOBALS['STR_AUCUN_RESULTAT']);
122  $tpl->assign('display_barcode', !empty($GLOBALS['site_parameters']['display_ean_code_on_product_list']));
123  $tpl->assign('results', $results_array);
124  $tpl->assign('form_add_search_product_list', $form_add_search_product_list);
125  $output .= $tpl->fetch();
126  }
127  echo String::convert_encoding($output, $page_encoding, GENERAL_ENCODING);
128 }
get_quick_search_results($search, $maxRows, $active_only=false, $search_category=null, $mode= 'products')
get_quick_search_results()
Definition: fonctions.php:4555
highlight_found_text($text, $terms, &$found_words_array, $found_tags=array('< span class="search_tag">', '</span >'))
Highlights terms in text.
Definition: format.php:1120
$result
static convert_encoding($string, $new_encoding, $original_encoding=null)
Converts the character encoding of string $string to $new_encoding from optionally $original_encoding...
Definition: String.php:375
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
Definition: String.php:54
$search
Definition: produit.php:36
output_general_http_header($page_encoding=null, $cache_duration_in_seconds=null)
Envoie les headers avant l'envoi du HTML.
Definition: fonctions.php:1528
redirect_and_die($url, $permanent_redirection=false, $avoid_loop=false)
Redirige vers l'URL demandée et arrête le programme.
Definition: fonctions.php:1551
static strlen($string)
Returns the length of the given string.
Definition: String.php:36
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(empty($_GET['id'])) if(!empty($GLOBALS['site_parameters']['allow_multiple_product_url_with_category'])) $product_object
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
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
if(!defined('IN_PEEL')) display_prices_with_taxes_active()
display_prices_with_taxes_active()
Definition: fonctions.php:23
$found_words_array
Definition: search.php:147
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
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
$results_array
Definition: produit.php:26
$labels_array
Definition: produit.php:27
$GLOBALS['page_columns_count']
if(!check_if_module_active('search')) $page_encoding
Definition: produit.php:23
$search_category
Definition: produit.php:37
static html_entity_decode($string, $quote_style=ENT_COMPAT, $charset=GENERAL_ENCODING)
String::html_entity_decode()
Definition: String.php:517
$maxRows
Definition: produit.php:28
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...
$output
Definition: produit.php:25
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:41:34 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.