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 //
15 
16 if (!defined('IN_PEEL')) {
17  die();
18 }
19 
26 function affiche_tagcloud($return_mode = false)
27 {
28  // Avec la complicité de 3dvf.fr
29  $output = '';
30  $max = 0;
31  if(empty($GLOBALS['site_parameters']['tagcloud_display_count'])) {
32  $limit = 25;
33  } else {
34  $limit = $GLOBALS['site_parameters']['tagcloud_display_count'];
35  }
36  $query = "SELECT tag_name AS tag, nbsearch AS quantity
37  FROM peel_tag_cloud
38  WHERE lang = '" . real_escape_string($_SESSION['session_langue']) . "' AND nbsearch>0 AND " . get_filter_site_cond('tag_cloud') . "
39  GROUP BY tag_name
40  ORDER BY RAND()*(10+quantity) DESC
41  LIMIT ". intval($limit);
42 
43  $result = query($query);
44  if (num_rows($result) > 0) {
45  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/tagcloud.tpl');
46  $tpl_tags = array();
47  while ($row = fetch_assoc($result)) {
48  $row['quantity'] = max(1, $row['quantity']);
49  $this_quantity = log($row['quantity']);
50  $tags[String::strtolower($row['tag'])] = $this_quantity;
51  if ($this_quantity > $max) {
52  $max = $this_quantity;
53  }
54  if (!isset($min) || $this_quantity < $min) {
55  $min = $this_quantity;
56  }
57  }
58  ksort($tags);
59  foreach ($tags as $key => $value) {
60  $tpl_tags[] = array(
61  'href' => get_url('search') . '?match=1&search=' . $key,
62  'value' => $value,
63  'key' => $key,
64  'level' => intval(($value-$min) / max(1, $max-$min) * 10)
65  );
66  }
67  $tpl->assign('tags', $tpl_tags);
68  $output .= $tpl->fetch();
69  }
70  if ($return_mode) {
71  return $output;
72  } else {
73  echo $output;
74  }
75 }
76 
83 function sql_tagcloud($motclef)
84 {
85  $motclef = trim($motclef);
86 
87  if (!empty($motclef)) {
88  $result = query('SELECT id, nbsearch
89  FROM peel_tag_cloud
90  WHERE tag_name = "'.nohtml_real_escape_string($motclef).'" AND lang = "'.nohtml_real_escape_string($_SESSION['session_langue']).'" AND ' . get_filter_site_cond('tag_cloud'));
91  if ($enr = fetch_assoc($result)) {
92  query('UPDATE `peel_tag_cloud`
93  SET `nbsearch`=nbsearch+1
94  WHERE `id`="'.intval($enr['id']).'" AND ' . get_filter_site_cond('tag_cloud'));
95  } else {
96  query('INSERT INTO `peel_tag_cloud` (`tag_name`,`nbsearch`,`lang`,`site_id`)
97  VALUES ("'.nohtml_real_escape_string($motclef).'","1","'.nohtml_real_escape_string($_SESSION['session_langue']).'","'.nohtml_real_escape_string(get_site_id_sql_set_value($GLOBALS['site_id'])).'")');
98  }
99  }
100 }
101 
$result
if(!defined('IN_PEEL')) affiche_tagcloud($return_mode=false)
affiche_tagcloud()
Definition: fonctions.php:26
sql_tagcloud($motclef)
Insertion Tag de recherche.
Definition: fonctions.php:83
static strtolower($string)
Returns string with all alphabetic characters converted to lowercase.
Definition: String.php:135
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
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
real_escape_string($value)
real_escape_string()
Definition: database.php:374
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
num_rows($query_result)
num_rows()
Definition: database.php:321
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
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
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:04 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.