PEEL Shopping
Open source ecommerce : PEEL Shopping
FormError.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: FormError.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
27 class FormError {
28  var $error = array();
29 
36  function bg($name)
37  {
38  if (isset($this->error[$name])) {
39  return ' class="form_item_error"';
40  }
41  }
42 
49  function text($name = null)
50  {
51  if (!empty($name) && isset($this->error[$name])) {
52  $output = ((!empty($this->error[$name])) ? $this->error[$name] : $GLOBALS['STR_EMPTY_FIELD']);
53  } elseif (empty($name) && $this->count()) {
54  $output = '';
55  foreach($this->error as $this_name => $this_value) {
56  if (!empty($this->error[$this_name])) {
57  $output .= $this->error[$this_name];
58  } else {
59  $output .= '[' . $this_name . ']' . $GLOBALS['STR_BEFORE_TWO_POINTS'] . ': ' . $GLOBALS['STR_EMPTY_FIELD'];
60  }
61  $output .= '<br />';
62  }
63  }
64  if(!empty($output)) {
65  return $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $output))->fetch();
66  } else {
67  return false;
68  }
69  }
70 
78  function add($name, $text = null)
79  {
80  $this->error[$name] = ($text ? $text : '');
81  }
82 
89  function has_error($name)
90  {
91  return isset($this->error[$name]);
92  }
93 
99  function count()
100  {
101  return count($this->error);
102  }
103 
113  function valide_form(&$frm, $error_field_messages_array = array(), $field_minimal_lengths_array = array(), $field_validation_function_names_array = array())
114  {
115  if(!empty($error_field_messages_array)) {
116  foreach($error_field_messages_array as $this_field => $this_message) {
117  if ((empty($frm[$this_field]) || (is_array($frm[$this_field]) && count($frm[$this_field]) == 0)) || (!empty($field_minimal_lengths_array[$this_field]) && String::strlen($frm[$this_field])<$field_minimal_lengths_array[$this_field]) || (!empty($field_validation_function_names_array[$this_field]) && $field_validation_function_names_array[$this_field]($frm[$this_field]) === false)) {
118  if(String::substr($this_message, 0, 4) == 'STR_' && isset($GLOBALS[$this_message])) {
119  $this_text = $GLOBALS[$this_message];
120  } else {
121  $this_text = $this_message;
122  }
123  $this->add($this_field, $this_text);
124  }
125  }
126  }
127  }
128 }
129 
if(!empty($GLOBALS['site_parameters']['order_specific_field_titles'])) if(check_if_module_active('socolissimo')&&!empty($_REQUEST)&&!empty($_REQUEST['PUDOFOID'])&&!empty($_REQUEST['CEEMAIL'])&&!empty($_REQUEST['SIGNATURE'])&&!empty($_REQUEST['ORDERID'])) elseif(!empty($_POST)) elseif(check_if_module_active('socolissimo')&&!empty($_SESSION['session_commande']['is_socolissimo_order'])) foreach(array('bill'=> 1, 'ship'=> 2) as $address_type=> $session_commande_address_id) $frm['societe1']
text($name=null)
formError::text()
Definition: FormError.php:49
bg($name)
formError::bg()
Definition: FormError.php:36
static strlen($string)
Returns the length of the given string.
Definition: String.php:36
has_error($name)
formError::has_error()
Definition: FormError.php:89
add($name, $text=null)
formError::add()
Definition: FormError.php:78
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
$GLOBALS['page_columns_count']
count()
formError::count()
Definition: FormError.php:99
valide_form(&$frm, $error_field_messages_array=array(), $field_minimal_lengths_array=array(), $field_validation_function_names_array=array())
Valide les informations d'un tableau de données et ajoute des erreurs à l'objet d'erreur si nécessair...
Definition: FormError.php:113
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
Definition: String.php:112

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