diff -uN /www/drupal-4.6/modules/superteaser/superteaser.install ./superteaser.install --- /www/drupal-4.6/modules/superteaser/superteaser.install Wed Dec 31 18:00:00 1969 +++ ./superteaser.install Fri Jun 2 21:06:31 2006 @@ -0,0 +1,16 @@ + $value) { + variable_set($name, $value); + } + + variable_del('superteaser_algorithms'); +} + +?> \ No newline at end of file diff -uN /www/drupal-4.6/modules/superteaser/superteaser.module ./superteaser.module --- /www/drupal-4.6/modules/superteaser/superteaser.module Mon Nov 28 07:39:51 2005 +++ ./superteaser.module Fri Jun 2 20:13:52 2006 @@ -1,5 +1,5 @@ 180, - '_superteaser_truncate_at_paragraph' => 100, - '_superteaser_truncate_at_sentence' => 80, - '_superteaser_truncate_at_space' => 10, - '_superteaser_truncate_exact' => -50, + return array( + '_superteaser_truncate_at_break' => variable_get('_superteaser_truncate_at_break', 180), + '_superteaser_truncate_at_paragraph' => variable_get('_superteaser_truncate_at_paragraph', 100), + '_superteaser_truncate_at_sentence' => variable_get('_superteaser_truncate_at_sentence', 80), + '_superteaser_truncate_at_space' => variable_get('_superteaser_truncate_at_space', 10), + '_superteaser_truncate_exact' => variable_get('_superteaser_truncate_exact', -50), ); - return variable_get('superteaser_algorithms', $default); } /** @@ -381,12 +380,6 @@ * Implementation of hook_settings. */ function superteaser_settings() { - if ($_POST['op'] == 'Save configuration') { - variable_set('superteaser_algorithms', $_POST['edit']['superteaser_algorithms']); - variable_set('superteaser_fuzzy', $_POST['edit']['superteaser_fuzzy']); - variable_set('superteaser_break', $_POST['edit']['superteaser_break']); - drupal_set_message(t('The configuration has been saved.')); - } $labels = array( '_superteaser_truncate_at_break' => t('Explicit break, if found'), '_superteaser_truncate_at_paragraph' => t('End of paragraph'), @@ -394,15 +387,34 @@ '_superteaser_truncate_at_space' => t('Between words'), '_superteaser_truncate_exact' => t('Mid-word'), ); - $form = ''; $algorithms = _superteaser_get_algorithms(); arsort($algorithms); + $form = array(); + $form['superteaser_algorithms'] = array( + '#type' => 'fieldset', + '#title' => t('Algorithms'), + '#collapsible' => TRUE, + '#collapsed' => FALSE + ); + foreach ($algorithms as $name => $value) { - $form .= form_textfield($labels[$name], "superteaser_algorithms][$name", $value, 6, 5); + $form['superteaser_algorithms'][$name] = array( + '#type' => 'textfield', + '#title' => $labels[$name], + '#default_value' => $value, + '#size' => 6, + '#maxlength' => 5 + ); } $break = _superteaser_get_break(); - $form .= form_textfield(t('Explicit break string'), 'superteaser_break', $break, 12, 50); + $form['superteaser_break'] = array( + '#type' => 'textfield', + '#title' => t('Explicit break string'), + '#default_value' => $break, + '#size' => 12, + '#maxlength' => 50 + ); $fuzzy = _superteaser_get_fuzzy(); $choices = array( @@ -410,7 +422,12 @@ 'shorter' => t('Shorter than target length'), 'best' => t('Whichever is closest to target length'), ); - $form .= form_radios(t('Teaser length preference, if not exact'), 'superteaser_fuzzy', $fuzzy, $choices); + $form['superteaser_fuzzy'] = array( + '#type' => 'radios', + '#title' => t('Teaser length preference, if not exact'), + '#default_value' => $fuzzy, + '#options' => $choices + ); return $form; } @@ -418,7 +435,7 @@ /** * Implementation of hook_nodeapi. */ -function superteaser_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { +function superteaser_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) { switch ($op) { case 'validate': if (!isset($node->teaser)) {