Subversion Repositories eFlore/Archives.eflore-consultation-v2

Rev

Rev 39 | Blame | Last modification | View Log | RSS feed

<?php

class blockdedonnees {
    
    protected $identifiant;
    protected $donnees;
    protected $collectionBlocksfils;
    protected $erreur;
    
    function __construct($identifiant)
    {
        $this->identifiant = $identifiant;
        $this->donnees = array();
        $this->collectionBlocksfils = array();
    }
   
    function affecterIdentifiant($identifiant)
    {
        $this->identifiant = $identifiant;
    }
   
    function affecterDonnees($donnees)
    {
        $this->donnees = $donnees;
    }
    
    function recupererDonnees()
    {
        return $this->donnees;
    }
    
    function ajouterDonnee($clef, $valeur)
    {
        $this->donnees["$clef"] = $valeur;
    }
    
    function recupererDonnee($clef)
    {
        return $this->donnees["$clef"];
    }
    
    function recupererErreur()
    {
        return $this->erreur;
    }
    
    function recupererBlockFils()
    {
        return $this->blocksfils;
    }
    
    function ajouterCollectionBlockFils($collection_block)
    {
        array_push($this->collectionBlocksfils, $collection_block);
    }
    
    function recupererCollectionBlockFils()
    {
        return $this->collectionBlocksfils;
    }
    
        function afficherPattern($chemin,$nom_fonction)
        {
                /*echo "identifiant: $this->identifiant</br>";
                echo "chemin: $chemin</br>";
                echo "nom_fonction: $nom_fonction</br>";*/
                
                if($chemin==$this->identifiant)
                {
                        call_user_func($nom_fonction,$this->donnees);
                }
                else
                {
                        
                        $etape_chemin = explode('>',$chemin);
                        if($this->identifiant==$etape_chemin[0])
                        {       //echo "collection</br>";
                                for($i=0;$i<count($this->collectionBlocksfils);$i++)
                                {
                                        $collection =$this->collectionBlocksfils[$i];
                                        //echo "collection2</br>";
                                        if ($collection->recupererIdentifiant()==$etape_chemin[1])
                                        {
                                                echo "collection3</br>";
                                                array_shift($etape_chemin);
                                                $collection->afficherPattern(implode('>',$etape_chemin),$nom_fonction);
                                        }                       
                                }
                        }
                }       
        }
    
    function afficher()
    {
        echo '<ol>';
        foreach ($this->donnees as $key => $value) {
            echo '<li>'.$key.' : '.$value;
        }
        echo '</ol>';
        for ($i = 0; $i < count($this->collectionBlocksfils); $i++) {
            $collection = $this->collectionBlocksfils[$i];
            echo '<ol>';
            $collection->afficher();
            echo '</ol>';
        }
    }
}
?>