Index: modules/node/node.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.pages.inc,v retrieving revision 1.57 diff -u -r1.57 node.pages.inc --- modules/node/node.pages.inc 14 Mar 2009 23:01:36 -0000 1.57 +++ modules/node/node.pages.inc 27 Mar 2009 18:27:14 -0000 @@ -238,12 +238,13 @@ $form['buttons']['#weight'] = 100; $form['buttons']['submit'] = array( '#type' => 'submit', - '#access' => !variable_get('node_preview', 0) || (!form_get_errors() && isset($form_state['node_preview'])), + '#access' => variable_get('node_preview_' . $node->type, 1) != DRUPAL_REQUIRED || (!form_get_errors() && isset($form_state['node_preview'])), '#value' => t('Save'), '#weight' => 5, '#submit' => array('node_form_submit'), ); $form['buttons']['preview'] = array( + '#access' => variable_get('node_preview_' . $node->type, 1) != DRUPAL_DISABLED, '#type' => 'submit', '#value' => t('Preview'), '#weight' => 10, @@ -372,7 +373,7 @@ // Extract a teaser, if it hasn't been set (e.g. by a module-provided // 'teaser' form item). if (!isset($node->teaser)) { - $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format); + $node->teaser = empty($node->body) ? '' : node_teaser($node->body, $node->format, variable_get('teaser_length_' . $type, 600)); // Chop off the teaser from the body if needed. if (!$node->teaser_include && $node->teaser == substr($node->body, 0, strlen($node->teaser))) { $node->body = substr($node->body, strlen($node->teaser)); Index: modules/node/content_types.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.inc,v retrieving revision 1.64 diff -u -r1.64 content_types.inc --- modules/node/content_types.inc 26 Jan 2009 14:08:43 -0000 1.64 +++ modules/node/content_types.inc 27 Mar 2009 18:27:13 -0000 @@ -136,6 +136,17 @@ '#options' => drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), '#description' => t('The minimum number of words for the body field to be considered valid for this content type. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.') ); + $form['submission']['node_preview'] = array( + '#type' => 'radios', + '#title' => t('Preview post'), + '#default_value' => variable_get('node_preview_' . $type->type, DRUPAL_OPTIONAL), + '#options' => array( + DRUPAL_DISABLED => t('Disabled'), + DRUPAL_OPTIONAL => t('Optional'), + DRUPAL_REQUIRED => t('Required'), + ), + '#description' => t('Should users preview posts before submitting?'), + ); $form['submission']['help'] = array( '#type' => 'textarea', '#title' => t('Explanation or submission guidelines'), @@ -171,6 +182,13 @@ '#default_value' => variable_get('node_submitted_'. $type->type, TRUE), '#description' => t('Enable the submitted by Username on date text.'), ); + $form['display']['teaser_length'] = array( + '#type' => 'select', + '#title' => t('Length of trimmed posts'), + '#default_value' => 600, + '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'), + '#description' => t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited' . Note that this setting will only affect new or updated content and will not affect existing teasers.") + ); $form['old_type'] = array( '#type' => 'value', '#value' => $type->type, @@ -223,6 +241,13 @@ } /** + * Helper function for teaser length choices. + */ +function _node_characters($length) { + return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters'); +} + +/** * Implementation of hook_form_validate(). */ function node_type_form_validate($form, &$form_state) { @@ -407,6 +432,8 @@ function node_type_delete_confirm_submit($form, &$form_state) { node_type_delete($form_state['values']['type']); + variable_del('teaser_length_' . $form_state['values']['type']); + variable_del('node_preview_' . $form_state['values']['type']); $t_args = array('%name' => $form_state['values']['name']); drupal_set_message(t('The content type %name has been deleted.', $t_args)); watchdog('menu', 'Deleted content type %name.', $t_args, WATCHDOG_NOTICE); Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1031 diff -u -r1.1031 node.module --- modules/node/node.module 14 Mar 2009 23:01:36 -0000 1.1031 +++ modules/node/node.module 27 Mar 2009 18:27:14 -0000 @@ -1019,7 +1019,7 @@ if (!isset($node->teaser)) { if (isset($node->body)) { $node->format = (!empty($node->body_format) ? $node->body_format : FILTER_FORMAT_DEFAULT); - $node->teaser = node_teaser($node->body, isset($node->format) ? $node->format : NULL); + $node->teaser = node_teaser($node->body, isset($node->format) ? $node->format : NULL, variable_get('teaser_length_' . $node->type, 600)); // Chop off the teaser from the body if needed. The teaser_include // property might not be set (eg. in Blog API postings), so only act on // it, if it was set with a given value. @@ -1692,15 +1692,9 @@ 'weight' => -10, ); - $items['admin/content/node-settings'] = array( - 'title' => 'Post settings', - 'description' => 'Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('node_configure'), - 'access arguments' => array('administer nodes'), - ); - $items['admin/content/node-settings/rebuild'] = array( + $items['admin/reports/status/rebuild'] = array( 'title' => 'Rebuild permissions', + 'page callback' => 'drupal_get_form', 'page arguments' => array('node_configure_rebuild_confirm'), // Any user than can potentially trigger a node_access_needs_rebuild(TRUE) // has to be allowed access to the 'node access rebuild' confirm form. @@ -1946,7 +1940,7 @@ $item->body = $content; unset($item->teaser); } - + // Allow modules to modify the fully-built node. node_invoke_node($item, 'alter', $teaser, FALSE); } @@ -3168,3 +3162,26 @@ function theme_node_links($element) { return theme('links', $element['#value'], array('class' => 'links inline')); } + +function node_requirements($phase) { + $requirements = array(); + // Ensure translations don't break at install time + $t = get_t(); + // Only show rebuild button if there are either 0, or 2 or more, rows + // in the {node_access} table, or if there are modules that + // implement hook_node_grants(). + $grant_count = db_result(db_query('SELECT COUNT(*) FROM {node_access}')); + if ($grant_count != 1 || count(module_implements('node_grants')) > 0) { + $value = format_plural($grant_count, 'One permission in use', '@count permissions in use', array('@count' => $grant_count)); + } else { + $value = $t('Disabled'); + } + $description = $t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings. Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.'); + + $requirements['node_access'] = array( + 'title' => $t('Node Access Permissions'), + 'value' => $value, + 'description' => $description . ' ' . l('Rebuild Permissions', 'admin/reports/status/rebuild'), + ); + return $requirements; +} Index: modules/node/node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.42 diff -u -r1.42 node.admin.inc --- modules/node/node.admin.inc 17 Mar 2009 03:34:32 -0000 1.42 +++ modules/node/node.admin.inc 27 Mar 2009 18:27:14 -0000 @@ -7,60 +7,6 @@ */ /** - * Menu callback; presents general node configuration options. - */ -function node_configure() { - // Only show rebuild button if there are either 0, or 2 or more, rows - // in the {node_access} table, or if there are modules that - // implement hook_node_grants(). - if (db_result(db_query('SELECT COUNT(*) FROM {node_access}')) != 1 || count(module_implements('node_grants')) > 0) { - $status = '
' . t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') . '
'; - $status .= '' . t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') . '
'; - - $form['access'] = array( - '#type' => 'fieldset', - '#title' => t('Node access status'), - ); - $form['access']['status'] = array('#markup' => $status); - $form['access']['rebuild'] = array( - '#type' => 'submit', - '#value' => t('Rebuild permissions'), - '#submit' => array('node_configure_access_submit'), - ); - } - - $form['default_nodes_main'] = array( - '#type' => 'select', '#title' => t('Number of posts on main page'), - '#default_value' => 10, - '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), - '#description' => t('The default maximum number of posts to display per page on overview pages such as the main page.') - ); - $form['teaser_length'] = array( - '#type' => 'select', '#title' => t('Length of trimmed posts'), - '#default_value' => 600, - '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'), - '#description' => t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited' . Note that this setting will only affect new or updated content and will not affect existing teasers.") - ); - - $form['node_preview'] = array( - '#type' => 'radios', - '#title' => t('Preview post'), - '#default_value' => 0, - '#options' => array(t('Optional'), t('Required')), - '#description' => t('Must users preview posts before submitting?'), - ); - - return system_settings_form($form, TRUE); -} - -/** - * Helper function for teaser length choices. - */ -function _node_characters($length) { - return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters'); -} - -/** * Form button submit callback. */ function node_configure_access_submit($form, &$form_state) { @@ -80,7 +26,7 @@ */ function node_configure_rebuild_confirm_submit($form, &$form_state) { node_access_rebuild(TRUE); - $form_state['redirect'] = 'admin/content/node-settings'; + $form_state['redirect'] = 'admin/reports/status'; } /** Index: modules/node/node.install =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.install,v retrieving revision 1.14 diff -u -r1.14 node.install --- modules/node/node.install 17 Mar 2009 12:41:54 -0000 1.14 +++ modules/node/node.install 27 Mar 2009 18:27:14 -0000 @@ -415,6 +415,26 @@ db_add_index($ret, 'node', 'node_frontpage', array('promote', 'status', 'sticky', 'created')); return $ret; } +/** + * Extend the existing default preview and teaser settings to all node types. + */ +function node_update_7003() { + //Get original settings and all types. + $original_length = variable_get('teaser_length', 600); + $original_preview = variable_get('node_preview', 0); + + // Map old preview setting to new values order. + $original_preview ? $original_preview = 2 : $original_preview = 1; + $type_list = node_get_types('types'); + + // Apply original settings to all types. + foreach ($type_list as $type) { + variable_set('teaser_length_' . $type, $original_length); + variable_set('node_preview_' . $type, $original_preview); + } + // Delete old variable but leave 'teaser_length' for aggregator module upgrade. + variable_del('node_preview'); +} /** * End of 6.x to 7.x updates Index: modules/system/system.module =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.module,v retrieving revision 1.673 diff -u -r1.673 system.module --- modules/system/system.module 17 Mar 2009 15:26:29 -0000 1.673 +++ modules/system/system.module 27 Mar 2009 18:27:15 -0000 @@ -57,6 +57,21 @@ define('DRUPAL_USER_TIMEZONE_SELECT', 2); /** + * Disabled option on forms and settings + */ +define('DRUPAL_DISABLED', 0); + +/** + * Optional option on forms and settings + */ +define('DRUPAL_OPTIONAL', 1); + +/** + * Required option on forms and settings + */ +define('DRUPAL_REQUIRED', 2); + +/** * Implementation of hook_help(). */ function system_help($path, $arg) { Index: modules/system/system.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.admin.inc,v retrieving revision 1.131 diff -u -r1.131 system.admin.inc --- modules/system/system.admin.inc 17 Mar 2009 15:26:29 -0000 1.131 +++ modules/system/system.admin.inc 27 Mar 2009 18:27:15 -0000 @@ -1224,6 +1224,12 @@ '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), '#required' => TRUE, ); + $form['default_nodes_main'] = array( + '#type' => 'select', '#title' => t('Number of posts on front page'), + '#default_value' => 10, + '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), + '#description' => t('The maximum number of posts per page to display on overview pages like the front page above.') + ); $form['site_403'] = array( '#type' => 'textfield', '#title' => t('Default 403 (access denied) page'), Index: modules/aggregator/aggregator.install =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.install,v retrieving revision 1.20 diff -u -r1.20 aggregator.install --- modules/aggregator/aggregator.install 22 Dec 2008 19:38:31 -0000 1.20 +++ modules/aggregator/aggregator.install 27 Mar 2009 18:27:13 -0000 @@ -23,6 +23,7 @@ variable_del('aggregator_fetcher'); variable_del('aggregator_parser'); variable_del('aggregator_processors'); + variable_del('aggregator_teaser_length'); } /** @@ -266,3 +267,9 @@ db_add_field($ret, 'aggregator_feed', 'hash', array('type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '')); return $ret; } +/** + * Add aggregator teaser length to settings from old global default teaser length + */ +function aggregator_update_7001() { + variable_set('aggregator_teaser_length', variable_get('teaser_length')); +} Index: modules/aggregator/aggregator.pages.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.pages.inc,v retrieving revision 1.24 diff -u -r1.24 aggregator.pages.inc --- modules/aggregator/aggregator.pages.inc 3 Feb 2009 18:55:29 -0000 1.24 +++ modules/aggregator/aggregator.pages.inc 27 Mar 2009 18:27:13 -0000 @@ -378,7 +378,7 @@ foreach ($feeds as $feed) { switch ($feed_length) { case 'teaser': - $teaser = node_teaser($feed->description); + $teaser = node_teaser($feed->description, NULL, variable_get('aggregator_teaser_length', 600)); if ($teaser != $feed->description) { $teaser .= '\n"; } Index: modules/aggregator/aggregator.processor.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/aggregator/aggregator.processor.inc,v retrieving revision 1.3 diff -u -r1.3 aggregator.processor.inc --- modules/aggregator/aggregator.processor.inc 26 Jan 2009 14:08:42 -0000 1.3 +++ modules/aggregator/aggregator.processor.inc 27 Mar 2009 18:27:13 -0000 @@ -111,6 +111,15 @@ 'select' => t('multiple selector')), '#description' => t('The type of category selection widget displayed on categorization pages. (For a small number of categories, checkboxes are easier to use, while a multiple selector works well with large numbers of categories.)'), ); + drupal_function_exists('_node_characters'); + $form['modules']['aggregator']['aggregator_teaser_length'] = array( + '#type' => 'select', + '#title' => t('Length of trimmed description'), + '#default_value' => 600, + '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'), + '#description' => t("The maximum number of characters used in the trimmed version of a description. Drupal will use this setting to determine at which offset long descriptions should be trimmed. Note that this setting will only affect new or updated content and will not affect existing teasers.") + ); + } }