Skip to content

Commit d3af79f

Browse files
committed
Fix incomplete fillup of table template
1 parent b1d4ffc commit d3af79f

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
*
@@ -253,8 +241,6 @@ protected function _prepArgs(array $args)
253241
return $args;
254242
}
255243

256-
// --------------------------------------------------------------------
257-
258244
/**
259245
* Add a table caption
260246
*
@@ -267,8 +253,6 @@ public function setCaption($caption)
267253
return $this;
268254
}
269255

270-
// --------------------------------------------------------------------
271-
272256
/**
273257
* Generate the table
274258
*
@@ -422,8 +406,6 @@ public function generate($tableData = null)
422406
return $out;
423407
}
424408

425-
// --------------------------------------------------------------------
426-
427409
/**
428410
* Clears the table arrays. Useful if multiple tables are being generated
429411
*
@@ -439,8 +421,6 @@ public function clear()
439421
return $this;
440422
}
441423

442-
// --------------------------------------------------------------------
443-
444424
/**
445425
* Set table data from a database result object
446426
*
@@ -450,7 +430,7 @@ public function clear()
450430
protected function _setFromDBResult($object)
451431
{
452432
// First generate the headings from the table column names
453-
if ($this->autoHeading === true && empty($this->heading))
433+
if ($this->autoHeading && empty($this->heading))
454434
{
455435
$this->heading = $this->_prepArgs($object->getFieldNames());
456436
}
@@ -461,17 +441,16 @@ protected function _setFromDBResult($object)
461441
}
462442
}
463443

464-
// --------------------------------------------------------------------
465-
466444
/**
467445
* Set table data from an array
468446
*
469-
* @param array $data
447+
* @param array $data
448+
*
470449
* @return void
471450
*/
472451
protected function _setFromArray($data)
473452
{
474-
if ($this->autoHeading === true && empty($this->heading))
453+
if ($this->autoHeading && empty($this->heading))
475454
{
476455
$this->heading = $this->_prepArgs(array_shift($data));
477456
}
@@ -482,8 +461,6 @@ protected function _setFromArray($data)
482461
}
483462
}
484463

485-
// --------------------------------------------------------------------
486-
487464
/**
488465
* Compile Template
489466
*
@@ -497,18 +474,15 @@ protected function _compileTemplate()
497474
return;
498475
}
499476

500-
$temp = $this->_defaultTemplate();
501-
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)
477+
foreach ($this->_defaultTemplate() as $field => $template)
502478
{
503-
if (! isset($this->template[$val]))
479+
if (! isset($this->template[$field]))
504480
{
505-
$this->template[$val] = $temp[$val];
481+
$this->template[$field] = $template;
506482
}
507483
}
508484
}
509485

510-
// --------------------------------------------------------------------
511-
512486
/**
513487
* Default Template
514488
*
@@ -543,6 +517,4 @@ protected function _defaultTemplate()
543517
'table_close' => '</table>',
544518
];
545519
}
546-
547-
// --------------------------------------------------------------------
548520
}

0 commit comments

Comments
 (0)