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(); }
$disp = "<a href=\"?action=edit&id=" . $row['id'] . "\">(missing)</a>"; $cell_attr['style'] = 'background-color: red; color: white;'; } } $tableau->add_callback('display', mark_missing); // Indicate that we want to sort according to name, and in // ascending order $tableau->set_default_sort('name', 0); // We are now set and done, let's display the table component $tableau->display(); } else { if ($_GET['table'] == 'responsibilities') { print "<div class='linkbox'><span><a href=\"?table=staff\">Staff</a></span> <span><b>Responsibilities</b></span>{$linkbox_other_links}</div>"; // This is the specification for the second table, // which goes quite in the same way as previously. $tableau = new Tableau($connection, 'responsibilities'); $tableau->set_columns('id', new Tableau_IDColumn(), 'name', new Tableau_ForeignKeyColumn($connection, 'staff', 'name', 'name'), 'responsibility', new Tableau_ChoiceColumn(array('watering plants', 'making fires', 'calling fire brigade'))); $tableau->set_name('id', 'ID', 'name', 'Name', 'responsibility', 'Responsibility'); $tableau->set_comment('responsibility', 'What this guy or gal should do?'); $tableau->add_validator('name', value_required); $tableau->add_validator('responsibility', value_required); $tableau->set_default_sort('name'); // We set a default filter that shows only names containing 'c'. // The user can override this either by specifying her own filter, // or by hitting the 'Clear' button. $tableau->set_default_filters(array(array('name', 'LIKE', 'c'))); // Ok, display it. $tableau->display(); } } $end_time = microtime_float();
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; } }