Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 39 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42 fred 1
<?php
2
 
3
class blockdedonnees {
39 jpm 4
 
42 fred 5
    protected $identifiant;
6
    protected $donnees;
7
    protected $collectionBlocksfils;
8
    protected $erreur;
9
 
10
    function __construct($identifiant)
11
    {
12
        $this->identifiant = $identifiant;
13
        $this->donnees = array();
14
        $this->collectionBlocksfils = array();
15
    }
16
 
17
    function affecterIdentifiant($identifiant)
18
    {
19
        $this->identifiant = $identifiant;
20
    }
21
 
22
    function affecterDonnees($donnees)
23
    {
24
        $this->donnees = $donnees;
25
    }
26
 
27
    function recupererDonnees()
28
    {
29
        return $this->donnees;
30
    }
31
 
32
    function ajouterDonnee($clef, $valeur)
33
    {
34
        $this->donnees["$clef"] = $valeur;
35
    }
36
 
37
    function recupererDonnee($clef)
38
    {
39
        return $this->donnees["$clef"];
40
    }
41
 
42
    function recupererErreur()
43
    {
44
        return $this->erreur;
45
    }
46
 
47
    function recupererBlockFils()
48
    {
49
        return $this->blocksfils;
50
    }
51
 
52
    function ajouterCollectionBlockFils($collection_block)
53
    {
54
        array_push($this->collectionBlocksfils, $collection_block);
55
    }
56
 
39 jpm 57
    function recupererCollectionBlockFils()
58
    {
59
        return $this->collectionBlocksfils;
60
    }
42 fred 61
 
62
	function afficherPattern($chemin,$nom_fonction)
63
	{
64
		/*echo "identifiant: $this->identifiant</br>";
65
		echo "chemin: $chemin</br>";
66
		echo "nom_fonction: $nom_fonction</br>";*/
67
 
68
		if($chemin==$this->identifiant)
69
		{
70
			call_user_func($nom_fonction,$this->donnees);
71
		}
72
		else
73
		{
74
 
75
			$etape_chemin = explode('>',$chemin);
76
			if($this->identifiant==$etape_chemin[0])
77
			{	//echo "collection</br>";
78
				for($i=0;$i<count($this->collectionBlocksfils);$i++)
79
				{
80
					$collection =$this->collectionBlocksfils[$i];
81
					//echo "collection2</br>";
82
					if ($collection->recupererIdentifiant()==$etape_chemin[1])
83
					{
84
						echo "collection3</br>";
85
						array_shift($etape_chemin);
86
						$collection->afficherPattern(implode('>',$etape_chemin),$nom_fonction);
87
					}
88
				}
89
			}
90
		}
91
	}
92
 
93
    function afficher()
94
    {
95
        echo '<ol>';
96
        foreach ($this->donnees as $key => $value) {
97
            echo '<li>'.$key.' : '.$value;
98
        }
99
        echo '</ol>';
100
        for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
101
            $collection = $this->collectionBlocksfils[$i];
102
            echo '<ol>';
103
            $collection->afficher();
104
            echo '</ol>';
105
        }
106
    }
107
}
27 jpm 108
?>