changeset 5:e1318a313b1d

Popups: AddnReference 1.3
author Franck Deroche <franck@defr.org>
date Thu, 19 Mar 2009 11:34:01 +0100
parents 56772e0a00ae
children 990f71344a66 ab667e3dc8ba
files CHANGELOG.txt README.txt popups_reference.info popups_reference.js popups_reference.module
diffstat 5 files changed, 51 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/CHANGELOG.txt	Wed Jan 21 11:19:01 2009 +0100
+++ b/CHANGELOG.txt	Thu Mar 19 11:34:01 2009 +0100
@@ -1,8 +1,22 @@
+Drupal-6-1-0-RC3
+ * Recommended for use with Popups API 6.x-1.2
+Bug Fixes
+ * http://drupal.org/node/390146 (cYu) - Allow users with "admin nodes" permission to see links.
+ * http://drupal.org/node/388406 - Only autofill a single autocomplete field if there are mutliples.
+ 
+Drupal-6-1-0-RC2
+Bug Fixes
+ * http://drupal.org/node/361964 (DeFr) - Bad unicode in autocomplete
+ * http://drupal.org/node/379576 - RC1 checkbox showing up on all fields.
+Other
+ * http://drupal.org/node/380932 (KarenS) - Setting min php to 5.0 in .info file.
+ 
 Drupal-6-1-0-RC1
 New Features
  * http://drupal.org/node/310019 - Checkbox to toggle the "Add New:" links per field. Funded by Agaric Design.
- * http://drupal.org/node/308589 - Select the newly created node (requres Popups API 1.2RC1 or newer). Funded by Agaric Design
+ * http://drupal.org/node/308589 - Select the newly created node (requres Popups API 1.2-ALPHA1 or newer). Funded by Agaric Design
  * Added support for radio buttons widget.
+ * http://drupal.org/node/359524 by Cloudy - use human type names in link text.
 Other 
  * Better comments and function documentation.
  
--- a/README.txt	Wed Jan 21 11:19:01 2009 +0100
+++ b/README.txt	Thu Mar 19 11:34:01 2009 +0100
@@ -3,4 +3,8 @@
 
 TODO 
  * Fix losing highlighted selections on node add with multi-select box.
+ 
+LIMITATIONS
+ * http://drupal.org/node/378988 - conflicts with Hierarchical Select.
+
  
\ No newline at end of file
--- a/popups_reference.info	Wed Jan 21 11:19:01 2009 +0100
+++ b/popups_reference.info	Thu Mar 19 11:34:01 2009 +0100
@@ -1,14 +1,15 @@
-; $Id: popups_reference.info,v 1.1.2.1 2008/12/23 22:38:21 starbow Exp $
+; $Id: popups_reference.info,v 1.1.2.2 2009/02/24 04:13:46 starbow Exp $
 name = Popups: Add & Reference
 description = In-place popup to add a new node to Node Reference widget. 
 package = User interface
 core = 6.x
+php = 5.0
 dependencies[] = popups 
 dependencies[] = content
 
-; Information added by drupal.org packaging script on 2009-01-19
-version = "6.x-1.x-dev"
+; Information added by drupal.org packaging script on 2009-03-07
+version = "6.x-1.0-rc3"
 core = "6.x"
 project = "popups_reference"
-datestamp = "1232323985"
+datestamp = "1236409255"
 
