? 647228_6_ajax_link.patch
? ajax_link.patch
? d7ajax.kpf
? drupal.ajax-link.12.patch
? drupal.ajax-link.9.patch
? sites/all/modules/examples
? sites/all/modules/quicktabs
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: includes/ajax.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/ajax.inc,v
retrieving revision 1.29
diff -u -p -r1.29 ajax.inc
--- includes/ajax.inc	31 Mar 2010 19:34:56 -0000	1.29
+++ includes/ajax.inc	26 Apr 2010 03:55:13 -0000
@@ -410,9 +410,9 @@ function ajax_footer() {
  *   None. Additional code is added to the header of the page using
  *   drupal_add_js().
  */
-function ajax_process_form($element, &$form_state) {
+function ajax_process_element($element, &$form_state = array()) {
   // Nothing to do if there is neither a callback nor a path.
-  if (!(isset($element['#ajax']['callback']) || isset($element['#ajax']['path']))) {
+  if (!(isset($element['#ajax']['callback']) || isset($element['#ajax']['path']) || isset($element['#href']))) {
     return $element;
   }
 
@@ -443,6 +443,21 @@ function ajax_process_form($element, &$f
         $element['#ajax']['event'] = 'change';
         break;
 
+      case 'link':
+        $element['#ajax']['event'] = 'click';
+        if (!isset($element['#attributes']['id'])) {
+          if (isset($element['#id'])) {
+            $element['#attributes']['id'] = $element['#id'];
+          }
+          else if (isset($element['#options']['attributes']['id'])) {
+            $element['#attributes']['id'] = $element['#options']['attributes']['id'];
+          }
+          else {
+            $element['#attributes']['id'] = $element['#id'] = drupal_html_id('ajax-link');
+          }
+        }
+        break;
+
       default:
         return $element;
     }
@@ -452,7 +467,6 @@ function ajax_process_form($element, &$f
   if (isset($element['#ajax']['event'])) {
     $element['#attached']['library'][] = array('system', 'form');
     $element['#attached']['js']['misc/ajax.js'] = array('weight' => JS_LIBRARY + 2);
-
     $settings = $element['#ajax'];
 
     // Assign default settings.
@@ -464,37 +478,43 @@ function ajax_process_form($element, &$f
       'progress' => array('type' => 'throbber'),
     );
 
-    // Change path to url.
-    $settings['url'] = isset($settings['path']) ? url($settings['path']) : url('system/ajax');
-    unset($settings['path']);
-
-    // Add special data to $settings['submit'] so that when this element
-    // triggers an AJAX submission, Drupal's form processing can determine which
-    // element triggered it.
-    // @see _form_element_triggered_scripted_submission()
-    if (isset($settings['trigger_as'])) {
-      // An element can add a 'trigger_as' key within #ajax to make the element
-      // submit as though another one (for example, a non-button can use this
-      // to submit the form as though a button were clicked). When using this,
-      // the 'name' key is always required to identify the element to trigger
-      // as. The 'value' key is optional, and only needed when multiple elements
-      // share the same name, which is commonly the case for buttons.
-      $settings['submit']['_triggering_element_name'] = $settings['trigger_as']['name'];
-      if (isset($settings['trigger_as']['value'])) {
-        $settings['submit']['_triggering_element_value'] = $settings['trigger_as']['value'];
+    if ($element['#type'] != 'link') {
+      // Change path to url.
+      $settings['url'] = isset($settings['path']) ? url($settings['path']) : url('system/ajax');
+      unset($settings['path']);
+
+      // Add special data to $settings['submit'] so that when this element
+      // triggers an AJAX submission, Drupal's form processing can determine which
+      // element triggered it.
+      // @see _form_element_triggered_scripted_submission()
+      if (isset($settings['trigger_as'])) {
+        // An element can add a 'trigger_as' key within #ajax to make the element
+        // submit as though another one (for example, a non-button can use this
+        // to submit the form as though a button were clicked). When using this,
+        // the 'name' key is always required to identify the element to trigger
+        // as. The 'value' key is optional, and only needed when multiple elements
+        // share the same name, which is commonly the case for buttons.
+        $settings['submit']['_triggering_element_name'] = $settings['trigger_as']['name'];
+        if (isset($settings['trigger_as']['value'])) {
+          $settings['submit']['_triggering_element_value'] = $settings['trigger_as']['value'];
+        }
+        unset($settings['trigger_as']);
+      }
+      else {
+        // Most of the time, elements can submit as themselves, in which case the
+        // 'trigger_as' key isn't needed, and the element's name is used.
+        $settings['submit']['_triggering_element_name'] = $element['#name'];
+        // If the element is a (non-image) button, its name may not identify it
+        // uniquely, in which case a match on value is also needed.
+        // @see _form_button_was_clicked()
+        if (isset($element['#button_type']) && empty($element['#has_garbage_value'])) {
+          $settings['submit']['_triggering_element_value'] = $element['#value'];
+        }
       }
-      unset($settings['trigger_as']);
     }
     else {
-      // Most of the time, elements can submit as themselves, in which case the
-      // 'trigger_as' key isn't needed, and the element's name is used.
-      $settings['submit']['_triggering_element_name'] = $element['#name'];
-      // If the element is a (non-image) button, its name may not identify it
-      // uniquely, in which case a match on value is also needed.
-      // @see _form_button_was_clicked()
-      if (isset($element['#button_type']) && empty($element['#has_garbage_value'])) {
-        $settings['submit']['_triggering_element_value'] = $element['#value'];
-      }
+      // This is a link so we use its href as the url for our AJAX request.
+      $settings['url'] = url($element['#href'], isset($element['#options']) ? $element['#options'] : array());
     }
 
     // Convert a simple #ajax['progress'] string into an array.
@@ -516,7 +536,9 @@ function ajax_process_form($element, &$f
       'data' => array('ajax' => array($element['#id'] => $settings)),
     );
 
-    $form_state['cache'] = TRUE;
+    if (!empty($form_state)) {
+      $form_state['cache'] = TRUE;
+    }
   }
   return $element;
 }
Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1151
diff -u -p -r1.1151 common.inc
--- includes/common.inc	24 Apr 2010 14:53:59 -0000	1.1151
+++ includes/common.inc	26 Apr 2010 03:55:17 -0000
@@ -4716,6 +4716,12 @@ function drupal_pre_render_conditional_c
  */
 function drupal_pre_render_link($elements) {
   $options = isset($elements['#options']) ? $elements['#options'] : array();
+  if (isset($elements['#attributes'])) {
+    $options['attributes'] = $elements['#attributes'];
+    if (isset($elements['#options']['attributes'])) {
+      $options['attributes'] += $elements['#options']['attributes'];
+    }
+  }
   $elements['#markup'] = l($elements['#title'], $elements['#href'], $options);
   return $elements;
 }
Index: modules/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.923
diff -u -p -r1.923 system.module
--- modules/system/system.module	24 Apr 2010 14:49:14 -0000	1.923
+++ modules/system/system.module	26 Apr 2010 03:55:20 -0000
@@ -313,7 +313,7 @@ function system_element_info() {
     '#button_type' => 'submit',
     '#executes_submit_callback' => TRUE,
     '#limit_validation_errors' => FALSE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme_wrappers' => array('button'),
   );
   $types['button'] = array(
@@ -322,7 +322,7 @@ function system_element_info() {
     '#button_type' => 'submit',
     '#executes_submit_callback' => FALSE,
     '#limit_validation_errors' => FALSE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme_wrappers' => array('button'),
   );
   $types['image_button'] = array(
@@ -330,7 +330,7 @@ function system_element_info() {
     '#button_type' => 'submit',
     '#executes_submit_callback' => TRUE,
     '#limit_validation_errors' => FALSE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#return_value' => TRUE,
     '#has_garbage_value' => TRUE,
     '#src' => NULL,
@@ -341,7 +341,7 @@ function system_element_info() {
     '#size' => 60,
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'textfield',
     '#theme_wrappers' => array('form_element'),
   );
@@ -349,7 +349,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#size' => 60,
     '#maxlength' => 128,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'password',
     '#theme_wrappers' => array('form_element'),
   );
@@ -363,7 +363,7 @@ function system_element_info() {
     '#cols' => 60,
     '#rows' => 5,
     '#resizable' => TRUE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'textarea',
     '#theme_wrappers' => array('form_element'),
   );
@@ -376,7 +376,7 @@ function system_element_info() {
   $types['radio'] = array(
     '#input' => TRUE,
     '#default_value' => NULL,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'radio',
     '#theme_wrappers' => array('form_element'),
     '#title_display' => 'after',
@@ -391,7 +391,7 @@ function system_element_info() {
   $types['checkbox'] = array(
     '#input' => TRUE,
     '#return_value' => 1,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'checkbox',
     '#theme_wrappers' => array('form_element'),
     '#title_display' => 'after',
@@ -400,7 +400,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#size' => 0,
     '#multiple' => FALSE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'select',
     '#theme_wrappers' => array('form_element'),
   );
@@ -408,7 +408,7 @@ function system_element_info() {
     '#input' => TRUE,
     '#delta' => 10,
     '#default_value' => 0,
-    '#process' => array('form_process_weight', 'ajax_process_form'),
+    '#process' => array('form_process_weight', 'ajax_process_element'),
   );
   $types['date'] = array(
     '#input' => TRUE,
@@ -441,7 +441,7 @@ function system_element_info() {
   );
   $types['hidden'] = array(
     '#input' => TRUE,
-    '#process' => array('ajax_process_form'),
+    '#process' => array('ajax_process_element'),
     '#theme' => 'hidden',
   );
   $types['value'] = array(
@@ -452,13 +452,13 @@ function system_element_info() {
     '#pre_render' => array('drupal_pre_render_markup'),
   );
   $types['link'] = array(
-    '#pre_render' => array('drupal_pre_render_link', 'drupal_pre_render_markup'),
+    '#pre_render' => array('ajax_process_element', 'drupal_pre_render_link', 'drupal_pre_render_markup'),
   );
   $types['fieldset'] = array(
     '#collapsible' => FALSE,
     '#collapsed' => FALSE,
     '#value' => NULL,
-    '#process' => array('form_process_fieldset', 'ajax_process_form'),
+    '#process' => array('form_process_fieldset', 'ajax_process_element'),
     '#pre_render' => array('form_pre_render_fieldset'),
     '#theme_wrappers' => array('fieldset'),
   );
