diff --git a/core/ViewableData.php b/core/ViewableData.php
index 88800b70b..3de8bb850 100644
--- a/core/ViewableData.php
+++ b/core/ViewableData.php
@@ -828,6 +828,38 @@ class ViewableData extends Object implements IteratorAggregate {
}
}
+ /**
+ * Get part of class ancestry for css-class-usage.
+ * Avoids having to subclass just to built templates with new css-classes,
+ * and allows for versatile css inheritance and overrides.
+ *
+ *
+ *
+ *
+ *
+ * @uses {@link ClassInfo}
+ *
+ * @param string Classname to stop traversing upwards the ancestry (Default: ViewableData)
+ * @return string space-separated attribute encoded classes
+ */
+ function CSSClasses($stopAtClass = false) {
+ global $_ALL_CLASSES;
+ if(!$stopAtClass) $stopAtClass = 'ViewableData';
+
+ $classes = array();
+ $classAnchestry = ClassInfo::ancestry($this->class);
+ $viewableDataAnchestry = ClassInfo::ancestry($stopAtClass);
+ foreach($classAnchestry as $anchestor) {
+ if(!in_array($anchestor, $viewableDataAnchestry)) $classes[] = $anchestor;
+ }
+
+ // optionally add template identifier
+ if(isset($this->template) && $this->template != $this->class) {
+ $classes[] = $this->template;
+ }
+
+ return Convert::raw2att(implode(" ", $classes));
+ }
/**
@@ -835,7 +867,8 @@ class ViewableData extends Object implements IteratorAggregate {
* @var mixed
*/
public static $casting = array(
- 'BaseHref' => 'Varchar'
+ 'BaseHref' => 'Varchar',
+ 'CSSClasses' => 'Varchar',
);
/**
diff --git a/forms/TableListField.php b/forms/TableListField.php
index 009e37166..1a4853249 100755
--- a/forms/TableListField.php
+++ b/forms/TableListField.php
@@ -975,29 +975,6 @@ JS
return $idField->Value();
}
- /**
- * Get part of class ancestry for css-class-usage.
- * Avoids having to subclass just to built templates with new css-classes.
- */
- function Classes() {
- global $_ALL_CLASSES;
-
- $items = array();
- $parents = $_ALL_CLASSES['parents'][$this->class];
- foreach($parents as $parent) {
- if(!in_array($parent,$_ALL_CLASSES['parents']["TableListField"])) {
- $items[] = $parent;
- }
- }
- $items[] = $this->class;
- if($this->template != $this->class) {
- $items[] = $this->template;
- }
-
- return implode(" ", $items) . ' ' . $this->extraClass();
- }
-
-
/**
diff --git a/templates/ComplexTableField.ss b/templates/ComplexTableField.ss
index 30bc51fb7..a175ae6f5 100755
--- a/templates/ComplexTableField.ss
+++ b/templates/ComplexTableField.ss
@@ -1,4 +1,4 @@
-
+
<% include TableListField_PageControls %>
@@ -37,7 +37,7 @@
<% if Markable %> | <% end_if %>
$SummaryTitle |
<% control SummaryFields %>
- class="$Function"<% end_if %>>$SummaryValue |
+ class="$Function"<% end_if %>> |
<% end_control %>
<% if Can(show) %> | <% end_if %>
<% if Can(edit) %> | <% end_if %>
diff --git a/templates/TableField.ss b/templates/TableField.ss
index 45337d96a..1bab0a1c0 100755
--- a/templates/TableField.ss
+++ b/templates/TableField.ss
@@ -1,4 +1,4 @@
-
+
<% include TableListField_PageControls %>
<% if Message %>
diff --git a/templates/TableListField.ss b/templates/TableListField.ss
index 6f2fbb732..6681b0c4d 100755
--- a/templates/TableListField.ss
+++ b/templates/TableListField.ss
@@ -1,4 +1,4 @@
-
+
<% if Print %><% else %><% include TableListField_PageControls %><% end_if %>