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 :

Class et syntaxe & errmsg incompris ! [PHP 5.3]


Sujet :

Langage PHP

  1. #21
    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 Class et syntaxe & errmsg incompris !
    Voilà mosieur...

    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
    		class Stack extends Checkform
    		{	private $stackMsg = array(), $cntStack = 0 ;
     
    			function __construct()
    			{	$this->emptyStack() ;  	}
     
    			function __destruct()
    			{}
     
    			public function stackMessage($msg)
    			{	$this->stackMsg[] = $msg . "<br>\n" ; 
    				$this->cntStack++ ; 
     				print("Stacking[".$msg."] - cntStack[".$this->cntStack."]") ;
    				print_r($this->stackMsg); 
    			}
     
    			public function getStackError()
    			{	$str = "" ; 
    				print("getStackError[".self::cntStack."]") ;
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					$str .= $this->stackMsg[$i] ;
    				return($str) ; 
    			}
     
    			private function emptyStack()
    			{	$this->cntStack = 0 ;
    				$this->stackMsg = array() ;	 
    			}
    		}
    //	========================================================================================================================================================== //
    //		MAIN CLASS:   =========>>>>>>  CheckForm	
    //	========================================================================================================================================================== //
        	class Checkform
    		{	private $msg, $form, $cntField, $cntFilled, $valid, $stack ;
     
    			function __construct($form)
    			{	# On calcule le nombre d'entrée du tableau
        			$this->form  	  = $form ;
    				$this->cntField   = count($this->form);
    				$this->formValid  = false ;
     
    //				$this->stack = new Stack() ;
    //
    //              Error Handler
    //				=============				
    				try {
    					$this->Validate() ;
    				}	catch (Exception $E)
    					{	$this->exception_handler($E) ; }
    #
    #				Choix du message en fonction du nbre de champ remplit OUI || NON (qui sera délivré par getMessage)
    #				==================================================================================================	
    				$this->msg = new Message($this->cntFilled,$this->cntField) ;
     
    			}
     
    			private function getCountFields()
    			{ 	return($this->cntField) ;	}
     
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			public function getStackError()
    			{	print("getStackErrorCF") ;
    				return(Stack::getStackError() ) ; }
     
    			public function stackMessage($msg)
    			{	print("stackMessageCF") ;
    				Stack::stackMessage($msg) ; 
    			}
    //          ==================================	
    //          All Screen message area routines			
    //          ==================================	
    			public function getMessage()
    			{	return($this->msg->getMessage()) ;  	}
    //          ==================================	
     
    			public function isFormValid()
    			{	return($this->formValid) ; }
     
    			protected function chkRange($name,$value,$minl,$maxl)
    			{	$len = strlen($value) ;
    				print("ChkRange[".$value."][".$len."][".$minl."][".$maxl."]") ;
    				if ( ( $len >= $minl && $len <= $maxl) )  
    					return(true) ;
    				else
    					{	$msg = "Le champ[".$name."] doit avoir une longueur comprise entre ".$minl." et ".$maxl ;
    					    $this->stackMessage($msg) ;
    						return(false) ;
    					}
    			}
     
    			public function Validate()
    			{	$this->cntFilled = 0 ;
     
    				for($i = 0 ; $i < $this->getCountFields() ; $i++) 
    				{	if ($this->form[$i] instanceof Validator)
    						if ($this->form[$i]->Filled() )
    							{	$this->cntFilled++ ;
    								$this->form[$i]->Validate() ;
    							}
    				}
    			}
    //
    //          Error Handler Processing
    //			========================	
    			function exception_handler($E)
    			{	$T = $E->getTrace() ; 
    			//	======================================================================
    				print("FORM Validator error diagnostic" .  "<br>\n") ;
    				print("=======================" .  "<br>\n") ;
     				print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
    				print("<br>\n") ;
    				print("Trace: " . "<br>\n") ;
    				print("------ " . "<br>\n") ;
    				print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
    				print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
     				print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
    				print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
    				//	======================================================================
    				user_error("Connexion error in File: (" . $E->getFile() . ") - line: (" . $E->getLine() . ")" , E_USER_WARNING) ;  
       			}
    //	
    //      End of class CheckForm
    //		======================		
    		}

  2. #22
    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 Class et syntaxe & errmsg incompris !
    Par rapport à hier, quelque chose à changé car j'imprime bien le stack....

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    stackMessageCFStacking[Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - 
    
    cntStack[4]
    
    Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [2] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [3] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    )
    Les msgs sont de l'ordre du debugging mais au moment de l'insertion du msg, le stack est correct !

  3. #23
    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 classe et msg incompri....
    Mais tu as les deux l'une en dessous de l'autre dans la même fenêtre

  4. #24
    Membre Expert Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Par défaut
    Je percute pas depuis ce matin

    Mais :

    ta methode stackMessage() l'attaque tu via un objet ou une classe ? Car je vois ca :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
     
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			public function getStackError()
    			{	print("getStackErrorCF") ;
    				return(Stack::getStackError() ) ; }
     
    			public function stackMessage($msg)
    			{	print("stackMessageCF") ;
    				Stack::stackMessage($msg) ; 
    			}

    Mais si tu l'attaque en static via ta classe (et donc pas en objet), tu ne peux pas utiliser les propiétés $this->cntStack comme tu n'as d'objet de cette classe d'où ton message

    [26-May-2010 15:37:01] PHP Notice: Undefined property: Checkform::$cntStack in F:\WebSites\test\checkform.php on line 500
    C'est à priori aussi simple que ca et c'est ce qui expliquait que j'avais pas d'erreurs vu que j'attaquais Stack avec un objet et non en static

  5. #25
    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 Class..... vous avez dit facile......
    Dans chaque validation, je suis susceptible d'ajouter un msg dans le stack, tu as un appel d'ailleurs dans ChkRange un peu + bas dans la classe CF

  6. #26
    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 Class et syntaxe & errmsg incompris !
    Pige pas ton propos sur le "static" ....

  7. #27
    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 Class et syntaxe & errmsg incompris !
    J'ai essayé comme ceci !

    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
        	class Checkform
    		{	private $msg, $form, $cntField, $cntFilled, $valid, $stack ;
    	
    			function __construct($form)
    			{	# On calcule le nombre d'entrée du tableau
        			$this->form  	  = $form ;
    				$this->cntField   = count($this->form);
    				$this->formValid  = false ;
    
    				$this->stack = new Stack() ;
    //
    //              Error Handler
    //				=============				
    				try {
    					$this->Validate() ;
    				}	catch (Exception $E)
    					{	$this->exception_handler($E) ; }
    #
    #				Choix du message en fonction du nbre de champ remplit OUI || NON (qui sera délivré par getMessage)
    #				==================================================================================================	
    				$this->msg = new Message($this->cntFilled,$this->cntField) ;
    				
    			}
    			
    			private function getCountFields()
    			{ 	return($this->cntField) ;	}
    			
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			public function getStackError()
    			{	print("getStackErrorCF") ;
    				return($this->stack->getStackError() ) ; }
    			
    			public function stackMessage($msg)
    			{	print("stackMessageCF") ;
    550 ==>		$this->stack->stackMessage($msg) ; 
    			}

    Le log me donne:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    [26-May-2010 16:23:21] PHP Notice:  Validating TEXT[xs] in F:\WebSites\test\checkform.php on line 414
    [26-May-2010 16:23:21] PHP Fatal error:  Call to a member function stackMessage() on a non-object in F:\WebSites\test\checkform.php on line 550

  8. #28
    Membre Expert Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Par défaut
    Je saisi pas pourquoi tu veux attaquer getStackError() par ta classe parent ? ne serait ce pas plus simple de créer un objet de ta classe fille et d'attaquer ta methode d'attaquer fille par ton objet ? Tu as une contrainte sur ce choix ou..?

  9. #29
    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 Class..... vous avez dit facile......
    Je crois que la raison est simple, la méthode getStackError est utilisée par la page HTML pour affichage.... et celle-ci se fout pas mal de tout le reste.... et ne tient pas à connaitre les autres classes...

    Voila pkoi - peut être je me trompe - j'ai faut ce choix d'architecture....
    Quel préténtion, et un coup de pied dans les chevilles

  10. #30
    Membre Expert Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Par défaut
    Sinon bizarre mais j'ai pas encore d'erreur ^^

    [MOD=abus]
    Il faudrait que tu redonnes la derniere version de checkform et Stack
    [/MOD]

  11. #31
    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 Class OOP vous avez dit facile ?
    Voici le dernier test effectué, j'instancie Stack de la même façon que Message....

    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
    //	========================================================================================================================================================== //
    //		STACK	
    //	========================================================================================================================================================== //
    		class Stack  
    		{	private $stackMsg = array(), $cntStack = 0 ;
    					
    			function __construct()
    			{	$this->emptyStack() ;  	}
    				
    			function __destruct()
    			{}
    				
    			public function getStackError()
    			{	$str = "" ; 
    				print("getStackError[".$this->cntStack."]") ;
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					$str .= $this->stackMsg[$i] ;
    				return($str) ; 
    			}
    				
    			public function stackMessage($msg)
    			{	$this->stackMsg[] = $msg . "<br>\n" ; 
    				$this->cntStack++ ; 
     				print("Stacking[".$msg."] - cntStack[".$this->cntStack."]") ;
    				print_r($this->stackMsg); 
    			}
    				
    			private function emptyStack()
    			{	$this->cntStack = 0 ;
    				$this->stackMsg = array() ;	 
    			}
    		}
    //	========================================================================================================================================================== //
    //		MAIN CLASS:   =========>>>>>>  CheckForm	
    //	========================================================================================================================================================== //
        	class Checkform
    		{	private $msg, $form, $cntField, $cntFilled, $valid, $stack ;
    	
    			function __construct($form)
    			{	# On calcule le nombre d'entrée du tableau
        			$this->form  	  = $form ;
    				$this->cntField   = count($this->form);
    				$this->formValid  = false ;
    
    				$this->stack = new Stack() ;
    //
    //              Error Handler
    //				=============				
    				try {
    					$this->Validate() ;
    				}	catch (Exception $E)
    					{	$this->exception_handler($E) ; }
    #
    #				Choix du message en fonction du nbre de champ remplit OUI || NON (qui sera délivré par getMessage)
    #				==================================================================================================	
    				$this->msg = new Message($this->cntFilled,$this->cntField) ;
    				
    			}
    			
    			private function getCountFields()
    			{ 	return($this->cntField) ;	}
    			
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			public function getStackError()
    			{	print("getStackErrorCF") ;
    				return($this->stack->getStackError() ) ; }
    			
    			public function stackMessage($msg)
    			{	print("stackMessageCF") ;
    550 ==>		$this->stack->stackMessage($msg) ; 
    			}
    //          ==================================	
    //          All Screen message area routines			
    //          ==================================	
    			public function getMessage()
    			{	return($this->msg->getMessage()) ;  	}
    //          ==================================	
    
    			public function isFormValid()
    			{	return($this->formValid) ; }
    
    			protected function chkRange($name,$value,$minl,$maxl)
    			{	$len = strlen($value) ;
    				print("ChkRange[".$value."][".$len."][".$minl."][".$maxl."]") ;
    				if ( ( $len >= $minl && $len <= $maxl) )  
    					return(true) ;
    				else
    					{	$msg = "Le champ[".$name."] doit avoir une longueur comprise entre ".$minl." et ".$maxl ;
    					    $this->stackMessage($msg) ;
    						return(false) ;
    					}
    			}
    			
    			public function Validate()
    			{	$this->cntFilled = 0 ;
    			
    				for($i = 0 ; $i < $this->getCountFields() ; $i++) 
    				{	if ($this->form[$i] instanceof Validator)
    						if ($this->form[$i]->Filled() )
    							{	$this->cntFilled++ ;
    								$this->form[$i]->Validate() ;
    							}
    				}
    			}
    //
    //          Error Handler Processing
    //			========================	
    			function exception_handler($E)
    			{	$T = $E->getTrace() ; 
    			//	======================================================================
    				print("FORM Validator error diagnostic" .  "<br>\n") ;
    				print("=======================" .  "<br>\n") ;
     				print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
    				print("<br>\n") ;
    				print("Trace: " . "<br>\n") ;
    				print("------ " . "<br>\n") ;
    				print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
    				print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
     				print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
    				print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
    				//	======================================================================
    				user_error("Connexion error in File: (" . $E->getFile() . ") - line: (" . $E->getLine() . ")" , E_USER_WARNING) ;  
       			}
    //	
    //      End of class CheckForm
    //		======================		
    		}
    Et j'ai dans le log PHP

    [26-May-2010 16:23:21] PHP Notice: Validating TEXT[xs] in F:\WebSites\test\checkform.php on line 414
    [26-May-2010 16:23:21] PHP Fatal error: Call to a member function stackMessage() on a non-object in F:\WebSites\test\checkform.php on line 550


    non-object ??????????????

    Je ne compte pas y passer la soirée, je pense arrêter bientôt....

    Demain jusque 15h cela ira pour moi.

    @+

  12. #32
    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 Class..... vous avez dit facile......
    Si tu trouves la solution, envoie un mail quand même mais moi je chipotte encore un peu mais je lève le pied.......

  13. #33
    Membre Expert Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Par défaut
    Ce que tu essaies de faire est de créer un lien entre mere et fille (l'inverse de l'haéritage finalement). Je pense que tu devrais revoir l'organisation de ton code pour faire circuler l'info uniquement de fille->mere et pas l'inverse.

  14. #34
    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 Class OOP vous avez dit facile ?
    Je ne suis pas sur de bien te comprendre....

    La fille est la classe qui valide et envoie un msg vers la mère en effet via la propriété stackMessage.

    La mère fait de même vers sa mère, la grand mère de la fille pour affichage via le propriété getStackMessage

    J'ai une piste, je vais creuser l'affaire.....

  15. #35
    Membre Expert Avatar de Madfrix
    Profil pro
    Inscrit en
    Juin 2007
    Messages
    2 326
    Détails du profil
    Informations personnelles :
    Localisation : France, Gironde (Aquitaine)

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 326
    Par défaut
    non avec ta dernière version, tu as cassé tous tes liens d'heritages (du moins naturels -> extends). Ah bon y'a une 3ieme classe en jeu..?

    PS: tu peux remplacer

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    private $stackMsg = array(), $cntStack = 0 ;

    par

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    private $stackMsg, $cntStack;

    ->emptyStack()

  16. #36
    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 OOP vous avez dit facile
    J'ai remis la class Stack dans CheckForm pour voir....
    Voici:


    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
    //	========================================================================================================================================================== //
    //		MAIN CLASS:   =========>>>>>>  CheckForm	
    //	========================================================================================================================================================== //
        	class Checkform
    		{	private $stackMsg = array(), $cntStack = 0 ;
    			private $msg, $form, $cntField, $cntFilled, $valid, $stack ;
     
    			function __construct($form)
    			{	# On calcule le nombre d'entrée du tableau
        			$this->form  	  = $form ;
    				$this->cntField   = count($this->form);
    				$this->formValid  = false ;
    				$this->emptyStack() ;
     
    //				$this->stack = new Stack() ;
    //
    //              Error Handler
    //				=============				
    				try {
    					$this->Validate() ;
    				}	catch (Exception $E)
    					{	$this->exception_handler($E) ; }
    #
    #				Choix du message en fonction du nbre de champ remplit OUI || NON (qui sera délivré par getMessage)
    #				==================================================================================================	
    				$this->msg = new Message($this->cntFilled,$this->cntField) ;
     
    			}
     
    			private function getCountFields()
    			{ 	return($this->cntField) ;	}
     
    //          ==================================	
    //          All Error Stacking functions			
    //          ==================================	
    			public function getStackError()
    			{	$str = "" ; 
    				print("getStackError[".$this->cntStack."]") ;
    				for ($i = 0 ; $i < $this->cntStack ; $i++)
    					$str .= $this->stackMsg[$i] ;
    				return($str) ; 
    			}
     
    			public function stackMessage($msg)
    			{	$this->stackMsg[] = $msg . "<br>\n" ; 
    				$this->cntStack++ ; 
     				print("Stacking[".$msg."] - cntStack[".$this->cntStack."]") ;
    				print_r($this->stackMsg); 
    			}
     
    			private function emptyStack()
    			{	$this->cntStack = 0 ;
    				$this->stackMsg = array() ;	 
    			}
    //          ==================================	
    //          All Screen message area routines			
    //          ==================================	
    			public function getMessage()
    			{	return($this->msg->getMessage()) ;  	}
    //          ==================================	
     
    			public function isFormValid()
    			{	return($this->formValid) ; }
     
    			protected function chkRange($name,$value,$minl,$maxl)
    			{	$len = strlen($value) ;
    				print("ChkRange[".$value."][".$len."][".$minl."][".$maxl."]") ;
    				if ( ( $len >= $minl && $len <= $maxl) )  
    					return(true) ;
    				else
    					{	$msg = "Le champ[".$name."] doit avoir une longueur comprise entre ".$minl." et ".$maxl ;
    					    $this->stackMessage($msg) ;
    						return(false) ;
    					}
    			}
     
    			public function Validate()
    			{	$this->cntFilled = 0 ;
     
    				for($i = 0 ; $i < $this->getCountFields() ; $i++) 
    				{	if ($this->form[$i] instanceof Validator)
    						if ($this->form[$i]->Filled() )
    							{	$this->cntFilled++ ;
    								$this->form[$i]->Validate() ;
    							}
    				}
    			}
    //
    //          Error Handler Processing
    //			========================	
    			function exception_handler($E)
    			{	$T = $E->getTrace() ; 
    			//	======================================================================
    				print("FORM Validator error diagnostic" .  "<br>\n") ;
    				print("=======================" .  "<br>\n") ;
     				print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
    				print("<br>\n") ;
    				print("Trace: " . "<br>\n") ;
    				print("------ " . "<br>\n") ;
    				print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
    				print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
     				print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
    				print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
    				//	======================================================================
    				user_error("Connexion error in File: (" . $E->getFile() . ") - line: (" . $E->getLine() . ")" , E_USER_WARNING) ;  
       			}
    //	
    //      End of class CheckForm
    //		======================		
    		}
    Dans le log, j'ai...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    [26-May-2010 17:34:59] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 676
    [26-May-2010 17:34:59] PHP Notice:  Validating TEXT[xs] in F:\WebSites\test\checkform.php on line 414
    [26-May-2010 17:34:59] PHP Notice:  TEXT Validating CHKRANGE[xs]-[3]-[30] in F:\WebSites\test\checkform.php on line 408
    [26-May-2010 17:34:59] PHP Notice:  Validating TEXT[gg] in F:\WebSites\test\checkform.php on line 414
    [26-May-2010 17:34:59] PHP Notice:  TEXT Validating CHKRANGE[gg]-[3]-[30] in F:\WebSites\test\checkform.php on line 408
    Ce qui est correct

    A l'écran, j'ai:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    Stacking[Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[4]Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [2] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [3] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    Jaffiche le stack via print_r et j'ai bien 4 entrées (de 0 à 3)

    Mais dans la zone d'affichage j'ai:



    Mais 0 ligne au lieu de 4......

  17. #37
    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 Class OOP vous avez dit facile ?
    En gros je conclus d'après les displays:
    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
    Stacking
    
    [Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] - cntStack[1]
    
    Array ( [0] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    Stacking
    [Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] - cntStack[2]
    
    Array ( [0] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    Stacking
    [Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[1]
    
    Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    
    Stacking
    [Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[2]
    
    Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    Stacking
    [Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] - cntStack[3]
    
    Array ( [0] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [2] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    Stacking
    [Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] - cntStack[4]
    
    Array ( [0] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [2] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [3] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    Stacking
    [Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[3]
    
    Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [2] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    ) 
    
    Stacking
    [Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[4]
    
    Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [2] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [3] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    En conclusion, il semblerait que j'insère plusieurs fois le même msg, je fais une remise à zero (raz) à chaque champ et surement à la fin puisque je n'ai plus rien à afficher.....

    Je vais laisser cela murir....

  18. #38
    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 OOP vous avez dit facile
    J'ai trouvé une raison de la redondance, je n'ai plus que:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    Stacking[Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] - cntStack[1]Array ( [0] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    ) 
     
    Stacking[Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[1]Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    )
     
    Stacking[Le champ[prenom] doit avoir une longueur comprise entre 3 et 30] - cntStack[2]Array ( [0] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[prenom] doit avoir une longueur comprise entre 3 et 30
    ) 
     
    Stacking[Le champ[nom] doit avoir une longueur comprise entre 3 et 30] - cntStack[2]Array ( [0] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    [1] => Le champ[nom] doit avoir une longueur comprise entre 3 et 30
    )
    A chaque X, j'agis comme si j'insrrrais un msg pour la 1ère X, onc il y a eu une raz de l'indexe du stack.......

  19. #39
    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 OOP
    J'arrête pour ajd'hui, j'ai une tête comme un saut...

    @demain et grand merci de ta patience

  20. #40
    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 Class et syntaxe & errmsg incompris !
    Madfrix

    Je suis debout depuis 4 h.....
    Je parsème mon code de user_error afin de voir où l'indice cntStack est raz.
    Pour l'instant je cherche tjs.
    Voici le log à cet instant:

    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
    [27-May-2010 07:41:40] PHP Notice:  Start of Constructor[] in F:\WebSites\test\checkform.php on line 559
    [27-May-2010 07:41:40] PHP Notice:  emptyStack[0] in F:\WebSites\test\checkform.php on line 610
    [27-May-2010 07:41:40] PHP Notice:  Start of Validate cntStack[0] in F:\WebSites\test\checkform.php on line 638
     
    [27-May-2010 07:41:40] PHP Notice:  Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 642
    [27-May-2010 07:41:40] PHP Notice:  Start of field validation cntStack[] in F:\WebSites\test\checkform.php on line 435
    [27-May-2010 07:41:40] PHP Notice:  TEXT Validating CHKRANGE[xx]-[3]-[30] in F:\WebSites\test\checkform.php on line 444
     
    [27-May-2010 07:41:40] PHP Notice:  Validating field[1]  cntStack[0] in F:\WebSites\test\checkform.php on line 642
    [27-May-2010 07:41:40] PHP Notice:  Start of field validation cntStack[] in F:\WebSites\test\checkform.php on line 435
    [27-May-2010 07:41:40] PHP Notice:  TEXT Validating CHKRANGE[xx]-[3]-[30] in F:\WebSites\test\checkform.php on line 444
    [27-May-2010 07:41:40] PHP Notice:  End of Validate cntStack[0] in F:\WebSites\test\checkform.php on line 647
     
    [27-May-2010 07:41:40] PHP Notice:  End of Constructor[0] in F:\WebSites\test\checkform.php on line 579
    [27-May-2010 07:41:40] PHP Notice:  POST SUBMIT CATCHED in F:\WebSites\test\checkform.php on line 727
     
    [27-May-2010 07:41:40] PHP Notice:  Start of Validate cntStack[0] in F:\WebSites\test\checkform.php on line 638
    [27-May-2010 07:41:40] PHP Notice:  Validating field[0]  cntStack[0] in F:\WebSites\test\checkform.php on line 642
     
    [27-May-2010 07:41:40] PHP Notice:  Start of field validation cntStack[1] in F:\WebSites\test\checkform.php on line 435
    [27-May-2010 07:41:40] PHP Notice:  TEXT Validating CHKRANGE[xx]-[3]-[30] in F:\WebSites\test\checkform.php on line 444
    [27-May-2010 07:41:40] PHP Notice:  Validating field[1]  cntStack[0] in F:\WebSites\test\checkform.php on line 642
    [27-May-2010 07:41:40] PHP Notice:  Start of field validation cntStack[1] in F:\WebSites\test\checkform.php on line 435
    [27-May-2010 07:41:40] PHP Notice:  TEXT Validating CHKRANGE[xx]-[3]-[30] in F:\WebSites\test\checkform.php on line 444
     
    [27-May-2010 07:41:40] PHP Notice:  End of Validate cntStack[0] in F:\WebSites\test\checkform.php on line 647
    [27-May-2010 07:41:40] PHP Notice:  getStackError[0] in F:\WebSites\test\checkform.php on line 592
    Comme tu vois, je sème bcp mais je n'ai pas encore récolté...
    Si tu veux la source pour que nous travaillons sur la même base, je veux bien te la refiler.

    J'attends un signe de vie de ta part...

+ Répondre à la discussion
Cette discussion est résolue.
Page 2 sur 3 PremièrePremière 123 DernièreDernière

Discussions similaires

  1. Réponses: 14
    Dernier message: 04/12/2005, 09h08
  2. [deb.]Probleme de syntax decl de pl class
    Par Marc_3 dans le forum C++
    Réponses: 11
    Dernier message: 01/12/2005, 13h23
  3. Réponses: 13
    Dernier message: 15/11/2005, 16h47
  4. syntaxe css lien sur classe
    Par mussara dans le forum Mise en page CSS
    Réponses: 8
    Dernier message: 03/08/2005, 10h52

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