Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 44 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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