From a19320d52f7a65e1a211bc17f036dedaf1c55369 Sat, 8 Oct 2011 21:53:36 +0200
From: Jorrit Schippers <jorrit@161217.no-reply.drupal.org>
Date: Sat, 8 Oct 2011 21:52:12 +0200
Subject: [PATCH] Merge patch #1180510 from views 7.x-3.x to views 6.x-3.x.

diff --git a/handlers/views_handler_argument_string.inc b/handlers/views_handler_argument_string.inc
index 1505f7e..d4c2c28 100644
--- a/handlers/views_handler_argument_string.inc
+++ b/handlers/views_handler_argument_string.inc
@@ -230,29 +230,8 @@
     return $value;
   }
 
-  function case_transform($string, $option) {
-		global $multibyte;
-		
-    switch ($this->options[$option]) {
-      default:
-        return $string;
-      case 'upper':
-        return drupal_strtoupper($string);
-      case 'lower':
-        return drupal_strtolower($string);
-      case 'ucfirst':
-        return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1);
-      case 'ucwords':
-        if ($multibyte == UNICODE_MULTIBYTE) {
-          return mb_convert_case($string, MB_CASE_TITLE);
-        } else {
-          return ucwords($string);
-        }
-    }
-  }
-
   function title() {
-    $this->argument = $this->case_transform($this->argument, 'case');
+    $this->argument = $this->case_transform($this->argument, $this->options['case']);
     if (!empty($this->options['transform_dash'])) {
       $this->argument = strtr($this->argument, '-', ' ');
     }
@@ -284,7 +263,7 @@
   }
 
   function summary_name($data) {
-    return $this->case_transform(parent::summary_name($data), 'case');
+    return $this->case_transform(parent::summary_name($data), $this->options['case']);
   }
 
 }
diff --git a/handlers/views_handler_field.inc b/handlers/views_handler_field.inc
index 99cfb77..8c3f5fb 100644
--- a/handlers/views_handler_field.inc
+++ b/handlers/views_handler_field.inc
@@ -312,6 +312,7 @@
         'absolute' => array('default' => '', 'translatable' => FALSE),
         'external' => array('default' => '', 'translatable' => FALSE),
         'replace_spaces' => array('default' => '', 'translatable' => FALSE),
+        'path_case' => array('default' => 'none', 'translatable' => FALSE),
         'trim_whitespace' => array('default' => FALSE),
         'alt' => array('default' => '', 'translatable' => TRUE),
         'rel' => array('default' => ''),
@@ -508,7 +509,23 @@
           'edit-options-alter-make-link' => array(1)
         ),
       );
-
+      $form['alter']['path_case'] = array(
+        '#type' => 'select',
+        '#title' => t('Transform the case'),
+        '#description' => t('When printing url paths, how to transform the case of the filter value.'),
+        '#process' => array('views_process_dependency'),
+        '#dependency' => array(
+          'edit-options-alter-make-link' => array(1),
+        ),
+       '#options' => array(
+          'none' => t('No transform'),
+          'upper' => t('Upper case'),
+          'lower' => t('Lower case'),
+          'ucfirst' => t('Capitalize first letter'),
+          'ucwords' => t('Capitalize each word'),
+        ),
+        '#default_value' => $this->options['alter']['path_case'],
+      );
       $form['alter']['link_class'] = array(
         '#title' => t('Link class'),
         '#type' => 'textfield',
@@ -916,6 +933,10 @@
       // were removed by check_plain().
       $path = strip_tags(html_entity_decode(strtr($path, $tokens)));
 
+      if (!empty($alter['path_case']) && $alter['path_case'] != 'none') {
+        $path = $this->case_transform($path, $this->options['alter']['path_case']);
+      }
+
       if (!empty($alter['replace_spaces'])) {
         $path = str_replace(' ', '-', $path);
       }
diff --git a/includes/handlers.inc b/includes/handlers.inc
index 21b150a..177a348 100644
--- a/includes/handlers.inc
+++ b/includes/handlers.inc
@@ -414,6 +414,43 @@
   }
 
   /**
+   * Transform a string by a certain method.
+   *
+   * @param $string
+   *    The input you want to transform.
+   * @param $option
+   *    How do you want to transform it, possible values:
+   *      - upper: Uppercase the string.
+   *      - lower: lowercase the string.
+   *      - ucfirst: Make the first char uppercase.
+   *      - ucwords: Make each word in the string uppercase.
+   *
+   * @return string
+   *    The transformed string.
+   */
+  function case_transform($string, $option) {
+    global $multibyte;
+
+    switch ($option) {
+      default:
+        return $string;
+      case 'upper':
+        return drupal_strtoupper($string);
+      case 'lower':
+        return drupal_strtolower($string);
+      case 'ucfirst':
+        return drupal_strtoupper(drupal_substr($string, 0, 1)) . drupal_substr($string, 1);
+      case 'ucwords':
+        if ($multibyte == UNICODE_MULTIBYTE) {
+          return mb_convert_case($string, MB_CASE_TITLE);
+        }
+        else {
+          return ucwords($string);
+        }
+    }
+  }
+
+  /**
    * Validate the options form.
    */
   function options_validate($form, &$form_state) { }
