Précédent   Forum des professionnels en informatique > PHP > Langage > Syntaxe
Syntaxe Forum d'entraide sur la syntaxe de PHP et la POO. Avant de poster -> FAQ syntaxe, Cours d'initiation et cours de POO
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 30/08/2011, 14h07   #1
 
Inscription : mai 2007
Messages : 304
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 304
Points : -10
Points : -10
Par défaut Appel d'une fonction n'affiche pas le résultat

Bonjour ,
j'ai un souci avec ce fichier qui n'affiche pas le résultat de la fonction :_constructTreeNode

merci en avance voir mon code
Code :
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
<?php
 
$id = Tools::getValue('id');
$action = Tools::getValue('action');
 
// suppression du block
if(!empty($id) && $action=='del'){
    Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'discount
                                WHERE `id_discount`="'.$id.'"');
    Form::msgConfirm($this->l('Block supprimé'),array('module'=>'codepromoauto','form'=>'default'));
}
 
function _constructTreeNode($node)
	{	
	    $ret = '	<tr>
						<td><input type="checkbox" name="categoryBox[]" class="noborder" value="'.$node['id'].'"/> &nbsp;</td>
						<td>'.$node['id'].'</td>
						<td><label for="groupBox_'.$node['id'].'" class="t">'.$node['name'].'</label></td>';
	    if(!empty($node['children']))
	    {
	    	$ret .= '	<tr>';	    	
	        foreach ($node['children'] AS $child)
	            $ret .= constructTreeNode($child);
	        $ret .= '	</tr>';
	    }
	    $ret .= '	</tr>';
	    return $ret;
	}
 
$this->_html.= Html::linkBo($this->l('Accédez Ã* la configuration'),array('module'=>'codepromoauto','form'=>'configuration'),array('img'=>'config.png')).'<br/><br/>';
$this->_html.= Html::linkBo($this->l('Nouveau bloc'),array('module'=>'codepromoauto','form'=>'codepromoauto'),array('img'=>'add.png')).'<br/><br/>';
 
$blocks = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'discount_type_lang WHERE `id_lang`="'.$cookie->id_lang.'"');
$this->_html.=
'<fieldset>
			<legend>'.$this->l('Options imported voucher').'</legend>	
 
			<label>'.$this->l('Type:').' &nbsp;</label>
			<div class="margin-form">
			<select name="id_discount_type" id="id_discount_type" onchange="free_shipping()">
				<option value="0">'.$this->l('-- Choose --').'</option>';
				$discountTypes = Discount::getDiscountTypes(intval($cookie->id_lang));
				foreach ($discountTypes AS $discountType)
				$this->_html .= '<option value="'.intval($discountType['id_discount_type']).'">'.$discountType['name'].'</option>';
 
			$this->_html .= '</select> <sup>*</sup>
			</div>
 
			<div id="value-div" style="display:none">
				<label>'.$this->l('Value:&nbsp;').'</label>
				<div class="margin-form">
					<input style="float:left;width:80px" type="text" name="value" id="discount_value" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />
					<select id="id_currency" name="id_currency" style="float:left;margin-left:10px;width:50px;display:none">
						<option value="0">--</option>';
						foreach (Currency::getCurrencies() as $row)
							$this->_html .='<option value="'.(int)$row['id_currency'].'">'.$row['sign'].'</option>';
					$this->_html .= '</select>
					<span id="percent-span" style="margin-left:10px;display:none;float:left;font-size:12px;font-weight:bold;color:black"> %</span>
					<sup style="float:left;margin-left:5px">*</sup>
					<p class="clear">'.$this->l('Either the monetary amount or the %, depending on Type selected above').'</p>
				</div>	
				<div class="clear">&nbsp;</div>			
			</div>
 
 
 
			<label>'.$this->l('Description:').' &nbsp;</label>
				';
					foreach ($this->_languages as $language)
						$this->_html .= '<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
											<input size="33" type="text" name="description_'.$language['id_lang'].'" /><sup> *</sup>
											<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
 
										</div>';							
		$this->_html .= $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'description', 'description', true);
		$this->_html .= '<br/><div class="clear" / >
			<br/>
 
			<label>'.$this->l('Categories:').' &nbsp;</label>';
				$ulTree = '<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
								<tr>
									<th>'.$this->l('Choose').'</th>
									<th>'.$this->l('ID').'</th>
									<th>'.$this->l('Categories').'</th>
								</tr>';
								foreach ($categTree['children'] AS $child)
								    $ulTree .= $this->_constructTreeNode($child);				    
				$ulTree .= '</table>'."\n";
 
				$this->_html .= $ulTree;
				$this->_html .= '<div class="clear" / >
 
			<br/>
			<p>
			<label>'.$this->l('Total quantity:').' </label>
				<div class="margin-form">
					<input type="text" size="15" name="quantity" /> <sup>*</sup>
					<p class="clear">'.$this->l('Total quantity available (mainly for vouchers open to everyone)').'</p>
				</div>
				<label>'.$this->l('Qty per each user:').' </label>
				<div class="margin-form">
					<input type="text" size="15" name="quantity_per_user" /> <sup>*</sup>
					<p class="clear">'.$this->l('Number of times a single customer can use this voucher').'</p>
				</div>
				<label>'.$this->l('Minimum amount').'</label>
				<div class="margin-form">
					<input type="text" size="15" name="minimal" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); " /> <sup>*</sup>
					<p class="clear">'.$this->l('Leave blank or 0 if not applicable').'</p>
				</div>
				<div class="margin-form">
					<p>
						<input type="checkbox" name="cumulable" id="cumulable_on" value="1" />
						<label class="t" for="cumulable_on"> '.$this->l('Cumulative with other vouchers').'</label>
					</p>
				</div>
				<div class="margin-form">
					<p>
						<input type="checkbox" name="cumulable_reduction" id="cumulable_reduction_on" value="1" />
						<label class="t" for="cumulable_reduction_on"> '.$this->l('Cumulative with price reductions').'</label>
					</p>
				</div>';
				includeDatepicker(array('date_from', 'date_to'), true);
				$this->_html .= '<label>'.$this->l('From:').' </label>
				<div class="margin-form">
					<input type="text" size="20" id="date_from" name="date_from" /> <sup>*</sup>
					<p class="clear">'.$this->l('Start date/time from which voucher can be used').'<br />'.$this->l('Format: YYYY-MM-DD HH:MM:SS').'</p>
				</div>
				<label>'.$this->l('To:').' </label>
				<div class="margin-form">
					<input type="text" size="20" id="date_to" name="date_to" /> <sup>*</sup>
					<p class="clear">'.$this->l('End date/time at which voucher is no longer valid').'<br />'.$this->l('Format: YYYY-MM-DD HH:MM:SS').'</p>
				</div>
				<label>'.$this->l('Status:').' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1"/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="active" id="active_off" />
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					<p>'.$this->l('Enable or disable voucher').'</p>
				</div>
 
			<br/><br/>
 
				<label>'.$this->l('File add &nbsp;').'&nbsp; </label>
				<input type="file" name="fileCSV" />
				<br/><br/>
				<div class="margin-form clear">
					<input class="button" type="submit" name="submitCsv" class="button" value="'.$this->l('Update').'">
				</div>			
			</fieldset>';
 
 
