Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

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

Rev 72 Rev 80
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($bool_descendance = FALSE)
-
 
33
    {
-
 
34
        if ($bool_descendance == TRUE) {
-
 
35
            $aso_donnees = array();
-
 
36
            $aso_donnees[$this->recupererIdentifiant()] = $this->donnees;
-
 
37
            $collections_blocks_fils = $this->recupererCollectionBlockFils();
-
 
38
            if (is_array($collections_blocks_fils)) {
-
 
39
                for($i = 0; $i < count($collections_blocks_fils); $i++) {
-
 
40
                    $collection = $collections_blocks_fils[$i];
-
 
41
                    $blocks_de_donnees = $collection->recupererBlocksDeDonnees();
-
 
42
                    for($j = 0; $j < count($blocks_de_donnees); $j++) {
-
 
43
                        $block = $blocks_de_donnees[$j];
-
 
44
                        $donnees = $block->recupererDonnees();
-
 
45
                        $aso_donnees[$this->recupererIdentifiant()][$block->recupererIdentifiant()] = $donnees;
-
 
46
                    }
-
 
47
                }
-
 
48
            }
-
 
49
            return $aso_donnees;
33
    {
50
        } else {
-
 
51
            return $this->donnees;
34
        return $this->donnees;
52
        }
35
    }
53
    }
36
    
54
    
37
    function ajouterDonnee($clef, $valeur)
55
    function ajouterDonnee($clef, $valeur)
38
    {
56
    {
39
        $this->donnees["$clef"] = $valeur;
57
        $this->donnees[$clef] = $valeur;
40
    }
58
    }
41
    
59
    
42
    function recupererDonnee($clef)
60
    function recupererDonnee($clef)
43
    {
61
    {
44
        return $this->donnees["$clef"];
62
        return $this->donnees[$clef];
45
    }
63
    }
46
    
64
    
47
    function recupererErreur()
65
    function recupererErreur()
48
    {
66
    {
49
        return $this->erreur;
67
        return $this->erreur;
50
    }
68
    }
51
    
-
 
52
    function recupererBlockFils()
-
 
53
    {
-
 
54
        return $this->blocksfils;
-
 
55
    }
-
 
56
    
69
    
57
    function ajouterCollectionBlockFils($collection_block)
70
    function ajouterCollectionBlockFils($collection_block)
58
    {
71
    {
59
        array_push($this->collectionBlocksfils, $collection_block);
72
        array_push($this->collectionBlocksfils, $collection_block);
60
    }
73
    }
61
    
74
    
62
    function recupererCollectionBlockFils()
75
    function recupererCollectionBlockFils()
63
    {
76
    {
64
        return $this->collectionBlocksfils;
77
        return $this->collectionBlocksfils;
65
    }
78
    }
66
    
79
    
67
    function afficherPattern($chemin, $nom_fonction)
80
    function afficherPattern($chemin, $nom_fonction, $recuperer_descendance = FALSE, $aso_parametres = array())
68
    {
81
    {
69
        $retour = '';
82
        $retour = '';
70
        if($chemin == $this->recupererIdentifiant()) {
83
        if($chemin == $this->recupererIdentifiant()) {
71
            $retour .= call_user_func($nom_fonction, $this->recupererDonnees());
84
            $retour .= call_user_func($nom_fonction, $this->recupererDonnees($recuperer_descendance), $aso_parametres);
72
        } else {
85
        } else {
73
            $etape_chemin = explode('>', $chemin);
86
            $etape_chemin = explode('>', $chemin);
74
            if($this->identifiant == $etape_chemin[0]) {
87
            if($this->identifiant == $etape_chemin[0]) {
75
                $collection_block_fils = $this->recupererCollectionBlockFils();
88
                $collection_block_fils = $this->recupererCollectionBlockFils();
76
                for($i = 0; $i < count($collection_block_fils); $i++) {
89
                for($i = 0; $i < count($collection_block_fils); $i++) {
77
                    $collection = $collection_block_fils[$i];
90
                    $collection = $collection_block_fils[$i];
78
                    if ($collection->recupererIdentifiant() == $etape_chemin[1]) {
91
                    if ($collection->recupererIdentifiant() == $etape_chemin[1]) {
79
                        array_shift($etape_chemin);
92
                        array_shift($etape_chemin);
80
                        $retour .= $collection->afficherPattern(implode('>', $etape_chemin), $nom_fonction);
93
                        $retour .= $collection->afficherPattern(implode('>', $etape_chemin), $nom_fonction, $recuperer_descendance, $aso_parametres);
81
                    }
94
                    }
82
                }
95
                }
83
            }
96
            }
84
        }
97
        }
85
        return $retour;
98
        return $retour;
86
    }
99
    }
