--- node.module.bkp 2006-06-29 13:31:06.000000000 +0200 +++ node.module 2006-06-29 14:47:43.000000000 +0200 @@ -776,9 +776,29 @@ '#options' => array(0 => t('Unlimited'), 200 => t('200 characters'), 400 => t('400 characters'), 600 => t('600 characters'), 800 => t('800 characters'), 1000 => t('1000 characters'), 1200 => t('1200 characters'), 1400 => t('1400 characters'), 1600 => t('1600 characters'), 1800 => t('1800 characters'), 2000 => t('2000 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.") + '#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, unless specified otherwise below.") ); + $form['update_all_teasers'] = array( + '#type' => 'checkbox', '#title' => t('Update trimmed posts'), '#default_value' => variable_get('update_all_teasers', 0), '#description' => 'Check this in order to trim all your posts (usefull when you modified the length).' + ); + + if (variable_get('update_all_teasers', 0)) { + $sql = 'SELECT nid FROM {node}'; + $result = db_query($sql); + + while ($node_id = db_fetch_object($result)) { + $node = node_load($node_id->nid); + if (!isset($node->teaser)) + continue; + $node->teaser = isset($node->body) ? node_teaser($node->body, isset($node->format) ? $node->format : NULL) : ''; + $node_query = 'UPDATE {node_revisions} SET `teaser` = \'%s\' WHERE nid=\'%d\''; + + $query_values = array($node->teaser, $node->nid); + db_query($node_query, $query_values); + } + } + $form['node_preview'] = array( '#type' => 'radios', '#title' => t('Preview post'), '#default_value' => variable_get('node_preview', 0), '#options' => array(t('Optional'), t('Required')), '#description' => t('Must users preview posts before submitting?')