--- relativity.module 2008-06-24 15:31:48.104678919 +0200 +++ new.relativity.module 2008-06-24 14:11:08.000000000 +0200 @@ -47,11 +47,15 @@ function relativity_node_list($use_blank * with various filters for restricting what is seen. Someday, maybe :) * javanaut */ -function relativity_list_possible_children($type='', $parent_nid='') { +function relativity_list_possible_children($type='', $parent_nid='', $is_autocomplete=false) { if (!$type && !$parent_nid) { $type = arg(2); $parent_nid = is_numeric(arg(4)) ? arg(4) : $_GET['parent_node'] + 0; } + if($is_autocomplete == null){ + $is_autocomplete = false; + } + $links = array(); $parent = node_load($parent_nid); @@ -91,7 +95,7 @@ function relativity_list_possible_childr $result = db_query('SELECT n.nid FROM {node} n WHERE n.type = \'%s\' AND n.status = 1 ORDER BY n.title', $type); } } - + while($child = db_fetch_object($result)) { if (in_array($child->nid, $excluded_nids)) { continue; } $child_node = node_load($child->nid); @@ -107,12 +111,26 @@ function relativity_list_possible_childr $key .= $parent_tree[$i]->tid.';'; } } - $links[$key][] = array('title' => $child_node->title, 'child_node' => $child_node->nid, 'parent_node' => $parent_nid); + + if ($is_autocomplete === false) { + $links[$key][] = array('title' => $child_node->title, 'child_node' => $child_node->nid, 'parent_node' => $parent_nid); + } else { + $links[$child_node->title.' [nid:' . $child_node->nid . ']'] = check_plain($child_node->title); + } } else { - $links[] = theme('relativity_link', $child_node->title, "addparent/$child_node->nid/parent/$parent_nid", $parent_nid); + if ($is_autocomplete === false) { + $links[] = theme('relativity_link', $child_node->title, "addparent/$child_node->nid/parent/$parent_nid", $parent_nid); + } else { + $links[$child_node->title.' [nid:' . $child_node->nid . ']'] = check_plain($child_node->title); + } } } } + + if($is_autocomplete !== false){ + print drupal_to_js($links); + exit(); + } if (count($links)) { if ($use_taxonomy) { @@ -299,6 +317,7 @@ function relativity_menu($may_cache) { $items[] = array('path' => 'relativity/listnodes/'. arg(2).'/parent/'.arg(4), 'title' => t('list of !type nodes to attach', array('!type'=>node_get_types('name',arg(2)))), 'callback' => 'relativity_list_possible_children', + 'callback arguments' => array('','',arg(5)), 'access' => node_access('update', node_load(arg(4))) && user_access("access content"), 'type' => MENU_CALLBACK ); @@ -482,12 +501,6 @@ function relativity_advanced_settings() '#description' => t('If checked, nodes cannot be created without a parent if they require a parent to exist.'), ); - // Node Sorting Options - $group['sorting_options'] = array( - '#type' => 'fieldset', - '#title' => t('Node Sorting Options'), - ); - $group['global_options']['relativity_use_taxonomy'] = array( '#type' => 'checkbox', '#title' => t('Use Taxonomy to attach nodes'), @@ -496,6 +509,23 @@ function relativity_advanced_settings() '#description' => t('If checked, nodes cannot be attached if they don\'t belong to a taxonomy term. When listing nodes to attach, possible children will be displayed in a taxonomy tree.'), ); + $group['global_options']['relativity_select_method'] = array( + '#type' => 'radios', + '#title' => t('How should nodes be selected?'), + '#return_value' => 1, + '#default_value' => variable_get('relativity_select_method', t('Both')), + '#options' => array(t('List') => t('List'), t('Autocomplete') => t('Autocomplete'), t('Both') => t('Both')), + '#description' => '