2009-10-28 14:30:55 +00:00
|
|
|
<?php
|
2010-02-10 17:27:03 +00:00
|
|
|
// Génération de tableau
|
2009-10-28 14:30:55 +00:00
|
|
|
function theme_table($table, $attrs)
|
|
|
|
{
|
2010-01-22 08:58:39 +00:00
|
|
|
global $firephp;
|
|
|
|
//$firephp->log($table, 'table');
|
|
|
|
$output = '';
|
|
|
|
$output.= '<table'.theme_attr($attrs).'>'."\n";
|
|
|
|
if(isset($table['head']) && !empty($table['head'])) $output.= theme_tablehead($table['head']);
|
|
|
|
if(isset($table['body']) && !empty($table['body'])) $output.= theme_tablebody($table['body']);
|
|
|
|
$output.= '</table>'."\n";
|
|
|
|
return $output;
|
2009-10-28 14:30:55 +00:00
|
|
|
}
|
|
|
|
|
2010-01-22 08:58:39 +00:00
|
|
|
function theme_tablehead($head)
|
|
|
|
{
|
|
|
|
global $firephp;
|
|
|
|
//$firephp->log($head, 'head');
|
|
|
|
$output = '';
|
|
|
|
$output.= '<thead'.theme_attr($head['attrs']).'>'."\n";
|
|
|
|
$output.= theme_tablerow( array( 'data' => $head ) , true);
|
|
|
|
$output.= '</thead>'."\n";
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function theme_tablebody($body)
|
2009-10-28 14:30:55 +00:00
|
|
|
{
|
2010-01-22 08:58:39 +00:00
|
|
|
$output = '';
|
|
|
|
$output.= '<tbody'.theme_attr($body['attrs']).'>'."\n";
|
|
|
|
$output.= theme_tablerow($body['data']);
|
|
|
|
$output.= '</tbody>'."\n";
|
|
|
|
return $output;
|
2009-10-28 14:30:55 +00:00
|
|
|
}
|
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
//Génération d'une ligne de tableau
|
2010-01-22 08:58:39 +00:00
|
|
|
function theme_tablerow($rows, $head = false)
|
2009-10-28 14:30:55 +00:00
|
|
|
{
|
2010-01-22 08:58:39 +00:00
|
|
|
global $firephp;
|
|
|
|
//$firephp->log($rows, 'rows');
|
|
|
|
$output = '';
|
|
|
|
foreach($rows as $row)
|
|
|
|
{
|
|
|
|
$output.= '<tr'.theme_attr($row['attrs']).'>'."\n";
|
|
|
|
$output.= theme_tablecell($row['data'], $head);
|
|
|
|
$output.= '</tr>'."\n";
|
|
|
|
}
|
|
|
|
return $output;
|
2009-10-28 14:30:55 +00:00
|
|
|
}
|
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
//Génération cellule
|
2010-01-22 08:58:39 +00:00
|
|
|
function theme_tablecell($cells, $head)
|
2009-10-28 14:30:55 +00:00
|
|
|
{
|
2010-01-22 08:58:39 +00:00
|
|
|
global $firephp;
|
|
|
|
//$firephp->log($cells, 'cells');
|
|
|
|
$tags = 'td';
|
|
|
|
if($head) $tags = 'th';
|
|
|
|
$output = '';
|
|
|
|
foreach($cells as $cell)
|
|
|
|
{
|
|
|
|
$output.= '<'.$tags.theme_attr($cell['attrs']).'>'.$cell['data'].'</'.$tags.'>'."\n";
|
|
|
|
}
|
|
|
|
return $output;
|
2009-10-28 14:30:55 +00:00
|
|
|
}
|
|
|
|
|
2010-02-10 17:27:03 +00:00
|
|
|
//Génération d'un div
|
2009-10-28 14:30:55 +00:00
|
|
|
function theme_div()
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function theme_attr($attributs)
|
|
|
|
{
|
|
|
|
$attrs = '';
|
2010-01-22 08:58:39 +00:00
|
|
|
if(is_array($attributs) && !empty($attributs))
|
2009-10-28 14:30:55 +00:00
|
|
|
{
|
2010-01-22 08:58:39 +00:00
|
|
|
foreach( $attributs as $attr_name => $attr_value )
|
2009-10-28 14:30:55 +00:00
|
|
|
{
|
|
|
|
$attrs.=' '.$attr_name.'="'.$attr_value.'"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $attrs;
|
|
|
|
}
|
|
|
|
|
|
|
|
|