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
|
class tableDesigner extends html{
private $tbdesigner;
private $data;
private $id_container;
private $table_title;
private $id_title;
private $html ;
function __construct( $tbdesigner,
$data,
$id_container = "",
$id_title = "Click Me to toggle",
$table_title = "Table Title",
$css = array("","","","")
)
{
$this->tbdesigner = $tbdesigner;
$this->data = $data;
$this->id_container = $id_container;
$this->id_title = $id_title;
$this->table_title = $table_title;
$this->html = new html($css) ;
}
function printTable($return=FALSE) {
$tb = "";
$close_container = ($this->id_container!="") ? TRUE : FALSE;
$tb .= "<div id=\"".$this->id_title."\">".$this->id_title."</div>\n";
if ($close_container)
$tb .= "<div id=\"".$this->id_container."\">\n";
$tb .= "<table".$this->getClassTag("table").">\n";
$tb .= "<tr".$this->getClassTag("tr").">\n";
// for($i=0;$i<count($this->tbdesigner);$i++) {
foreach ($this->tbdesigner as $key => $value) {
// $tb .= "<td".$this->getClassTag("td")."><span".$this->getClassTag("tbdesigner").">".$this->tbdesigner[$key]."</span></td>\n";
$tb .= "<td".$this->getClassTag("td")."><span".$this->getClassTag("tbdesigner").">".$value."</span></td>\n";
}
$tb .= "</tr>\n";
//$i=0;
// for($i=0;$i<count($this->data);$i++) {
foreach ($this->data as $key => $value) {
// print_r($this->data[$key] . CRLF) ;
$tb .= "<tr".$this->getClassTag("tr").">\n";
//$j=0;
// for($j=0;$j<count($this->tbdesigner);$j++) {
foreach($this->tbdesigner as $css => $cssvalue) {
if ($this->data[$key][''.$this->tbdesigner[$css].'']=="")
$this->data[$key][''.$this->tbdesigner[$css].'']=" ";
$tb .= "<td".$this->getClassTag("td").">".$this->data[$key][''.$this->tbdesigner[$css].'']."</td>\n";
//$j++;
}
$tb .= "</tr>\n";
//$i++;
}
$tb .= "</table>\n";
if ($close_container)
$tb .= "</div>\n";
$tb .= "\n";
if ($return)
return $tb;
else
echo $tb;
}
/* DEBUG METHOD */
function printAllData()
{
$in = print_r($this->tbdesigner,true);
$dt = print_r($this->data,true);
echo "tbdesigner:<br />\n";
echo "<pre>".$in."</pre>\n";
echo "<br />\n<br />\n";
echo "DATA:<br />\n";
echo "<pre>".$dt."</pre>\n";
}
} |
Partager