Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

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

Rev Author Line No. Line
36 jpm 1
<?php
27 jpm 2
 
36 jpm 3
class blockdedonnees {
27 jpm 4
 
5
    protected $identifiant;
6
    protected $donnees;
7
    protected $collectionBlocksfils;
8
    protected $erreur;
9
 
36 jpm 10
    function __construct($identifiant)
11
    {
12
        $this->identifiant = $identifiant;
13
        $this->donnees = array();
14
        $this->collectionBlocksfils = array();
15
    }
27 jpm 16
 
36 jpm 17
    function affecterIdentifiant($identifiant)
18
    {
27 jpm 19
        $this->identifiant = $identifiant;
20
    }
21
 
36 jpm 22
    function affecterDonnees($donnees)
23
    {
27 jpm 24
        $this->donnees = $donnees;
25
    }
26
 
27
    function recupererDonnees()
28
    {
29
        return $this->donnees;
30
    }
31
 
36 jpm 32
    function ajouterDonnee($clef, $valeur)
27 jpm 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
 
36 jpm 52
    function ajouterCollectionBlockFils($collection_block)
27 jpm 53
    {
36 jpm 54
        array_push($this->collectionBlocksfils, $collection_block);
27 jpm 55
    }
39 jpm 56
 
57
    function recupererCollectionBlockFils()
58
    {
59
        return $this->collectionBlocksfils;
60
    }
27 jpm 61
 
36 jpm 62
    function afficherPattern($chemin, $fonction)
27 jpm 63
    {
36 jpm 64
        if ($chemin == $this->identifiant) {
65
 
66
        } else {
67
            $etape_chemin = explode('>', $chemin);
68
            if($chemin == $etape_chemin[0]) {
39 jpm 69
                for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
36 jpm 70
                    $collection = $this->collectionBlocksfils[$i];
71
                    if ($collection->recupererIdentifiant() == $etape_chemin[1]) {
27 jpm 72
                        array_shift($etape_chemin);
36 jpm 73
                        afficherPattern(implode('>', $etape_chemin), $fonction);
74
                    }
27 jpm 75
                }
76
            }
36 jpm 77
        }
27 jpm 78
    }
79
 
80
    function afficher()
81
    {
36 jpm 82
        echo '<ol>';
39 jpm 83
        foreach ($this->donnees as $key => $value) {
36 jpm 84
            echo '<li>'.$key.' : '.$value;
27 jpm 85
        }
36 jpm 86
        echo '</ol>';
39 jpm 87
        for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
36 jpm 88
            $collection = $this->collectionBlocksfils[$i];
89
            echo '<ol>';
27 jpm 90
            $collection->afficher();
36 jpm 91
            echo '</ol>';
27 jpm 92
        }
93
    }
94
}
95
?>