diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-10-11 19:44:35 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-10-11 19:44:35 +0000 |
commit | 75fe6b6c0ae85d2b53cb803d5b028b050fd6d454 (patch) | |
tree | 70ea02551300ed5a696b4d289cfc4722924d58ca /modules/forum.module | |
parent | ecf5ed57d66a182ae0e269942169e0a6cf3a3912 (diff) | |
download | brdo-75fe6b6c0ae85d2b53cb803d5b028b050fd6d454.tar.gz brdo-75fe6b6c0ae85d2b53cb803d5b028b050fd6d454.tar.bz2 |
- Patch #33752 by chx, adrian, et al: another batch of form API changes/fixes.
Diffstat (limited to 'modules/forum.module')
-rw-r--r-- | modules/forum.module | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/modules/forum.module b/modules/forum.module index ed53943ed..07232f441 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -136,7 +136,7 @@ function forum_admin() { /** * Implementation of hook_taxonomy(). */ -function forum_taxonomy($op, $type, $object) { +function forum_taxonomy($op, $type, $object = NULL) { if ($op == 'delete' && $type == 'term' && $object->vid == _forum_get_vid()) { $results = db_query('SELECT f.nid FROM {forum} f WHERE f.tid = %d', $object->tid); while ($node = db_fetch_object($results)) { @@ -158,7 +158,7 @@ function forum_taxonomy($op, $type, $object) { function _forum_confirm_delete($tid) { $term = taxonomy_get_term($tid); - $form['tid'] = array(type => 'hidden', value => $tid); + $form['tid'] = array('#type' => 'hidden', '#value' => $tid); return confirm_form('forum_confirm_delete', $form, t('Are you sure you want to delete the forum %name?', array('%name' => theme('placeholder', $term->name))), 'admin/forums', t('Deleting a forum or container will delete all sub-forums as well. This action cannot be undone.'), t('Delete'), t('Cancel')); @@ -170,17 +170,17 @@ function _forum_confirm_delete($tid) { * @param $edit Associative array containing a container term to be added or edited. */ function forum_form_container($edit = array()) { - $form['name'] = array(title => t('Container name'), type => 'textfield', default_value => $edit['name'], size => 60, maxlength => 64, description => t('The container name is used to identify related forums.'), required => TRUE); - $form['description'] = array(type => 'textarea', title => t('Description'), default_value => $edit['description'], cols => 60, rows => 5, description => ('The container description can give users more information about the forums it contains.')); - $form['parent'][tree] = TRUE; + $form['name'] = array('#title' => t('Container name'), '#type' => 'textfield', '#default_value' => $edit['name'], '#size' => 60, '#maxlength' => 64, '#description' => t('The container name is used to identify related forums.'), '#required' => TRUE); + $form['description'] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => $edit['description'], '#cols' => 60, '#rows' => 5, '#description' => ('The container description can give users more information about the forums it contains.')); + $form['parent']['#tree'] = TRUE; $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'container'); - $form['weight'] = array(type => 'weight', title => t('Weight'), default_value => $edit['weight'], delta => 10, description => t('When listing containers, those with with light (small) weights get listed before containers with heavier (larger) weights. Containers with equal weights are sorted alphabetically.')); + $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), '#default_value' => $edit['weight'], '#delta' => 10, '#description' => t('When listing containers, those with with light (small) weights get listed before containers with heavier (larger) weights. Containers with equal weights are sorted alphabetically.')); - $form['vid'] = array(type => 'hidden', value => _forum_get_vid()); - $form['submit'] = array(type => 'submit', value => t('Submit')); + $form['vid'] = array('#type' => 'hidden', '#value' => _forum_get_vid()); + $form['submit'] = array('#type' => 'submit', '#value' => t('Submit')); if ($edit['tid']) { - $form['delete'] = array(type => 'submit', value => t('Delete')); - $form['tid'] = array(type => 'hidden', value => $edit['tid']); + $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); + $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']); } return drupal_get_form('forum_form_container', $form); @@ -192,17 +192,17 @@ function forum_form_container($edit = array()) { * @param $edit Associative array containing a forum term to be added or edited. */ function forum_form_forum($edit = array()) { - $form['name'] = array(type => 'textfield', title => t('Forum name'), default_value => $edit['name'], size => 60, maxlength => 64, description => t('The forum name is used to identify related discussions.'), required => TRUE); - $form['description'] = array(type => 'textarea', title => t('Description'), default_value => $edit['description'], cols => 60, rows => 5, description => ('The forum description can give users more information about the discussion topics it contains.')); - $form['parent'][tree] = TRUE; + $form['name'] = array('#type' => 'textfield', '#title' => t('Forum name'), '#default_value' => $edit['name'], '#size' => 60, '#maxlength' => 64, '#description' => t('The forum name is used to identify related discussions.'), '#required' => TRUE); + $form['description'] = array('#type' => 'textarea', '#title' => t('Description'), '#default_value' => $edit['description'], '#cols' => 60, '#rows' => 5, '#description' => ('The forum description can give users more information about the discussion topics it contains.')); + $form['parent']['#tree'] = TRUE; $form['parent'][0] = _forum_parent_select($edit['tid'], t('Parent'), 'forum'); - $form['weight'] = array(type => 'weight', title => t('Weight'), default_value => $edit['weight'], delta => 10, description => t('When listing forums, those with with light (small) weights get listed before containers with heavier (larger) weights. Forums with equal weights are sorted alphabetically.')); + $form['weight'] = array('#type' => 'weight', '#title' => t('Weight'), '#default_value' => $edit['weight'], '#delta' => 10, '#description' => t('When listing forums, those with with light (small) weights get listed before containers with heavier (larger) weights. Forums with equal weights are sorted alphabetically.')); - $form['vid'] = array(type => 'hidden', value => _forum_get_vid()); - $form['submit' ] = array(type => 'submit', value => t('Submit')); + $form['vid'] = array('#type' => 'hidden', '#value' => _forum_get_vid()); + $form['submit' ] = array('#type' => 'submit', '#value' => t('Submit')); if ($edit['tid']) { - $form['delete'] = array(type => 'submit', value => t('Delete')); - $form['tid'] = array(type => 'hidden', value => $edit['tid']); + $form['delete'] = array('#type' => 'submit', '#value' => t('Delete')); + $form['tid'] = array('#type' => 'hidden', '#value' => $edit['tid']); } return drupal_get_form('forum_form_forum', $form); @@ -250,7 +250,7 @@ function _forum_parent_select($tid, $title, $child_type) { $description = t('You may place your forum inside a parent container or forum, or at the top (root) level of your forum.'); } - return array(type => 'select', title => $title, default_value => $parent, options => $options, description => $description, required => TRUE); + return array('#type' => 'select', '#title' => $title, '#default_value' => $parent, '#options' => $options, '#description' => $description, '#required' => TRUE); } /** @@ -299,7 +299,7 @@ function _forum_get_vid() { // Check to see if a forum vocabulary exists $vid = db_result(db_query("SELECT vid FROM {vocabulary} WHERE module = '%s'", 'forum')); if (!$vid) { - $edit = array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum')); + $edit = array('name' => 'Forums', 'multiple' => 0, 'required' => 1, 'hierarchy' => 1, 'relations' => 0, 'module' => 'forum', 'nodes' => array('forum' => 1)); taxonomy_save_vocabulary($edit); $vid = $edit['vid']; } @@ -315,13 +315,13 @@ function _forum_get_vid() { function forum_admin_configure() { $form = array(); - $form['forum_icon_path'] = array(type => 'textfield', title => t('Forum icon path'), default_value => variable_get('forum_icon_path', ''), size => 30, maxlength => 255, description => t('The path to the forum icons. Leave blank to disable icons. Don\'t add a trailing slash. Default icons are available in the "misc" directory. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16. ')); + $form['forum_icon_path'] = array('#type' => 'textfield', '#title' => t('Forum icon path'), '#default_value' => variable_get('forum_icon_path', ''), '#size' => 30, '#maxlength' => 255, '#description' => t('The path to the forum icons. Leave blank to disable icons. Don\'t add a trailing slash. Default icons are available in the "misc" directory. You may use images of whatever size you wish, but it is recommended to use 15x15 or 16x16. ')); $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 10000)); - $form['forum_hot_topic'] = array(type => 'select', title => t('Hot topic threshold'), default_value => variable_get('forum_hot_topic', 15), options => $number, description => t('The number of posts a topic must have to be considered hot.')); + $form['forum_hot_topic'] = array('#type' => 'select', '#title' => t('Hot topic threshold'), '#default_value' => variable_get('forum_hot_topic', 15), '#options' => $number, '#description' => t('The number of posts a topic must have to be considered hot.')); $number = drupal_map_assoc(array(10, 25, 50, 75, 100)); - $form['forum_per_page'] = array(type => 'select', title => t('Topics per page'), default_value => variable_get('forum_per_page', 25), options => $number, description => t('The default number of topics displayed per page; links to browse older messages are automatically being displayed.')); + $form['forum_per_page'] = array('#type' => 'select', '#title' => t('Topics per page'), '#default_value' => variable_get('forum_per_page', 25), '#options' => $number, '#description' => t('The default number of topics displayed per page; links to browse older messages are automatically being displayed.')); $forder = array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4=> t('Posts - least active first')); - $form['forum_order'] = array(type => 'radios', title => t('Default order'), default_value => variable_get('forum_order', '1'), options => $forder, description => t('The default display order for topics.')); + $form['forum_order'] = array('#type' => 'radios', '#title' => t('Default order'), '#default_value' => variable_get('forum_order', '1'), '#options' => $forder, '#description' => t('The default display order for topics.')); return system_settings_form('forum_admin_configure', $form); } @@ -349,7 +349,7 @@ function forum_block($op = 'list', $delta = 0, $edit = array()) { return $blocks; case 'configure': - $form['forum_block_num_'. $delta] = array(type => 'select', title => t('Number of topics'), default_value => variable_get('forum_block_num_'. $delta, '5'), options => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20))); + $form['forum_block_num_'. $delta] = array('#type' => 'select', '#title' => t('Number of topics'), '#default_value' => variable_get('forum_block_num_'. $delta, '5'), '#options' => drupal_map_assoc(array(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20))); return $form; case 'save': @@ -555,7 +555,7 @@ function forum_update($node) { * Implementation of hook_form(). */ function forum_form(&$node) { - $form['title'] = array(type => 'textfield', title => t('Subject'), default_value => $node->title, size => 60, maxlength => 128, required => TRUE); + $form['title'] = array('#type' => 'textfield', '#title' => t('Subject'), '#default_value' => $node->title, '#size' => 60, '#maxlength' => 128, '#required' => TRUE); if (!$node->nid) { // new topic @@ -565,17 +565,13 @@ function forum_form(&$node) { $node->taxonomy = array($node->tid); } - if (function_exists('taxonomy_node_form')) { - $form['taxonomy'] = taxonomy_node_form('forum', $node); - } - if ($node->nid) { // if editing, give option to leave shadows $shadow = (count(taxonomy_node_get_terms($node->nid)) > 1); - $form['shadow'] = array(type => 'checkbox', 'title' => t('Leave shadow copy'), default_value => $shadow, description => t('If you move this topic, you can leave a link in the old forum to the new forum.')); + $form['shadow'] = array('#type' => 'checkbox', 'title' => t('Leave shadow copy'), '#default_value' => $shadow, '#description' => t('If you move this topic, you can leave a link in the old forum to the new forum.')); } - $form['body'] = array(type => 'textarea', title => t('Body'), default_value => $node->body, required => TRUE + $form['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#required' => TRUE ); $form = array_merge($form, filter_form($node->format)); |