Source for file options.php
Documentation is available at options.php
* Functions needed to display the options pages.
* @copyright © 1999-2006 The SquirrelMail Project Team
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: options.php,v 1.34.2.15 2006/04/14 22:27:08 jervfors Exp $
/**********************************************/
/* Define constants used in the options code. */
/**********************************************/
/* Define constants for the various option types. */
define('SMOPT_TYPE_STRING', 0);
define('SMOPT_TYPE_STRLIST', 1);
define('SMOPT_TYPE_TEXTAREA', 2);
define('SMOPT_TYPE_INTEGER', 3);
define('SMOPT_TYPE_FLOAT', 4);
define('SMOPT_TYPE_BOOLEAN', 5);
define('SMOPT_TYPE_HIDDEN', 6);
define('SMOPT_TYPE_COMMENT', 7);
define('SMOPT_TYPE_FLDRLIST', 8);
/* Define constants for the options refresh levels. */
define('SMOPT_REFRESH_NONE', 0);
define('SMOPT_REFRESH_FOLDERLIST', 1);
define('SMOPT_REFRESH_ALL', 2);
/* Define constants for the options size. */
define('SMOPT_SIZE_SMALL', 1);
define('SMOPT_SIZE_MEDIUM', 2);
define('SMOPT_SIZE_LARGE', 3);
define('SMOPT_SIZE_NORMAL', 5);
define('SMOPT_SAVE_DEFAULT', 'save_option');
define('SMOPT_SAVE_NOOP', 'save_option_noop');
* SquirrelOption: An option for Squirrelmail.
* This class is a work in progress. When complete, it will handle
* presentation and saving of Squirrelmail user options in a simple,
* streamline manner. Stay tuned for more stuff.
* Also, I'd like to ask that people leave this alone (mostly :) until
* I get it a little further along. That should only be a day or two or
* three. I will remove this message when it is ready for primetime usage.
/* The name of the Save Function for this option. */
/* The various 'values' for this options. */
($name, $caption, $type, $refresh_level, $initial_value =
'', $possible_values =
'', $htmlencoded =
false) {
/* Set the basic stuff. */
/* Check for a current value. */
if (isset
($GLOBALS[$name])) {
$this->value =
$GLOBALS[$name];
} else if (!empty($initial_value)) {
$this->value =
$initial_value;
/* Check for a new value. */
/* Set the default save function. */
/* Set the value for this option. */
/* Set the new value for this option. */
/* Set the size for this option. */
/* Set the comment for this option. */
/* Set the script for this option. */
/* Set the "post script" for this option. */
/* Set the save function for this option. */
global $javascript_on, $color;
// Use new value if available
$tempValue =
$this->value;
/* Get the widget for this option type. */
$result =
'<font color="' .
$color[2] .
'">'
/* Add the "post script" for this option. */
// put correct value back if need be
$this->value =
$tempValue;
/* Now, return the created widget. */
$result =
"<input type=\"text\" name=\"new_$this->name\" value=\"" .
"\" size=\"$width\" $this->script />\n";
/* Begin the select tag. */
$result =
"<select name=\"new_$this->name\" $this->script>\n";
/* Add each possible value to the select list. */
/* Start the next new option string. */
$new_option =
'<option value="' .
/* If this value is the current value, select it. */
if ($real_value ==
$this->value) {
$new_option .=
' selected="selected"';
/* Add the display value to our option string. */
/* And add the new option string to our select tag. */
/* Close the select tag and return our happy result. */
$result .=
"</select>\n";
/* Begin the select tag. */
$result =
"<select name=\"new_$this->name\" $this->script>\n";
/* Add each possible value to the select list. */
/* For folder list, we passed in the array of boxes.. */
/* Start the next new option string. */
/* If this value is the current value, select it. */
if ($real_value ==
$this->value) {
$new_option .=
' selected="selected"';
/* Add the display value to our option string. */
/* And add the new option string to our select tag. */
/* Close the select tag and return our happy result. */
$result .=
"</select>\n";
default:
$rows =
5; $cols =
50;
$result =
"<textarea name=\"new_$this->name\" rows=\"$rows\" "
.
"cols=\"$cols\" $this->script>"
// add onChange javascript handler to a regular string widget
// which will strip out all non-numeric chars
return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
.
'for (i=0;i<origVal.length;i++) { if (origVal.charAt(i)>=\'0\' '
.
'&& origVal.charAt(i)<=\'9\') newVal += origVal.charAt(i); } '
// add onChange javascript handler to a regular string widget
// which will strip out all non-numeric (period also OK) chars
return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
.
'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
.
'&& origVal.charAt(i)<=\'9\') || origVal.charAt(i)==\'.\') '
.
'newVal += origVal.charAt(i); } this.value=newVal;" />'
/* Do the whole current value thing. */
$yes_chk =
' checked="checked"';
$no_chk =
' checked="checked"';
/* Build the yes choice. */
$yes_option =
'<input type="radio" name="new_' .
$this->name
/* Build the no choice. */
$no_option =
'<input type="radio" name="new_' .
$this->name
/* Build and return the combined "boolean widget". */
$result =
"$yes_option $no_option";
$result =
'<input type="hidden" name="new_' .
$this->name
.
'" ' .
$this->script .
' />';
/* Can't save the pref if we don't have the username */
$result =
'<input type="hidden" '
.
'name="' .
$name .
'" '
/* Build a simple array with which to start. */
/* Create option group for each option group name. */
foreach ($optgrps as $grpkey =>
$grpname) {
$result[$grpkey] =
array();
$result[$grpkey]['name'] =
$grpname;
$result[$grpkey]['options'] =
array();
/* Create a new SquirrelOption for each set of option values. */
foreach ($optvals as $grpkey =>
$grpopts) {
foreach ($grpopts as $optset) {
/* Create a new option with all values given. */
(isset
($optset['initial_value']) ?
$optset['initial_value'] :
''),
(isset
($optset['posvals']) ?
$optset['posvals'] :
''),
(isset
($optset['htmlencoded']) ?
$optset['htmlencoded'] :
false)
/* If provided, set the size for this option. */
if (isset
($optset['size'])) {
$next_option->setSize($optset['size']);
/* If provided, set the comment for this option. */
if (isset
($optset['comment'])) {
/* If provided, set the save function for this option. */
if (isset
($optset['save'])) {
/* If provided, set the script for this option. */
if (isset
($optset['script'])) {
/* If provided, set the "post script" for this option. */
if (isset
($optset['post_script'])) {
/* Add this option to the option array. */
$result[$grpkey]['options'][] =
$next_option;
/* Return our resulting array. */
/* Print each option group. */
foreach ($option_groups as $next_optgrp) {
/* If it is not blank, print the name for this option group. */
if ($next_optgrp['name'] !=
'') {
'<b>' .
$next_optgrp['name'] .
'</b>' ,
'center' ,'', 'valign="middle" colspan="2" nowrap' )
/* Print each option in this option group. */
foreach ($next_optgrp['options'] as $option) {
/* Print an empty row after this option group. */
html_tag( 'td', ' ', 'left', '', 'colspan="2"' )
html_tag( 'td', '<input type="submit" value="' .
_("Submit") .
'" name="' .
$name .
'" /> ', 'right', '', 'colspan="2"' )
Documentation generated on Sat, 07 Oct 2006 16:32:45 +0300 by phpDocumentor 1.3.0RC6