--- a/popups_reference.js	Wed Jan 21 11:19:01 2009 +0100
+++ b/popups_reference.js	Thu Mar 19 11:34:01 2009 +0100
@@ -1,4 +1,4 @@
-// $Id: popups_reference.js,v 1.1.2.1 2009/01/18 22:40:33 starbow Exp $
+// $Id: popups_reference.js,v 1.1.2.3 2009/03/06 01:54:08 starbow Exp $
 
 /**
  * Popups: Add and Reference behavior
@@ -38,10 +38,20 @@
       $(document).bind('popups_form_success.popups_reference', function() {
         // Info about the new node was placed in a cookie when it was created.
         var nid = popups_reference_get_cookie_value('PopupRefNid');
-        var title = popups_reference_get_cookie_value('PopupRefTitle');
+        var title = decodeURIComponent(popups_reference_get_cookie_value('PopupRefTitle'));
         $wrapper.find('select').val(nid); // Select
-        $wrapper.find('input.form-autocomplete').val(title); // Autocomplete
         $wrapper.find(':radio[value=' + nid + ']').select(); // Radio buttons
+        
+        // Get the first empty autocomplete field to fill (http://drupal.org/node/388406).
+        $emptyAutos = $wrapper.find('input.form-autocomplete').filter(function(i) {
+          return !$(this).val();
+        });
+        if ($emptyAutos.length) {
+          $emptyAutos.eq(0).val(title);
+        }
+        else { // There are no empty fields, use the first one.
+          $wrapper.find('input.form-autocomplete:first').val(title);
+        }
       });
     });
   });
--- a/popups_reference.module	Wed Jan 21 11:19:01 2009 +0100
+++ b/popups_reference.module	Thu Mar 19 11:34:01 2009 +0100
@@ -1,5 +1,5 @@
 <?php
-// $Id: popups_reference.module,v 1.1.2.6 2009/01/18 22:40:33 starbow Exp $
+// $Id: popups_reference.module,v 1.1.2.12 2009/03/07 06:54:25 starbow Exp $
 
 /**
  * @file
@@ -13,7 +13,7 @@
  * Modifies the nodereference setting form and the basic node form. 
  */
 function popups_reference_form_alter(&$form, $form_state, $form_id) {
-  if ($form_id == 'content_field_edit_form') {
+  if ($form_id == 'content_field_edit_form' && $form['#field']['type'] == 'nodereference') {
     // Add a checkbox to the nodereference settings page.
     $field_name = $form['#field']['field_name'];
     $form['field']['show_add_link'] = array(
@@ -57,7 +57,8 @@
   if ($op == 'insert') {
       $five = time()+300; // 5 minutes in the future.
       setcookie("PopupRefNid", $node->nid, $five, '/'); 
-      setcookie("PopupRefTitle", $node->title, $five, '/');
+//      setcookie("PopupRefTitle", $node->title, $five, '/');
+      setrawcookie("PopupRefTitle", rawurlencode($node->title), $five, '/');
   }
 }
 
@@ -85,8 +86,8 @@
       $fields[$field_name]['type'] == 'nodereference' &&
       variable_get('popups_reference_show_add_link_'. $field_name, TRUE)) {
     $type = $form['type']['#value'];
-    $field = content_fields($field_name, $form['type']['#value']);
-
+    $field = content_fields($field_name, $type);
+    
     $wrapper_id = 'popups-reference-' . _popups_reference_counter();
     $links = _popups_reference_links($field, $type, $wrapper_id, $field['widget']['type']);
     if ($links) {
@@ -105,15 +106,15 @@
  * @param $field
  * @param $src_type - the type of base node.
  * @param $wrapper_id - id for the wrapper around the node reference.
- * @param $type - the type of the node being referenced.
+ * @param $type - the type of widget.
  * @return Array of html links.
  */
-function _popups_reference_links($field, $src_type, $wrapper_id, $type) {
-  if ($type == 'nodereference_select' || $type == 'nodereference_buttons') { 
+function _popups_reference_links($field, $src_type, $wrapper_id, $widget_type) {
+  if ($widget_type == 'nodereference_select' || $widget_type == 'nodereference_buttons') { 
     // Target the wrapper for replacing.
     popups_add_popups(array('a.'.$wrapper_id=>array('targetSelectors'=>array('#'.$wrapper_id))));
   }
-  else if ($type == 'nodereference_autocomplete') { 
+  else if ($widget_type == 'nodereference_autocomplete') { 
     // Don't replace the autocomplete when done.
     popups_add_popups(array('a.'.$wrapper_id=>array('noUpdate'=>TRUE)));
   }
@@ -130,10 +131,12 @@
   $links = array();
   $all_types = node_get_types();
   foreach ($field['referenceable_types'] as $add_type => $value) {
-    if (!empty($value) && user_access("create $add_type content")) {
+    if (!empty($value) && (user_access("create $add_type content") || user_access('administer nodes'))) {
+    //if (!empty($value) && user_access("create $add_type content")) {
       drupal_add_js(drupal_get_path('module', 'popups_reference') .'/popups_reference.js');
       $path = 'node/add/' . str_replace('_', '-', $add_type);
-      $links[] = l("Add $add_type", $path, $options);
+      $name = $all_types[$add_type]->name;
+      $links[] = l("Add $name", $path, $options);
     }
   }
   return $links;