87
    
100
    
88
    function attribuerContexte($chemin, $cle_contexte, $cle_donnee)
101
    function attribuerContexte($chemin, $cle_contexte, $cle_donnee)
89
    {
102
    {
90
        if ($chemin == $this->recupererIdentifiant()) {
103
        if ($chemin == $this->recupererIdentifiant()) {
91
            $donnees = $this->recupererDonnees();
104
            $donnees = $this->recupererDonnees();
92
            return $donnees;
105
            return $donnees;
93
        } else {
106
        } else {
94
            $etape_chemin = explode('>', $chemin);
107
            $etape_chemin = explode('>', $chemin);
95
            if($this->identifiant == $etape_chemin[0]) {
108
            if($this->identifiant == $etape_chemin[0]) {
96
                $collection_block_fils = $this->recupererCollectionBlockFils();
109
                $collection_block_fils = $this->recupererCollectionBlockFils();
97
                for($i = 0; $i < count($collection_block_fils); $i++) {
110
                for($i = 0; $i < count($collection_block_fils); $i++) {
98
                    $collection = $collection_block_fils[$i];
111
                    $collection = $collection_block_fils[$i];
99
                    if ($collection->recupererIdentifiant() == $etape_chemin[1]) {
112
                    if ($collection->recupererIdentifiant() == $etape_chemin[1]) {
100
                        array_shift($etape_chemin);
113
                        array_shift($etape_chemin);
101
                        $donnees = null;
114
                        $donnees = null;
102
                        $donnees = $collection->attribuerContexte(implode('>', $etape_chemin), $cle_contexte, $cle_donnee);
115
                        $donnees = $collection->attribuerContexte(implode('>', $etape_chemin), $cle_contexte, $cle_donnee);
103
                        if (isset($donnees)) {
116
                        if (isset($donnees)) {
104
                            $i = count($collection_block_fils);
117
                            $i = count($collection_block_fils);
105
                        }
118
                        }
106
                    }
119
                    }
107
                }
120
                }
108
            }
121
            }
109
        }
122
        }
110
        $this->ajouterDonnee($cle_contexte, $donnees[$cle_donnee]);
123
        $this->ajouterDonnee($cle_contexte, $donnees[$cle_donnee]);
111
        return null;
124
        return null;
112
    }
125
    }
113
    
126
    
114
    function afficher()
127
    function afficher()
115
    {
128
    {
116
        echo '<ol>';
129
        echo '<ol>';
117
        foreach ($this->donnees as $key => $value) {
130
        foreach ($this->donnees as $key => $value) {
118
            echo '<li>'.$key.' : '.$value;
131
            echo '<li>'.$key.' : '.$value;
119
        }
132
        }
120
        echo '</ol>';
133
        echo '</ol>';
121
        for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
134
        for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
122
            $collection = $this->collectionBlocksfils[$i];
135
            $collection = $this->collectionBlocksfils[$i];
123
            echo '<ol>';
136
            echo '<ol>';
124
            $collection->afficher();
137
            $collection->afficher();
125
            echo '</ol>';
138
            echo '</ol>';
126
        }
139
        }
127
    }
140
    }
128
}
141
}
129
?>
142
?>