Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 87 | Rev 140 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 87 Rev 139
Line 41... Line 41...
41
        }
41
        }
42
    }
42
    }
Line 43... Line 43...
43
    
43
    
44
    function attribuerCollectionBlockFils($un_block_donnees, $id)
44
    function attribuerCollectionBlockFils($un_block_donnees, $id)
-
 
45
    {
-
 
46
        if ($un_block_donnees->recupererIdentifiant() == $id ) {
-
 
47
            return $un_block_donnees->ajouterCollectionBlockFils($this->collectionblockdedonnees);
-
 
48
        } else if (is_array($un_block_donnees->recupererCollectionBlockFils()) AND count($un_block_donnees->recupererCollectionBlockFils()) > 0) {
-
 
49
            $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
-
 
50
            for($i = 0; $i < count($collection_block_fils); $i++) {
-
 
51
                $blocks_de_donnees = $collection_block_fils[$i]->recupererBlocksDeDonnees();
-
 
52
                for ($i = 0; $i < count($blocks_de_donnees); $i++) {
-
 
53
                    $this->attribuerCollectionBlockFils($blocks_de_donnees[$i], $id);
-
 
54
                }
-
 
55
            }
-
 
56
        }
-
 
57
    }
-
 
58
    
-
 
59
    function recupererCollectionBlockFils($un_block_donnees, $id)
45
    {
60
    {
46
        $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
61
        $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
47
        for($i = 0; $i < count($collection_block_fils); $i++) {
62
        for($i = 0; $i < count($collection_block_fils); $i++) {
48
            $collection = $collection_block_fils[$i];
63
            $une_collection = $collection_block_fils[$i];
-
 
64
            if ($une_collection->recupererIdentifiant() == $id ) {
-
 
65
                return $une_collection->recupererBlocksDeDonnees();
49
            if ($collection->recupererIdentifiant() == $this->identifiant_parent) {
66
            } else {
50
                $blocks_de_donnees = $collection->recupererBlocksDeDonnees();
67
                $blocks_de_donnees = $une_collection->recupererBlocksDeDonnees();
51
                foreach ($blocks_de_donnees as $cle => $val) {
68
                for ($i = 0; $i < count($blocks_de_donnees); $i++) {
-
 
69
                    $block = $blocks_de_donnees[$i];
52
                    if ($cle == $id) {
70
                    if (is_array($block->recupererCollectionBlockFils()) AND count($block->recupererCollectionBlockFils()) > 0) {
53
                        return $blocks_de_donnees[$cle]->ajouterCollectionBlockFils($this->collectionblockdedonnees);
71
                        return $this->recupererCollectionBlockFils($block, $id);
54
                    }
72
                    }
55
                }
-
 
56
            } else if (is_object($this->blockdedonneesParent->recupererCollectionBlockFils())) {
-
 
57
                return $this->attribuerCollectionBlockFils($un_block_donnees->recupererCollectionBlockFils());
73
                }
58
            }
74
            }
-
 
75
        }
59
        }
76
        return null;
Line 60... Line 77...
60
    }
77
    }
61
    
78
    
62
    function construire()
79
    function construire()
63
    {
80
    {
64
        if (is_null($this->identifiant_parent)) {
81
        if (is_null($this->identifiant_parent)) {
65
            $sql = $this->getSQL();
82
            $sql = $this->getSQL();
66
            if(!is_null($sql)) {
83
            if (!is_null($sql)) {
67
                $this->openCursor($sql);
84
                $this->openCursor($sql);
68
                while ($this->fetch());
85
                while ($this->fetch());
69
                $this->closeCursor();
-
 
70
            }
-
 
71
        } else {
-
 
72
            $this->contexteRefTmp = $this->contexteRef;
-
 
73
            for($i = 0; $i < count($this->contexteRefTmp); $i++) {
-
 
74
                $this->contexteRef = $this->contexteRefTmp[$i]->recupererDonnees();
-
 
75
                $sql = $this->getSQL();
-
 
76
                if(!is_null($sql)) {
-
 
77
                    $this->openCursor($sql, $i);
-
 
78
                    while ($this->fetch());
-
 
79
                    $this->closeCursor();
-
 
80
                }
-
 
81
            }
86
                $this->closeCursor();
82
            //$this->contexteRef = $this->contexteRefTmp;
-
 
83
        }
87
            }
Line 84... Line 88...
84
        //echo '<pre>'.print_r($this->contexteRef, true).'</pre>';
88
        }
85
    }
89
    }
86
    
90
    
Line 91... Line 95...
91
        $this->$contexteRef = $this->blockdedonnees;
95
        $this->$contexteRef = $this->blockdedonnees;
Line 92... Line 96...
92
        
96
        
93
        construire();
97
        construire();
Line 94... Line 98...
94
    }
98
    }
95
    
99
    
-
 
100
    function construireParRecursivite($niveau_max, $aso_contexte = null, $id = null)
-
 
101
    {
-
 
102
        static $niveau_courant = 0;
-
 
103
        if ($niveau_courant > $niveau_max) {
-
 
104
            return null;
-
 
105
        }
-
 
106
        
-
 
107
        if (!is_null($aso_contexte)) {
-
 
108
            $this->contexteRef = $aso_contexte;
-
 
109
        }
-
 
110
        if (is_null($id)) {
-
 
111
            $id = $this->identifiantblockdedonnees;
-
 
112
            $this->identifiant_parent = $this->blockdedonneesParent->recupererIdentifiant();
-
 
113
        } else {
-
 
114
            $this->identifiant_parent = $id;
-
 
115
        }
-
 
116
        
-
 
117
        $sql = $this->getSQL();
-
 
118
        //echo '<pre>'.print_r($sql, true).'</pre>';
-
 
119
        if (!is_null($sql)) {
-
 
120
            $this->openCursor($sql, $id);
96
    function contruireParRecursivite()
121
            for ($i = 0; $this->fetch($id.'-'.$i); $i++);
-
 
122
            $this->closeCursor($this->identifiant_parent);
-
 
123
            
-
 
124
            $blocks_de_donnees = $this->recupererCollectionBlockFils($this->blockdedonneesParent, $id);
-
 
125
            if (count($blocks_de_donnees) > 0) {
-
 
126
                $niveau_courant++;
-
 
127
            }
-
 
128
            for ($i = 0; $i < count($blocks_de_donnees); $i++) {
-
 
129
                $block = $blocks_de_donnees[$i];
-
 
130
                $this->construireParRecursivite($niveau_max, $block->recupererDonnees(), $block->recupererIdentifiant());
97
    {
131
            }
Line 98... Line 132...
98
        
132
        }
99
    }
133
    }
100
    
134
    
-
 
135
    function openCursor($sql, $id = null)
-
 
136
    {
101
    function openCursor($sql, $id = null)
137
        $resultat = mysql_query($sql, $this->connexion);
-
 
138
        if (!$resultat) {
-
 
139
            echo 'Numéro erreur Mysql : '.mysql_errno().'<br />'."\n";
102
    {
140
            echo 'Erreur Mysql : '.mysql_error().'<br />'."\n";
103
        $res = mysql_query($sql, $this->connexion);
-
 
104
        if (!$res) echo mysql_errno().': '.mysql_error()."\n";
141
            echo 'Requête : '.'<pre>'.$sql.'</pre>';
105
        $this->idRes = $res;
142
        }
106
        $this->collectionblockdedonnees = new collectionblockdedonnees($this->identifiantblockdedonnees);
143
        $this->idRes = $resultat;
107
        if (is_null($this->identifiant_parent)) {
144
        if (is_null($id)) {
108
            $this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees);
145
            $this->collectionblockdedonnees = new collectionblockdedonnees($this->identifiantblockdedonnees);
109
        } else {
146
        } else {
Line 110... Line 147...
110
            $this->attribuerCollectionBlockFils($this->blockdedonneesParent, $id);
147
            $this->collectionblockdedonnees = new collectionblockdedonnees($id);
111
        }
148
        }
112
    }
149
    }
113
    
150
    
114
    function fetch()
-
 
-
 
151
    function fetch($identifiant = null)
115
    {
152
    {
116
        $res = mysql_fetch_assoc($this->idRes);
-
 
117
        if (!$res) {
-
 
118
            
153
        $resultat = mysql_fetch_assoc($this->idRes);
119
        } else {
154
        if (!$resultat) {
120
            //$this->blockdedonnees = new blockdedonnees($this->identifiantblockdedonnees);
155
            // Nous ne faisons rien car aucune donnée n'est collectée.
121
            //$this->blockdedonnees->affecterDonnees($res);
156
        } else {
Line 122... Line 157...
122
            $this->collectionblockdedonnees->ajouterDonnees($res);
157
            $this->collectionblockdedonnees->ajouterDonnees($resultat, $identifiant);
123
        }
158
        }
124
        return $res;
159
        return $resultat;
-
 
160
    }
-
 
161
    
-
 
162
    function closeCursor($id = null)
-
 
163
    {
-
 
164
        mysql_free_result($this->idRes);
-
 
165
        // Nous ajoutons les données de la requêtes seulement si elle a ramenée des données
-
 
166
        if (count($this->collectionblockdedonnees->recupererBlocksDeDonnees()) > 0) {
-
 
167
            if (is_null($id)) {
125
    }
168
                $this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees);
126
    
169
            } else {
127
    function closeCursor()
170
                $this->attribuerCollectionBlockFils($this->blockdedonneesParent, $id);
128
    {
171
            }