Index: content.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content.module,v retrieving revision 1.134 diff -u -r1.134 content.module --- content.module 8 Jul 2007 01:50:58 -0000 1.134 +++ content.module 10 Jul 2007 02:49:29 -0000 @@ -32,18 +32,12 @@ */ function content_init() { drupal_add_css(drupal_get_path('module', 'content') .'/content.css'); -// This should not be needed anymore ? -// if (arg(0) == 'admin') { -// module_load_include('inc', 'content', 'content_admin'); -// } - -// We should really get rid of those... -// if (module_exists('views')) { -// module_load_include('inc', 'content', 'content_views'); -// } -// if (module_exists('pathauto')) { -// module_load_include('inc', 'content', 'content_pathauto'); -// } + if (module_exists('views')) { + module_load_include('inc', 'content', 'content_views'); + } + if (module_exists('pathauto')) { + module_load_include('inc', 'content', 'content_pathauto'); + } } /** @@ -129,19 +123,19 @@ function content_theme() { return array( 'field' => array( - 'arguments' => array('node', 'field', 'items', 'teaser', 'page'), + 'arguments' => array('node' => NULL, 'field' => NULL, 'items' => NULL, 'teaser' => FALSE, 'page' => FALSE), ), 'content_admin_field_overview_form' => array( - 'arguments' => array('form'), + 'arguments' => array('form' => NULL), ), 'content_admin_display_overview_form' => array( - 'arguments' => array('form'), + 'arguments' => array('form' => NULL), ), 'content_admin_field_add_new_field_widget_type' => array( - 'arguments' => array('form'), + 'arguments' => array('form' => NULL), ), 'content_view_multiple_field' => array( - 'arguments' => array('items', 'field', 'data'), + 'arguments' => array('items' => NULL, 'field' => NULL, 'data' => NULL), ), ); } @@ -210,11 +204,10 @@ } /** - * Submit form callback for node type fields. + * Validate form callback to handle node type fields. * - * At submit time, the widget does whatever data massaging is necessary so that - * the field has the content in the expected format and can commit the changes - * to the database. + * Both widgets and fields have a chance to raise error flags when a node is + * being validated. */ function content_submit(&$node) { _content_widget_invoke('submit', $node); @@ -285,23 +278,20 @@ /** * Implementation of hook_nodeapi(). - * - * When a revision is deleted, make sure the appropriate cache item is cleared. - * @todo: deprecate op==validate & op==submit in favor of form callbacks. */ function content_nodeapi(&$node, $op, $teaser, $page) { switch ($op) { case 'load': return content_load($node); - case 'validate': - content_validate($node); - break; - - case 'submit': - content_submit($node); - break; - +// case 'validate': +// content_validate($node); +// break; +// +// case 'submit': +// content_submit($node); +// break; +// case 'insert': content_insert($node); break; @@ -332,6 +322,8 @@ $node = $form['#node']; if ($form['type']['#value'] .'_node_form' == $form_id) { $form = array_merge($form, content_form($node)); + $form['#validate'][] = 'content_validate'; + $form['#submit'][] = 'content_submit'; } } } @@ -356,7 +348,6 @@ */ function content_field($op, &$node, $field, &$node_field, $teaser, $page) { $db_info = content_database_info($field); - switch ($op) { case 'load': $column_names = array(); @@ -442,7 +433,7 @@ $column_assignments = array(); foreach ($db_info['columns'] as $column => $attributes) { $column_names[] = $attributes['column']; - if ($item[$column] == '' && !$attributes['not null'] && !$field['required']) { + if (empty($item[$column]) && !$attributes['not null'] && !$field['required']) { $column_placeholders[] = '%s'; $column_assignments[] = $attributes['column'] .' = %s'; $item[$column] = 'NULL'; Index: content_admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_admin.inc,v retrieving revision 1.70 diff -u -r1.70 content_admin.inc --- content_admin.inc 8 Jul 2007 01:50:59 -0000 1.70 +++ content_admin.inc 9 Jul 2007 20:27:41 -0000 @@ -992,14 +992,14 @@ $setting_names = module_invoke($widget_type['module'], 'widget_settings', 'save', $field); if (is_array($setting_names)) { foreach ($setting_names as $setting) { - $widget_settings[$setting] = $form_values[$setting]; + $widget_settings[$setting] = isset($form_values[$setting]) ? $form_values[$setting] : ''; } } $field_settings = array(); $setting_names = module_invoke($field_type['module'], 'field_settings', 'save', $field); if (is_array($setting_names)) { foreach ($setting_names as $setting) { - $field_settings[$setting] = $form_values[$setting]; + $field_settings[$setting] = isset($form_values[$setting]) ? $form_values[$setting] : ''; } } Index: content_copy.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/content_copy.module,v retrieving revision 1.9 diff -u -r1.9 content_copy.module --- content_copy.module 8 Jul 2007 01:50:59 -0000 1.9 +++ content_copy.module 9 Jul 2007 19:52:42 -0000 @@ -26,9 +26,10 @@ * Implementation of hook_menu(). */ function content_copy_menu() { + $items = array(); $items['admin/content/types/export'] = array( - 'title' => t('Export'), + 'title' => 'Export', 'page callback' => 'drupal_get_form', 'page arguments' => array('content_copy_export_form'), 'access arguments' => array('administer content types'), @@ -36,7 +37,7 @@ 'weight' => 3, ); $items['admin/content/types/import'] = array( - 'title' => t('Import'), + 'title' => 'Import', 'page callback' => 'drupal_get_form', 'page arguments' => array('content_copy_import_form'), 'access arguments' => array('administer content types'), @@ -149,17 +150,23 @@ return $form; } +function content_copy_export_form_submit($form, &$form_state) { + $form_state['rebuild'] = TRUE; +} + + /** * Process the export, get field admin forms for all requested fields * and save the form values as formatted text. */ -function content_copy_export($form_id, $form_values) { +function content_copy_export($form, &$form_values) { // Set a global variable to tell when to intervene with form_alter(). $GLOBALS['content_copy']['status'] = 'export'; // Get the content type info by submitting the content type form. - drupal_execute('node_type_form', array(), node_get_types('type', $form_values['type_name'])); + $node_form = array(); + drupal_execute('node_type_form', $node_form, node_get_types('type', $form_values['type_name'])); // Get an array of groups to export. // Record a macro for each group by submitting the group edit form. @@ -167,7 +174,8 @@ $content_type = content_types($form_values['type_name']); foreach ($form_values['groups'] as $group) { - drupal_execute('fieldgroup_edit_group_form', array(), $content_type, $group, 'edit'); + $field_form = array(); + drupal_execute('fieldgroup_edit_group_form', $field_form, $content_type, $group, 'edit'); } } @@ -185,7 +193,8 @@ $widget_module = $widget_types[$field['widget']['type']]['module']; if (!empty($field_module) && module_exists($field_module) && !empty($widget_module) && module_exists($widget_module)) { - drupal_execute('_content_admin_field', array(), $form_values['type_name'], $field_name); + $field_form = array(); + drupal_execute('_content_admin_field', $field_form, $form_values['type_name'], $field_name); } } @@ -431,7 +440,7 @@ */ function content_copy_form_alter(&$form, $form_id) { $alter_forms = array('node_type_form', '_content_admin_field', 'fieldgroup_edit_group_form'); - if ($GLOBALS['content_copy']['status'] == 'export' && in_array($form_id, $alter_forms)) { + if (isset($GLOBALS['content_copy']) && $GLOBALS['content_copy']['status'] == 'export' && in_array($form_id, $alter_forms)) { $form['#submit'][] = 'content_copy_record_macro'; } } Index: fieldgroup.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/fieldgroup.module,v retrieving revision 1.34 diff -u -r1.34 fieldgroup.module --- fieldgroup.module 8 Jul 2007 01:50:59 -0000 1.34 +++ fieldgroup.module 9 Jul 2007 19:51:45 -0000 @@ -289,7 +289,7 @@ if (empty($content_type)) { return $groups; } - elseif (!$groups[$content_type]) { + elseif (empty($groups[$content_type])) { return array(); } return $sorted ? $groups_sorted[$content_type] : $groups[$content_type]; @@ -357,7 +357,7 @@ $form['groups'] = fieldgroup_display_overview_form($form['type_name']['#value']); $form['groups']['#theme'] = 'fieldgroup_display_overview_form'; $form['#submit'][] = 'fieldgroup_display_overview_form_submit'; - if (!is_array($form['submit']) && count(fieldgroup_groups($form['type_name']['#value']))) { + if ((!array_key_exists('submit', $form) || is_array($form['submit'])) && count(fieldgroup_groups($form['type_name']['#value']))) { $form['submit'] = array('#type' => 'submit', '#value' => t('Submit'), '#weight' => 10); } } Index: number.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/number.module,v retrieving revision 1.53 diff -u -r1.53 number.module --- number.module 1 Mar 2007 04:52:44 -0000 1.53 +++ number.module 9 Jul 2007 20:25:44 -0000 @@ -69,7 +69,7 @@ $form['advanced_options']['allowed_values_php'] = array( '#type' => 'textarea', '#title' => t('Code'), - '#default_value' => $field['allowed_values_php'], + '#default_value' => isset($field['allowed_values_php']) ? $field['allowed_values_php'] : '', '#rows' => 6, '#description' => t('Advanced Usage Only: PHP code that returns a keyed array of allowed values. Should not include <?php ?> delimiters. If this field is filled out, the array returned by this code will override the allowed values list above.'), ); @@ -264,9 +264,14 @@ switch ($op) { case 'form': $form = array(); - - $prefixes = explode('|', $field['prefix']); - $suffixes = explode('|', $field['suffix']); + $prefixes = array(); + $suffixes = array(); + if (!empty($field['prefix'])) { + $prefixes = explode('|', $field['prefix']); + } + if (!empty($field['suffix'])) { + $suffixes = explode('|', $field['suffix']); + } // We take the plural form (if any) for forms. $prefix = array_pop($prefixes); $suffix = array_pop($suffixes); @@ -350,7 +355,7 @@ } $allowed_values[$field['field_name']] = array(); - if ($field['allowed_values_php']) { + if (isset($field['allowed_values_php'])) { ob_start(); $result = eval($field['allowed_values_php']); if (is_array($result)) { Index: optionwidgets.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/optionwidgets.module,v retrieving revision 1.19 diff -u -r1.19 optionwidgets.module --- optionwidgets.module 6 Jul 2007 12:30:50 -0000 1.19 +++ optionwidgets.module 9 Jul 2007 21:30:33 -0000 @@ -84,7 +84,6 @@ case 'form': $options = _optionwidgets_options($field, $node); - $form = array(); $form[$field['field_name']] = array('#tree' => TRUE); @@ -157,7 +156,6 @@ case 'process form values': $options = _optionwidgets_options($field, $node); - if ($field['multiple'] || $field['widget']['type'] == 'options_onoff') { $keys = (array) $items['keys']; } Index: text.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/cck/text.module,v retrieving revision 1.52 diff -u -r1.52 text.module --- text.module 8 Jul 2007 01:50:59 -0000 1.52 +++ text.module 9 Jul 2007 21:28:37 -0000 @@ -120,7 +120,7 @@ } } } - if (isset($field['max_length'])) { + if (!empty($field['max_length'])) { foreach ($items as $delta => $data) { $error_field = $field['field_name'] .']['. $delta .'][value'; if (strlen($data['value']) > $field['max_length']) {