From a3644638aaf0418598196a870204e0b632a4c8ad Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Fri, 17 Apr 2015 06:28:40 -0400
Subject: [PATCH] Allow preference sections to define CSS class names

---
 program/include/rcmail.php      |   14 +++++++++++++-
 program/steps/settings/func.inc |    7 +++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/program/include/rcmail.php b/program/include/rcmail.php
index 2a154d9..638acda 100644
--- a/program/include/rcmail.php
+++ b/program/include/rcmail.php
@@ -1127,7 +1127,19 @@
                 // format each col
                 foreach ($a_show_cols as $col) {
                     $val = is_array($row_data[$col]) ? $row_data[$col][0] : $row_data[$col];
-                    $table->add($col, empty($attrib['ishtml']) ? $this->Q($val) : $val);
+
+                    // escape html
+                    if (empty($attrib['ishtml'])) {
+                        $val = html::quote($val);
+                    }
+
+                    // check if we want to add a class to this table cell
+                    $clskey = $col . '_class';
+                    if (!empty($row_data[$clskey])) {
+                        $col .= ' ' . $row_data[$clskey];
+                    }
+
+                    $table->add($col, $val);
                 }
             }
         }
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index c763dd3..a136d38 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -73,6 +73,13 @@
 
     list($list, $cols) = rcmail_user_prefs();
 
+    // add section keys as class name to the primary col
+    array_walk($list, function(&$item, $key) use ($attrib) {
+        if (!isset($item['section_class'])) {
+            $item['section_class'] = trim($attrib['classprefix'] . $key);
+        }
+    });
+
     // create XHTML table
     $out = $RCMAIL->table_output($attrib, $list, $cols, 'id');
 

--
Gitblit v1.9.1