summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2005-12-05 09:11:33 +0000
committerDries Buytaert <dries@buytaert.net>2005-12-05 09:11:33 +0000
commit28fdb3975e2bc53061277f4fdb1147dc8d3ba128 (patch)
tree06c355049d6e98b30417addd2a0942962e4f18cc
parent3e36be3b24423566e6d9de2c1c8cbea5ca68b295 (diff)
downloadbrdo-28fdb3975e2bc53061277f4fdb1147dc8d3ba128.tar.gz
brdo-28fdb3975e2bc53061277f4fdb1147dc8d3ba128.tar.bz2
- Patch #39778 by chx: obliterate nodeapi op form in favor of the forms API's way of doing things. Tested with help from webchick.
-rw-r--r--modules/block.module28
-rw-r--r--modules/block/block.module28
-rw-r--r--modules/blog.module2
-rw-r--r--modules/blog/blog.module2
-rw-r--r--modules/book.module2
-rw-r--r--modules/book/book.module2
-rw-r--r--modules/comment.module34
-rw-r--r--modules/comment/comment.module34
-rw-r--r--modules/filter.module25
-rw-r--r--modules/filter/filter.module25
-rw-r--r--modules/forum.module2
-rw-r--r--modules/forum/forum.module2
-rw-r--r--modules/menu.module228
-rw-r--r--modules/menu/menu.module228
-rw-r--r--modules/node.module19
-rw-r--r--modules/node/node.module19
-rw-r--r--modules/page.module2
-rw-r--r--modules/page/page.module2
-rw-r--r--modules/path.module38
-rw-r--r--modules/path/path.module38
-rw-r--r--modules/story.module2
-rw-r--r--modules/story/story.module2
-rw-r--r--modules/taxonomy.module72
-rw-r--r--modules/taxonomy/taxonomy.module72
-rw-r--r--modules/upload.module48
-rw-r--r--modules/upload/upload.module48
26 files changed, 500 insertions, 504 deletions
diff --git a/modules/block.module b/modules/block.module
index c07b56851..d15f3ed4c 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -445,10 +445,32 @@ function block_box_delete_confirm_submit($form_id, $form_values) {
function block_box_form($edit = array()) {
- $form['title'] = array('#type' => 'textfield', '#title' => t('Block title'), '#default_value' => $edit['title'], '#maxlength' => 64, '#description' => t('The title of the block as shown to the user.'));
+ $form['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block title'),
+ '#default_value' => $edit['title'],
+ '#maxlength' => 64,
+ '#description' => t('The title of the block as shown to the user.'),
+ '#weight' => -18,
+ );
+ $form['body'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Block body'),
+ '#default_value' => $edit['body'],
+ '#rows' => 15,
+ '#description' => t('The content of the block as shown to the user.'),
+ '#weight' => -17,
+ );
$form['format'] = filter_form($edit['format']);
- $form['body'] = array('#type' => 'textarea', '#title' => t('Block body'), '#default_value' => $edit['body'], '#rows' => 15, '#description' => t('The content of the block as shown to the user.'));
- $form['info'] = array('#type' => 'textfield', '#title' => t('Block description'), '#default_value' => $edit['info'], '#maxlength' => 64, '#description' => t('A brief description of your block. Used on the <a href="%overview">block overview page</a>.', array('%overview' => url('admin/block'))), '#required' => TRUE);
+ $form['info'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block description'),
+ '#default_value' => $edit['info'],
+ '#maxlength' => 64,
+ '#description' => t('A brief description of your block. Used on the <a href="%overview">block overview page</a>.', array('%overview' => url('admin/block'))),
+ '#required' => TRUE,
+ '#weight' => -15,
+ );
return $form;
}
diff --git a/modules/block/block.module b/modules/block/block.module
index c07b56851..d15f3ed4c 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -445,10 +445,32 @@ function block_box_delete_confirm_submit($form_id, $form_values) {
function block_box_form($edit = array()) {
- $form['title'] = array('#type' => 'textfield', '#title' => t('Block title'), '#default_value' => $edit['title'], '#maxlength' => 64, '#description' => t('The title of the block as shown to the user.'));
+ $form['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block title'),
+ '#default_value' => $edit['title'],
+ '#maxlength' => 64,
+ '#description' => t('The title of the block as shown to the user.'),
+ '#weight' => -18,
+ );
+ $form['body'] = array(
+ '#type' => 'textarea',
+ '#title' => t('Block body'),
+ '#default_value' => $edit['body'],
+ '#rows' => 15,
+ '#description' => t('The content of the block as shown to the user.'),
+ '#weight' => -17,
+ );
$form['format'] = filter_form($edit['format']);
- $form['body'] = array('#type' => 'textarea', '#title' => t('Block body'), '#default_value' => $edit['body'], '#rows' => 15, '#description' => t('The content of the block as shown to the user.'));
- $form['info'] = array('#type' => 'textfield', '#title' => t('Block description'), '#default_value' => $edit['info'], '#maxlength' => 64, '#description' => t('A brief description of your block. Used on the <a href="%overview">block overview page</a>.', array('%overview' => url('admin/block'))), '#required' => TRUE);
+ $form['info'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Block description'),
+ '#default_value' => $edit['info'],
+ '#maxlength' => 64,
+ '#description' => t('A brief description of your block. Used on the <a href="%overview">block overview page</a>.', array('%overview' => url('admin/block'))),
+ '#required' => TRUE,
+ '#weight' => -15,
+ );
return $form;
}
diff --git a/modules/blog.module b/modules/blog.module
index a901da8e3..7215eb135 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -230,7 +230,7 @@ function blog_form(&$node) {
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title);
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
- $form = array_merge($form, filter_form($node->format));
+ $form['filter'] = filter_form($node->format);
return $form;
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index a901da8e3..7215eb135 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -230,7 +230,7 @@ function blog_form(&$node) {
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title);
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
- $form = array_merge($form, filter_form($node->format));
+ $form['filter'] = filter_form($node->format);
return $form;
}
diff --git a/modules/book.module b/modules/book.module
index 5d4c9d6f8..7618c24e5 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -255,7 +255,7 @@ function book_form(&$node) {
$form['body'] = array(
'#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
$form['log'] = array(
'#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE
diff --git a/modules/book/book.module b/modules/book/book.module
index 5d4c9d6f8..7618c24e5 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -255,7 +255,7 @@ function book_form(&$node) {
$form['body'] = array(
'#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
$form['log'] = array(
'#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE
diff --git a/modules/comment.module b/modules/comment.module
index e34b4b610..7e2b3e0f7 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -232,8 +232,26 @@ function comment_link($type, $node = 0, $main = 0) {
}
function comment_form_alter($form_id, &$form) {
- if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
- $form['workflow']['comment_'. $form['type']['#value']] = array('#type' => 'radios', '#title' => t('Default comment setting'), '#default_value' => variable_get('comment_'. $form['type']['#value'], COMMENT_NODE_READ_WRITE), '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
+ if (isset($form['type'])) {
+ if ($form['type']['#value'] .'_node_settings' == $form_id) {
+ $form['workflow']['comment_'. $form['type']['#value']] = array('#type' => 'radios', '#title' => t('Default comment setting'), '#default_value' => variable_get('comment_'. $form['type']['#value'], COMMENT_NODE_READ_WRITE), '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
+ }
+ if ($form['type']['#value'] .'_node_form' == $form_id && user_access('administer comments')) {
+ $node = $form['#node'];
+ $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
+ $form['user_comments'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User Comments'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['user_comments']['comment'] = array(
+ '#type' => 'radios',
+ '#parents' => array('comment'),
+ '#default_value' => $selected,
+ '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
+ );
+ }
}
}
@@ -246,15 +264,6 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
case 'fields':
return array('comment');
- case 'form':
- if (user_access('administer comments')) {
- $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
- $form['user_comments'] = array('#type' => 'fieldset', '#title' => t('User Comments'), '#collapsible' => TRUE, '#collapsed' => TRUE);
- $form['user_comments']['comment'] = array('#type' => 'radios', '#parents' => array('comment'), '#default_value' => $selected, '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')));
- return $form;
- }
- break;
-
case 'load':
return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
case 'validate':
@@ -1156,8 +1165,7 @@ function comment_form($edit, $title = NULL) {
$form['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
- $form['format']['#weight'] = 18;
+ $form['format'] = filter_form($node->format, 18);
$form['cid'] = array('#type' => 'value', '#value' => $edit['cid']);
$form['pid'] = array('#type' => 'value', '#value' => $edit['pid']);
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index e34b4b610..7e2b3e0f7 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -232,8 +232,26 @@ function comment_link($type, $node = 0, $main = 0) {
}
function comment_form_alter($form_id, &$form) {
- if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
- $form['workflow']['comment_'. $form['type']['#value']] = array('#type' => 'radios', '#title' => t('Default comment setting'), '#default_value' => variable_get('comment_'. $form['type']['#value'], COMMENT_NODE_READ_WRITE), '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
+ if (isset($form['type'])) {
+ if ($form['type']['#value'] .'_node_settings' == $form_id) {
+ $form['workflow']['comment_'. $form['type']['#value']] = array('#type' => 'radios', '#title' => t('Default comment setting'), '#default_value' => variable_get('comment_'. $form['type']['#value'], COMMENT_NODE_READ_WRITE), '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')), '#description' => t('Users with the <em>administer comments</em> permission will be able to override this setting.'));
+ }
+ if ($form['type']['#value'] .'_node_form' == $form_id && user_access('administer comments')) {
+ $node = $form['#node'];
+ $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
+ $form['user_comments'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('User Comments'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['user_comments']['comment'] = array(
+ '#type' => 'radios',
+ '#parents' => array('comment'),
+ '#default_value' => $selected,
+ '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')),
+ );
+ }
}
}
@@ -246,15 +264,6 @@ function comment_nodeapi(&$node, $op, $arg = 0) {
case 'fields':
return array('comment');
- case 'form':
- if (user_access('administer comments')) {
- $selected = isset($node->comment) ? $node->comment : variable_get("comment_$node->type", COMMENT_NODE_READ_WRITE);
- $form['user_comments'] = array('#type' => 'fieldset', '#title' => t('User Comments'), '#collapsible' => TRUE, '#collapsed' => TRUE);
- $form['user_comments']['comment'] = array('#type' => 'radios', '#parents' => array('comment'), '#default_value' => $selected, '#options' => array(t('Disabled'), t('Read only'), t('Read/Write')));
- return $form;
- }
- break;
-
case 'load':
return db_fetch_array(db_query("SELECT last_comment_timestamp, last_comment_name, comment_count FROM {node_comment_statistics} WHERE nid = %d", $node->nid));
case 'validate':
@@ -1156,8 +1165,7 @@ function comment_form($edit, $title = NULL) {
$form['comment'] = array('#type' => 'textarea', '#title' => t('Comment'), '#rows' => 15, '#default_value' => $edit['comment'] ? $edit['comment'] : $user->signature, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
- $form['format']['#weight'] = 18;
+ $form['format'] = filter_form($node->format, 18);
$form['cid'] = array('#type' => 'value', '#value' => $edit['cid']);
$form['pid'] = array('#type' => 'value', '#value' => $edit['pid']);
diff --git a/modules/filter.module b/modules/filter.module
index 4f793a07d..93d7a9424 100644
--- a/modules/filter.module
+++ b/modules/filter.module
@@ -750,7 +750,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
* @return
* HTML for the form element.
*/
-function filter_form($value = FILTER_FORMAT_DEFAULT) {
+function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = -16) {
if ($value == FILTER_FORMAT_DEFAULT) {
$value = variable_get('filter_default_format', 1);
}
@@ -759,11 +759,17 @@ function filter_form($value = FILTER_FORMAT_DEFAULT) {
$extra = l(t('More information about formatting options'), 'filter/tips');
if (count($formats) > 1) {
- $form['format'] = array('#type' => 'fieldset', '#title' => t('Input format'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -16);
+ $form = array(
+ '#type' => 'fieldset',
+ '#title' => t('Input format'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => $weight,
+ );
// Multiple formats available: display radio buttons with tips.
foreach ($formats as $format) {
- $form['format'][$format->format] = array(
- '#type' => 'filter_format',
+ $form[$format->format] = array(
+ '#type' => 'radio',
'#title' => $format->name,
'#default_value' => $value,
'#return_value' => $format->format,
@@ -772,16 +778,19 @@ function filter_form($value = FILTER_FORMAT_DEFAULT) {
'#validate' => array('filter_form_validate' => array())
);
}
- return $form;
}
else {
// Only one format available: use a hidden form item and only show tips.
$format = array_shift($formats);
- $form['format'][$format->name] = array('#type' => 'value', '#value' => $format->format);
+ $form[$format->name] = array('#type' => 'value', '#value' => $format->format);
$tips = _filter_tips(variable_get('filter_default_format', 1), false);
- $form['format']['guidelines'] = array('#type' => 'markup', '#title' => t('Formatting guidelines'), '#value' => theme('filter_tips', $tips, false, $extra));
- return $form;
+ $form['guidelines'] = array(
+ '#type' => 'markup',
+ '#title' => t('Formatting guidelines'),
+ '#value' => theme('filter_tips', $tips, false, $extra),
+ );
}
+ return $form;
}
function filter_form_validate($element) {
diff --git a/modules/filter/filter.module b/modules/filter/filter.module
index 4f793a07d..93d7a9424 100644
--- a/modules/filter/filter.module
+++ b/modules/filter/filter.module
@@ -750,7 +750,7 @@ function check_markup($text, $format = FILTER_FORMAT_DEFAULT, $check = TRUE) {
* @return
* HTML for the form element.
*/
-function filter_form($value = FILTER_FORMAT_DEFAULT) {
+function filter_form($value = FILTER_FORMAT_DEFAULT, $weight = -16) {
if ($value == FILTER_FORMAT_DEFAULT) {
$value = variable_get('filter_default_format', 1);
}
@@ -759,11 +759,17 @@ function filter_form($value = FILTER_FORMAT_DEFAULT) {
$extra = l(t('More information about formatting options'), 'filter/tips');
if (count($formats) > 1) {
- $form['format'] = array('#type' => 'fieldset', '#title' => t('Input format'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -16);
+ $form = array(
+ '#type' => 'fieldset',
+ '#title' => t('Input format'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => $weight,
+ );
// Multiple formats available: display radio buttons with tips.
foreach ($formats as $format) {
- $form['format'][$format->format] = array(
- '#type' => 'filter_format',
+ $form[$format->format] = array(
+ '#type' => 'radio',
'#title' => $format->name,
'#default_value' => $value,
'#return_value' => $format->format,
@@ -772,16 +778,19 @@ function filter_form($value = FILTER_FORMAT_DEFAULT) {
'#validate' => array('filter_form_validate' => array())
);
}
- return $form;
}
else {
// Only one format available: use a hidden form item and only show tips.
$format = array_shift($formats);
- $form['format'][$format->name] = array('#type' => 'value', '#value' => $format->format);
+ $form[$format->name] = array('#type' => 'value', '#value' => $format->format);
$tips = _filter_tips(variable_get('filter_default_format', 1), false);
- $form['format']['guidelines'] = array('#type' => 'markup', '#title' => t('Formatting guidelines'), '#value' => theme('filter_tips', $tips, false, $extra));
- return $form;
+ $form['guidelines'] = array(
+ '#type' => 'markup',
+ '#title' => t('Formatting guidelines'),
+ '#value' => theme('filter_tips', $tips, false, $extra),
+ );
}
+ return $form;
}
function filter_form_validate($element) {
diff --git a/modules/forum.module b/modules/forum.module
index 935150565..7e12b8c6b 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -591,7 +591,7 @@ function forum_form(&$node) {
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
return $form;
}
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index 935150565..7e12b8c6b 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -591,7 +591,7 @@ function forum_form(&$node) {
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
return $form;
}
diff --git a/modules/menu.module b/modules/menu.module
index eea4e0522..1eb896873 100644
--- a/modules/menu.module
+++ b/modules/menu.module
@@ -106,21 +106,17 @@ function menu_configure() {
$primary_options[$mid] = $menu['items'][$mid]['title'];
}
- $form['settings_links'] = array(
- '#type' => 'fieldset',
- '#title' => t('Primary links settings'),
- );
-
+ $form['settings_links'] = array('#type' => 'fieldset', '#title' => t('Primary links settings'));
$form['settings_links']['intro'] = array(
- '#type' => 'item',
- '#value' => t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the menu settings pane on each post authoring form.', array('%menu' => url('admin/menu'))),
+ '#type' => 'markup',
+ '#value' => t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the \'Menu settings\' pane on each edit node form.', array('%menu' => url('admin/menu')))
);
$form['settings_links']['menu_primary_menu'] = array(
'#type' => 'select',
'#title' => t('Menu containing primary links'),
'#default_value' => variable_get('menu_primary_menu', 0),
- '#options' => $primary_options,
+ '#options' => $primary_options
);
$secondary_options[0] = t('No secondary links');
@@ -133,32 +129,9 @@ function menu_configure() {
'#title' => t('Menu containing secondary links'),
'#default_value' => variable_get('menu_secondary_menu', 0),
'#options' => $secondary_options,
- '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'),
- );
-
- $form['settings_authoring'] = array(
- '#type' => 'fieldset',
- '#title' => t('Post authoring form settings'),
- );
-
- $form['settings_authoring']['intro'] = array(
- '#type' => 'item',
- '#value' => t('On each post authoring form there is a menu settings pane. This setting allows you to limit what is displayed in the parent item drop-down menu of that pane. This can be used to force new menu items to be created in the primary links menu or to hide admin menu items.'),
+ '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.')
);
- $authoring_options = array(0 => t('Show all menus'));
- foreach ($menu['items'][0]['children'] as $mid) {
- $authoring_options[$mid] = $menu['items'][$mid]['title'];
- }
-
- $form['settings_authoring']['menu_parent_items'] = array(
- '#type' => 'select',
- '#title' => t('Restrict parent items to'),
- '#default_value' => variable_get('menu_parent_items', 0),
- '#options' => $authoring_options,
- '#description' => t('Choose the menu from which parent items will be made available. Only this menu item and its children will be shown.'),
- );
-
return system_settings_form('menu_configure', $form);
}
@@ -192,12 +165,6 @@ function menu_nodeapi(&$node, $op) {
if (user_access('administer menu')) {
switch ($op) {
- case 'form':
- $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
- $edit['nid'] = isset($node->nid) ? $node->nid : '';
- return menu_node_form($edit);
- break;
-
case 'insert':
case 'update':
if ($node->menu['delete']) {
@@ -593,51 +560,29 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
/**
* Return a list of menu items that are valid possible parents for the
- * given menu item. The list excludes the given item and its children.
- *
- * @param $mid
- * The menu item id for which to generate a list of parents.
- * If $mid == 0 then the complete tree is returned.
- * @param $pid
- * The menu item id of the menu item at which to start the tree.
- * If $pid > 0 then this item will be included in the tree.
- * @param $depth
- * The current depth in the tree - used when recursing to indent the tree.
- * @return
- * An array of menu titles keyed on the mid.
+ * given menu item.
*/
function menu_parent_options($mid, $pid = 0, $depth = 0) {
$menu = menu_get_menu();
$options = array();
- if (!isset($menu['items'][$pid])) {
- return $options;
- }
-
- // Exclude $mid and its children from the list unless $mid is 0.
- if ($mid && $mid == $pid) {
- return $options;
- }
-
- // Add the current $pid to the list.
- if ($pid > 0 && ($menu['items'][$pid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT))) {
- $title = ' '. $menu['items'][$pid]['title'];
- for ($i = 0; $i < $depth; $i++) {
- $title = '--'. $title;
- }
- if (!($menu['items'][$pid]['type'] & MENU_VISIBLE_IN_TREE)) {
- $title .= ' ('. t('disabled') .')';
- }
- $options[$pid] = $title;
- $depth ++;
- }
-
- // Add children of $pid to the list recursively.
- if ($menu['items'][$pid]['children']) {
+ if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) {
usort($menu['items'][$pid]['children'], '_menu_sort');
foreach ($menu['items'][$pid]['children'] as $child) {
- $options += menu_parent_options($mid, $child, $depth);
+ if ($child != $mid) {
+ if ($child > 0 && ($menu['items'][$child]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT))) {
+ $title = ' '. $menu['items'][$child]['title'];
+ for ($i = 0; $i < $depth; $i++) {
+ $title = '--'. $title;
+ }
+ if (!($menu['items'][$child]['type'] & (MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IF_HAS_CHILDREN))) {
+ $title .= ' ('. t('disabled') .')';
+ }
+ $options[$child] = $title;
+ }
+ $options += menu_parent_options($mid, $child, $depth + 1);
+ }
}
}
@@ -647,84 +592,87 @@ function menu_parent_options($mid, $pid = 0, $depth = 0) {
/**
* Add menu item fields to the node form.
*/
-function menu_node_form($edit = array()) {
- $item = array();
- if ($edit['nid'] > 0) {
- $item = db_fetch_array(db_query("SELECT * FROM {menu} WHERE path = 'node/%d'", $edit['nid']));
- if (is_array($edit['menu'])) {
- $item = !is_array($item) ? $edit['menu'] : (($_POST['op'] == t('Preview')) ? array_merge($item, $edit['menu']) : array_merge($edit['menu'], $item));
+function menu_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $edit['nid'] = $form['nid']['#value'];
+
+ $item = array();
+ if ($edit['nid'] > 0) {
+ $item = db_fetch_array(db_query("SELECT * FROM {menu} WHERE path = 'node/%d'", $edit['nid']));
+ if (is_array($edit['menu'])) {
+ $item = !is_array($item) ? $edit['menu'] : (($_POST['op'] == t('Preview')) ? array_merge($item, $edit['menu']) : array_merge($edit['menu'], $item));
+ }
}
- }
- $form['menu'] = array(
- '#type' => 'fieldset',
- '#title' => t('Menu settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#tree' => TRUE,
- );
-
- $form['menu']['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title'),
- '#default_value' => $item['title'],
- '#description' => t('The name to display for this link.'),
- );
-
- $form['menu']['description'] = array(
- '#type' => 'textfield',
- '#title' => t('Description'),
- '#default_value' => $item['description'],
- '#description' => t('The description displayed when hovering over a menu item.'),
- );
+ $form['menu'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Menu settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#tree' => TRUE,
+ );
- // Generate a list of possible parents.
- $options = menu_parent_options($item['mid'], variable_get('menu_parent_items', 0));
+ $form['menu']['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title'),
+ '#default_value' => $item['title'],
+ '#description' => t('The name to display for this link.'),
+ );
- $form['menu']['pid'] = array(
- '#type' => select,
- '#title' => t('Parent item'),
- '#default_value' => $item['pid'],
- '#options' => $options,
- );
+ $form['menu']['description'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Description'),
+ '#default_value' => $item['description'],
+ '#description' => t('The description displayed when hovering over a menu item.'),
+ );
- $form['menu']['path'] = array(
- '#type' => 'hidden',
- '#value' => $item['path'],
- );
+ // Generate a list of possible parents.
+ $options = menu_parent_options($item['mid'], variable_get('menu_parent_items', 0));
- $form['menu']['weight'] = array(
- '#type' => 'weight',
- '#title' => t('Weight'),
- '#default_value' => $item['weight'],
- '#delta' => 10,
- '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
- );
+ $form['menu']['pid'] = array(
+ '#type' => select,
+ '#title' => t('Parent item'),
+ '#default_value' => $item['pid'],
+ '#options' => $options,
+ );
- $form['menu']['mid'] = array(
- '#type' => 'hidden',
- '#value' => $item['mid'] ? $item['mid'] : 0,
- );
+ $form['menu']['path'] = array(
+ '#type' => 'hidden',
+ '#value' => $item['path'],
+ );
- $form['menu']['type'] = array(
- '#type' => 'hidden',
- '#value' => $item['type'] ? $item['type'] : MENU_CUSTOM_ITEM,
- );
+ $form['menu']['weight'] = array(
+ '#type' => 'weight',
+ '#title' => t('Weight'),
+ '#default_value' => $item['weight'],
+ '#delta' => 10,
+ '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
+ );
- if ($item['mid'] > 0) {
- $form['menu']['delete'] = array(
- '#type' => 'checkbox',
- '#title' => t('Check to delete this menu item.'),
- '#default_value' => $item['delete'],
+ $form['menu']['mid'] = array(
+ '#type' => 'hidden',
+ '#value' => $item['mid'] ? $item['mid'] : 0,
);
- $form['menu']['advanced'] = array(
- '#type' => 'item',
- '#value' => t('You may also <a href="%edit">edit the advanced settings</a> for this menu item.', array('%edit' => url("admin/menu/item/edit/{$item['mid']}"))),
+ $form['menu']['type'] = array(
+ '#type' => 'hidden',
+ '#value' => $item['type'] ? $item['type'] : MENU_CUSTOM_ITEM,
);
- }
- return $form;
+ if ($item['mid'] > 0) {
+ $form['menu']['delete'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Check to delete this menu item.'),
+ '#default_value' => $item['delete'],
+ );
+
+ $form['menu']['advanced'] = array(
+ '#type' => 'item',
+ '#value' => t('You may also <a href="%edit">edit the advanced settings</a> for this menu item.', array('%edit' => url("admin/menu/item/edit/{$item['mid']}"))),
+ );
+ }
+ }
}
/**
diff --git a/modules/menu/menu.module b/modules/menu/menu.module
index eea4e0522..1eb896873 100644
--- a/modules/menu/menu.module
+++ b/modules/menu/menu.module
@@ -106,21 +106,17 @@ function menu_configure() {
$primary_options[$mid] = $menu['items'][$mid]['title'];
}
- $form['settings_links'] = array(
- '#type' => 'fieldset',
- '#title' => t('Primary links settings'),
- );
-
+ $form['settings_links'] = array('#type' => 'fieldset', '#title' => t('Primary links settings'));
$form['settings_links']['intro'] = array(
- '#type' => 'item',
- '#value' => t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the menu settings pane on each post authoring form.', array('%menu' => url('admin/menu'))),
+ '#type' => 'markup',
+ '#value' => t('Primary links is a navigation system which usually (depending on your theme) appears at the top-right of the browser window. There are usually two rows of links, primary and secondary. You may control which links appear in this area by choosing a menu from which the links will be generated and then placing your links into the menu using the <a href="%menu">menu administration</a> or the \'Menu settings\' pane on each edit node form.', array('%menu' => url('admin/menu')))
);
$form['settings_links']['menu_primary_menu'] = array(
'#type' => 'select',
'#title' => t('Menu containing primary links'),
'#default_value' => variable_get('menu_primary_menu', 0),
- '#options' => $primary_options,
+ '#options' => $primary_options
);
$secondary_options[0] = t('No secondary links');
@@ -133,32 +129,9 @@ function menu_configure() {
'#title' => t('Menu containing secondary links'),
'#default_value' => variable_get('menu_secondary_menu', 0),
'#options' => $secondary_options,
- '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.'),
- );
-
- $form['settings_authoring'] = array(
- '#type' => 'fieldset',
- '#title' => t('Post authoring form settings'),
- );
-
- $form['settings_authoring']['intro'] = array(
- '#type' => 'item',
- '#value' => t('On each post authoring form there is a menu settings pane. This setting allows you to limit what is displayed in the parent item drop-down menu of that pane. This can be used to force new menu items to be created in the primary links menu or to hide admin menu items.'),
+ '#description' => t('If you select the same menu as primary links then secondary links will display the appropriate second level of your navigation hierarchy.')
);
- $authoring_options = array(0 => t('Show all menus'));
- foreach ($menu['items'][0]['children'] as $mid) {
- $authoring_options[$mid] = $menu['items'][$mid]['title'];
- }
-
- $form['settings_authoring']['menu_parent_items'] = array(
- '#type' => 'select',
- '#title' => t('Restrict parent items to'),
- '#default_value' => variable_get('menu_parent_items', 0),
- '#options' => $authoring_options,
- '#description' => t('Choose the menu from which parent items will be made available. Only this menu item and its children will be shown.'),
- );
-
return system_settings_form('menu_configure', $form);
}
@@ -192,12 +165,6 @@ function menu_nodeapi(&$node, $op) {
if (user_access('administer menu')) {
switch ($op) {
- case 'form':
- $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
- $edit['nid'] = isset($node->nid) ? $node->nid : '';
- return menu_node_form($edit);
- break;
-
case 'insert':
case 'update':
if ($node->menu['delete']) {
@@ -593,51 +560,29 @@ function menu_overview_tree_rows($pid = 0, $depth = 0) {
/**
* Return a list of menu items that are valid possible parents for the
- * given menu item. The list excludes the given item and its children.
- *
- * @param $mid
- * The menu item id for which to generate a list of parents.
- * If $mid == 0 then the complete tree is returned.
- * @param $pid
- * The menu item id of the menu item at which to start the tree.
- * If $pid > 0 then this item will be included in the tree.
- * @param $depth
- * The current depth in the tree - used when recursing to indent the tree.
- * @return
- * An array of menu titles keyed on the mid.
+ * given menu item.
*/
function menu_parent_options($mid, $pid = 0, $depth = 0) {
$menu = menu_get_menu();
$options = array();
- if (!isset($menu['items'][$pid])) {
- return $options;
- }
-
- // Exclude $mid and its children from the list unless $mid is 0.
- if ($mid && $mid == $pid) {
- return $options;
- }
-
- // Add the current $pid to the list.
- if ($pid > 0 && ($menu['items'][$pid]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT))) {
- $title = ' '. $menu['items'][$pid]['title'];
- for ($i = 0; $i < $depth; $i++) {
- $title = '--'. $title;
- }
- if (!($menu['items'][$pid]['type'] & MENU_VISIBLE_IN_TREE)) {
- $title .= ' ('. t('disabled') .')';
- }
- $options[$pid] = $title;
- $depth ++;
- }
-
- // Add children of $pid to the list recursively.
- if ($menu['items'][$pid]['children']) {
+ if (isset($menu['items'][$pid]) && $menu['items'][$pid]['children']) {
usort($menu['items'][$pid]['children'], '_menu_sort');
foreach ($menu['items'][$pid]['children'] as $child) {
- $options += menu_parent_options($mid, $child, $depth);
+ if ($child != $mid) {
+ if ($child > 0 && ($menu['items'][$child]['type'] & (MENU_MODIFIABLE_BY_ADMIN | MENU_IS_ROOT))) {
+ $title = ' '. $menu['items'][$child]['title'];
+ for ($i = 0; $i < $depth; $i++) {
+ $title = '--'. $title;
+ }
+ if (!($menu['items'][$child]['type'] & (MENU_VISIBLE_IN_TREE | MENU_VISIBLE_IF_HAS_CHILDREN))) {
+ $title .= ' ('. t('disabled') .')';
+ }
+ $options[$child] = $title;
+ }
+ $options += menu_parent_options($mid, $child, $depth + 1);
+ }
}
}
@@ -647,84 +592,87 @@ function menu_parent_options($mid, $pid = 0, $depth = 0) {
/**
* Add menu item fields to the node form.
*/
-function menu_node_form($edit = array()) {
- $item = array();
- if ($edit['nid'] > 0) {
- $item = db_fetch_array(db_query("SELECT * FROM {menu} WHERE path = 'node/%d'", $edit['nid']));
- if (is_array($edit['menu'])) {
- $item = !is_array($item) ? $edit['menu'] : (($_POST['op'] == t('Preview')) ? array_merge($item, $edit['menu']) : array_merge($edit['menu'], $item));
+function menu_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+ $edit['nid'] = $form['nid']['#value'];
+
+ $item = array();
+ if ($edit['nid'] > 0) {
+ $item = db_fetch_array(db_query("SELECT * FROM {menu} WHERE path = 'node/%d'", $edit['nid']));
+ if (is_array($edit['menu'])) {
+ $item = !is_array($item) ? $edit['menu'] : (($_POST['op'] == t('Preview')) ? array_merge($item, $edit['menu']) : array_merge($edit['menu'], $item));
+ }
}
- }
- $form['menu'] = array(
- '#type' => 'fieldset',
- '#title' => t('Menu settings'),
- '#collapsible' => TRUE,
- '#collapsed' => TRUE,
- '#tree' => TRUE,
- );
-
- $form['menu']['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Title'),
- '#default_value' => $item['title'],
- '#description' => t('The name to display for this link.'),
- );
-
- $form['menu']['description'] = array(
- '#type' => 'textfield',
- '#title' => t('Description'),
- '#default_value' => $item['description'],
- '#description' => t('The description displayed when hovering over a menu item.'),
- );
+ $form['menu'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Menu settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#tree' => TRUE,
+ );
- // Generate a list of possible parents.
- $options = menu_parent_options($item['mid'], variable_get('menu_parent_items', 0));
+ $form['menu']['title'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title'),
+ '#default_value' => $item['title'],
+ '#description' => t('The name to display for this link.'),
+ );
- $form['menu']['pid'] = array(
- '#type' => select,
- '#title' => t('Parent item'),
- '#default_value' => $item['pid'],
- '#options' => $options,
- );
+ $form['menu']['description'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Description'),
+ '#default_value' => $item['description'],
+ '#description' => t('The description displayed when hovering over a menu item.'),
+ );
- $form['menu']['path'] = array(
- '#type' => 'hidden',
- '#value' => $item['path'],
- );
+ // Generate a list of possible parents.
+ $options = menu_parent_options($item['mid'], variable_get('menu_parent_items', 0));
- $form['menu']['weight'] = array(
- '#type' => 'weight',
- '#title' => t('Weight'),
- '#default_value' => $item['weight'],
- '#delta' => 10,
- '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
- );
+ $form['menu']['pid'] = array(
+ '#type' => select,
+ '#title' => t('Parent item'),
+ '#default_value' => $item['pid'],
+ '#options' => $options,
+ );
- $form['menu']['mid'] = array(
- '#type' => 'hidden',
- '#value' => $item['mid'] ? $item['mid'] : 0,
- );
+ $form['menu']['path'] = array(
+ '#type' => 'hidden',
+ '#value' => $item['path'],
+ );
- $form['menu']['type'] = array(
- '#type' => 'hidden',
- '#value' => $item['type'] ? $item['type'] : MENU_CUSTOM_ITEM,
- );
+ $form['menu']['weight'] = array(
+ '#type' => 'weight',
+ '#title' => t('Weight'),
+ '#default_value' => $item['weight'],
+ '#delta' => 10,
+ '#description' => t('Optional. In the menu, the heavier items will sink and the lighter items will be positioned nearer the top.'),
+ );
- if ($item['mid'] > 0) {
- $form['menu']['delete'] = array(
- '#type' => 'checkbox',
- '#title' => t('Check to delete this menu item.'),
- '#default_value' => $item['delete'],
+ $form['menu']['mid'] = array(
+ '#type' => 'hidden',
+ '#value' => $item['mid'] ? $item['mid'] : 0,
);
- $form['menu']['advanced'] = array(
- '#type' => 'item',
- '#value' => t('You may also <a href="%edit">edit the advanced settings</a> for this menu item.', array('%edit' => url("admin/menu/item/edit/{$item['mid']}"))),
+ $form['menu']['type'] = array(
+ '#type' => 'hidden',
+ '#value' => $item['type'] ? $item['type'] : MENU_CUSTOM_ITEM,
);
- }
- return $form;
+ if ($item['mid'] > 0) {
+ $form['menu']['delete'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Check to delete this menu item.'),
+ '#default_value' => $item['delete'],
+ );
+
+ $form['menu']['advanced'] = array(
+ '#type' => 'item',
+ '#value' => t('You may also <a href="%edit">edit the advanced settings</a> for this menu item.', array('%edit' => url("admin/menu/item/edit/{$item['mid']}"))),
+ );
+ }
+ }
}
/**
diff --git a/modules/node.module b/modules/node.module
index 001d700f0..33e1721d0 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -1605,9 +1605,16 @@ function node_form($node) {
$form['created'] = array('#type' => 'value', '#value' => $node->created);
$form['changed'] = array('#type' => 'value', '#value' => $node->changed);
$form['type'] = array('#type' => 'value', '#value' => $node->type);
+ $form['#node'] = $node;
// Get the node-specific bits.
$form = array_merge($form, node_invoke($node, 'form'));
+ if (!isset($form['title']['#weight'])) {
+ $form['title']['#weight'] = -18;
+ }
+ if (!isset($form['body']['#weight'])) {
+ $form['body']['#weight'] = -17;
+ }
// If this is a new node, fill in the default values.
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
@@ -1651,18 +1658,6 @@ function node_form($node) {
$form['revision'] = array('#type' => 'value', '#value' => $node->revision);
}
- $nodeapi = node_invoke_nodeapi($node, 'form');
- if (is_array($nodeapi)) {
- foreach ($nodeapi as $key => $element) {
- $nodeapi[$key]['#weight'] = isset($nodeapi[$key]['#weight']) ? $nodeapi[$key]['#weight'] : -4;
- }
- // Append extra node form elements.
- $form = array_merge($form, $nodeapi);
- }
-
- $form['title']['#weight'] = isset($form['title']['#weight']) ? $form['title']['#weight'] : -18;
- $form['body']['#weight'] = isset($form['body']['#weight']) ? $form['body']['#weight'] : -17;
-
// Add the buttons.
$form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 19);
diff --git a/modules/node/node.module b/modules/node/node.module
index 001d700f0..33e1721d0 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1605,9 +1605,16 @@ function node_form($node) {
$form['created'] = array('#type' => 'value', '#value' => $node->created);
$form['changed'] = array('#type' => 'value', '#value' => $node->changed);
$form['type'] = array('#type' => 'value', '#value' => $node->type);
+ $form['#node'] = $node;
// Get the node-specific bits.
$form = array_merge($form, node_invoke($node, 'form'));
+ if (!isset($form['title']['#weight'])) {
+ $form['title']['#weight'] = -18;
+ }
+ if (!isset($form['body']['#weight'])) {
+ $form['body']['#weight'] = -17;
+ }
// If this is a new node, fill in the default values.
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
@@ -1651,18 +1658,6 @@ function node_form($node) {
$form['revision'] = array('#type' => 'value', '#value' => $node->revision);
}
- $nodeapi = node_invoke_nodeapi($node, 'form');
- if (is_array($nodeapi)) {
- foreach ($nodeapi as $key => $element) {
- $nodeapi[$key]['#weight'] = isset($nodeapi[$key]['#weight']) ? $nodeapi[$key]['#weight'] : -4;
- }
- // Append extra node form elements.
- $form = array_merge($form, $nodeapi);
- }
-
- $form['title']['#weight'] = isset($form['title']['#weight']) ? $form['title']['#weight'] : -18;
- $form['body']['#weight'] = isset($form['body']['#weight']) ? $form['body']['#weight'] : -17;
-
// Add the buttons.
$form['preview'] = array('#type' => 'button', '#value' => t('Preview'), '#weight' => 19);
diff --git a/modules/page.module b/modules/page.module
index 5a20bb4e8..b012c9aaf 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -96,7 +96,7 @@ function page_form(&$node) {
$form['body'] = array(
'#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
$form['log'] = array(
'#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE
diff --git a/modules/page/page.module b/modules/page/page.module
index 5a20bb4e8..b012c9aaf 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -96,7 +96,7 @@ function page_form(&$node) {
$form['body'] = array(
'#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE
);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
$form['log'] = array(
'#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE
diff --git a/modules/path.module b/modules/path.module
index 6929ba822..5ba006086 100644
--- a/modules/path.module
+++ b/modules/path.module
@@ -185,14 +185,6 @@ function path_nodeapi(&$node, $op, $arg) {
}
break;
- case 'form':
- $form['path'] = array('#type' => 'fieldset', '#title' => t('URL path settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
- $form['path']['path'] = array('#type' => 'textfield', '#default_value' => $node->path, '#maxlength' => 250, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'));
- if ($node->path) {
- $form['path']['pid'] = array('#type' => 'hidden', '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $node->path)));
- }
- return $form;
-
case 'load':
$path = "node/$node->nid";
$alias = drupal_get_path_alias($path);
@@ -224,6 +216,36 @@ function path_nodeapi(&$node, $op, $arg) {
}
/**
+ * Implementation of hook_form_alter().
+ */
+function path_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $path = $form['#node']->path;
+ $form['path'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('URL path settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['path']['path'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $path,
+ '#maxlength' => 250,
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
+ );
+ if ($node->path) {
+ $form['path']['pid'] = array(
+ '#type' => 'value',
+ '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $path))
+ );
+ }
+ }
+}
+
+
+/**
* Implementation of hook_perm().
*/
function path_perm() {
diff --git a/modules/path/path.module b/modules/path/path.module
index 6929ba822..5ba006086 100644
--- a/modules/path/path.module
+++ b/modules/path/path.module
@@ -185,14 +185,6 @@ function path_nodeapi(&$node, $op, $arg) {
}
break;
- case 'form':
- $form['path'] = array('#type' => 'fieldset', '#title' => t('URL path settings'), '#collapsible' => TRUE, '#collapsed' => TRUE);
- $form['path']['path'] = array('#type' => 'textfield', '#default_value' => $node->path, '#maxlength' => 250, '#collapsible' => TRUE, '#collapsed' => TRUE, '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'));
- if ($node->path) {
- $form['path']['pid'] = array('#type' => 'hidden', '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $node->path)));
- }
- return $form;
-
case 'load':
$path = "node/$node->nid";
$alias = drupal_get_path_alias($path);
@@ -224,6 +216,36 @@ function path_nodeapi(&$node, $op, $arg) {
}
/**
+ * Implementation of hook_form_alter().
+ */
+function path_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $path = $form['#node']->path;
+ $form['path'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('URL path settings'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ );
+ $form['path']['path'] = array(
+ '#type' => 'textfield',
+ '#default_value' => $path,
+ '#maxlength' => 250,
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#description' => t('Optionally specify an alternative URL by which this node can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
+ );
+ if ($node->path) {
+ $form['path']['pid'] = array(
+ '#type' => 'value',
+ '#value' => db_result(db_query("SELECT pid FROM {url_alias} WHERE dst = '%s'", $path))
+ );
+ }
+ }
+}
+
+
+/**
* Implementation of hook_perm().
*/
function path_perm() {
diff --git a/modules/story.module b/modules/story.module
index 6cc443436..cd7d3c5bc 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -89,7 +89,7 @@ function story_form(&$node) {
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title);
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
$form['log'] = array('#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['log']['message'] = array('#type' => 'textarea', '#default_value' => $node->log, '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
diff --git a/modules/story/story.module b/modules/story/story.module
index 6cc443436..cd7d3c5bc 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -89,7 +89,7 @@ function story_form(&$node) {
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title);
$form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
- $form = array_merge($form, filter_form($node->format));
+ $form['format'] = filter_form($node->format);
$form['log'] = array('#type' => 'fieldset', '#title' => t('Log message'), '#collapsible' => TRUE, '#collapsed' => TRUE);
$form['log']['message'] = array('#type' => 'textarea', '#default_value' => $node->log, '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index f58f6db29..52fec1033 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -500,51 +500,52 @@ function taxonomy_get_vocabularies($type = NULL) {
/**
* Generate a form for selecting terms to associate with a node.
*/
-function taxonomy_node_form($node) {
- if (!array_key_exists('taxonomy', $node)) {
- if ($node->nid) {
- $terms = taxonomy_node_get_terms($node->nid);
+function taxonomy_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $node = $form['#node'];
+
+ if (!array_key_exists('taxonomy', $node)) {
+ if ($node->nid) {
+ $terms = taxonomy_node_get_terms($node->nid);
+ }
+ else {
+ $terms = array();
+ }
}
else {
- $terms = array();
+ $terms = $node->taxonomy;
}
- }
- else {
- $terms = $node->taxonomy;
- }
- $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
- while ($vocabulary = db_fetch_object($c)) {
- if ($vocabulary->tags) {
- $typed_terms = array();
- foreach ($terms as $term) {
- if ($term->vid == $vocabulary->vid) {
+ $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
- // Commas and quotes in terms are special cases, so encode 'em.
- if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) {
- $term->name = '"'.preg_replace('/"/', '""', $term->name).'"';
- }
+ while ($vocabulary = db_fetch_object($c)) {
+ if ($vocabulary->tags) {
+ $typed_terms = array();
+ foreach ($terms as $term) {
+ if ($term->vid == $vocabulary->vid) {
- $typed_terms[] = $term->name;
+ // Commas and quotes in terms are special cases, so encode 'em.
+ if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) {
+ $term->name = '"'.preg_replace('/"/', '""', $term->name).'"';
+ }
+
+ $typed_terms[] = $term->name;
+ }
}
- }
- $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
+ $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
- $form['taxonomy']['tags'][$vocabulary->vid] = array('#type' => 'textfield', '#default_value' => $typed_string, '#maxlength' => 100, '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid, '#required' => $vocabulary->required, '#title' => $vocabulary->name, '#description' => t('A comma-separated list of terms describing this content (Example: funny, bungie jumping, "Company, Inc.").'));
+ $form['taxonomy']['tags'][$vocabulary->vid] = array('#type' => 'textfield', '#default_value' => $typed_string, '#maxlength' => 100, '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid, '#required' => $vocabulary->required, '#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);
+ $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, $ntterms, $help, 'taxonomy');
+ }
}
- else {
- $ntterms = array_key_exists('taxonomy', $node) ? $terms : array_keys($terms);
- $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, $ntterms, $help, 'taxonomy');
+ if (isset($form['taxonomy'])) {
+ $form['taxonomy']['#tree'] = TRUE;
+ $form['taxonomy']['#weight'] = -15;
}
}
- if ($form) {
- $form['taxonomy']['#tree'] = TRUE;
- $form['taxonomy']['#weight'] = -15;
- return $form;
- }
- else {
- return array();
- }
}
/**
@@ -1056,9 +1057,6 @@ function taxonomy_nodeapi($node, $op, $arg = 0) {
case 'rss item':
return taxonomy_rss_item($node);
break;
- case 'form':
- return taxonomy_node_form($node);
- break;
}
}
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index f58f6db29..52fec1033 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -500,51 +500,52 @@ function taxonomy_get_vocabularies($type = NULL) {
/**
* Generate a form for selecting terms to associate with a node.
*/
-function taxonomy_node_form($node) {
- if (!array_key_exists('taxonomy', $node)) {
- if ($node->nid) {
- $terms = taxonomy_node_get_terms($node->nid);
+function taxonomy_form_alter($form_id, &$form) {
+ if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
+ $node = $form['#node'];
+
+ if (!array_key_exists('taxonomy', $node)) {
+ if ($node->nid) {
+ $terms = taxonomy_node_get_terms($node->nid);
+ }
+ else {
+ $terms = array();
+ }
}
else {
- $terms = array();
+ $terms = $node->taxonomy;
}
- }
- else {
- $terms = $node->taxonomy;
- }
- $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
- while ($vocabulary = db_fetch_object($c)) {
- if ($vocabulary->tags) {
- $typed_terms = array();
- foreach ($terms as $term) {
- if ($term->vid == $vocabulary->vid) {
+ $c = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s' ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
- // Commas and quotes in terms are special cases, so encode 'em.
- if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) {
- $term->name = '"'.preg_replace('/"/', '""', $term->name).'"';
- }
+ while ($vocabulary = db_fetch_object($c)) {
+ if ($vocabulary->tags) {
+ $typed_terms = array();
+ foreach ($terms as $term) {
+ if ($term->vid == $vocabulary->vid) {
- $typed_terms[] = $term->name;
+ // Commas and quotes in terms are special cases, so encode 'em.
+ if (preg_match('/,/', $term->name) || preg_match('/"/', $term->name)) {
+ $term->name = '"'.preg_replace('/"/', '""', $term->name).'"';
+ }
+
+ $typed_terms[] = $term->name;
+ }
}
- }
- $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
+ $typed_string = implode(', ', $typed_terms) . (array_key_exists('tags', $terms) ? $terms['tags'][$vocabulary->vid] : NULL);
- $form['taxonomy']['tags'][$vocabulary->vid] = array('#type' => 'textfield', '#default_value' => $typed_string, '#maxlength' => 100, '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid, '#required' => $vocabulary->required, '#title' => $vocabulary->name, '#description' => t('A comma-separated list of terms describing this content (Example: funny, bungie jumping, "Company, Inc.").'));
+ $form['taxonomy']['tags'][$vocabulary->vid] = array('#type' => 'textfield', '#default_value' => $typed_string, '#maxlength' => 100, '#autocomplete_path' => 'taxonomy/autocomplete/'. $vocabulary->vid, '#required' => $vocabulary->required, '#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);
+ $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, $ntterms, $help, 'taxonomy');
+ }
}
- else {
- $ntterms = array_key_exists('taxonomy', $node) ? $terms : array_keys($terms);
- $form['taxonomy'][$vocabulary->vid] = taxonomy_form($vocabulary->vid, $ntterms, $help, 'taxonomy');
+ if (isset($form['taxonomy'])) {
+ $form['taxonomy']['#tree'] = TRUE;
+ $form['taxonomy']['#weight'] = -15;
}
}
- if ($form) {
- $form['taxonomy']['#tree'] = TRUE;
- $form['taxonomy']['#weight'] = -15;
- return $form;
- }
- else {
- return array();
- }
}
/**
@@ -1056,9 +1057,6 @@ function taxonomy_nodeapi($node, $op, $arg = 0) {
case 'rss item':
return taxonomy_rss_item($node);
break;
- case 'form':
- return taxonomy_node_form($node);
- break;
}
}
diff --git a/modules/upload.module b/modules/upload.module
index 8237031cc..f52563d3e 100644
--- a/modules/upload.module
+++ b/modules/upload.module
@@ -145,11 +145,28 @@ function upload_file_download($file) {
}
function upload_form_alter($form_id, &$form) {
- if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
- $form['workflow']['upload_'. $form['type']['#value']] = array(
- '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => variable_get('upload_'. $form['type']['#value'], 1),
- '#options' => array(t('Disabled'), t('Enabled')),
- );
+ if (isset($form['type'])) {
+ if ($form['type']['#value'] .'_node_settings' == $form_id) {
+ $form['workflow']['upload_'. $form['type']['#value']] = array(
+ '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => variable_get('upload_'. $form['type']['#value'], 1),
+ '#options' => array(t('Disabled'), t('Enabled')),
+ );
+ }
+ if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
+ drupal_add_js('misc/progress.js');
+ drupal_add_js('misc/upload.js');
+ $form['attachments'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('File attachments'),
+ '#collapsible' => TRUE,
+ '#collapsed' => empty($node->files),
+ '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
+ '#prefix' => '<div class="attachments">',
+ '#suffix' => '</div>',
+ );
+ $form['attachments'] += _upload_form($form['#node']);
+ $form['#attributes'] = array('enctype' => 'multipart/form-data');
+ }
}
}
@@ -234,13 +251,6 @@ function upload_nodeapi(&$node, $op, $arg) {
}
break;
- case 'form':
- if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
- $output = upload_form($node);
- $output['#attributes'] = array('enctype' => 'multipart/form-data');
- }
- break;
-
case 'load':
if (variable_get("upload_$node->type", 1) == 1) {
$output['files'] = upload_load($node);
@@ -401,20 +411,6 @@ function upload_delete($node) {
db_query("DELETE FROM {files} WHERE nid = %d", $node->nid);
}
-function upload_form($node) {
- drupal_add_js('misc/progress.js');
- drupal_add_js('misc/upload.js');
-
- $form['attachments'] = array(
- '#type' => 'fieldset', '#title' => t('File attachments'), '#collapsible' => TRUE, '#collapsed' => empty($node->files),
- '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
- '#prefix' => '<div class="attachments">', '#suffix' => '</div>'
- );
- $form['attachments'] += _upload_form($node);
-
- return $form;
-}
-
function _upload_form($node) {
$header = array(t('Delete'), t('List'), t('Description'), t('Size'));
$rows = array();
diff --git a/modules/upload/upload.module b/modules/upload/upload.module
index 8237031cc..f52563d3e 100644
--- a/modules/upload/upload.module
+++ b/modules/upload/upload.module
@@ -145,11 +145,28 @@ function upload_file_download($file) {
}
function upload_form_alter($form_id, &$form) {
- if (isset($form['type']) && $form['type']['#value'] .'_node_settings' == $form_id) {
- $form['workflow']['upload_'. $form['type']['#value']] = array(
- '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => variable_get('upload_'. $form['type']['#value'], 1),
- '#options' => array(t('Disabled'), t('Enabled')),
- );
+ if (isset($form['type'])) {
+ if ($form['type']['#value'] .'_node_settings' == $form_id) {
+ $form['workflow']['upload_'. $form['type']['#value']] = array(
+ '#type' => 'radios', '#title' => t('Attachments'), '#default_value' => variable_get('upload_'. $form['type']['#value'], 1),
+ '#options' => array(t('Disabled'), t('Enabled')),
+ );
+ }
+ if ($form['type']['#value'] .'_node_form' == $form_id && variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
+ drupal_add_js('misc/progress.js');
+ drupal_add_js('misc/upload.js');
+ $form['attachments'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('File attachments'),
+ '#collapsible' => TRUE,
+ '#collapsed' => empty($node->files),
+ '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
+ '#prefix' => '<div class="attachments">',
+ '#suffix' => '</div>',
+ );
+ $form['attachments'] += _upload_form($form['#node']);
+ $form['#attributes'] = array('enctype' => 'multipart/form-data');
+ }
}
}
@@ -234,13 +251,6 @@ function upload_nodeapi(&$node, $op, $arg) {
}
break;
- case 'form':
- if (variable_get("upload_$node->type", 1) == 1 && user_access('upload files')) {
- $output = upload_form($node);
- $output['#attributes'] = array('enctype' => 'multipart/form-data');
- }
- break;
-
case 'load':
if (variable_get("upload_$node->type", 1) == 1) {
$output['files'] = upload_load($node);
@@ -401,20 +411,6 @@ function upload_delete($node) {
db_query("DELETE FROM {files} WHERE nid = %d", $node->nid);
}
-function upload_form($node) {
- drupal_add_js('misc/progress.js');
- drupal_add_js('misc/upload.js');
-
- $form['attachments'] = array(
- '#type' => 'fieldset', '#title' => t('File attachments'), '#collapsible' => TRUE, '#collapsed' => empty($node->files),
- '#description' => t('Changes made to the attachments are not permanent until you save this post. The first "listed" file will be included in RSS feeds.'),
- '#prefix' => '<div class="attachments">', '#suffix' => '</div>'
- );
- $form['attachments'] += _upload_form($node);
-
- return $form;
-}
-
function _upload_form($node) {
$header = array(t('Delete'), t('List'), t('Description'), t('Size'));
$rows = array();