?>
manjava est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 14h41   #2
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 13 807
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 41
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2008
Messages : 13 807
Points : 35 793
Points : 35 793
Ta classe, elle est déclarée où ?
__________________
Pas de question technique par MP !
Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, contactez-moi !
Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
Mon livre sur jQuery
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 15h08   #3
 
Inscription : mai 2007
Messages : 304
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 304
Points : -10
Points : -10
Pour ce fichier j'ai pas de classe

Merci en avance
manjava est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 15h11   #4
Modérateur
 
Inscription : septembre 2010
Messages : 7 116
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 116
Points : 8 465
Points : 8 465
fait un var_dump($ulTree)
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 15h14   #5
Responsable Développement Web

 
Avatar de Bovino
 
Homme Didier Mouronval
Développeur Web
Inscription : juin 2008
Messages : 13 807
Détails du profil
Informations personnelles :
Nom : Homme Didier Mouronval
Âge : 41
Localisation : France, Gironde (Aquitaine)

Informations professionnelles :
Activité : Développeur Web
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : juin 2008
Messages : 13 807
Points : 35 793
Points : 35 793
$this s'applique à quoi selon toi ?
__________________
Pas de question technique par MP !
Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
Vous possédez un blog et aimeriez diffuser vos billets sur le forum, contactez-moi !
Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
Mon livre sur jQuery
Bovino est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 15h41   #6
 
Inscription : mai 2007
Messages : 304
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 304
Points : -10
Points : -10
merci de vous réponse en fait j'ai fait s'afficher juste le
Code :
1
2
3
4
5
6
string '<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
								<tr>
									<th>Choisir</th>
									<th>ID</th>
									<th>Catégories</th>
								</tr></table>
merci en avance
manjava est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 15h47   #7
Modérateur
 
Inscription : septembre 2010
Messages : 7 116
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 116
Points : 8 465
Points : 8 465
donc il renvoie bien quelque chose, montre ton vrai code
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 15h52   #8
 
Inscription : mai 2007
Messages : 304
Détails du profil
Informations forums :
Inscription : mai 2007
Messages : 304
Points : -10
Points : -10
fichier default.php

