PEEL Shopping
Open source ecommerce : PEEL Shopping
meta.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: meta.php 46935 2015-09-18 08:49:48Z gboussin $
14 
15 define('IN_PEEL_ADMIN', true);
16 include("../configuration.inc.php");
18 necessite_priv("admin_content,admin_webmastering");
19 
20 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_ADMIN_META_PAGE_TITLE'];
21 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
22 
23 $id = vb($_REQUEST['id']);
24 
26 $frm = $_POST;
27 
28 switch (vb($_REQUEST['mode'])) {
29  case "ajout" :
31  break;
32 
33  case "modif" :
35  break;
36 
37  case "suppr" :
40  break;
41 
42  case "insere" :
43  case "maj" :
44  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
45  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
46  }
47  if (!$form_error_object->count()) {
48  maj_meta($_POST['id'], $_POST);
50  } else {
51  if ($form_error_object->has_error('token')) {
52  echo $form_error_object->text('token');
53  }
54  if(!empty($_GET['id'])) {
55  affiche_formulaire_modif_meta($_GET['id'], $frm);
56  } else {
58  }
59  }
60  break;
61 
62  default :
64  break;
65 }
66 
67 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
68 
81 {
82  if(empty($frm)){
83  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
84  $qid = query("SELECT *
85  FROM peel_meta
86  WHERE id = " . intval($id) . " AND " . get_filter_site_cond('meta', null, true));
87  $frm = fetch_assoc($qid);
88  }
89  if (!empty($frm)) {
90  $frm["nouveau_mode"] = "maj";
91  $frm["titre_bouton"] = $GLOBALS['STR_ADMIN_FORM_SAVE_CHANGES'];
93  } else {
94  redirect_and_die(get_current_url(false).'?mode=ajout');
95  }
96 }
97 
105 {
106  /* Valeurs par défaut */
107  if(empty($frm)) {
108  $frm = array();
109  $frm['technical_code'] = "";
110  }
111  $frm['nouveau_mode'] = "insere";
112  $frm['id'] = "";
113  $frm['site_id'] = "";
114  $frm['titre_bouton'] = $GLOBALS['STR_ADMIN_ADD'];
115 
117 }
118 
126 {
127  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_formulaire_meta.tpl');
128  $tpl->assign('action', get_current_url(false) . '?start=0');
129  $tpl->assign('form_token', get_form_token_input($_SERVER['PHP_SELF'] . $frm['nouveau_mode'] . intval($frm['id'])));
130  $tpl->assign('mode', $frm["nouveau_mode"]);
131  $tpl->assign('id', intval($frm['id']));
132  $tpl_langs = array();
133  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
134  $tpl_langs[] = array('lng' => $lng,
135  'meta_titre' => vb($frm['meta_titre_' . $lng]),
136  'meta_key' => vb($frm['meta_key_' . $lng]),
137  'meta_desc' => vb($frm['meta_desc_' . $lng]),
138  );
139  }
140  $tpl->assign('langs', $tpl_langs);
141  $tpl->assign('technical_code', vb($frm['technical_code']));
142  $tpl->assign('titre_bouton', $frm['titre_bouton']);
143  $tpl->assign('site_id_select_options', get_site_id_select_options(vb($frm['site_id'])));
144  $tpl->assign('site_id_select_multiple', !empty($GLOBALS['site_parameters']['multisite_using_array_for_site_id']));
145  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
146  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
147  $tpl->assign('STR_OR', $GLOBALS['STR_OR']);
148  $tpl->assign('STR_ADMIN_META_PAGE_TITLE', $GLOBALS['STR_ADMIN_META_PAGE_TITLE']);
149  $tpl->assign('STR_ADMIN_LANGUAGES_SECTION_HEADER', $GLOBALS['STR_ADMIN_LANGUAGES_SECTION_HEADER']);
150  $tpl->assign('STR_ADMIN_META_TITLE', $GLOBALS['STR_ADMIN_META_TITLE']);
151  $tpl->assign('STR_ADMIN_META_KEYWORDS', $GLOBALS['STR_ADMIN_META_KEYWORDS']);
152  $tpl->assign('STR_ADMIN_SEPARATE_KEYWORDS_EXPLAIN', $GLOBALS['STR_ADMIN_SEPARATE_KEYWORDS_EXPLAIN']);
153  $tpl->assign('STR_ADMIN_META_DESCRIPTION', $GLOBALS['STR_ADMIN_META_DESCRIPTION']);
154  $tpl->assign('STR_ADMIN_VARIOUS_INFORMATION_HEADER', $GLOBALS['STR_ADMIN_VARIOUS_INFORMATION_HEADER']);
155  $tpl->assign('STR_ADMIN_TECHNICAL_CODE', $GLOBALS['STR_ADMIN_TECHNICAL_CODE']);
156  echo $tpl->fetch();
157 }
158 
166 {
167  /* Efface le meta */
168  query("DELETE FROM peel_meta WHERE id = " . intval($id) . " AND " . get_filter_site_cond('meta', null, true));
169  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_META_META_DELETED'], $id)))->fetch();
170 }
171 
179 function maj_meta($id, $frm)
180 {
181  if(empty($id)) {
182  $sql = 'INSERT INTO';
183  } else {
184  $sql = 'UPDATE';
185  }
186  $sql .= ' peel_meta SET
187  technical_code = "' . nohtml_real_escape_string($frm['technical_code']) . '"
188  , site_id = "' . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . '"
189  ';
190  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
191  $sql .= '
192  , meta_titre_' . $lng . ' = "' . nohtml_real_escape_string($frm['meta_titre_' . $lng]) . '"
193  , meta_key_' . $lng . ' = "' . nohtml_real_escape_string($frm['meta_key_' . $lng]) . '"
194  , meta_desc_' . $lng . ' = "' . nohtml_real_escape_string($frm['meta_desc_' . $lng]) . '"';
195  }
196  if(!empty($id)) {
197  $sql .= '
198  WHERE id = ' . intval($id) . " AND " . get_filter_site_cond('meta', null, true);
199  }
200  /* Met à jour la table meta */
201  $qid = query($sql);
202 }
203 
210 {
211  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_liste_meta.tpl');
212 
213  $anchor = '';
214  $result = query("SELECT *
215  FROM peel_meta
216  WHERE " . get_filter_site_cond('meta', null, true));
217  if (!(num_rows($result) == 0)) {
218  $tpl_results = array();
219  while ($ligne = fetch_assoc($result)) {
220  // On génère le lien vers les métas ici :
221  // - si le titre est vide, on se sert de la description, sinon des mots clés
222  $meta_titre = String::html_entity_decode_if_needed(trim($ligne['meta_titre_' . $_SESSION['session_langue']]));
223  $meta_desc = String::html_entity_decode_if_needed(trim($ligne['meta_desc_' . $_SESSION['session_langue']]));
224  $meta_key = String::html_entity_decode_if_needed(trim($ligne['meta_key_' . $_SESSION['session_langue']]));
225  $anchor= '';
226  if (!empty($meta_titre)) {
227  $anchor = $meta_titre;
228  } elseif (!empty($meta_desc)) {
229  $anchor = $meta_desc;
230  } elseif (!empty($meta_key)) {
231  $meta_key_array = explode(',', $meta_key);
232  for ($i = 0; $i < 4; $i++) {
233  $anchor .= $meta_key_array[$i] . ' ';
234  }
235  $anchor .= ' ...';
236  }
237  if(empty($anchor)) {
238  $anchor .= '['.$ligne['id'].']';
239  }
240  $tpl_results[] = array('href' => get_current_url(false) . '?mode=modif&id=' . $ligne['id'],
241  'technical_code' => $ligne['technical_code'],
242  'anchor' => $anchor,
243  'site_name' => get_site_name($ligne['site_id']),
244  'drop_href' => get_current_url(false) . '?mode=suppr&id=' . $ligne['id']
245  );
246  }
247  $tpl->assign('results', $tpl_results);
248  }
249  $tpl->assign('administrer_url', $GLOBALS['administrer_url']);
250  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
251  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
252  $tpl->assign('STR_ADMIN_ADD', $GLOBALS['STR_ADMIN_ADD']);
253  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
254  $tpl->assign('STR_ADMIN_META_PAGE_TITLE', $GLOBALS['STR_ADMIN_META_PAGE_TITLE']);
255  $tpl->assign('STR_ADMIN_META_UPDATE', $GLOBALS['STR_ADMIN_META_UPDATE']);
256  $tpl->assign('STR_ADMIN_META_EMPTY_EXPLAIN', $GLOBALS['STR_ADMIN_META_EMPTY_EXPLAIN']);
257  echo $tpl->fetch();
258 }
259 
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
$result
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
$form_error_object
Definition: meta.php:25
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
$tpl_langs
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
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
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
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
$id
Definition: meta.php:23
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
supprime_meta($id)
Supprime le meta spécifié par $id.
Definition: meta.php:165
affiche_formulaire_modif_meta($id, &$frm)
FONCTIONS.
Definition: meta.php:80
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
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
$frm
Definition: meta.php:26
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
maj_meta($id, $frm)
Met à jour le meta $id avec de nouvelles valeurs.
Definition: meta.php:179
affiche_formulaire_meta(&$frm)
affiche_formulaire_meta()
Definition: meta.php:125
affiche_formulaire_ajout_meta(&$frm)
Affiche un formulaire vierge pour ajouter une information de meta.
Definition: meta.php:104
$GLOBALS['DOC_TITLE']
Definition: meta.php:20
get_form_token_input($name= 'general', $use_existing_token=true, $return_as_input_form=true)
get_form_token_input()
Definition: fonctions.php:94
affiche_liste_meta()
affiche_liste_meta()
Definition: meta.php:209
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
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:29:16 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.