IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Architecture de classe


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Architecture de classe
    Bonjour, j'éprouve depuis un certain temps un problème d'architecture de classe.
    J'essaye de m'écrire un script de validation de forme....

    Ma forme est écrite en HTML insérée de balises <?PHP ?>, mais le problème n'est pas là....

    J'ai une classe Form, String & autres classes à venir.... car en fonction du type de champ, les validations sont très simililaires et l'intention est de les mettre dans une classe Validator......

    En finalité, et c'est le but final, j'affiche en bas de forme un msg fonction du nombre d'erreur rencontrée et du nombre de champ encore à remplir puis un OK final.... là je n'arrive jamais....

    Je mets mon code validate.php en pièce attachée et voici le log.php avec les points - que je juge délicat - en gras.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
     
    
    PHP Warning:  Update Screen[index] done ! in F:\WebSites\checkform\class\newScreen.php on line 127
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Screen->execute() F:\WebSites\checkform\class\newSkelt.php:174
    PHP   5. Screen->UpdScreen() F:\WebSites\checkform\class\newScreen.php:65
    PHP   6. user_error() F:\WebSites\checkform\class\newScreen.php:127
    PHP Notice:  String[__construct] [nom][ccccccccc][9] in F:\WebSites\checkform\class\validate.php on line 233
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Skeleton->displayPage() F:\WebSites\checkform\class\newSkelt.php:324
    PHP   5. require_once() F:\WebSites\checkform\class\newSkelt.php:405
    PHP   6. require_once() F:\WebSites\checkform\config\myPage.php:181
    PHP   7. String->__construct() F:\WebSites\checkform\doc\do_index.php:26
    PHP   8. user_error() F:\WebSites\checkform\class\validate.php:233
    PHP Notice:  ifFilled[nom][ccccccccc][9] in F:\WebSites\checkform\class\validate.php on line 258
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Skeleton->displayPage() F:\WebSites\checkform\class\newSkelt.php:324
    PHP   5. require_once() F:\WebSites\checkform\class\newSkelt.php:405
    PHP   6. require_once() F:\WebSites\checkform\config\myPage.php:181
    PHP   7. String->__construct() F:\WebSites\checkform\doc\do_index.php:26
    PHP   8. String->execute() F:\WebSites\checkform\class\validate.php:235
    PHP   9. String->ifFilled() F:\WebSites\checkform\class\validate.php:244
    PHP  10. user_error() F:\WebSites\checkform\class\validate.php:258
    PHP Notice:  ifFilled[nom][ccccccccc][9][1] in F:\WebSites\checkform\class\validate.php on line 263
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Skeleton->displayPage() F:\WebSites\checkform\class\newSkelt.php:324
    PHP   5. require_once() F:\WebSites\checkform\class\newSkelt.php:405
    PHP   6. require_once() F:\WebSites\checkform\config\myPage.php:181
    PHP   7. String->__construct() F:\WebSites\checkform\doc\do_index.php:26
    PHP   8. String->execute() F:\WebSites\checkform\class\validate.php:235
    PHP   9. String->ifFilled() F:\WebSites\checkform\class\validate.php:244
    PHP  10. user_error() F:\WebSites\checkform\class\validate.php:263
    PHP Notice:  ifFilled[nom][ccccccccc][9] in F:\WebSites\checkform\class\validate.php on line 258
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Skeleton->displayPage() F:\WebSites\checkform\class\newSkelt.php:324
    PHP   5. require_once() F:\WebSites\checkform\class\newSkelt.php:405
    PHP   6. require_once() F:\WebSites\checkform\config\myPage.php:181
    PHP   7. Form->__construct() F:\WebSites\checkform\doc\do_index.php:48
    PHP   8. Form->execute() F:\WebSites\checkform\class\validate.php:87
    PHP   9. String->execute() F:\WebSites\checkform\class\validate.php:114
    PHP  10. String->ifFilled() F:\WebSites\checkform\class\validate.php:244
    PHP  11. user_error() F:\WebSites\checkform\class\validate.php:258
    PHP Notice:  ifFilled[nom][ccccccccc][9][1] in F:\WebSites\checkform\class\validate.php on line 263
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Skeleton->displayPage() F:\WebSites\checkform\class\newSkelt.php:324
    PHP   5. require_once() F:\WebSites\checkform\class\newSkelt.php:405
    PHP   6. require_once() F:\WebSites\checkform\config\myPage.php:181
    PHP   7. Form->__construct() F:\WebSites\checkform\doc\do_index.php:48
    PHP   8. Form->execute() F:\WebSites\checkform\class\validate.php:87
    PHP   9. String->execute() F:\WebSites\checkform\class\validate.php:114
    PHP  10. String->ifFilled() F:\WebSites\checkform\class\validate.php:244
    PHP  11. user_error() F:\WebSites\checkform\class\validate.php:263
    PHP Notice:  stillFill[0] - cntFilled[0] in F:\WebSites\checkform\class\validate.php on line 149
    PHP Stack trace:
    PHP   1. {main}() F:\WebSites\checkform\index.php:0
    PHP   2. setScreen->execute() F:\WebSites\checkform\index.php:15
    PHP   3. Skeleton->execute() F:\WebSites\checkform\class\setScreen.php:154
    PHP   4. Skeleton->displayPage() F:\WebSites\checkform\class\newSkelt.php:324
    PHP   5. require_once() F:\WebSites\checkform\class\newSkelt.php:405
    PHP   6. require_once() F:\WebSites\checkform\config\myPage.php:181
    PHP   7. require_once() F:\WebSites\checkform\doc\do_index.php:72
    PHP   8. Form->getMsg() F:\WebSites\checkform\config\formdef.php:157
    PHP   9. user_error() F:\WebSites\checkform\class\validate.php:149
    Ma forme ne contient qu'un seul champ: ifFilled[nom][ccccccccc][9] qui contient 9 X "c" !

    Donc, selon mon idée;la variable cntFilled est incrémentée..... mais non !
    Pourquoi ? That's THE question !

    Lors de la définition de la forme, j'utilise String qui est instanciée...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    *	Instanciation de la FORME
    *	=========================
    */	
    	$cf = new Form(		$fields = array (  	new String   (  "nom"			,  	MUST  	,   Alpha			, 3		, 30 )  
    /* ,                           
     											new String   (  "prenom"		,  	MUST  	, 	Alpha			, 3		, 30 )  ,
     											new Email    (  "email"  		,  	MUST	, 	Mail 			, 8		, 30 )  ,
     											new Email    (  "cemail"  		,  	MUST	, 	Mail 			, 8		, 30 )  ,
    											new Phone  	 (  "phone"			, 	MUST 	, 	Num  			, 10	, 10 )  , 															                                            new Integer  (  "numero" 		,   MUST	, 	UINT			, 1		,  5 )  ,
    											new String   (  "boite"  		,  	OPT		, 	aNum    		, 1		,  5 )  ,
     											new String   (  "voie"			,  	MUST  	, 	aNumE			, 3		, 30 )  ,
     											new Integer  (  "zip"   		,  	MUST	, 	UINT 			, 5		,  5 )  ,
    											new Date     ( 	"date"			,	MUST						, 8		,  8 )  ,
     											new Select   (  "pays"  		,	MUST  	     							 )  ,
    											new Select   (  "question"		, 	MUST  	     							 )  ,
     											new String   (  "secretanswer"	,  	MUST  	,   Alpha			, 5		, 15 )  ,	                        
     											new Select   (  "job"  			,	MUST  	     							 )  ,
     											new Password (	"pass" 			,	MUST 	, 	aNum        	, 6 	,  8 )  ,
     											new Password (	"cpass" 		,	MUST 	, 	aNum        	, 6 	,  8 )  ,
    											new Textarea (  "text" 			,	MUST 	, 	aNumE   	 	, 10	,500 )  ,
    											new Same     (  "email" 		,	"cemail" 	                             ) 	,
    											new Same     (  "pass" 			,	"cpass" 	                             ) 
    */
    										),	
    						$debug=false
    					);

    Voilà.... cela fait bcp de question....

    Merci à ceussss qui se pencheront sur mon problème
    Fichiers attachés Fichiers attachés

  2. #2
    Membre Expert
    Avatar de gene69
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    1 769
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Janvier 2006
    Messages : 1 769
    Par défaut
    je suis embété ton fichier est illisible.

  3. #3
    Membre éclairé Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Par défaut Voici le fichier illisible
    Gene, comme annoncé voici le fichier illisible.....

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    <?php
     	require_once $_SERVER['DOCUMENT_ROOT'] . "/config/newFuncts.php";
     	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/define/equate.php";  
    
    define ("MISSING" 	, "Le champ [%s] est manquant, encodez le , svp !" ) ;
    define ("FLDLENGTH" , "Le champ [%s] doit avoir une longueur comprise entre %d et %d caractères !") ;
    define ("INVCAR" 	, "Le champ [%s] contient des caractères invalides !")    						;
    define ("UINTV"     , "Le champ [%s] n'est pas du type [unsigned integer <= 65536]")				;							
    define ("NOTZERO"	, "Pour le champ [%s] ,Vous devez faire un choix !")					                ;
    define ("NUMERIC"   , "contient un ou plusieurs caractères autres que 0 => 9 !")                    ;  
    define ("NOTSAME"	, "la zone [%s] doit être identique à la zone [%s] !")                          ;
                           
    /** =========================================================================================================================================================
    *	Start Of Class: STACK
    * ======================================================================================================================================================== */
    class Stack
    {	protected static $stackMsg = array();
    
    	public static $cntStack = 0 ;
    					
    	function __construct()
    	{	$this->emptyStack() ;  	}
     				
    	function __destruct()
    	{}
    				
    //  ==================================	
    //  All Error Stacking functions			
    //  ==================================	
    	public function getCntStack()
    	{	return(self::$cntStack) ; }	
    
    	public function getStackError() 				// Public car function appelée fu formulaire...
    	{	$str = "" ; 
    		for ($i = 0 ; $i < self::$cntStack ; $i++) {
    			$str .= self::$stackMsg[$i] ;
    		}
    		return($str) ; 
    	}
    
    	public function stackMessage($msg)
    	{	self::$stackMsg[self::$cntStack++] = $msg . "\n" ; 
    	}
    				
    	public function emptyStack()
    	{	self::$cntStack = 0 ;
    		self::$stackMsg = array() ;	 
    	}
    }
    /** =========================================================================================================================================================
    *	End Of Class: STACK
    * ======================================================================================================================================================== */
    
    		
    /** =========================================================================================================================================================
    *	Start Of Class: FORM
    * ======================================================================================================================================================== */
    class Form extends Stack
    {	private   		$form ;
    	private   		$name, $must, $type, $minL, $maxL, $value, $len, $debug ;
    	protected		$cntFilled = 0, $stillFill = 0 ;
    					
    	const 	VIDE 	= 0		,
    			KO		= -1 	,
    			OK		= 1		,
    			STILL	= 9 	;
    	
    	private   	$msg, $tabMsg = array	( 	VIDE => "Prêt à recevoir l'encodade de votre formulaire"     		,
    											KO    => "Veuillez corriger les fautes/complètez votre formulaire"  ,
    											OK    => "Parfait, pas(plus) d'erreur(s) dans ce formulaire"  		,
    											STILL => "Il y a encore des champs obligatoires à rempir !" 
    										) ; 
    	
    	protected $firstLevel  = array	( STRING	,	INTEGER	,	EMAIL	,	PASSWORD	,	TEXTAREA	,	PHONE	,	DATE	,	SELECT	) ;
    	protected $secondLevel = array	( SAME	) ;
    /**
    *		constructor
    *		===========
    */	
    		function __construct(array $form, $debug=false)
    		{   $this->form       = $form ;
    			$this->cntField   = count($this->form) ; 
    			$this->debug      = $debug ;
    			$this->stack      = new Stack($this->debug) ;
    				
    			$this->execute() ;
    		}
    
    /**
    * 			constructor
    *			===========
    */	
    		function execute()
    		{	$this->cntField  = count($this->form) ;
    /**
    * 			First Level Validation 
    *			======================
    */	
    			for($i = 0 ; $i < $this->cntField ; $i++) 
    			{	$this->class = get_class($this->form[$i]) ;
    				if (in_array($this->class,$this->firstLevel))
    					{	$this->field = $this->form[$i] ;
    						$this->name  = $this->form[$i]->name ;
    						$this->must  = $this->form[$i]->must ;
    						$this->type  = $this->form[$i]->type ;
    						$this->minL  = $this->form[$i]->minL ;
    						$this->maxL  = $this->form[$i]->maxL ;
    						$this->value = (isset($_POST[$this->name])) ? trim($_POST[$this->name]) : NULL ;
    						$this->len   = strlen($this->value) ;
    
    						switch($this->class) 
    						{	case STRING		:  	//$result = new string($this->name,$this->must,$this->type,$this->minL,$this->maxL) ;
    												$result = $this->form[$i]->execute() ;
    												break ;
    						}			
    					}
    			}
    /**
    * 			Second Level Validation 
    *			=======================
    */	
    			for($i = 0 ; $i < $this->cntField ; $i++) 
    			{	$this->class = get_class($this->form[$i]) ;
    				if (in_array($this->class,$this->secondLevel))
    					{	$result = $this->form[$i] ;
    //						$result = new Field($field, $this->debug) ;
    					}
    			}
    		}
    			
    /**
    * 		__destruct
    *		========
    */	
    		function __destruct()
    		{	 }
    
    /**
    * 	getMsg
    *	======
    */	
    	function getMsg()                   		// Public car function appelée du formulaire...
    	{	
    //
    //		affichage du message inférieur
    //		==============================			
    		if ($this->isFormValid() )
    		 	{	user_error("stillFill[".$this->stillFill."] - cntFilled[".$this->cntFilled."]" , E_USER_NOTICE) ;
    			
    				if ($this->cntFilled)
    					if ($this->stillFill)
    						$this->msg = STILL ;
    					else
    						$this->msg = OK ;
    				else
    					if ($this->stillFill)
    						$this->msg = STILL ;
    					else
    						$this->msg = VIDE ;
    			}
    		else
    			{	if ($this->cntFilled)
    					if ($this->stillFill)
    						$this->msg = STILL ;
    					else
    						$this->msg = KO ;
    				else
    					if ($this->stillFill)
    						$this->msg = STILL ;
    					else
    						$this->msg = KO ;
    			}
    			
    		return( $this->tabMsg[$this->msg] ) ;  
    	}
    /**
    * 	getCntError
    *	===========
    */	
    	function getCntError()
    	{ 	if ($this->debug)
    			user_error("cntStack[".$this->getCntStack()."]", E_USER_NOTICE) ;
    		return($this->getCntStack()) ;	
    	}       
    
    /**
    * 	isFormValid
    *	===========
    */	
    	function isFormValid()
    	{ 	if ($this->debug)
    			user_error("cntStack[".$this->getCntStack()."]", E_USER_NOTICE) ;
    		return($this->getCntStack() == 0) ;	
    	}       
    /**
    *	display
    *	=======
    */	
    	function display()
    	{	for($i = 0 ; $i < $this->cntField ; $i++) 
    		{	}
    	}
    	
    }
    /** =========================================================================================================================================================
    *	End Of Class: FORM
    * ======================================================================================================================================================== */
    
    
    
    
    
    /** =========================================================================================================================================================
    *	Start Of Class: STRING
    * ======================================================================================================================================================== */
    //
    //	"prenom" ,  ON  , 	aE   , 3, 30 
    //
    class String extends Form
    {	private   	$name, $must, $type, $minL, $maxL, $debug ;
    	private   	$value, $len ;
    	protected	$cntFilled, $stillFill ;
    
    	function __construct($name, $must, $type, $minL, $maxL)
    	{	$this->name   = $name  ;
    		$this->must   = $must  ;
    		$this->type   = $type  ;
    		$this->minL   = $minL  ;
    		$this->maxL   = $maxL  ;
    		$this->value  = (isset($_POST[$this->name])) ? trim($_POST[$this->name]) : NULL ;
    		$this->len    = strlen($this->value) ;
    				
    //		$this->execute() ;
    	}
    	
    	function __destruct()
    	{}
    	
    	function execute()
    	{	user_error("String[execute] [".$this->name."][".$this->value."][".$this->len."]" , E_USER_NOTICE) ;
    
    		if ($this->ifFilled())  
    			{	$this->cntFilled++ ;
    				if ($this->ifRange() )
    					return($this->validate()) ;   
    				else
    					return(false) ;
    			}
    		else
    			if ($this->mustFill() ) 
    				{	$this->stillFill++ ;
    					return(false) ;
    				}
    			else
    				return(true) ;
    	}
    	
    /**
    *	ifFilled
    *	=======
    */	
    	function ifFilled()
    	{	
    ***** 263 ==>
    user_error("ifFilled[".$this->name."][".$this->value."][".$this->len."]" , E_USER_NOTICE) ;
    		if ((!empty($this->value)) == true)
    			{	
    //				if ($this->debug)
    ***** 267 ==>
    user_error("ifFilled[".$this->name."][".$this->value."][".$this->len."]" , E_USER_NOTICE) ;
    				return(true) ;
    			}
    		else
    			return(false) ;
    	}
    
    /**
    * 	ifRange
    *
    *	chkRange - définit dans newFunct.php
    */	
     	function ifRange() {
    		if ( $this->chkRange($this->value, $this->minL, $this->maxL) )
    			return(true) ;
    		else
    			{	$this->msg = sprintf(FLDLENGTH,$this->name,$this->minL,$this->maxL) ;
    				$this->stackMessage($this->msg) ;
    			}
    		return(false) ;
    	}
    
    /**
    * 	mustFill
    *
    */	
    	function mustFill() {
    		if ($this->must) 
    			{	$this->msg = sprintf("Le champ[%s] doit être encodé !", $this->name) ;
    		$this->stillFill++ ;
    				$this->stackMessage($this->msg) ;
    			}
    //		if ($this->debug)
    //			user_error("mustFill[".$this->msg."]" , E_USER_NOTICE) ;   
    	    return( (bool) $this->must) ;
    	}
    	
    /**
    * 	chkRange (
    *
    */	
        function chkRange( $value, $minL, $maxL ) {
    		$len = strlen($value) ;
    		return( ($minL <= $len && $len <= $maxL) ? true : false ) ; 
    	}
    	
    /**
    * 	validate
    *
    */	
    	function validate() {
    		switch($this->type) 
    		{	case Alpha    	:	if ( ctype_alpha($this->value) )  // a -> z qlque soit la case
    									return(true) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    									
    			case aE			:	if ( preg_match("^[a-zA-Z]{".$this->len."}$^", $this->value) )  
    									return(true) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    								
    		 	case aNum      	:	if ( ctype_alnum($this->value) )  // a -> z qlque soit la case  
    									return(true) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    								
    		 	case Num      	:	if ( is_numeric($this->value) )  
    									return(true) ;
    								else
    									return($this->message($this->name, NUMERIC)) ;
    								
    		 	case aNumE      :	if ( preg_match("^[a-z]|[A-Z][0-9]|[,.:;/]{".$this->len."}$^", $this->value) )  
    									return(true) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    								
    			case Mail      	:	if ( filter_var ( $this->value, FILTER_VALIDATE_EMAIL) )		 
    									return(true) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    								
    			case URL       	:	if ( filter_var ( $this->value, FILTER_VALIDATE_URL  )  )
    									return(true) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    			
    			case UINT		:	if ( is_numeric($this->value) )  
    									if ($this->value <= UINTV)
    									   	return(true) ;
    									else
    										return($this->message($this->name, UINTV)) ;
    								else
    									{	$this->stackMessage(sprintf(INVCAR , $this->name )) ;
    										return(false) ;
    									}
    								
    			default			:	throw new Exception("Invalid Type in [Validate][".$this->type."] class[2] !") 	;
    		}
    	}
    
    /**
    *	display
    *	=======
    */	
    	function display()
    	{	
    	}
    }
    /** =========================================================================================================================================================
    *	End Of Class: STRING
    * ======================================================================================================================================================== */
    
    bla bla bla mais pas impliqué pour l'instant.....
    Merci Gene

Discussions similaires

  1. Architecture de classe pour POO
    Par LegGohan dans le forum Langage
    Réponses: 7
    Dernier message: 09/11/2011, 10h28
  2. [PHP 5.3] Architecture de classes, découpage et héritage
    Par ETVigan dans le forum Langage
    Réponses: 4
    Dernier message: 23/09/2010, 14h55
  3. Réponses: 4
    Dernier message: 12/06/2009, 10h50
  4. Architecture, Operator, classe abstraite
    Par neptune dans le forum C#
    Réponses: 2
    Dernier message: 03/06/2008, 11h30
  5. [c++]Architecture des classes pour un jeu
    Par Pegasus32 dans le forum C++
    Réponses: 23
    Dernier message: 16/02/2005, 14h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo