Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 140 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 140 Rev 145
Line 5... Line 5...
5
    protected $identifiantblockdedonnees;
5
    protected $identifiantblockdedonnees;
6
    protected $identifiant_parent;
6
    protected $identifiant_parent;
7
    protected $connexion;
7
    protected $connexion;
8
    protected $contexteRef;
8
    protected $contexteRef;
9
    protected $contexteRefTmp;
9
    protected $contexteRefTmp;
-
 
10
    protected $contexteChemin;
10
    protected $contexteSQL;
11
    protected $contexteSQL;
11
    protected $blockdedonneesParent;
12
    protected $blockdedonneesParent;
12
    protected $collectionblockdedonnees;
13
    protected $collectionblockdedonnees;
13
    protected $idRes;
14
    protected $idRes;
Line 14... Line 15...
14
    
15
    
15
    function __construct($une_connexion, $un_block_donnees_parent, $chemin_macro_element)
16
    function __construct($une_connexion, $un_block_donnees_parent, $chemin_macro_element)
16
    {
17
    {
17
        $this->connexion = $une_connexion;
18
        $this->connexion = $une_connexion;
18
        $this->blockdedonneesParent = $un_block_donnees_parent;
19
        $this->blockdedonneesParent = $un_block_donnees_parent;
19
        $tab_etape_chemin = array_reverse(explode('>', $chemin_macro_element));
20
        $tab_etape_chemin = array_reverse(explode('>', $chemin_macro_element));
20
        $identifiant = $tab_etape_chemin[0];
21
        $this->identifiantblockdedonnees = $tab_etape_chemin[0];
-
 
22
        $this->identifiant_parent = NULL;//$this->blockdedonneesParent->recupererIdentifiant();
-
 
23
        $this->contexteRef = $this->blockdedonneesParent->recupererDonnees();
21
        $this->identifiantblockdedonnees = $identifiant;
24
        $this->contexteMultiple = FALSE;
-
 
25
        if (count($tab_etape_chemin) > 1) {
22
        if (count($tab_etape_chemin) > 1) {
26
            $this->contexteMultiple = TRUE;
23
            $this->identifiant_parent = $tab_etape_chemin[1];
-
 
24
            $this->contexteRef = $this->attribuerContexteRef($this->blockdedonneesParent);
-
 
25
        } else {
-
 
26
            $this->identifiant_parent = NULL;
-
 
27
            $this->contexteRef = $this->blockdedonneesParent->recupererDonnees();
27
            $this->identifiant_parent = $tab_etape_chemin[1];
28
        }
28
        }
Line 29... Line 29...
29
    }
29
    }
30
    
30
    
31
    function attribuerContexteRef($un_block_donnees)
31
    function attribuerContexteRef($un_block_donnees, $id)
32
    {
32
    {
33
        $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
33
        $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
34
        for($i = 0; $i < count($collection_block_fils); $i++) {
34
        for($i = 0; $i < count($collection_block_fils); $i++) {
35
            $collection = $collection_block_fils[$i];
35
            $collection = $collection_block_fils[$i];
36
            if ($collection->recupererIdentifiant() == $this->identifiant_parent) {
36
            if ($collection->recupererIdentifiant() == $id) {
37
                return $collection->recupererBlocksDeDonnees();
37
                return $collection->recupererBlocksDeDonnees();
38
            } else if (is_object($un_block_donnees->recupererCollectionBlockFils())) {
38
            } else if (is_object($un_block_donnees->recupererCollectionBlockFils())) {
39
                $this->attribuerContexteRef($un_block_donnees->recupererCollectionBlockFils());
39
                $this->attribuerContexteRef($un_block_donnees->recupererCollectionBlockFils(), $id);
40
            }
40
            }
Line 41... Line 41...
41
        }
41
        }
42
    }
42
    }
43
    
43
    
-
 
44
    function attribuerCollectionBlockFils($un_block_donnees, $id, $num = null, $num_courant = null)
-
 
