summaryrefslogtreecommitdiff
path: root/includes/theme.inc
diff options
context:
space:
mode:
Diffstat (limited to 'includes/theme.inc')
-rw-r--r--includes/theme.inc77
1 files changed, 77 insertions, 0 deletions
diff --git a/includes/theme.inc b/includes/theme.inc
index 9eaa9e8bd..ae284d34d 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -122,6 +122,83 @@ function theme_node($node, $main) {
return $output;
}
+function _theme_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;
+}
+
+
+/**
+ Returns themed table.
+
+ @param $header
+ @param $rows
+
+ @return a string contraining the \a node output.
+**/
+
+function theme_table($header, $rows) {
+
+ $output = "<table>\n";
+
+ /*
+ ** Emit the table header:
+ */
+
+ if (is_array($header)) {
+ $output .= " <tr>";
+ foreach ($header as $cell) {
+ if (is_array($cell) && $cell["field"]) {
+ $cell = tablesort($cell, $header);
+ }
+ $output .= _theme_table_cell($cell, 1);
+ }
+ $output .= " </tr>\n";
+ }
+
+ /*
+ ** Emit the table rows:
+ */
+
+ if (is_array($rows)) {
+ foreach ($rows as $number => $row) {
+ if ($number % 2 == 1) {
+ $output .= " <tr class=\"light\">";
+ }
+ else {
+ $output .= " <tr class=\"dark\">";
+ }
+
+ foreach ($row as $cell) {
+ $output .= _theme_table_cell($cell, 0);
+ }
+ $output .= " </tr>\n";
+ }
+ }
+
+ $output .= "</table>\n";
+
+ return $output;
+}
+
/**
Returns themed box.