2,29 → 2,86 |
|
class macroElement implements iMacroElement{ |
|
protected $identifiantblockdedonnees; |
protected $identifiantblockdedonnees; |
protected $identifiant_parent; |
protected $connexion; |
protected $contexteRef; |
protected $contexteRef; |
protected $contexteRefTmp; |
protected $contexteSQL; |
protected $blockdedonneesParent; |
protected $collectionblockdedonnees; |
protected $idRes; |
|
function __construct($une_connexion, $un_block_données_parent, $identifiant) |
function __construct($une_connexion, $un_block_donnees_parent, $chemin_macro_element) |
{ |
$this->connexion = $une_connexion; |
$this->blockdedonneesParent = $un_block_donn; |
$this->identifiantblockdedonnees = $identifiant; |
$this->contexteRef = $this->blockdedonneesParent->recupererDonnees(); |
$this->blockdedonneesParent = $un_block_donnees_parent; |
$tab_etape_chemin = array_reverse(explode('>', $chemin_macro_element)); |
$identifiant = $tab_etape_chemin[0]; |
$this->identifiantblockdedonnees = $identifiant; |
if (count($tab_etape_chemin) > 1) { |
$this->identifiant_parent = $tab_etape_chemin[1]; |
$this->contexteRef = $this->attribuerContexteRef($this->blockdedonneesParent); |
} else { |
$this->identifiant_parent = NULL; |
$this->contexteRef = $this->blockdedonneesParent->recupererDonnees(); |
} |
} |
|
function attribuerContexteRef($un_block_donnees) |
{ |
$collection_block_fils = $un_block_donnees->recupererCollectionBlockFils(); |
for($i = 0; $i < count($collection_block_fils); $i++) { |
$collection = $collection_block_fils[$i]; |
if ($collection->recupererIdentifiant() == $this->identifiant_parent) { |
return $collection->recupererBlocksDeDonnees(); |
} else if (is_object($un_block_donnees->recupererCollectionBlockFils())) { |
return $this->attribuerContexteRef($un_block_donnees->recupererCollectionBlockFils()); |
} |
} |
} |
|
function attribuerCollectionBlockFils($un_block_donnees, $id) |
{ |
$collection_block_fils = $un_block_donnees->recupererCollectionBlockFils(); |
for($i = 0; $i < count($collection_block_fils); $i++) { |
$collection = $collection_block_fils[$i]; |
if ($collection->recupererIdentifiant() == $this->identifiant_parent) { |
$blocks_de_donnees = $collection->recupererBlocksDeDonnees(); |
foreach ($blocks_de_donnees as $cle => $val) { |
if ($cle == $id) { |
return $blocks_de_donnees[$cle]->ajouterCollectionBlockFils($this->collectionblockdedonnees); |
} |
} |
} else if (is_object($this->blockdedonneesParent->recupererCollectionBlockFils())) { |
return $this->attribuerCollectionBlockFils($un_block_donnees->recupererCollectionBlockFils()); |
} |
} |
} |
|
function construire() |
{ |
$sql = $this->getSQL(); |
if(!is_null($sql)) { |
$this->openCursor($sql); |
while ($this->fetch()); |
$this->closeCursor(); |
} |
function construire() |
{ |
if (is_null($this->identifiant_parent)) { |
$sql = $this->getSQL(); |
if(!is_null($sql)) { |
$this->openCursor($sql); |
while ($this->fetch()); |
$this->closeCursor(); |
} |
} else { |
$this->contexteRefTmp = $this->contexteRef; |
for($i = 0; $i < count($this->contexteRefTmp); $i++) { |
$this->contexteRef = $this->contexteRefTmp[$i]->recupererDonnees(); |
$sql = $this->getSQL(); |
if(!is_null($sql)) { |
$this->openCursor($sql, $i); |
while ($this->fetch()); |
$this->closeCursor(); |
} |
} |
//$this->contexteRef = $this->contexteRefTmp; |
} |
//echo '<pre>'.print_r($this->contexteRef, true).'</pre>'; |
} |
|
function contruireParRecursivitePlate() |
41,13 → 98,17 |
|
} |
|
function openCursor($sql) |
function openCursor($sql, $id = null) |
{ |
$res = mysql_query($sql, $this->connexion); |
if (!$res) echo mysql_errno().': '.mysql_error()."\n"; |
$this->idRes = $res; |
$this->collectionblockdedonnees = new collectionblockdedonnees($this->identifiantblockdedonnees); |
$this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees); |
$this->collectionblockdedonnees = new collectionblockdedonnees($this->identifiantblockdedonnees); |
if (is_null($this->identifiant_parent)) { |
$this->blockdedonneesParent->ajouterCollectionBlockFils($this->collectionblockdedonnees); |
} else { |
$this->attribuerCollectionBlockFils($this->blockdedonneesParent, $id); |
} |
} |
|
function fetch() |