1506 |
return $match[1]; |
return $match[1]; |
1507 |
} |
} |
1508 |
|
|
1509 |
|
/** |
1510 |
|
* Compose un tableau et retourne son code HTML |
1511 |
|
* |
1512 |
|
* @param string $id ID CSS du conteneur |
1513 |
|
* @param array $headers entêtes de colonnes |
1514 |
|
* @param array $rows lignes |
1515 |
|
* @return string code HTML |
1516 |
|
*/ |
1517 |
public function compose_generate_table($id, $headers, $rows) { |
public function compose_generate_table($id, $headers, $rows) { |
1518 |
|
// |
1519 |
|
$html = ''; |
1520 |
// Début conteneur |
// Début conteneur |
1521 |
echo '<div id="'.$id.'">'; |
$html .= '<div id="'.$id.'">'; |
1522 |
// Début tableau |
// Début tableau |
1523 |
echo '<table class="tab-tab">'; |
$html .= '<table class="tab-tab">'; |
1524 |
// Début entête |
// Début entête |
1525 |
echo '<thead>'; |
$html .= '<thead>'; |
1526 |
echo '<tr class="ui-tabs-nav ui-accordion ui-state-default tab-title">'; |
$html .= '<tr class="ui-tabs-nav ui-accordion ui-state-default tab-title">'; |
1527 |
// Colonnes |
// Colonnes |
1528 |
$nb_colonnes = count($headers); |
$nb_colonnes = count($headers); |
1529 |
$index_last_col = $nb_colonnes - 1; |
$index_last_col = $nb_colonnes - 1; |
1534 |
if ($i === $index_last_col) { |
if ($i === $index_last_col) { |
1535 |
$col = ' lastcol'; |
$col = ' lastcol'; |
1536 |
} |
} |
1537 |
echo '<th class="title col-'.$i.$col.'">'; |
$html .= '<th class="title col-'.$i.$col.'">'; |
1538 |
echo '<span class="name">'; |
$html .= '<span class="name">'; |
1539 |
echo $header; |
$html .= $header; |
1540 |
echo '</span>'; |
$html .= '</span>'; |
1541 |
echo '</th>'; |
$html .= '</th>'; |
1542 |
} |
} |
1543 |
// Fin entête |
// Fin entête |
1544 |
echo '</tr>'; |
$html .= '</tr>'; |
1545 |
echo '</thead>'; |
$html .= '</thead>'; |
1546 |
// Début corps |
// Début corps |
1547 |
echo '<tbody>'; |
$html .= '<tbody>'; |
1548 |
// Lignes |
// Lignes |
1549 |
foreach ($rows as $cells) { |
foreach ($rows as $cells) { |
1550 |
// Début ligne |
// Début ligne |
1551 |
echo '<tr class="tab-data">'; |
$html .= '<tr class="tab-data">'; |
1552 |
// Cellules |
// Cellules |
1553 |
foreach ($cells as $j => $cell) { |
foreach ($cells as $j => $cell) { |
1554 |
if ($j === 0) { |
if ($j === 0) { |
1557 |
if ($j === $index_last_col) { |
if ($j === $index_last_col) { |
1558 |
$col = ' lastcol'; |
$col = ' lastcol'; |
1559 |
} |
} |
1560 |
echo '<td class="title col-'.$j.$col.'">'; |
$html .= '<td class="title col-'.$j.$col.'">'; |
1561 |
echo '<span class="name">'; |
$html .= '<span class="name">'; |
1562 |
echo $cell; |
$html .= $cell; |
1563 |
echo '</span>'; |
$html .= '</span>'; |
1564 |
echo '</td>'; |
$html .= '</td>'; |
1565 |
} |
} |
1566 |
// Fin ligne |
// Fin ligne |
1567 |
echo "</tr>"; |
$html .= "</tr>"; |
1568 |
} |
} |
1569 |
// Fin corps |
// Fin corps |
1570 |
echo '</tbody>'; |
$html .= '</tbody>'; |
1571 |
// Fin tableau |
// Fin tableau |
1572 |
echo '</table>'; |
$html .= '</table>'; |
1573 |
// Fin conteneur |
// Fin conteneur |
1574 |
echo '</div>'; |
$html .= '</div>'; |
1575 |
|
// |
1576 |
|
return $html; |
1577 |
} |
} |
1578 |
} |
} |
1579 |
|
|