45
    {
-
 
46
        if ($un_block_donnees->recupererIdentifiant() == $id AND is_null($num)) {
-
 
47
            return $un_block_donnees->ajouterCollectionBlockFils($this->collectionblockdedonnees);
44
    function attribuerCollectionBlockFils($un_block_donnees, $id)
48
        } else if ($un_block_donnees->recupererIdentifiant() == $id AND !is_null($num) AND $num == $num_courant) {
45
    {
49
            //echo '<pre>'.print_r($this->contexteRefTmp, true).'</pre>';
46
        if ($un_block_donnees->recupererIdentifiant() == $id ) {
50
            //echo $un_block_donnees->recupererIdentifiant().'----'.$num.'-'.$num_courant.'<br />';
47
            return $un_block_donnees->ajouterCollectionBlockFils($this->collectionblockdedonnees);
51
            return $un_block_donnees->ajouterCollectionBlockFils($this->collectionblockdedonnees);
48
        } else if (is_array($un_block_donnees->recupererCollectionBlockFils()) AND count($un_block_donnees->recupererCollectionBlockFils()) > 0) {
52
        } else if (is_array($un_block_donnees->recupererCollectionBlockFils()) AND count($un_block_donnees->recupererCollectionBlockFils()) > 0) {
49
            $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
53
            $collection_block_fils = $un_block_donnees->recupererCollectionBlockFils();
-
 
54
            for($i = 0; $i < count($collection_block_fils); $i++) {
50
            for($i = 0; $i < count($collection_block_fils); $i++) {
55
                $blocks_de_donnees = $collection_block_fils[$i]->recupererBlocksDeDonnees();
51
                $blocks_de_donnees = $collection_block_fils[$i]->recupererBlocksDeDonnees();
56
                for ($j = 0; $j < count($blocks_de_donnees); $j++) {
52
                for ($i = 0; $i < count($blocks_de_donnees); $i++) {
57
                    //echo $blocks_de_donnees[$j]->recupererIdentifiant().'-'.$id.'----'.$num.'-'.$j.'<br />';
53
                    $this->attribuerCollectionBlockFils($blocks_de_donnees[$i], $id);
58
                    $this->attribuerCollectionBlockFils($blocks_de_donnees[$j], $id, $num, $j);
54
                }
59
                }
Line 76... Line 81...
76
        return null;
81
        return null;
77
    }
82
    }
Line 78... Line 83...
78
    
83
    
79
    function construire()
84
    function construire()
-
 
85
    {
80
    {
86
        if ($this->contexteMultiple == FALSE) {
81
        $sql = $this->getSQL();
87
            $sql = $this->getSQL();
82
        if (!is_null($sql)) {
88
            if (!is_null($sql)) {
83
            $this->openCursor($sql);
89
                $this->openCursor($sql);
84
            while ($this->fetch());
90
                while ($this->fetch());
-
 
91
                $this->closeCursor();
-
 
92
            }
-
 
93
        } else {
-
 
94
            $this->contexteRefTmp = $this->attribuerContexteRef($this->blockdedonneesParent, $this->identifiant_parent);
-
 
95
            //echo '<pre>'.print_r($this->contexteRefTmp, true).'</pre>';
-
 
96
            for($i = 0; $i < count($this->contexteRefTmp); $i++) {
-
 
97
                $this->contexteRef = $this->contexteRefTmp[$i]->recupererDonnees();
-
 
98
                $sql = $this->getSQL();
-
 
99
                if (!is_null($sql)) {
-
 
100
                    $this->openCursor($sql);
-
 
101
                    while ($this->fetch());
-
 
102
                    $this->closeCursor($this->identifiant_parent, $i);
-
 
103
                }
85
            $this->closeCursor();
104
            }
86
        }
105
        }
Line 87... Line 106...
87
    }
106
    }
88
    
107
    
Line 102... Line 121...
102
        } else {
121
        } else {
103
            $this->identifiant_parent = $id;
122
            $this->identifiant_parent = $id;
104
        }
123
        }
Line 105... Line 124...
105
        
124
        
106
        $sql = $this->getSQL();
-
 
107
        //echo '<pre>'.print_r($sql, true).'</pre>';
125
        $sql = $this->getSQL();
108
        if (!is_null($sql)) {
126
        if (!is_null($sql)) {
109
            $this->openCursor($sql, $id);
127
            $this->openCursor($sql, $id);
110
            for ($i = 0; $this->fetch($id.'-'.$i); $i++);
128
            for ($i = 0; $this->fetch($id.'-'.$i); $i++);
Line 155... Line 173...
155
            $this->collectionblockdedonnees->ajouterDonnees($resultat, $identifiant);
173
            $this->collectionblockdedonnees->ajouterDonnees($resultat, $identifiant);
156
        }
174
        }
157
        return $resultat;
175
        return $resultat;
158
    }
176
    }
Line 159... Line 177...
159
    
177
    
160
    function closeCursor($id = null)
178
    function closeCursor($id = null, $num = null)
161
    {
179
    {
162
        mysql_free_result($this->idRes);
180
        mysql_free_result($this->idRes);
163
        // Nous ajoutons les données de la requêtes seulement si elle a ramenée des données
181
        // Nous ajoutons les données de la requêtes seulement si elle a ramenée des données
164
        if (count($this->collectionblockdedonnees->recupererBlocksDeDonnees()) > 0) {
182
        if (count($this->collectionblockdedonnees->recupererBlocksDeDonnees()) > 0) {
165
            if (is_null($id)) {
183
            if (is_null($id)) {
166
                $this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees);
184
                $this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees);
167
            } else {
185
            } else {
168
                $this->attribuerCollectionBlockFils($this->blockdedonneesParent, $id);
186
                $this->attribuerCollectionBlockFils($this->blockdedonneesParent, $id, $num);
169
            }
187
            }
170
        }
188
        }
171
    }
189
    }
172
}
190
}
173
?>
191
?>