Index: views_alpha_pager.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/views_alpha_pager/views_alpha_pager.module,v
retrieving revision 1.5.2.28
diff -u -u -p -r1.5.2.28 views_alpha_pager.module
--- views_alpha_pager.module	11 Aug 2007 05:16:35 -0000	1.5.2.28
+++ views_alpha_pager.module	13 Aug 2007 12:23:46 -0000
@@ -43,6 +43,14 @@ function views_alpha_pager_settings() {
     '#options' => array('a' => t('First Letter'), '*' => t('All')),
     '#description' => t('Selecting "All" will display all values when no page is selected, howerver, it will still use the numeric pager'),
   );
+  $form['views_alpha_pager_clean_url'] = array(
+    '#type' => 'radios',
+    '#title' => t('Clean URLs'),
+    '#default_value' => variable_get('views_alpha_pager_clean_url', 0),
+    '#options' => array(t('Disabled'), t('Enabled')),
+    '#description' => t('This option makes Views Alpha Pager emit "clean" URLs (i.e. without <code>?q=</code> in the URL.).  This is a Views Alpha Pager option because these "clean" URLs will break views arguments, so do not use them if you use views arguments.'),
+    '#disabled' => !variable_get('clean_url', 0),
+  );
   return system_settings_form($form);
 }
 
@@ -170,7 +178,13 @@ function views_alpha_pager_views_query_a
   $items['*'] = t('All');
 
   // determine which page we are on
-  $apage = isset($_GET['apage']) ? substr($_GET['apage'], 0, 1) : '';
+  if (_views_alpha_pager_clean_url()) {
+    $arg = arg(1);
+  }
+  else {
+    $arg = isset($_GET['apage']) ? $_GET['apage'] : '';
+  }
+  $apage = substr($arg, 0, 1);
   if ($apage != '*') {
     if ($apage == '') {
       if (variable_get('views_alpha_pager_default', 'a') == 'a') {
@@ -203,10 +217,22 @@ function views_alpha_pager_views_query_a
   }
 
   // save the pager so we can add it to the top and bottom easily
-  $link = isset($view->alpha_pager_link) ? $view->alpha_pager_link : array(
-    'href' => $_GET['q'],
-    'query' => drupal_query_string_encode($_GET, array('q', 'apage'))
-  );
+  if (isset($view->alpha_pager_link)) {
+    $link = $view->alpha_pager_link;
+  }
+  elseif (_views_alpha_pager_clean_url()) {
+    $url = explode('/', $_GET['q']);
+    if (count($url) > 1) {
+      array_pop($url);
+    }
+    $link = array('href' => implode('/', $url));
+  }
+  else {
+    $link = array(
+      'href' => $_GET['q'],
+      'query' => drupal_query_string_encode($_GET, array('q', 'apage'))
+    );
+  }
   $view->alpha_pager_output = theme('alpha_pager', $items, $apage, $link);
 }
 
@@ -275,11 +301,29 @@ function theme_alpha_pager($items, $curr
   }
 }
 
-function theme_alpha_pager_link($item, $item_display, $attributes = array(), $link = array()) {
-  if ($link['query'] != '') {
-    $link['query'] .= '&';
+function _views_alpha_pager_clean_url() {
+  // Cache the clean_url variable to improve performance.
+  static $clean_url;
+  if (!isset($clean_url)) {
+    $clean_url = variable_get('views_alpha_pager_clean_url', 0);
   }
-  $link['query'] .= 'apage='. $item;
+  return $clean_url;
+}
+
+function theme_alpha_pager_link($item, $item_display, $attributes = array(), $link = array()) {
   $attributes['title'] = t('Go to @page listings', array('@page' => $item));
-  return l($item_display, $link['href'], $attributes, $link['query']);
+  if (_views_alpha_pager_clean_url()) {
+    if (substr($link['href'], 0, -1) != '/') {
+      $link['href'] .= '/';
+    }
+    $link['href'] .= $item;
+    return l($item_display, $link['href'], $attributes);
+  }
+  else {
+    if ($link['query'] != '') {
+      $link['query'] .= '&';
+    }
+    $link['query'] .= 'apage='. $item;
+    return l($item_display, $link['href'], $attributes, $link['query']);
+  }
 }
