? content_type_reference.info ? persistent_fieldset.info ? subform-uberpatch.patch ? subform.info Index: content_type_reference.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/subform/content_type_reference.install,v retrieving revision 1.1 diff -u -r1.1 content_type_reference.install --- content_type_reference.install 4 Dec 2006 14:02:42 -0000 1.1 +++ content_type_reference.install 27 Dec 2006 23:30:00 -0000 @@ -1,20 +1,35 @@ CCK: Defines a field type for referencing a content type. Note: Requires content.module.'); } } @@ -26,16 +25,14 @@ ); } - /** * Implementation of hook_field_settings(). */ -function content_type_reference_field_settings( $op, $field ) { - switch ($op) - { +function content_type_reference_field_settings($op, $field) { + switch ($op) { case 'database columns': $columns = array( - 'cn' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => '\'\''), + 'cn' => array('type' => 'varchar', 'length' => 128, 'not null' => TRUE, 'default' => "''"), ); return $columns; } @@ -70,13 +67,12 @@ * Implementation of hook_field_formatter(). */ function content_type_reference_field_formatter($field, $item, $formatter, $field) { - $text = ''; if (isset($item['cn'])) { $fields = _content_type_reference_get_content_types(); $referenced_field = $fields[ $item['cn'] ]; - if ( $referenced_field ) { + if ($referenced_field) { $text = $referenced_field; } } @@ -88,11 +84,6 @@ } } - - - - - /** * Implementation of hook_widget_info(). */ @@ -101,7 +92,7 @@ 'content_type_reference' => array( 'label' => 'Select List', 'field types' => array('content_type_reference'), - ) + ), ); } @@ -147,30 +138,10 @@ * Return an array of all content types */ function _content_type_reference_get_content_types() { - - $fieldsResult = db_query('select - type_name, label - from - node_type_content - order by - label'); - while ($obj = db_fetch_object($fieldsResult)) { - $fieldsList[ $obj->type_name ] = $obj->label; + $fieldsList = array(); + $result = db_query('SELECT type_name, label FROM {node_type_content} ORDER BY label'); + while ($obj = db_fetch_object($result)) { + $fieldsList[$obj->type_name] = $obj->label; } return $fieldsList; } - - - - - - - - - - - - - - - Index: persistent_fieldset.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/subform/persistent_fieldset.module,v retrieving revision 1.2 diff -u -r1.2 persistent_fieldset.module --- persistent_fieldset.module 12 Dec 2006 00:29:30 -0000 1.2 +++ persistent_fieldset.module 27 Dec 2006 23:30:01 -0000 @@ -1,4 +1,6 @@ TRUE, '#collapsed' => FALSE, '#input' => TRUE ); - return $type; - + return array( + 'persistent_fieldset' => array( + '#collapsible' => TRUE, + '#collapsed' => FALSE, + '#input' => TRUE, + ), + ); } /** @@ -56,3 +63,9 @@ return '' . ($element['#title'] ? ''. $element['#title'] .'' : '') . ($element['#description'] ? '
'. $element['#description'] .'
' : '') . $element['#children'] . "\n"; } + + +function persistent_fieldset_callback($id,$state = 0) { + print drupal_to_js(TRUE); + exit(); +} Index: subform.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/subform/subform.install,v retrieving revision 1.2 diff -u -r1.2 subform.install --- subform.install 6 Dec 2006 04:14:34 -0000 1.2 +++ subform.install 27 Dec 2006 23:30:01 -0000 @@ -1,33 +1,20 @@ CONTENT.MODULE IS NOT ENABLED. DISABLING SUBFORM NOW."; - } - if( !module_exist( "views" ) ) { - $missing_dependencies[] = "SUBFORM DEPENDENCY VIEWS.MODULE IS NOT ENABLED. DISABLING SUBFORM NOW."; - } - if( !module_exist( "views_ui" ) ) { - $missing_dependencies[] = "SUBFORM DEPENDENCY VIEWS_UI.MODULE IS NOT ENABLED. DISABLING SUBFORM NOW."; - } - if( !module_exist( "content_type_reference" ) ) { - $missing_dependencies[] = "SUBFORM DEPENDENCY CONTENT_TYPE_REFERENCE.MODULE IS NOT ENABLED. DISABLING SUBFORM NOW."; - } - if( !module_exist( "persistent_fieldset" ) ) { - $missing_dependencies[] = "SUBFORM DEPENDENCY PERSISTENT_FIELDSET.MODULE IS NOT ENABLED. DISABLING SUBFORM NOW."; - } - - $javascript = ""; - - $missing_dependencies_msg = implode( "
", $missing_dependencies ); - if( strlen( $missing_dependencies_msg ) > 0 ) { - $missing_dependencies_msg = $missing_dependencies_msg . "
"; - $javascript = " - - "; - } - - - return $javascript . "" . $missing_dependencies_msg . "" . t('CCK: Defines a cck field type for inserting a subform that allows you to create associations between the current node and some other nodes of a specified type. Note: Requires content.module and content_type_reference.module.'); } } @@ -70,56 +27,36 @@ ); } - -/** - * Check if a table exists. - */ -function _subform_db_table_exists($table) { - return db_num_rows(db_query("SHOW TABLES LIKE '{" . db_escape_table($table) . "}'")); -} - - /** * Implementation of hook_field_settings(). * - * this function returns an array that can either: - * define form api info that will be asked of the user during field creation - * list fields that will be saved + * This function returns an array that can either: + * Define form api info that will be asked of the user during field creation + * List fields that will be saved * or - * list columns that should be created in the database upon field creation completion + * List columns that should be created in the database upon field creation completion * * hook_field_settings($op, $field): Handles displaying, validating, and saving field settings forms. In addition, manages how they're stored in the database and provides Views integration. * */ -function subform_field_settings( $op, &$field ) { - - // sd( "field settings " . $op ); - // sds( "field", $field ); - - switch ($op) - { - +function subform_field_settings($op, &$field) { + switch ($op) { case 'form': - - return _subform_get_subform_field_settings_form( $op, &$field ); + return _subform_get_subform_field_settings_form($op, $field); case 'save': - views_invalidate_cache(); - drupal_set_message( "Cleared views module cache to force new subform selection views to show up." ); - + drupal_set_message('Cleared views module cache to force new subform selection views to appear.'); return array( - 'relation_type_id', 'relation_direction', 'display_children', - 'edit_children', 'add_new', 'delete_relation', - 'reference_existing', 'confirm_delete', 'edit_after_submit', - 'depth_limit' - ); + 'relation_type_id', 'relation_direction', 'display_children', + 'edit_children', 'add_new', 'delete_relation', + 'reference_existing', 'confirm_delete', 'edit_after_submit', + 'depth_limit' + ); case 'database columns': - return array(); - + return array(); } - } /** @@ -127,39 +64,31 @@ * hook_field($op, &$node, $field, &$node_field, $teaser, $page): Define the behavior of a field type. */ function subform_field($op, &$node, $field, &$items, $teaser, $page) { - - // sd( "
hook_field subform " . $field['field_name'] . " in_subform = " . print_r( $node->in_subform, true ) . "
" ); - - - // we don't want to do anything if we're nested ||if they selected "NONE" as the relation - if( isset( $node->in_subform ) || $field['relation_type_id'] == -1 ) { + // We don't want to do anything if we're nested or "NONE" is the relation + if (isset($node->in_subform) || $field['relation_type_id'] == -1 ) { return; } - - - $relation_def = _subform_get_relation_def( $field ); - - + + $relation_def = _subform_get_relation_def($field); + switch ($op) { - case 'view': - - drupal_set_html_head(theme('stylesheet_import', base_path() . drupal_get_path('module', 'subform') .'/subform.css')); - + drupal_add_css(drupal_get_path('module','subform') .'/subform.css'); $output = ""; - // if children should be displayed, and its possible to have any children already - if( $field['display_children'] && $node->nid != NULL ) { - - $related_nids = _subform_get_child_nids( $field, $node->nid ); - - $output .= "
"; - $output .= "" . $field['widget']['label'] . ""; - $output .= _subform_view_nids_in_fieldset( $related_nids, $node, $field['relation_type_id'] ); - $output .= "
"; - + // If children should be displayed, and its possible to have any children already + if ($field['display_children'] && $node->nid != NULL) { + $related_nids = _subform_get_child_nids($field, $node->nid); + $element = array( + '#collapsible' => FALSE, //@@@ Make it configurable? + '#attributes' => array('class' => 'subform-fieldset'), + '#title' => $field['widget']['label'], + '#description' => NULL, // @@@ It's possible to have a description here. + '#children' => '', + '#value' => _subform_view_nids_in_fieldset($related_nids,$node,$field['relation_type_id']), + ); + $output .= theme('fieldset',$element); } - return $output; } } @@ -186,6 +115,7 @@ * hook_field_formatter($field, $item, $formatter, $node): Prepare an individual item for viewing in a browser. */ function subform_field_formatter($field, $item, $formatter, $field) { + // } /** @@ -206,122 +136,98 @@ * hook_widget: Define the behavior of a widget. */ function subform_widget($op, &$node, $field, &$field_field) { - global $user; global $view_select_prefs; - $relation_def = _subform_get_relation_def( $field ); + $relation_def = _subform_get_relation_def($field); $parent_type = $relation_def['parent_type']; $child_type = $relation_def['child_type']; - - if( $field['relation_type_id'] == -1 ) { + if ($field['relation_type_id'] == -1) { sd( 'Subform ' . $field['widget']['label'] . ' is not associated with any relation.' ); return ""; } - if( $child_type == NULL ) { + if ($child_type == NULL) { sd( 'Subform ' . $field['widget']['label'] . ' was unable to calculate what type to display' ); return; } - - - + switch ($op) { case 'form': - drupal_set_html_head( theme('stylesheet_import', base_path() . drupal_get_path('module', 'subform') .'/subform.css') ); - return _subform_get_widget_form( $node, $field, $relation_def, $parent_type, $child_type ); + drupal_add_css(drupal_get_path('module','subform') .'/subform.css'); + return _subform_get_widget_form($node, $field, $relation_def, $parent_type, $child_type); case 'submit': - _subform_widget_submit( $node, $field, $field_field, $relation_def, $child_type ); + _subform_widget_submit($node, $field, $field_field, $relation_def, $child_type); break; } - } - +/** + * Implementation of hook_nodeapi(). + */ function subform_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { + // At this point, the nid of a new node is known + if ($op == "insert") { - // sd( "
subform_nodeapi - $op
" ); - - // at this point, the nid of a new node is known - if( $op == "insert" ) { - - // if this new node was marked as being part of new relation definition(s) - if( isset( $node->effective_nids ) ) { + // If this new node was marked as being part of new relation definition(s) + if (isset($node->effective_nids)) { + foreach ($node->effective_nids as $effective_nid) { + // Pull out its node id, and replace the temp relation id used in the relation records + _subform_fix_relations($effective_nid, $node->nid); - foreach( $node->effective_nids as $effective_nid ) { - - // pull out its node id, and replace the temp relation id used in the relation records - _subform_fix_relations( $effective_nid, $node->nid ); - - if( $node->subform_redirect == $effective_nid ) { - drupal_goto( "node/$node->nid/edit" ); + if ($node->subform_redirect == $effective_nid) { + drupal_goto("node/$node->nid/edit"); } } } } } +/** + * Implementation of views_default_views(). + */ function subform_views_default_views() { - $subform_list = db_query( " - -/* ------------- SQL FORMATTER by Milk ------------- */ - -SELECT - node_field.field_name, - node_field_instance.type_name AS parent_type, - global_settings -FROM - node_field -INNER JOIN - node_field_instance - ON - node_field.field_name = node_field_instance.field_name -WHERE - TYPE = 'subform' - -/* ------------- SQL FORMATTER by Milk ------------- */ + $result = db_query( + "SELECT f.field_name, i.type_name AS parent_type, global_settings + FROM {node_field} f + INNER JOIN {node_field_instance} i + ON f.field_name = i.field_name + WHERE f.type = 'subform'"); - "); - - while ( $obj = db_fetch_object( $subform_list ) ) { - - $field = unserialize( $obj->global_settings ); + while ($obj = db_fetch_object($result)) { - // sd( "subform views hook, looking at subform record.
" . print_r( $field, true ) . "
" ); + $field = unserialize($obj->global_settings); - - // if in subform config they selected "NONE" as the relation - if( $field['relation_type_id'] == -1 ) { + // If in subform config they selected "NONE" as the relation + if ($field['relation_type_id'] == -1) { continue; } - - $relation_def = _subform_get_relation_def( $field ); + $relation_def = _subform_get_relation_def($field); $child_type = $relation_def['child_type']; - if( $child_type == NULL ) { + if ($child_type == NULL) { continue; } - $view = new stdClass(); - $view->name = "subform_" . substr( $obj->field_name, 6, 128 ); + $view->name = "subform_" . substr($obj->field_name, 6, 128); $view->description = 'controls the select list for subform ' . $obj->field_name; $view->page = TRUE; - $view->url = "subform_" . substr( $obj->field_name, 6, 128 ); + $view->url = "subform_" . substr($obj->field_name, 6, 128); $view->page_type = 'table'; $view->use_pager = FALSE; $view->nodes_per_page = '15'; - $view->field = array ( - array ( + $view->field = array( + array( 'tablename' => 'subform_dummy', 'field' => 'dummy', 'label' => 'Reference', ), - array ( + array( 'tablename' => 'node', 'field' => 'title', 'label' => 'Title', @@ -332,34 +238,31 @@ ), ); - $view->filter = array ( - array ( + $view->filter = array( + array( 'tablename' => 'node', 'field' => 'type', 'operator' => 'OR', 'options' => '', - 'value' => array ( + 'value' => array( 0 => "$child_type", ), ), ); - $view->requires = array( node ); - - $views[ $view->name ] = $view; - + $view->requires = array('node'); + $views[$view->name] = $view; } - return $views; - } - -function subform_views_pre_view( &$view, &$items ) { - +/** + * + */ +function subform_views_pre_view(&$view, &$items) { global $view_select_prefs; - if( $view_select_prefs == NULL ) { + if ($view_select_prefs == NULL) { return; } @@ -367,26 +270,25 @@ $full_nodes = $view_select_prefs['full_nodes']; $field = $view_select_prefs['field']; - // loop through them - foreach( $items as $item_key => $item_value ) { + foreach ($items as $item_key => $item_value) { $nid = $item_value->nid; - // if deletion is not enabled, then don't give people an option to deselect a referenced node - if( ( $field['delete_relation'] == false ) && $duplicate_nids[ $nid ] ) { - unset( $items[ $item_key ] ); + // If deletion is not enabled, then don't give people an option to deselect a referenced node + if (($field['delete_relation'] == false) && $duplicate_nids[$nid]) { + unset($items[$item_key]); continue; } - // if a node is not referenced, but its cardinality is full - if( !$duplicate_nids[ $nid ] && $full_nodes[ $nid ] ) { - unset( $items[ $item_key ] ); + // If a node is not referenced, but its cardinality is full + if (!$duplicate_nids[$nid] && $full_nodes[$nid]) { + unset($items[$item_key]); continue; } - // if we want don't the user to see child nodes, then we probably also don't want them to see a list of all possible child nodes - if( $field['display_children'] == false ) { - unset( $items[ $item_key ] ); + // If we want don't the user to see child nodes, then we probably also don't want them to see a list of all possible child nodes + if ($field['display_children'] == false) { + unset($items[$item_key]); continue; } @@ -396,20 +298,18 @@ // example // edit-field_projects-subform-reference-44 - if( isset( $duplicate_nids[ $nid ] ) ) { - $checked = "checked"; + if (isset($duplicate_nids[$nid])) { + $checked = 'checked'; } else { - $checked = ""; + $checked = ''; } - - drupal_add_js('modules/subform/subform.js'); - - $items[ $item_key ]->subform_dummy_dummy = ""; - - } - + drupal_add_js(drupal_get_path('module','subform') .'/subform.js'); + + // @@@ JQuery + $items[$item_key]->subform_dummy_dummy = ""; + } } function subform_handler_pass_through($fieldinfo, $fielddata, $value, $data) { @@ -417,277 +317,183 @@ return $value; } +/** + * Implemention of hook_views_tables(). + */ function subform_views_tables() { - - $table = array( - 'name' => 'subform_dummy', - 'join' => array( - 'left' => array( - 'table' => 'node', - 'field' => 'nid', - ), - 'right' => array( - 'field' => 'nid', + return array( + 'subform_dummy' => array( + // @@@ Needed anymore? + 'name' => 'subform_dummy', + 'join' => array( + 'left' => array( + 'table' => 'node', + 'field' => 'nid', + ), + 'right' => array( + 'field' => 'nid', + ), ), - ), - - 'fields' => array( - 'dummy' => array( - 'name' => 'dummy', - 'sortable' => false, - 'handler' => 'subform_handler_pass_through', - 'option' => 'string', - 'help' => 'this is a dummy field for subform to put checkboxes in, REQUIRED if you want your subform selection list to work', + 'fields' => array( + 'dummy' => array( + 'name' => 'dummy', + 'sortable' => false, + 'handler' => 'subform_handler_pass_through', + 'option' => 'string', + 'help' => 'this is a dummy field for subform to put checkboxes in, REQUIRED if you want your subform selection list to work', + ), ), ), ); - - $tables[ $table['name'] ] = $table; - - return $tables; } - - - - - - - - - - - - - - - - - -function _subform_prefix_fields( &$node, $prefix ) { - - foreach( $node as $key_name => $key_value ) { - - if( ( substr( $key_name, 0, 6 ) == "field_" ) || ( $key_name == "title" ) ) { +function _subform_prefix_fields(&$node, $prefix) { + foreach ($node as $key_name => $key_value) { + if ((substr($key_name, 0, 6) == 'field_') || ($key_name == 'title')) { $temp = $node[$key_name]; - unset( $node[$key_name] ); + unset($node[$key_name]); $new_key_name = $prefix . "_" . $key_name; $node[$new_key_name] = $temp; } - else if( is_array( $key_value ) ) { - _subform_prefix_fields( $key_value, $prefix ); + else if (is_array($key_value)) { + _subform_prefix_fields($key_value, $prefix); } - } - } -function _subform_prefix( &$node, $prefix ) { - - $keys_list = array_keys( $node ); - - foreach( $keys_list as $key_name ) { - - if( is_array( $node[ $key_name ] ) ) { +function _subform_prefix(&$node, $prefix) { + $keys_list = array_keys($node); + foreach ($keys_list as $key_name) { + if (is_array($node[$key_name])) { // sd( "
$key_name
" ); - - if( ( substr( $key_name, 0, 1 ) != "#" ) ) { + if ((substr($key_name, 0, 1) != '#')) { $temp = $node[$key_name]; - unset( $node[$key_name] ); - $new_key_name = $prefix . "_" . $key_name; + unset($node[$key_name]); + $new_key_name = $prefix . '_' . $key_name; $node[$new_key_name] = $temp; - _subform_prefix( $node[$new_key_name], $prefix ); + _subform_prefix($node[$new_key_name], $prefix); } else { - - _subform_prefix( $node[$key_name], $prefix ); + _subform_prefix($node[$key_name],$prefix); } - } - elseif( $key_name == "#name" ) { - - unset( $node[$key_name] ); + else if ($key_name == '#name') { + unset($node[$key_name]); } - } - } -function _subform_unprefix( &$node, $prefix ) { +function _subform_unprefix(&$node, $prefix) { // sd( "
_subform_unprefix( node, $prefix )
" ); - $keys_list = array_keys( $node ); + $keys_list = array_keys($node); - foreach( $keys_list as $key_name ) { + foreach ($keys_list as $key_name) { // sd( "
_subform_unprefix() - $key_name
" ); - if( substr( $key_name, 0, strlen( $prefix ) ) == $prefix ) { + if (substr($key_name, 0, strlen($prefix)) == $prefix) { $temp = $node[$key_name]; - unset( $node[$key_name] ); - $new_key_name = substr( $key_name, strlen( $prefix ) + 1, strlen( $key_name ) - strlen( $prefix ) - 1 ); + unset($node[$key_name]); + $new_key_name = substr($key_name, strlen($prefix) + 1, strlen($key_name) - strlen($prefix) - 1); $node[$new_key_name] = $temp; } - else if( is_array( $node[$key_name] ) ) { - _subform_unprefix( $node[$key_name], $prefix ); + else if (is_array($node[$key_name])) { + _subform_unprefix($node[$key_name], $prefix); } - } - } -function _subform_unprefix_fields( &$node, $prefix ) { +function _subform_unprefix_fields(&$node, $prefix) { - foreach( $node as $key_name => $key_value ) { - - if( substr( $key_name, 0, strlen( $prefix ) ) == $prefix ) { + foreach ($node as $key_name => $key_value) { + if (substr($key_name, 0, strlen($prefix)) == $prefix) { $temp = $node[$key_name]; - unset( $node[$key_name] ); + unset($node[$key_name]); $new_key_name = substr( $key_name, strlen( $prefix ), strlen( $key_name ) - strlen( $prefix ) ); $node[$new_key_name] = $temp; } - else if( is_array( $key_value ) ) { - _subform_unprefix_fields( $key_value, $prefix ); + else if (is_array($key_value)) { + _subform_unprefix_fields($key_value, $prefix); } - } - } -function _subform_unrequire( &$array ) { - - if( isset( $array['#required'] ) && $array['#required'] == 1 ) { +function _subform_unrequire(&$array) { + if (isset($array['#required']) && $array['#required'] == 1) { $array['#required'] = 0; } - - foreach( $array as $key => $sub_array ) { - - if( is_array( $sub_array ) ) { - _subform_unrequire( $array[$key] ); + foreach ($array as $key => $sub_array) { + if (is_array($sub_array)) { + _subform_unrequire($array[$key]); } } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -function _subform_fix_relations( $temp_id, $node_id ) { - - if( $temp_id >= 0 ) { - +function _subform_fix_relations($temp_id, $node_id) { + if ($temp_id >= 0) { // this can't be right return; } else { - - db_query( "UPDATE - `node_relation_instances` - SET - `node_one` = $node_id - WHERE `node_one` = $temp_id"); - - db_query( "UPDATE - `node_relation_instances` - SET - `node_two` = $node_id - WHERE `node_two` = $temp_id"); - + db_query('UPDATE {node_relation_instances} SET node_one = %d WHERE node_one = %d',$node_id,$temp_id); + db_query('UPDATE {node_relation_instances} SET node_two = %d WHERE node_two = %d',$node_id,$temp_id); } } - - function _subform_get_relations() { - - $relationsResult = db_query('SELECT - `node_content_relation_type`.`nid`, `field_type_one_cn`, `field_type_two_cn`, `title` - FROM - `node_content_relation_type` INNER JOIN `node` ON `node_content_relation_type`.`vid` = `node`.`vid` - WHERE - `node_content_relation_type`.`vid` - IN ( - SELECT MAX( vid ) AS vid - FROM `node_content_relation_type` - GROUP BY nid - );'); - while ($obj = db_fetch_object( $relationsResult )) { - $relationsList[ $obj->nid ] = $obj->title . " (" . $obj->field_type_one_cn ." <-> " . $obj->field_type_two_cn . ")"; + $relationsList = array(); + // @@@ This query sucks. + $result = db_query( + "SELECT rt.nid, field_type_one_cn, field_type_two_cn, title + FROM {node_content_relation_type} rt + INNER JOIN {node} n + ON rt.vid = n.vid + WHERE rt.vid IN ( + SELECT MAX(vid) AS vid + FROM node_content_relation_type + GROUP BY nid + )"); + while ($obj = db_fetch_object($result)) { + $relationsList[$obj->nid] = $obj->title . ' (' . $obj->field_type_one_cn .' <-> ' . $obj->field_type_two_cn . ')'; } return $relationsList; - } -function _subform_get_child_nids( &$field, $node_id ) { - +function _subform_get_child_nids(&$field, $node_id ) { // sd( "
" . print_r( $field, true ) . "
" ); - if( $field['relation_direction'] == "left" ) { - $parent_side = "node_two"; - $child_side = "node_one"; + if ($field['relation_direction'] == 'left') { + $parent_side = 'node_two'; + $child_side = 'node_one'; } else { - $parent_side = "node_one"; - $child_side = "node_two"; + $parent_side = 'node_one'; + $child_side = 'node_two'; } - - $query = " - SELECT - `node_relation_instances`.`$child_side` as nid - FROM - `node_relation_instances` INNER JOIN node ON `node_relation_instances`.`$child_side` = node.nid - WHERE - `node_relation_instances`.`type` = " . $field['relation_type_id'] . " - AND - `node_relation_instances`.`$parent_side` = $node_id"; - + + $result = db_query( + "SELECT i.%s AS nid + FROM {node_relation_instances} i + INNER JOIN {node} n + ON i.%s = n.nid + WHERE i.type = '%s' AND i.%s = %d",$child_side,$child_side,$field['relation_type_id'],$parent_side,$node_id); + // sd( "
$query
" ); - $related_results = db_query( $query ); - $related_nids = array(); - while ($obj = db_fetch_object( $related_results )) { + while ($obj = db_fetch_object($result)) { $related_nids[] = $obj->nid; } return $related_nids; - } -function _subform_get_nids_of_type( $child_type ) { + +function _subform_get_nids_of_type($child_type) { $big_query_string = " @@ -1253,9 +1059,9 @@ } // this fieldset wraps all children - $form[ $field['field_name'] ] = array('#tree' => TRUE); + $form[$field['field_name']] = array('#tree' => TRUE); $new_fieldset = array( - '#attributes' => array( 'class' => 'subform-fieldset' ), + '#attributes' => array( 'class' => 'subform-fieldset persistent' ), '#type' => 'persistent_fieldset', '#title' => $field['widget']['label'], '#collapsible' => 1, @@ -1359,7 +1165,7 @@ '#default_value' => "", ); - drupal_add_js('modules/subform/subform.js'); + drupal_add_js(drupal_get_path('module','subform') .'/subform.js'); if( $field['confirm_delete'] ) { $operations[] = "Delete"; @@ -1615,7 +1421,7 @@ ); - drupal_add_js('modules/subform/subform.js'); + drupal_add_js(drupal_get_path('module','subform') .'/subform.js'); // edit-field_projects-subform-37-create_new $new_fieldset['create_new'] = array( @@ -1928,7 +1734,7 @@ // immediately afte a clean install, if views has not been used, then there will be no view_view table, but we won't fall for that silliness - if( _subform_db_table_exists( "view_view" ) ) { + if( db_table_exists('view_view') ) { $customize_link_text = "Customize reference list. (If you have selected a new relation type or direction in this window, save these changes before using this link, otherwise this link will point you at a stale view definition)"; $form['reference_existing']['#description'] = l( $customize_link_text, _subform_view_edit_path_for( $field ) ); @@ -1964,3 +1770,10 @@ ); } + + +function subform_ajax($op) { +// $args + +} + --- /dev/null 2005-11-20 21:22:37.000000000 -0600 +++ content_type_reference.info 2006-12-27 13:45:03.000000000 -0600 @@ -0,0 +1,5 @@ +; $Id$ +name = Content Type Reference +description = Defines a field type for referencing a content type. +dependencies = content +package = CCK --- /dev/null 2005-11-20 21:22:37.000000000 -0600 +++ persistent_fieldset.info 2006-12-27 14:07:48.000000000 -0600 @@ -0,0 +1,3 @@ +; $Id$ +name = Persistent Fieldset +description = Provides a new forms api element that acts as a fieldset that remembers collapse state across page loads. --- /dev/null 2005-11-20 21:22:37.000000000 -0600 +++ subform.info 2006-12-27 14:14:45.000000000 -0600 @@ -0,0 +1,5 @@ +; $Id$ +name = Subform +description = This module provides a cck field type for inserting a subform that allows you to create associations between the current node and some other nodes of a specified type as well as inline create/read/update/delete child nodes. +dependencies = content views views_ui content_type_reference persistent_fieldset +package = CCK