extranet/includes/theme/theme.php

87 lines
1.8 KiB
PHP

<?php
// Génération de tableau
function theme_table($table, $attrs)
{
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;
}
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)
{
$output = '';
$output.= '<tbody'.theme_attr($body['attrs']).'>'."\n";
$output.= theme_tablerow($body['data']);
$output.= '</tbody>'."\n";
return $output;
}
//Génération d'une ligne de tableau
function theme_tablerow($rows, $head = false)
{
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;
}
//Génération cellule
function theme_tablecell($cells, $head)
{
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;
}
//Génération d'un div
function theme_div()
{
}
function theme_attr($attributs)
{
$attrs = '';
if(is_array($attributs) && !empty($attributs))
{
foreach( $attributs as $attr_name => $attr_value )
{
$attrs.=' '.$attr_name.'="'.$attr_value.'"';
}
}
return $attrs;
}