Index: modules/blog.module =================================================================== RCS file: /cvs/drupal/drupal/modules/blog.module,v retrieving revision 1.222 diff -u -F^f -r1.222 blog.module --- modules/blog.module 31 Jul 2005 08:58:01 -0000 1.222 +++ modules/blog.module 24 Aug 2005 16:28:26 -0000 @@ -204,16 +204,17 @@ function blog_form(&$node) { // Note: $item->description has been validated on aggregation. $node->body = ''. check_plain($item->title) .' - '. $item->description .' ['. check_plain($item->ftitle) ."]\n"; } + } if (function_exists('taxonomy_node_form')) { - $output .= implode('', taxonomy_node_form('blog', $node)); + $form['taxonomy'] = taxonomy_node_form('blog', $node); } - $output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE); - $output .= filter_form('format', $node->format); + $form['body'] = array(type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE, weight => 1); + # $form['format'] = filter_form($node->format); - return $output; + return $form; } /** Index: modules/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node.module,v retrieving revision 1.521 diff -u -F^f -r1.521 node.module --- modules/node.module 22 Aug 2005 20:39:43 -0000 1.521 +++ modules/node.module 24 Aug 2005 16:28:27 -0000 @@ -1,6 +1,7 @@ validated) { $edit = node_validate($edit); } + // Set the id of the top-level form tag + $form[attributes]['id'] = 'node-form'; + // Prepend extra node form elements. - $form = implode('', node_invoke_nodeapi($edit, 'form pre')); + $form = array_merge($form, node_invoke_nodeapi($node, 'form pre')); + + /** + * Basic node information. + * These elements set the value property, making them immutable. + */ + $form['uid'] = array(type => 'hidden', value => $node->uid); + $form['created'] = array(type => 'hidden', value => $node->created); + $form['changed'] = array(type => 'hidden', value => $node->changed); + $form['type'] = array(type => 'hidden', value => $node->type); // Get the node-specific bits. // We can't use node_invoke() because $param must be passed by reference. - $function = node_get_module_name($edit) .'_form'; + $function = node_get_module_name($node) .'_form'; $param = array(); if (function_exists($function)) { - $form .= $function($edit, $param); + $form = array_merge($form, $function($node, $param)); } // Append extra node form elements. - $form .= implode('', node_invoke_nodeapi($edit, 'form post')); - - $output .= '
'; - - // Add hidden 'op' variable, which specifies the default operation (Preview). - $output .= '\n"; - - // Add the admin-specific parts. - if (user_access('administer nodes')) { - $output .= '
'; - - $author = form_autocomplete(t('Authored by'), 'name', $edit->name, 30, 60, 'user/autocomplete'); - $author .= form_textfield(t('Authored on'), 'date', $edit->date, 30, 25, NULL, NULL, TRUE); + $form = array_merge($form, node_invoke_nodeapi($node, 'form post')); - $output .= '
'; - $output .= form_group_collapsible(t('Authoring information'), $author, TRUE); - $output .= "
\n"; - - $node_options = variable_get('node_options_'. $edit->type, array('status', 'promote')); - $options .= form_checkbox(t('Published'), 'status', 1, isset($edit->status) ? $edit->status : in_array('status', $node_options)); - $options .= form_checkbox(t('In moderation queue'), 'moderate', 1, isset($edit->moderate) ? $edit->moderate : in_array('moderate', $node_options)); - $options .= form_checkbox(t('Promoted to front page'), 'promote', 1, isset($edit->promote) ? $edit->promote : in_array('promote', $node_options)); - $options .= form_checkbox(t('Sticky at top of lists'), 'sticky', 1, isset($edit->sticky) ? $edit->sticky : in_array('sticky', $node_options)); - $options .= form_checkbox(t('Create new revision'), 'revision', 1, isset($edit->revision) ? $edit->revision : in_array('revision', $node_options)); - - $output .= '
'; - $output .= form_group_collapsible(t('Publishing options'), $options, TRUE); - $output .= "
\n"; + /** + * Node author information + */ + $form['author'] = array(type => 'fieldset', title => t('Authoring information'), collapsible => TRUE, collapsed => TRUE, weight => -1); + $form['author']['name'] = array(type => 'textfield', title => t('Authored by'), maxlength => 60, autocomplete_path => 'user/autocomplete', default_value => $node->name, weight => -1); + $form['author']['date'] = array(type => 'textfield', title =>t('Authored on'), maxlength => 25, required => TRUE, default_value => $node->date); + + + $node_options = variable_get('node_options_'. $node->type, array('status', 'promote')); + + /** + * Node options + */ + $form['options'] = array(type => 'fieldset', title => t('Publishing options'), collapsible => TRUE, collapsed => TRUE, weight => -1); + $form['options']['status'] = array(type => 'checkbox', title => t('Published'), default_value => in_array('status', $node_options)); + $form['options']['moderate'] = array(type => 'checkbox', title => t('In moderation queue'), default_value => in_array('moderate', $node_options)); + $form['options']['promote'] = array(type => 'checkbox', title => t('Promoted to front page'), default_value => in_array('promote', $node_options)); + $form['options']['sticky'] = array(type => 'checkbox', title =>t('Sticky at top of lists'), default_value => in_array('sticky', $node_options)); + $form['options']['revision'] = array(type => 'checkbox', title =>t('Create new revision'), default_value => in_array('revision', $node_options)); - $extras .= implode('
', node_invoke_nodeapi($edit, 'form admin')); - $output .= $extras ? '
'. $extras .'
' : '
'; - } // Add the default fields. - $output .= '
'; - $output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, NULL, NULL, TRUE); - - // Add the node-type-specific fields. - $output .= $form; - - // Add the hidden fields. - if ($edit->nid) { - $output .= form_hidden('nid', $edit->nid); - } - - if (isset($edit->uid)) { - // The use of isset() is mandatory in the context of user IDs, because - // user ID 0 denotes the anonymous user. - $output .= form_hidden('uid', $edit->uid); - } - - if ($edit->created) { - $output .= form_hidden('created', $edit->created); - } - - if ($edit->changed) { - $output .= form_hidden('changed', $edit->changed); - } - - $output .= form_hidden('type', $edit->type); + $form['title'] = array(type => 'textfield', title => t('Title'), size => 60, maxlength => 128, required => TRUE, default_value => $node->title); // Add the buttons. - $output .= form_submit(t('Preview')); + $form['preview'] = array(type => 'submit', value => t('Preview'), weight => 19); - if ($edit->type && (($_POST['op'] == t('Preview') && !form_get_errors()) || !variable_get('node_preview', 0))) { - $output .= form_submit(t('Submit')); + if ($node->type && (($_POST['op'] == t('Preview') && !form_get_errors()) || !variable_get('node_preview', 0))) { + $form['submit'] = array(type => 'submit', value => t('Submit'), weight => 20); } - if ($edit->nid && node_access('delete', $edit)) { - $output .= form_submit(t('Delete')); - } - $output .= '
'; - - $extra = node_invoke_nodeapi($edit, 'form param'); - foreach ($extra as $key => $value) { - if (is_array($value)) { - if (isset($param[$key])) { - $param[$key] = array_merge($param[$key], $value); - } - else { - $param[$key] = $value; - } - } - else { - $param[$key] = $value; - } - } + return drupal_get_form($node->type . '_node_form', $form, $_POST['edit'], 'node_form'); +} - $attributes = array('id' => 'node-form'); - if (is_array($param['options'])) { - $attributes = array_merge($param['options'], $attributes); - } - return form($output, ($param['method'] ? $param['method'] : 'post'), $param['action'], $attributes); +function theme_node_form($form) { + $output .= '
'; + $output .= '
'; + $output .= '
'; + $output .= form_render($form['author']); + $output .= '
'; + $output .= '
'; + $output .= form_render($form['options']); + $output .= '
'; + $output .= '
'; + $output .= '
'; + $output .= form_render($form); + $output .= '
'; + $output .= '
'; + return $output; } /** @@ -1402,7 +1373,7 @@ function node_add($type) { $node[$field] = $_GET['edit'][$field]; } } - $output = node_form($node); + $output = node_form(array2object($node)); drupal_set_title(t('Submit %name', array('%name' => node_invoke($node, 'node_name')))); } else { @@ -2000,4 +1971,5 @@ function node_db_rewrite_sql($query, $pr * @} End of "defgroup node_access". */ + ?> Index: modules/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system.module,v retrieving revision 1.226 diff -u -F^f -r1.226 system.module --- modules/system.module 22 Aug 2005 05:09:01 -0000 1.226 +++ modules/system.module 24 Aug 2005 16:28:28 -0000 @@ -49,6 +49,22 @@ function system_perm() { } /** + * Implementation of hook_elements(). + */ +function system_elements() { + $type['form'] = array(method => 'post', action => request_uri()); + $type['checkbox'] = array(input => TRUE, return_value => 1); + $type['submit'] = array(input => TRUE, name => 'op', button_type => 'submit'); + $type['button'] = array(input => TRUE, name => 'op', button_type => 'submit'); + $type['textfield'] = array(input => TRUE, size => 20, maxlength => 50, autocomplete_path => FALSE); + $type['textarea'] = array(input => TRUE, cols => 60, rows => 20); + $type['fieldset'] = array(input => TRUE, collapsible => FALSE, collapsed => FALSE); + $type['item'] = array(); + $type['hidden'] = array(); + return $type; +} + +/** * Implementation of hook_menu(). */ function system_menu($may_cache) { Index: modules/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy.module,v retrieving revision 1.217 diff -u -F^f -r1.217 taxonomy.module --- modules/taxonomy.module 25 Jul 2005 04:55:37 -0000 1.217 +++ modules/taxonomy.module 24 Aug 2005 16:28:28 -0000 @@ -515,14 +515,19 @@ function taxonomy_node_form($type, $node } } $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL); - $result[] = form_autocomplete($vocabulary->name, "$name][tags][". $vocabulary->vid, $typed_string, 60, 100, 'taxonomy/autocomplete/'. $vocabulary->vid, t('A comma-separated list of terms describing this content (Example: funny, bungie jumping, "Company, Inc.").'), NULL, ($vocabulary->required ? TRUE : FALSE)); + + # $result[] = form_autocomplete($vocabulary->name, "$name][tags][". $vocabulary->vid, $typed_string, 60, 100, 'taxonomy/autocomplete/'. $vocabulary->vid, t('A comma-separated list of terms describing this content (Example: funny, bungie jumping, "Company, Inc.").'), NULL, ($vocabulary->required ? TRUE : FALSE)); + + $form[$name]['tags'][$vocabulary->vid] = array( type => textfield, default_value => $typed_string, size => 60, maxlength => 100, + autocomplete_path => 'taxonomy/autocomplete/'. $vocabulary->vid, required => ($vocabulary->required ? TRUE : FALSE), title => $vocabulary->name, + description => t('A comma-separated list of terms describing this content (Example: funny, bungie jumping, "Company, Inc.").') ); } else { $ntterms = array_key_exists('taxonomy', $node) ? $terms : array_keys($terms); - $result[] = taxonomy_form($vocabulary->vid, $ntterms, $help, $name); + $form[$name][$vocabulary->vid] = taxonomy_form($vocabulary->vid, $ntterms, $help, $name); } } - return $result ? $result : array(); + return $form ? $form : array(); } /** Index: modules/upload.module =================================================================== RCS file: /cvs/drupal/drupal/modules/upload.module,v retrieving revision 1.46 diff -u -F^f -r1.46 upload.module --- modules/upload.module 17 Aug 2005 19:27:03 -0000 1.46 +++ modules/upload.module 24 Aug 2005 16:28:29 -0000 @@ -157,7 +157,6 @@ function upload_nodeapi(&$node, $op, $ar $node->list[$key] = $file->list; } } - if (($file = file_check_upload('upload')) && user_access('upload files')) { global $user; Index: modules/user.module =================================================================== RCS file: /cvs/drupal/drupal/modules/user.module,v retrieving revision 1.501 diff -u -F^f -r1.501 user.module --- modules/user.module 11 Aug 2005 13:52:44 -0000 1.501 +++ modules/user.module 24 Aug 2005 16:28:30 -0000 @@ -1,6 +1,6 @@ uid && !(arg(0) == 'user' && !is_numeric(arg(1)))) { $edit = $_POST['edit']; - $output = "
\n"; - // NOTE: special care needs to be taken because on pages with forms, // such as node and comment submission pages, the $edit variable // might already be set. - $output .= form_textfield(t('Username'), 'name', $edit['name'], 15, 64); - $output .= form_password(t('Password'), 'pass', $pass, 15, 64); - $output .= form_submit(t('Log in')); - $output .= "
\n"; - - $output = form($output, 'post', url('user/login', drupal_get_destination())); + $form['name'] = array(type => 'textfield', title => t('Username'), maxlength => 64, default_value => $edit['name'], size => 15, weight => 0); + $form['pass'] = array(type => 'password', title => t('Password'), maxlength => 64, default_value => $edit['pass'], size => 15, weight => 1); + $form['submit'] = array(type => 'submit', value => t('Log in'), weight => 2); + $form[action] = url('user/login', drupal_get_destination()); + $output .= drupal_get_form('user_login', $form, $_POST['edit'], 'user_login'); if (variable_get('user_register', 1)) { $items[] = l(t('Create new account'), 'user/register', array('title' => t('Create a new user account.'))); @@ -600,6 +597,13 @@ function user_block($op = 'list', $delta } } +function theme_user_login($form) { + $output = "
\n"; + $output .= form_render($form); + $output .= "
\n"; + return $output; +} + function theme_user_picture($account) { if (variable_get('user_pictures', 0)) { if ($account->picture && file_exists($account->picture)) {