Skip to content

Commit a5c0800

Browse files
authored
Merge pull request #4275 from paulbalandan/bugfix/view-table
Fix incomplete fillup of table template
2 parents 23ae16f + d3af79f commit a5c0800

File tree

1 file changed

+7
-35
lines changed

1 file changed

+7
-35
lines changed

system/View/Table.php

Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ public function __construct($config = [])
9898
}
9999
}
100100

101-
// --------------------------------------------------------------------
102-
103101
/**
104102
* Set the template
105103
*
@@ -117,8 +115,6 @@ public function setTemplate($template)
117115
return true;
118116
}
119117

120-
// --------------------------------------------------------------------
121-
122118
/**
123119
* Set the table heading
124120
*
@@ -145,8 +141,6 @@ public function setFooting()
145141
return $this;
146142
}
147143

148-
// --------------------------------------------------------------------
149-
150144
/**
151145
* Set columns. Takes a one-dimensional array as input and creates
152146
* a multi-dimensional array with a depth equal to the number of
@@ -194,8 +188,6 @@ public function makeColumns($array = [], $columnLimit = 0)
194188
return $new;
195189
}
196190

197-
// --------------------------------------------------------------------
198-
199191
/**
200192
* Set "empty" cells
201193
*
@@ -210,8 +202,6 @@ public function setEmpty($value)
210202
return $this;
211203
}
212204

213-
// --------------------------------------------------------------------
214-
215205
/**
216206
* Add a table row
217207
*
@@ -225,8 +215,6 @@ public function addRow()
225215
return $this;
226216
}
227217

228-
// --------------------------------------------------------------------
229-
230218
/**
231219
* Prep Args
232220
*
@@ -256,8 +244,6 @@ protected function _prepArgs(array $args)
256244
return $args;
257245
}
258246

259-
// --------------------------------------------------------------------
260-
261247
/**
262248
* Add a table caption
263249
*
@@ -270,8 +256,6 @@ public function setCaption($caption)
270256
return $this;
271257
}
272258

273-
// --------------------------------------------------------------------
274-
275259
/**
276260
* Generate the table
277261
*
@@ -425,8 +409,6 @@ public function generate($tableData = null)
425409
return $out;
426410
}
427411

428-
// --------------------------------------------------------------------
429-
430412
/**
431413
* Clears the table arrays. Useful if multiple tables are being generated
432414
*
@@ -442,8 +424,6 @@ public function clear()
442424
return $this;
443425
}
444426

445-
// --------------------------------------------------------------------
446-
447427
/**
448428
* Set table data from a database result object
449429
*
@@ -453,7 +433,7 @@ public function clear()
453433
protected function _setFromDBResult($object)
454434
{
455435
// First generate the headings from the table column names
456-
if ($this->autoHeading === true && empty($this->heading))
436+
if ($this->autoHeading && empty($this->heading))
457437
{
458438
$this->heading = $this->_prepArgs($object->getFieldNames());
459439
}
@@ -464,17 +444,16 @@ protected function _setFromDBResult($object)
464444
}
465445
}
466446

467-
// --------------------------------------------------------------------
468-
469447
/**
470448
* Set table data from an array
471449
*
472-
* @param array $data
450+
* @param array $data
451+
*
473452
* @return void
474453
*/
475454
protected function _setFromArray($data)
476455
{
477-
if ($this->autoHeading === true && empty($this->heading))
456+
if ($this->autoHeading && empty($this->heading))
478457
{
479458
$this->heading = $this->_prepArgs(array_shift($data));
480459
}
@@ -485,8 +464,6 @@ protected function _setFromArray($data)
485464
}
486465
}
487466

488-
// --------------------------------------------------------------------
489-
490467
/**
491468
* Compile Template
492469
*
@@ -500,18 +477,15 @@ protected function _compileTemplate()
500477
return;
501478
}
502479

503-
$temp = $this->_defaultTemplate();
504-
foreach (['table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close'] as $val)
480+
foreach ($this->_defaultTemplate() as $field => $template)
505481
{
506-
if (! isset($this->template[$val]))
482+
if (! isset($this->template[$field]))
507483
{
508-
$this->template[$val] = $temp[$val];
484+
$this->template[$field] = $template;
509485
}
510486
}
511487
}
512488

513-
// --------------------------------------------------------------------
514-
515489
/**
516490
* Default Template
517491
*
@@ -546,6 +520,4 @@ protected function _defaultTemplate()
546520
'table_close' => '</table>',
547521
];
548522
}
549-
550-
// --------------------------------------------------------------------
551523
}

0 commit comments

Comments
 (0)