summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc60
1 files changed, 60 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 4812e3e52..d3a909adf 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -182,6 +182,66 @@ function variable_del($name) {
unset($conf[$name]);
}
+function table_cell($cell, $header = 0) {
+ if (is_array($cell)) {
+ $data = $cell["data"];
+ foreach ($cell as $key => $value) {
+ if ($key != "data") {
+ $attributes .= " $key=\"$value\"";
+ }
+ }
+ }
+ else {
+ $data = $cell;
+ }
+
+ if ($header) {
+ $output = "<th$attributes>$data</th>";
+ }
+ else {
+ $output = "<td$attributes>$data</td>";
+ }
+
+ return $output;
+}
+
+function table($header, $rows) {
+
+ $output .= "<table>";
+
+ /*
+ ** Emit the table header:
+ */
+
+ $output .= " <tr>";
+ foreach ($header as $cell) {
+ $output .= table_cell($cell, 1);
+ }
+ $output .= " </tr>";
+
+ /*
+ ** Emit the table rows:
+ */
+
+ foreach ($rows as $number => $row) {
+ if ($number % 2 == 1) {
+ $output .= " <tr class=\"light\">";
+ }
+ else {
+ $output .= " <tr class=\"dark\">";
+ }
+
+ foreach ($row as $cell) {
+ $output .= table_cell($cell, 0);
+ }
+ $output .= " </tr>";
+ }
+
+ $output .= "</table>";
+
+ return $output;
+}
+
/**
* Format a single result entry of a search query:
*