Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 42 | 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
    }
44 jpm 21
 
22
    function recupererIdentifiant()
23
    {
24
        return $this->identifiant;
25
    }
42 fred 26
 
27
    function affecterDonnees($donnees)
28
    {
29
        $this->donnees = $donnees;
30
    }
31
 
32
    function recupererDonnees()
33
    {
34
        return $this->donnees;
35
    }
36
 
37
    function ajouterDonnee($clef, $valeur)
38
    {
39
        $this->donnees["$clef"] = $valeur;
40
    }
41
 
42
    function recupererDonnee($clef)
43
    {
44
        return $this->donnees["$clef"];
45
    }
46
 
47
    function recupererErreur()
48
    {
49
        return $this->erreur;
50
    }
51
 
52
    function recupererBlockFils()
53
    {
54
        return $this->blocksfils;
55
    }
56
 
57
    function ajouterCollectionBlockFils($collection_block)
58
    {
59
        array_push($this->collectionBlocksfils, $collection_block);
60
    }
61
 
39 jpm 62
    function recupererCollectionBlockFils()
63
    {
64
        return $this->collectionBlocksfils;
65
    }
42 fred 66
 
44 jpm 67
    function afficherPattern($chemin, $nom_fonction)
68
    {
69
        $retour = '';
70
        if($chemin == $this->recupererIdentifiant()) {
71
            $retour .= call_user_func($nom_fonction, $this->recupererDonnees());
72
        } else {
73
            $etape_chemin = explode('>', $chemin);
74
            if($this->identifiant == $etape_chemin[0]) {
75
                $collection_block_fils = $this->recupererCollectionBlockFils();
76
                for($i = 0; $i < count($collection_block_fils); $i++) {
77
                    $collection = $collection_block_fils[$i];
78
                    if ($collection->recupererIdentifiant() == $etape_chemin[1]) {
79
                        array_shift($etape_chemin);
80
                        $retour .= $collection->afficherPattern(implode('>', $etape_chemin), $nom_fonction);
81
                    }
82
                }
83
            }
84
        }
85
        return $retour;
86
    }
42 fred 87
 
88
    function afficher()
89
    {
90
        echo '<ol>';
91
        foreach ($this->donnees as $key => $value) {
92
            echo '<li>'.$key.' : '.$value;
93
        }
94
        echo '</ol>';
95
        for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
96
            $collection = $this->collectionBlocksfils[$i];
97
            echo '<ol>';
98
            $collection->afficher();
99
            echo '</ol>';
100
        }
101
    }
102
}
27 jpm 103
?>