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