Tout d'abord, meilleurs voeux pour 2011...
J'ai un souci dans une classe Table reprise d'autre part et déjà adaptée profondément...
La voici (ma version):
En 81, j'ai le msg dans le log.php: Undefined variable: nbsp in F:\WebSites\table\class\tableDesign.php on line 81 et pourtant; je suis persuadé de n'avoir rien modifié.... mais surement pas vrai !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 <?php $style = array("design" => "" , "title" => "" , "td" => "" , "tr" => "" , "table" => "" ) ; class tableDesign { private $id_container, $width, $cols, $table_title, $class_design, $class_title, $class_td, $class_tr, $class_table ; function __construct( $id_container="", // If table sould be contained in <div id="conainer" $id_style , $width ) { $this->id_container = $id_container; $this->cols = count($width) ; $this->width = $width ; foreach ($id_style as $key => $val) { switch($key) { case "design": $this->class_design = $val ; break ; case "title" : $this->class_title = $val ; break ; case "td" : $this->class_td = $val ; break ; case "tr" : $this->class_tr = $val ; break ; case "table" : $this->class_table = $val ; break ; default : user_error("Bad value for style" , E_USER_ERROR) ; } } } function getClassTag($node,$width=0) { switch($node) { case "design": return ($this->class_design !="" ?" class=\"".$this->class_design."\"" : "") ; break; case "title": return ($this->class_title != "" ? " class=\"".$this->class_title."\"" : "") ; break; case "td": return ($this->class_td != "" ? " class=\"".$this->class_td."\" width=\"".$width."\"" : "") ; break; case "tr": return ($this->class_tr != "" ? " class=\"".$this->class_tr."\"" : "") ; break; case "table": return ($this->class_table != "" ? " class=\"".$this->class_table."\"" : "" ) ; break; default: return ""; break; } } function addRow($rows) { if ($this->cols == count($rows) ) $this->data[] = $rows ; else user_error("Invalid Column count in AddRow function" , E_USER_ERROR) ; } function addImage($image,$border,$title) { //$this->data[] = "<img src=\"images/gplv3.png\" border=0 title=\"NEW\" />" ; } function display() { $tb = ""; // // Print HTML code // =============== if ($this->id_container != "") $tb .= "<div id=\"".$this->id_container."\">\n"; $tb .= "<table".$this->getClassTag("table").">\n"; // foreach ($this->data as $row => $data) { $tb .= "<tr".$this->getClassTag("tr").">\n"; $col = 0 ; foreach($data as $key => $cell) { if ($cell == "") ==>81 $cell = "$nbsp;" ; $tb .= "<td".$this->getClassTag("td",$this->width[$col++]).">".$cell."</td>\n"; } $tb .= "</tr>\n"; } $tb .= "</table>\n"; if ($this->id_container != "") $tb .= "</div>\n"; // // End of printing // =============== echo $tb .= "\n"; } } ?>
81 EST CORRIGE !
Que j'utilise ainsi:
Les changements apportés permettre d'avoir:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Test table</title> <style type="text/css"> #title{ cursor:pointer; } .design{ font-weight:bold; } .td{ border:1px solid black; text-align:center; padding:0px; margin: 0px; } .table { border-collapse: collapse; border:0px; margin: 0px; padding: 0px; } .row { color:red; } </style> </head> <body> <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/class/tableDesign.php" ; // define("dir_image" , "images" ) ; $style = array("design" => "design" , "title" => "title" , "td" => "td" , "tr" => "tr" , "table" => "table" ) ; class Image extends tabledesign { private $directory, $name, $width, $height, $title ; function __constructor($directory, $name, $width, $height , $title) { $this->directory = $directory ; $this->name = $name ; $this->width = $width ; $this->height = $height ; $this->title = $title ; } function __destructor() {} function display() { print( "<img src=\"images/paysviganais.jpg\" border=0 width=\"113\" height=\"113\" title=\"NEW\" />" ) ; } } $tb = new tableDesign( "content", $style , array(113,750,141) ); $row1 = array( "<img src=\"images/paysviganais.jpg\" border=0 width=\"113\" height=\"113\" title=\"Le pays Viganais\" />", "<img src=\"images/banniere.jpg\" border=0 width=\"750\" height=\"113\" title=\"Les Cimes\" />", "<img src=\"images/ETVictor.jpg\" border=0 width=\"141\" height=\"113\" title=\"Moi & Victor\" />" ) ; $row2 = array( "<img src=\"images/new.gif\" border=0 title=\"NEW\" />" , "<img src=\"images/del'aigoual.jpg\" border=0 width=\"750\" height=\"113\" title=\"Le mont Aiguoal\" />" , "Row1 Col2" ) ; $row3 = array( "<img src=\"images/new.gif\" border=0 title=\"NEW\" />" , "Row2 Col1" , "Row3 Col2" ) ; $row4 = array( //"<img src=\"images/gplv3.png\" border=0 title=\"NEW\" />", $tb->addImage("images/gplv3.png",0,"title") , "Esteban" , "Victor." ) ; $tb->addRow($row1) ; $tb->addRow($row2) ; $tb->addRow($row3) ; $tb->addRow($row4) ; $tb->display(); ?> </body> </html>
Ce qui me permettra de traiter le colspan ultérieurement...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2 <td class="td" width="123">
Que souhaiterais-je ajouter:
1) Il n'est pas rare d'avoir des tables imbriquées...
Donc inclure dans une cellule un autre script PHP
2) Pouvoir faire le "merge" de plusieurs colonnes mais là je suis proche d'une solution.
3) la méthode addImage ne donne pas (pour le moment) les résultats escomptés mais peut mieux faire
Mais toutes les idées qui viennent seront les bienvenues....
Ce n'est pas de trop pour le mal de crane ambiant.... ?
Partager