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(); }
function debutTable($orientation = VERTICAL, $attributs = array(), $nbLignes = 1, $title = "") { // On instancie un objet pour cr�er ce tableau HTML $tableau = new Tableau(2, $attributs); $this->orientation = $orientation; $this->nbl_horizontales = $nbLignes; if (!empty($title)) { $tableau->setLegende($title); } // Jamais d'affichage de l'ent�te des lignes $tableau->setAfficheEntete(1, FALSE); // Action selon l'orientation if ($orientation == VERTICAL) { // Pas d'affichage de l'ent�te des colonnes $tableau->setAfficheEntete(2, FALSE); // On cr�e un composant dans lequel on place le tableau $this->composants[$this->nbComposants] = array("type" => "DEBUTtable", "orientation" => $orientation, "tableau" => $tableau); // Renvoi de l'identifiant de la ligne, et incr�mentation return $this->nbComposants++; } else { $this->tableau = $tableau; } }