This commit is contained in:
2020-09-04 06:10:06 +08:00
commit 7cd6339996
33 changed files with 3380 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
include_once plugin_dir_path(dirname(__FILE__)) . 'includes/html_helper.php';
class APIgoatTemplate
{
public function __construct()
{
}
public function getTable(array $data, array $headers = null, array $classes = null)
{
$rows = '';
$cols = '';
$header = '';
$th = '';
foreach ($data as $row) {
if (is_array($row)) {
$header = '';
foreach ($row as $name => $field) {
if ($headers == null || in_array($name, $headers)) {
$cols .= td($field);
}
}
$rows .= tr($cols);
$cols = '';
} else {
$rows .= tr(td($row));
}
}
foreach ($headers as $name => $header) {
$th .= th($header);
}
return table(
thead($th) . tbody($rows),
"class='" . $classes['table'] . "'"
);
}
}