Adaptation v10

This commit is contained in:
Fred Tempez 2020-04-02 22:32:46 +02:00
parent 779a864761
commit 2053074e0b
1 changed files with 52 additions and 50 deletions

View File

@ -598,56 +598,58 @@ class template {
}
/**
* Crée un tableau
* @param array $cols Cols des colonnes (format: [col colonne1, col colonne2, etc])
* @param array $body Contenu (format: [[contenu1, contenu2, etc], [contenu1, contenu2, etc]])
* @param array $head Entêtes (format : [[titre colonne1, titre colonne2, etc])
* @param array $attributes Attributs ($key => $value)
* @return string
*/
public static function table(array $cols = [], array $body = [], array $head = [], array $attributes = []) {
// Attributs par défaut
$attributes = array_merge([
'class' => '',
'classWrapper' => '',
'id' => ''
], $attributes);
// Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="tableWrapper ' . $attributes['classWrapper']. '">';
// Début tableau
$html .= '<table id="' . $attributes['id'] . '" class="table ' . $attributes['class']. '">';
// Entêtes
if($head) {
// Début des entêtes
$html .= '<thead>';
$html .= '<tr>';
$i = 0;
foreach($head as $th) {
$html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>';
}
// Fin des entêtes
$html .= '</tr>';
$html .= '</thead>';
}
// Début contenu
$html .= '<tbody>';
foreach($body as $tr) {
$html .= '<tr>';
$i = 0;
foreach($tr as $td) {
$html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>';
}
$html .= '</tr>';
}
// Fin contenu
$html .= '</tbody>';
// Fin tableau
$html .= '</table>';
// Fin container
$html .= '</div>';
// Retourne le html
return $html;
}
* Crée un tableau
* @param array $cols Cols des colonnes (format: [col colonne1, col colonne2, etc])
* @param array $body Contenu (format: [[contenu1, contenu2, etc], [contenu1, contenu2, etc]])
* @param array $head Entêtes (format : [[titre colonne1, titre colonne2, etc])
* @param array $attributes Attributs ($key => $value)
* @return string
*/
public static function table(array $cols = [], array $body = [], array $head = [], array $attributes = [], array $rowsId = []) {
// Attributs par défaut
$attributes = array_merge([
'class' => '',
'classWrapper' => '',
'id' => ''
], $attributes);
// Début du wrapper
$html = '<div id="' . $attributes['id'] . 'Wrapper" class="tableWrapper ' . $attributes['classWrapper']. '">';
// Début tableau
$html .= '<table id="' . $attributes['id'] . '" class="table ' . $attributes['class']. '">';
// Entêtes
if($head) {
// Début des entêtes
$html .= '<thead>';
$html .= '<tr class="nodrag">';
$i = 0;
foreach($head as $th) {
$html .= '<th class="col' . $cols[$i++] . '">' . $th . '</th>';
}
// Fin des entêtes
$html .= '</tr>';
$html .= '</thead>';
}
// Début contenu
$j = 0;
foreach($body as $tr) {
// Id de ligne pour les tableaux drag and drop
$html .= '<tr id="' . $rowsId[$j] . '">';
$j++;
$i = 0;
foreach($tr as $td) {
$html .= '<td class="col' . $cols[$i++] . '">' . $td . '</td>';
}
$html .= '</tr>';
}
// Fin contenu
$html .= '</tbody>';
// Fin tableau
$html .= '</table>';
// Fin container
$html .= '</div>';
// Retourne le html
return $html;
}
/**
* Crée un champ texte court