mirror of
https://github.com/moodle/moodle.git
synced 2025-08-03 16:13:28 +02:00
New feature: you can now give a HTML class to a column with $table->column_class()
This commit is contained in:
parent
6580d0af68
commit
554906f69a
1 changed files with 13 additions and 4 deletions
|
@ -7,6 +7,7 @@ class flexible_table {
|
|||
var $headers = array();
|
||||
var $columns = array();
|
||||
var $column_style = array();
|
||||
var $column_class = array();
|
||||
var $column_suppress = array();
|
||||
var $setup = false;
|
||||
var $sess = NULL;
|
||||
|
@ -57,6 +58,12 @@ class flexible_table {
|
|||
}
|
||||
}
|
||||
|
||||
function column_class($column, $classname) {
|
||||
if(isset($this->column_class[$column])) {
|
||||
$this->column_class[$column] = ' '.$classname; // This space needed so that classnames don't run together in the HTML
|
||||
}
|
||||
}
|
||||
|
||||
function column_style($column, $property, $value) {
|
||||
if(isset($this->column_style[$column])) {
|
||||
$this->column_style[$column][$property] = $value;
|
||||
|
@ -82,11 +89,13 @@ class flexible_table {
|
|||
function define_columns($columns) {
|
||||
$this->columns = array();
|
||||
$this->column_style = array();
|
||||
$this->column_class = array();
|
||||
$colnum = 0;
|
||||
|
||||
foreach($columns as $column) {
|
||||
$this->columns[$column] = $colnum++;
|
||||
$this->column_style[$column] = array();
|
||||
$this->column_class[$column] = '';
|
||||
$this->column_suppress[$column] = false;
|
||||
}
|
||||
}
|
||||
|
@ -400,13 +409,13 @@ class flexible_table {
|
|||
}
|
||||
|
||||
if($this->headers[$index] === NULL) {
|
||||
echo '<th class="header c'.$index.'"> </th>';
|
||||
echo '<th class="header c'.$index.$this->column_class[$column].'"> </th>';
|
||||
}
|
||||
else if(!empty($this->sess->collapse[$column])) {
|
||||
echo '<th class="header c'.$index.'">'.$icon_hide.'</th>';
|
||||
echo '<th class="header c'.$index.$this->column_class[$column].'">'.$icon_hide.'</th>';
|
||||
}
|
||||
else {
|
||||
echo '<th class="header c'.$index.'" nowrap="nowrap"'.$this->make_styles_string($this->column_style[$column]).'>'.$this->headers[$index].$icon_sort.'<div class="commands">'.$icon_hide.'</div></th>';
|
||||
echo '<th class="header c'.$index.$this->column_class[$column].'" nowrap="nowrap"'.$this->make_styles_string($this->column_style[$column]).'>'.$this->headers[$index].$icon_sort.'<div class="commands">'.$icon_hide.'</div></th>';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -429,7 +438,7 @@ class flexible_table {
|
|||
break;
|
||||
}
|
||||
$column = $colbyindex[$index];
|
||||
echo '<td class="cell c'.$index.'"'.$this->make_styles_string($this->column_style[$column]).'>';
|
||||
echo '<td class="cell c'.$index.$this->column_class[$column].'"'.$this->make_styles_string($this->column_style[$column]).'>';
|
||||
if(empty($this->sess->collapse[$column])) {
|
||||
if($this->column_suppress[$column] && $suppress_lastrow !== NULL && $suppress_lastrow[$index] === $data) {
|
||||
echo ' ';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue