? nbproject
Index: semanticviews.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/semanticviews/Attic/semanticviews.module,v
retrieving revision 1.1.2.15
diff -u -p -r1.1.2.15 semanticviews.module
--- semanticviews.module	20 Feb 2010 14:43:06 -0000	1.1.2.15
+++ semanticviews.module	25 Feb 2010 10:38:11 -0000
@@ -15,6 +15,39 @@ function semanticviews_views_api() {
 }
 
 /**
+ * Helper function that returns an array with field aliases as key and the
+ * field tokens as values.
+ */
+function semanticviews_get_alias_tokens($view) {
+  $tokens = array();
+  // We want to use the last field, as that field does have access to all the
+  // field tokens.
+  $last_field_key = array_pop(array_keys($view->field));
+  $last_field = $view->field[$last_field_key];
+  // Now add replacements for our fields.
+  foreach ($last_field->view->display_handler->get_handlers('field') as $name => $handler) {
+    $tokens[$handler->field_alias] = "[$name]";
+    if ($name == $last_field->options['id']) {
+      break;
+    }
+  }
+  return $tokens;
+}
+
+/**
+ * Helper function that returns row replacements given a row and all tokens.
+ */
+function semanticviews_get_token_replacements($row, $tokens) {
+  $replacements = array();
+  foreach ($row as $alias => $value) {
+    if (!empty($tokens[$alias])) {
+      $replacements[$tokens[$alias]] = $value;
+    }
+  }
+  return $replacements;
+}
+
+/**
  * Preprocess theme function to print a single record from a row, with fields
  */
 function template_preprocess_semanticviews_view_fields(&$variables) {
@@ -63,6 +96,8 @@ function template_preprocess_semanticvie
  * Display the simple view of rows one after another
  */
 function template_preprocess_semanticviews_view_unformatted(&$variables) {
+  $view = $variables['view'];
+
   $variables['group_element'] = check_plain($variables['options']['group']['element_type']);
   $variables['group_attributes'] = array();
   if ($variables['options']['group']['class']) {
@@ -88,11 +123,19 @@ function template_preprocess_semanticvie
   }
   $striping = count($stripes);
 
+  // Get alias tokens.
+  $tokens = semanticviews_get_alias_tokens($view);
+
   foreach ($variables['rows'] as $id => $row) {
     $variables['row_attributes'][$id] = array();
     $classes = array();
     if ($variables['options']['row']['class']) {
-      $classes[] = str_replace('#', $id, $variables['options']['row']['class']);
+      // Get token replacements.
+      $replacements = semanticviews_get_token_replacements($view->result[$id], $tokens);
+      // Add replacement for the row number.
+      $replacements['#'] = $id;
+      // Final preparation of the row class.
+      $classes[] = strtr($variables['options']['row']['class'], $replacements);
     }
     if ($variables['options']['row']['first_class']) {
       // The FIRST class attribute can be used in two ways. When the "last every