Code :
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
<?php
 
$id = Tools::getValue('id');
$action = Tools::getValue('action');
 
// suppression du block
if(!empty($id) && $action=='del'){
    Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'discount
                                WHERE `id_discount`="'.$id.'"');
    Form::msgConfirm($this->l('Block supprimé'),array('module'=>'codepromoauto','form'=>'default'));
}
$this->_html.= Html::linkBo($this->l('Accédez Ã* la configuration'),array('module'=>'codepromoauto','form'=>'configuration'),array('img'=>'config.png')).'<br/><br/>';
$this->_html.= Html::linkBo($this->l('Nouveau bloc'),array('module'=>'codepromoauto','form'=>'codepromoauto'),array('img'=>'add.png')).'<br/><br/>';
 
$blocks = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'discount_type_lang WHERE `id_lang`="'.$cookie->id_lang.'"');
$this->_html.=
'<fieldset>
			<legend>'.$this->l('Options imported voucher').'</legend>	
 
			<label>'.$this->l('Type:').' &nbsp;</label>
			<div class="margin-form">
			<select name="id_discount_type" id="id_discount_type" onchange="free_shipping()">
				<option value="0">'.$this->l('-- Choose --').'</option>';
				$discountTypes = Discount::getDiscountTypes(intval($cookie->id_lang));
				foreach ($discountTypes AS $discountType)
				$this->_html .= '<option value="'.intval($discountType['id_discount_type']).'">'.$discountType['name'].'</option>';
 
			$this->_html .= '</select> <sup>*</sup>
			</div>
 
			<div id="value-div" style="display:none">
				<label>'.$this->l('Value:&nbsp;').'</label>
				<div class="margin-form">
					<input style="float:left;width:80px" type="text" name="value" id="discount_value" onKeyUp="javascript:this.value = this.value.replace(/,/g, \'.\');" />
					<select id="id_currency" name="id_currency" style="float:left;margin-left:10px;width:50px;display:none">
						<option value="0">--</option>';
						foreach (Currency::getCurrencies() as $row)
							$this->_html .='<option value="'.(int)$row['id_currency'].'">'.$row['sign'].'</option>';
					$this->_html .= '</select>
					<span id="percent-span" style="margin-left:10px;display:none;float:left;font-size:12px;font-weight:bold;color:black"> %</span>
					<sup style="float:left;margin-left:5px">*</sup>
					<p class="clear">'.$this->l('Either the monetary amount or the %, depending on Type selected above').'</p>
				</div>	
				<div class="clear">&nbsp;</div>			
			</div>
 
 
 
			<label>'.$this->l('Description:').' &nbsp;</label>
				';
					foreach ($this->_languages as $language)
						$this->_html .= '<div id="description_'.$language['id_lang'].'" style="display: '.($language['id_lang'] == $this->_defaultFormLanguage ? 'block' : 'none').'; float: left;">
											<input size="33" type="text" name="description_'.$language['id_lang'].'" /><sup> *</sup>
											<span class="hint" name="help_box">'.$this->l('Invalid characters:').' <>;=#{}<span class="hint-pointer">&nbsp;</span></span>
 
										</div>';							
		$this->_html .= $this->displayFlags($this->_languages, $this->_defaultFormLanguage, 'description', 'description', true);
		$this->_html .= '<br/><div class="clear" / >
			<br/>
 
			<label>'.$this->l('Categories:').' &nbsp;</label>';
				$ulTree = '<table cellspacing="0" cellpadding="0" class="table" style="width: 29.5em;">
								<tr>
									<th>'.$this->l('Choose').'</th>
									<th>'.$this->l('ID').'</th>
									<th>'.$this->l('Categories').'</th>
								</tr>';
								foreach ($categTree['children'] AS $child)
								    $ulTree .= $this->_constructTreeNode($child);				    
				$ulTree .= '</table>'."\n";
				 var_dump($ulTree);
				$this->_html .= $ulTree;
				$this->_html .= '<div class="clear" / >
 
			<br/>
			<p>
			<label>'.$this->l('Total quantity:').' </label>
				<div class="margin-form">
					<input type="text" size="15" name="quantity" /> <sup>*</sup>
					<p class="clear">'.$this->l('Total quantity available (mainly for vouchers open to everyone)').'</p>
				</div>
				<label>'.$this->l('Qty per each user:').' </label>
				<div class="margin-form">
					<input type="text" size="15" name="quantity_per_user" /> <sup>*</sup>
					<p class="clear">'.$this->l('Number of times a single customer can use this voucher').'</p>
				</div>
				<label>'.$this->l('Minimum amount').'</label>
				<div class="margin-form">
					<input type="text" size="15" name="minimal" onkeyup="javascript:this.value = this.value.replace(/,/g, \'.\'); " /> <sup>*</sup>
					<p class="clear">'.$this->l('Leave blank or 0 if not applicable').'</p>
				</div>
				<div class="margin-form">
					<p>
						<input type="checkbox" name="cumulable" id="cumulable_on" value="1" />
						<label class="t" for="cumulable_on"> '.$this->l('Cumulative with other vouchers').'</label>
					</p>
				</div>
				<div class="margin-form">
					<p>
						<input type="checkbox" name="cumulable_reduction" id="cumulable_reduction_on" value="1" />
						<label class="t" for="cumulable_reduction_on"> '.$this->l('Cumulative with price reductions').'</label>
					</p>
				</div>';
				includeDatepicker(array('date_from', 'date_to'), true);
				$this->_html .= '<label>'.$this->l('From:').' </label>
				<div class="margin-form">
					<input type="text" size="20" id="date_from" name="date_from" /> <sup>*</sup>
					<p class="clear">'.$this->l('Start date/time from which voucher can be used').'<br />'.$this->l('Format: YYYY-MM-DD HH:MM:SS').'</p>
				</div>
				<label>'.$this->l('To:').' </label>
				<div class="margin-form">
					<input type="text" size="20" id="date_to" name="date_to" /> <sup>*</sup>
					<p class="clear">'.$this->l('End date/time at which voucher is no longer valid').'<br />'.$this->l('Format: YYYY-MM-DD HH:MM:SS').'</p>
				</div>
				<label>'.$this->l('Status:').' </label>
				<div class="margin-form">
					<input type="radio" name="active" id="active_on" value="1"/>
					<label class="t" for="active_on"> <img src="../img/admin/enabled.gif" alt="'.$this->l('Enabled').'" title="'.$this->l('Enabled').'" /></label>
					<input type="radio" name="active" id="active_off" />
					<label class="t" for="active_off"> <img src="../img/admin/disabled.gif" alt="'.$this->l('Disabled').'" title="'.$this->l('Disabled').'" /></label>
					<p>'.$this->l('Enable or disable voucher').'</p>
				</div>
 
			<br/><br/>
 
				<label>'.$this->l('File add &nbsp;').'&nbsp; </label>
				<input type="file" name="fileCSV" />
				<br/><br/>
				<div class="margin-form clear">
					<input class="button" type="submit" name="submitCsv" class="button" value="'.$this->l('Update').'">
				</div>			
			</fieldset>';
