? handlers/.views_handler_field.inc.swp
Index: views.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/views.module,v
retrieving revision 1.332.2.24
diff -u -r1.332.2.24 views.module
--- views.module	10 Mar 2010 21:06:43 -0000	1.332.2.24
+++ views.module	20 Mar 2010 03:28:42 -0000
@@ -1328,3 +1328,36 @@
   list($usec, $sec) = explode(' ', microtime());
   return (float)$sec + (float)$usec;
 }
+
+/**
+ * Trim the field down to the specified length.
+ *
+ * @param $alter
+ *   - max_length: Maximum lenght of the string, the rest gets truncated.
+ *   - word_boundary: Trim only on a word boundary.
+ *   - ellipsis: Trim only on a word boundary.
+ *   - html: Take sure that the html is correct.
+ */
+function drupal_trim_text($alter, $value) {
+  dsm('strlen $value ' . drupal_strlen($value));
+  dsm('max_length ' . $alter['max_length']);
+  if (drupal_strlen($value) > $alter['max_length']) {
+    $value = drupal_substr($value, 0, $alter['max_length']);
+    if (!empty($alter['word_boundary'])) {
+      if (preg_match("/(.*)\b.+/us", $value, $matches)) {
+        $value = $matches[1];
+      }
+    } 
+    // Remove scraps of HTML entities from the end of a strings
+    $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value));
+    
+    if (!empty($alter['ellipsis'])) {
+      $value .= '...';
+    }
+  }
+  if (!empty($alter['html'])) {
+    $value = _filter_htmlcorrector($value);
+  }
+
+  return $value;
+}
Index: handlers/views_handler_field.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views/handlers/views_handler_field.inc,v
retrieving revision 1.14.2.28
diff -u -r1.14.2.28 views_handler_field.inc
--- handlers/views_handler_field.inc	19 Mar 2010 23:50:08 -0000	1.14.2.28
+++ handlers/views_handler_field.inc	20 Mar 2010 03:28:42 -0000
@@ -370,17 +370,6 @@
         ),
       );
 
-      $form['alter']['strip_tags'] = array(
-        '#type' => 'checkbox',
-        '#title' => t('Strip HTML tags'),
-        '#description' => t('If checked, all HTML tags will be stripped.'),
-        '#default_value' => $this->options['alter']['strip_tags'],
-        '#process' => array('views_process_dependency'),
-        '#dependency' => array(
-          'edit-options-alter-trim' => array(1)
-        ),
-      );
-
       $form['alter']['html'] = array(
         '#type' => 'checkbox',
         '#title' => t('Field can contain HTML'),
@@ -391,7 +380,16 @@
           'edit-options-alter-trim' => array(1)
         ),
       );
+
+      $form['alter']['strip_tags'] = array(
+        '#type' => 'checkbox',
+        '#title' => t('Strip HTML tags'),
+        '#description' => t('If checked, all HTML tags will be stripped.'),
+        '#default_value' => $this->options['alter']['strip_tags'],
+        '#process' => array('views_process_dependency'),
+      );
     }
+
     $form['empty'] = array(
       '#type' => 'textfield',
       '#title' => t('Empty text'),
@@ -506,6 +504,10 @@
       $tokens = $this->get_render_tokens($alter);
       $value = $this->render_altered($alter, $tokens);
     }
+ 
+    if (!empty($alter['strip_tags'])) {
+      $value = strip_tags($value);
+    }
 
     if (!empty($alter['trim']) && !empty($alter['max_length'])) {
       $value = $this->render_trim_text($alter, $value);
@@ -537,45 +539,12 @@
    */
   function render_trim_text($alter, $value) {
     if (!empty($alter['strip_tags'])) {
-      $value = strip_tags($value);
       // NOTE: It's possible that some external fields might override the
       // element type so if someone from, say, CCK runs into a bug here,
       // this may be why =)
       $this->definition['element type'] = 'span';
     }
-
-    if (drupal_strlen($value) <= $alter['max_length']) {
-      return $value;
-    }
-
-    $value = drupal_substr($value, 0, $alter['max_length']);
-
-    // TODO: replace this with cleanstring of ctools
-    if (!empty($alter['word_boundary'])) {
-      $regex = "(.*)\b.+";
-      if (function_exists('mb_ereg')) {
-        mb_regex_encoding('UTF-8');
-        $found = mb_ereg($regex, $value, $matches);
-      }
-      else {
-        $found = preg_match("/$regex/us", $value, $matches);
-      }
-      if ($found) {
-        $value = $matches[1];
-      }
-    }
-    // Remove scraps of HTML entities from the end of a strings
-    $value = rtrim(preg_replace('/(?:<(?!.+>)|&(?!.+;)).*$/us', '', $value));
-
-    if (!empty($alter['ellipsis'])) {
-      $value .= '&#8230;';
-    }
-
-    if (!empty($alter['html'])) {
-      $value = _filter_htmlcorrector($value);
-    }
-
-    return $value;
+    return drupal_trim_text($alter, $value);
   }
 
   /**
