=\'0\' '
+ . '&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
+ . 'newVal += origVal.charAt(i); } this.value=newVal;" />'
+ , $this->createWidget_String());
+ else
+ return $this->createWidget_String();
}
function createWidget_Boolean() {
/* Do the whole current value thing. */
if ($this->value != SMPREF_NO) {
- $yes_chk = ' CHECKED';
+ $yes_chk = ' checked="checked"';
$no_chk = '';
} else {
$yes_chk = '';
- $no_chk = ' CHECKED';
+ $no_chk = ' checked="checked"';
}
/* Build the yes choice. */
- $yes_option = ' "
- . _("Yes");
+ $yes_option = 'name . '" value="' . SMPREF_YES . '"'
+ . $yes_chk . ' ' . $this->script . ' /> '
+ . '';
/* Build the no choice. */
- $no_option = ' "
- . _("No");
+ $no_option = 'name . '" value="' . SMPREF_NO . '"'
+ . $no_chk . ' ' . $this->script . ' /> '
+ . '';
/* Build and return the combined "boolean widget". */
$result = "$yes_option $no_option";
@@ -228,8 +365,9 @@ class SquirrelOption {
}
function createWidget_Hidden() {
- $result = '';
+ $result = 'script . ' />';
return ($result);
}
@@ -238,12 +376,45 @@ class SquirrelOption {
return ($result);
}
- function hasChanged() {
- return ($this->changed);
+ function save() {
+ $function = $this->save_function;
+ $function($this);
+ }
+
+ function changed() {
+ return ($this->value != $this->new_value);
}
}
-function createOptionGroups($optgrps, $optvals) {
+function save_option($option) {
+ if ( !sqgetGlobalVar('username', $username, SQ_SESSION ) ) {
+ /* Can't save the pref if we don't have the username */
+ return;
+ }
+ global $data_dir;
+ setPref($data_dir, $username, $option->name, $option->new_value);
+}
+
+function save_option_noop($option) {
+ /* Do nothing here... */
+}
+
+function create_optpage_element($optpage) {
+ return create_hidden_element('optpage', $optpage);
+}
+
+function create_optmode_element($optmode) {
+ return create_hidden_element('optmode', $optmode);
+}
+
+function create_hidden_element($name, $value) {
+ $result = '';
+ return ($result);
+}
+
+function create_option_groups($optgrps, $optvals) {
/* Build a simple array with which to start. */
$result = array();
@@ -263,7 +434,8 @@ function createOptionGroups($optgrps, $optvals) {
$optset['name'],
$optset['caption'],
$optset['type'],
- $optset['refresh'],
+ (isset($optset['refresh']) ? $optset['refresh'] : SMOPT_REFRESH_NONE),
+ (isset($optset['initial_value']) ? $optset['initial_value'] : ''),
$optset['posvals']
);
} else {
@@ -272,7 +444,8 @@ function createOptionGroups($optgrps, $optvals) {
$optset['name'],
$optset['caption'],
$optset['type'],
- $optset['refresh']
+ (isset($optset['refresh']) ? $optset['refresh'] : SMOPT_REFRESH_NONE),
+ (isset($optset['initial_value']) ? $optset['initial_value'] : '')
);
}
@@ -281,11 +454,31 @@ function createOptionGroups($optgrps, $optvals) {
$next_option->setSize($optset['size']);
}
+ /* If provided, set the trailing_text for this option. */
+ if (isset($optset['trailing_text'])) {
+ $next_option->setTrailingText($optset['trailing_text']);
+ }
+
/* If provided, set the comment for this option. */
if (isset($optset['comment'])) {
$next_option->setComment($optset['comment']);
}
+ /* If provided, set the save function for this option. */
+ if (isset($optset['save'])) {
+ $next_option->setSaveFunction($optset['save']);
+ }
+
+ /* If provided, set the script for this option. */
+ if (isset($optset['script'])) {
+ $next_option->setScript($optset['script']);
+ }
+
+ /* If provided, set the "post script" for this option. */
+ if (isset($optset['post_script'])) {
+ $next_option->setPostScript($optset['post_script']);
+ }
+
/* Add this option to the option array. */
$result[$grpkey]['options'][] = $next_option;
}
@@ -295,100 +488,42 @@ function createOptionGroups($optgrps, $optvals) {
return ($result);
}
-function printOptionGroups($option_groups) {
+function print_option_groups($option_groups) {
+ /* Print each option group. */
foreach ($option_groups as $next_optgrp) {
- echo ''
- . $next_optgrp['name'] . " |
\n";
+ /* If it is not blank, print the name for this option group. */
+ if ($next_optgrp['name'] != '') {
+ echo html_tag( 'tr', "\n".
+ html_tag( 'td',
+ '' . $next_optgrp['name'] . '' ,
+ 'center' ,'', 'valign="middle" colspan="2" nowrap' )
+ ) ."\n";
+ }
+
+ /* Print each option in this option group. */
foreach ($next_optgrp['options'] as $option) {
if ($option->type != SMOPT_TYPE_HIDDEN) {
- echo "\n";
- echo ' '
- . $option->caption . ": | \n";
- echo ' ' . $option->createHTMLWidget() . " | \n";
- echo "
\n";
+ echo html_tag( 'tr', "\n".
+ html_tag( 'td', $option->caption . ':', 'right' ,'', 'valign="middle"' ) .
+ html_tag( 'td', $option->createHTMLWidget(), 'left' )
+ ) ."\n";
} else {
echo $option->createHTMLWidget();
}
}
- echo " |
\n";
- }
-}
-
-function OptionSelect( $title, $name, $data, $default, $show = '', $store = '' ) {
- echo "$title: | " .
- " |
\n";
-}
-
-function OptionRadio( $title, $name, $data, $default, $show = '', $store = '', $sep = ' ' ) {
- echo "$title: | ";
- foreach( $data as $key => $opt ) {
- if ( $store == '' ) {
- $vl = $key;
- } else{
- $vl = $opt[$store];
- }
- if ( $show == '' ) {
- $nm = $opt;
- } else{
- $nm = $opt[$show];
- }
- if ( $nm <> '') {
- echo "$nm $sep\n";
- }
- }
- echo " |
\n";
-}
-
-function OptionText( $title, $name, $value, $size ) {
- echo "$title: | " .
- "" .
- " |
\n";
-}
-
-function OptionHidden( $name, $value ) {
- echo "\n";
-}
-
-function OptionCheck( $title, $name, $value, $comment ) {
- if ( $value )
- $chk = 'checked';
- echo "$title: | " .
- " $comment" .
- " |
\n";
-}
-
-function OptionTitle( $title ) {
- echo "$title |
\n";
}
function OptionSubmit( $name ) {
- echo ' | ' .
- ' |
';
+ echo html_tag( 'tr',
+ html_tag( 'td', ' ', 'right', '', 'colspan="2"' )
+ ) . "\n";
}
-?>
+// vim: et ts=4
+?>
\ No newline at end of file