function _constructTreeNode($node)
{	
	    $ret = '	<tr>
						<td><input type="checkbox" name="categoryBox[]" class="noborder" value="'.$node['id'].'"/> &nbsp;</td>
						<td>'.$node['id'].'</td>
						<td><label for="groupBox_'.$node['id'].'" class="t">'.$node['name'].'</label></td>';
	    if(!empty($node['children']))
	    {
	    	$ret .= '	<tr>';	    	
	        foreach ($node['children'] AS $child)
	            $ret .= constructTreeNode($child);
	        $ret .= '	</tr>';
	    }
	    $ret .= '	</tr>';
	    return $ret;
}
 
 
?>
manjava est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 16h02   #9
Modérateur
 
Inscription : septembre 2010
Messages : 7 116
Détails du profil
Informations forums :
Inscription : septembre 2010
Messages : 7 116
Points : 8 465
Points : 8 465
a part recité on pas pas faire grand chose pour toi ...

Citation:
Envoyé par Bovino Voir le message
$this s'applique à quoi selon toi ?
__________________
http://blog.stealth35.com/
stealth35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 30/08/2011, 16h22   #10
Membre Expert
 
Avatar de gene69
 
Inscription : janvier 2006
Messages : 951
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 : 951
Points : 1 063
Points : 1 063
http://us2.php.net/manual/en/functio...uded-files.php
associé à un print_r(debug_backtrace());
__________________
PHP fait nativement la validation d'adresse électronique Vous êtes perdu en PHP? rassurez-vous ici (en)
Utilisez le bouton résolu!
gene69 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 06/09/2011, 14h48   #11
Candidat au titre de Membre du Club
 
Homme
Inscription : avril 2004
Messages : 16
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 25
Localisation : Suisse

Informations professionnelles :
Secteur : High Tech - Éditeur de logiciels

Informations forums :
Inscription : avril 2004
Messages : 16
Points : 11
Points : 11
Tu devrais faire un
Code :
var_dump($categTree['children']);
pour vérifier que ta variable est correctement initialisée.

Affiche le résultat si tu vois une anormalité.
Nic0tiN est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 14h59.


 
 
 
 
Partenaires

Hébergement Web