Ejemplo n.º 1
0
 function tableau($attributs = array())
 {
     // Cr�ation de l'objet tableau
     $tableau = new Tableau(2, $attributs);
     $tableau->setCouleurImpaire("silver");
     $tableau->setAfficheEntete(1, false);
     $tableau->setLegende("Lines in {$this->nomTable}");
     // Texte des ent�tes
     foreach ($this->schemaTable as $nom => $options) {
         if (!isset($this->auto_increment_key[$nom])) {
             $tableau->ajoutEntete(2, $nom, $this->entetes[$nom]);
         }
     }
     //    $tableau->ajoutEntete(2, "action", "Action");
     // Parcours de la table
     $requete = "SELECT * FROM {$this->nomTable} {$this->where_clause}";
     if (!empty($this->order_by_clause)) {
         $requete .= "ORDER BY {$this->order_by_clause}";
     }
     $resultat = $this->bd->execRequete($requete);
     $i = 0;
     while ($ligne = $this->bd->ligneSuivante($resultat)) {
         $i++;
         // Cr�ation des cellules
         foreach ($this->schemaTable as $nom => $options) {
             if (!isset($this->auto_increment_key[$nom])) {
                 if ($options['type'] == "time") {
                     // Show only hour and minutes
                     $time = explode(":", $ligne[$nom]);
                     $ligne[$nom] = $time[0] . ":" . $time[1];
                 }
                 if (isset($this->form_fields_type[$nom])) {
                     // La valeur est r�f�renc�e par la cl� externe $ligne[$nom]
                     $libelle = $this->form_fields[$nom][$ligne[$nom]];
                 } else {
                     // Attention: traitement des balises HTML avant affichage
                     $libelle = htmlSpecialChars($ligne[$nom]);
                 }
                 $tableau->ajoutValeur($i, $nom, $libelle);
             }
         }
         // Cr�ation de l'URL de modification
         $urlMod = $this->accesCle($ligne) . "&ihm_action=" . EDITER;
         $modLink = "<a href='{$this->nomScript}{$urlMod}'>modify</a>";
         $tableau->ajoutValeur($i, "Modify", $modLink);
         $urlDel = $this->accesCle($ligne) . "&ihm_action=" . DEL_BD;
         $jscript = "onClick=\"if (confirm('This will remove this tuple!?')) " . "{window.location = '{$this->nomScript}{$urlDel}';}  else alert ('Concelled');\" ";
         /* $jscript= "onClick=\"ConfirmAction"
            . "('This will remove this tuple!?', '$this->nomScript$urlDel')\"";*/
         $delLink = "<a {$jscript} href='#'>delete</a>";
         $tableau->ajoutValeur($i, "Delete", $delLink);
     }
     // Retour de la cha�ne contenant le tableau
     return $tableau->tableauHTML();
 }