From 623662614b34b6f05a5ba6330bc5a624c8e9b731 Mon Sep 17 00:00:00 2001 From: kink Date: Wed, 31 Mar 2004 11:30:17 +0000 Subject: [PATCH] Make use of forms.php functions. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@6977 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/addrbook_search.php | 17 ++--- src/addrbook_search_html.php | 79 +++++++++++----------- src/addressbook.php | 8 +-- src/folders.php | 22 +++---- src/folders_delete.php | 6 +- src/folders_rename_getname.php | 13 ++-- src/options.php | 3 +- src/options_highlight.php | 115 ++++++++++++++++----------------- 8 files changed, 125 insertions(+), 138 deletions(-) diff --git a/src/addrbook_search.php b/src/addrbook_search.php index 4cfca096..45e1ed2e 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -26,6 +26,7 @@ require_once(SM_PATH . 'include/validate.php'); require_once(SM_PATH . 'functions/strings.php'); require_once(SM_PATH . 'functions/global.php'); require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/forms.php'); /** lets get the global vars we may need */ sqgetGlobalVar('key', $key, SQ_COOKIE); @@ -189,7 +190,7 @@ if ($show == 'form' && !isset($listall)) { /* Empty search */ if (empty($query) && empty($show) && empty($listall)) { echo html_tag( 'p', '
' . - _("No persons matching your search was found"), + _("No persons matching your search were found"), 'center' ) . "\n\n", exit; @@ -206,20 +207,20 @@ if ($show == 'form' && empty($listall)) { html_tag( 'tr' ) . html_tag( 'td', ' ' . _("Search for") . "\n", 'left', '', 'nowrap valign="middle" width="10%"' ) . html_tag( 'td', '', 'left', '', '' ) . - '\n"; + addInput('query', $query, 28); /* List all backends to allow the user to choose where to search */ if ($abook->numbackends > 1) { - echo '' . _("in") . ' \n"; + echo addSelect('backend', $selopts, '-1', TRUE); } else { - echo '' . "\n"; + echo addHidden('backend', '-1'); } echo '' . diff --git a/src/addrbook_search_html.php b/src/addrbook_search_html.php index bf0c8a47..bfb0797d 100644 --- a/src/addrbook_search_html.php +++ b/src/addrbook_search_html.php @@ -42,27 +42,22 @@ function addr_insert_hidden() { global $body, $subject, $send_to, $send_to_cc, $send_to_bcc, $mailbox, $identity, $session; - echo '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '\n" . '' . - "\n"; + echo addHidden('body', "\n".$body); + } else { + echo addHidden('body', $body); } + echo addHidden('session', $session). + addHidden('subject', $subject). + addHidden('send_to', $send_to). + addHidden('send_to_bcc', $send_to_bcc). + addHidden('send_to_cc', $send_to_cc). + addHidden('identity', $identity). + addHidden('mailbox', $mailbox). + addHidden('from_htmladdr_search', 'true'); +} + /** * List search results @@ -74,8 +69,8 @@ function addr_display_result($res, $includesource = true) { if (sizeof($res) <= 0) return; - echo '
'."\n" . - '' . "\n"; + echo addForm($PHP_SELF, 'POST', 'addrbook'). + addHidden('html_addr_search_done', 'true'); addr_insert_hidden(); $line = 0; @@ -133,12 +128,12 @@ if ($javascript_on) { } else { echo html_tag( 'tr', '', '', $tr_bgcolor, 'nowrap' ) . html_tag( 'td', - ' ' . _("To") . ' ' . - ' ' . _("Cc") . ' ' . - ' ' . _("Bcc") . ' ' , + addCheckBox('send_to_search[T'.$line.']', FALSE, $email). + ' ' . _("To") . ' ' . + addCheckBox('send_to_search[C'.$line.']', FALSE, $email). + ' ' . _("Cc") . ' ' . + addCheckBox('send_to_search[B'.$line.']', FALSE, $email). + ' ' . _("Bcc") . ' ' , 'center', '', 'width="5%" nowrap' ) . html_tag( 'td', ' ' . htmlspecialchars($row['name']) . ' ', 'left', '', 'nowrap' ) . html_tag( 'td', ' ' . htmlspecialchars($row['email']) . ' ', 'left', '', 'nowrap' ) . @@ -159,7 +154,7 @@ if ($javascript_on) { 'center', '', 'colspan="'. $td_colspan .'"' ) ) . '' . - '' . + addHidden('html_addr_search_done', '1'). '
'; } @@ -188,34 +183,31 @@ echo '
' . html_tag( 'table', '', 'center', '', 'border="0"' ) . html_tag( 'tr' ) . html_tag( 'td', '', 'left', '', 'nowrap valign="middle"' ) . "\n" . - '
' . "\n
\n" . + addForm($PHP_SELF.'?html_addr_search=true', 'POST', 'f'). + "\n
\n" . ' ' . _("Search for") . "\n"; addr_insert_hidden(); if (! isset($addrquery)) $addrquery = ''; -echo ' \n"; +echo addInput('addrquery', $addrquery, 26); /* List all backends to allow the user to choose where to search */ if (!isset($backend)) { $backend = ''; } if ($abook->numbackends > 1) { - echo '' . _("in") . ' \n"; + echo addSelect('backend', $selopts, $backend, TRUE); } else { - echo '' . "\n"; + echo addHidden('backend', '-1'); } if (isset($session)) { - echo ""; + echo addHidden('session', $session); } echo '' . @@ -281,7 +273,7 @@ else { } else { if (sizeof($res) == 0) { echo html_tag( 'p', '
' . - _("No persons matching your search was found") . "\n" , + _("No persons matching your search were found") . "\n" , 'center' ) . "\n\n"; } else { @@ -293,7 +285,8 @@ else { if ($addrquery == '' || sizeof($res) == 0) { /* printf('
'."\n", $PHP_SELF); */ - echo '
' . "\n"; + echo '
'. + addForm('compose.php','POST','k'); addr_insert_hidden(); echo '' . "\n" . '
'; diff --git a/src/addressbook.php b/src/addressbook.php index a936aaff..c1f23075 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -255,11 +255,9 @@ if(sqgetGlobalVar('REQUEST_METHOD', $req_method, SQ_SERVER) && $req_method == 'P ), 'center', '', 'width="100%" ' ); address_form("editaddr", _("Update address"), $olddata); - echo '\n" . - '\n" . - '' . "\n" . + echo addHidden('oldnick', $olddata['nickname']). + addHidden('backend', $olddata['backend']). + addHidden('doedit', '1'). ''; } } else { diff --git a/src/folders.php b/src/folders.php index 1d7e29dd..dc708a34 100644 --- a/src/folders.php +++ b/src/folders.php @@ -22,6 +22,7 @@ require_once(SM_PATH . 'include/validate.php'); require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/plugin.php'); require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/forms.php'); displayPageHeader($color, 'None'); @@ -95,11 +96,9 @@ echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspaci ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[0] ) . - - "
\n". - "
\n". - _("as a subfolder of"). - '
'. + addForm('folders_create.php', 'POST', 'cf'). + addInput('folder_name', '', 25). + "
\n". _("as a subfolder of"). '
'. "\n"; if ($show_contain_subfolders_option) { - echo '
 ' + echo '
'. + addCheckBox('contain_subs', FALSE, '1') .'  ' . _("Let this folder contain subfolders") . '
'; } @@ -193,7 +193,7 @@ echo html_tag( 'tr', html_tag( 'td', '', 'center', $color[0] ); if ($count_special_folders < count($boxes)) { - echo "\n" + echo addForm('folders_rename_getname.php') . "\n" . ' \n"; @@ -256,7 +256,7 @@ echo html_tag( 'table', '', 'center', '', 'width="70%" cellpadding="4" cellspaci html_tag( 'td', '', 'center', $color[0], 'width="50%"' ); if ($count_special_folders < count($boxes)) { - echo "\n" + echo addForm('folders_subscribe.php?method=unsub') . "'; for ($q = 0; $q < count($box); $q++) { @@ -318,7 +318,7 @@ if(!$no_list_for_subscribe) { } } else { /* don't perform the list action -- this is much faster */ - echo "\n" + echo addForm('folders_subscribe.php?method=sub') . _("Subscribe to:") . '
' . '' . '\n" diff --git a/src/folders_delete.php b/src/folders_delete.php index 9c80a143..d14bf210 100644 --- a/src/folders_delete.php +++ b/src/folders_delete.php @@ -23,6 +23,7 @@ require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/tree.php'); require_once(SM_PATH . 'functions/display_messages.php'); require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/forms.php'); /* * Incoming values: @@ -62,9 +63,8 @@ if( !sqgetGlobalVar('confirmed', $tmp, SQ_POST) ) { html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[4] ) . sprintf(_("Are you sure you want to delete %s?"), imap_utf7_decode_local($mailbox)). - '

'. - - '\n" . + addForm('folders_delete.php', 'POST'). + addHidden('mailbox', $mailbox). '\n". '\n". '


'; diff --git a/src/folders_rename_getname.php b/src/folders_rename_getname.php index 32045dd8..a5a9aa3c 100644 --- a/src/folders_rename_getname.php +++ b/src/folders_rename_getname.php @@ -22,6 +22,7 @@ require_once(SM_PATH . 'functions/global.php'); require_once(SM_PATH . 'functions/imap_mailbox.php'); require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'functions/display_messages.php'); +require_once(SM_PATH . 'functions/forms.php'); /* get globals we may need */ sqgetGlobalVar('key', $key, SQ_COOKIE); @@ -65,16 +66,16 @@ echo '
' . ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[4] ) . - '
'. + addForm('folders_rename_do.php'). _("New name:"). '
' . htmlspecialchars($old_parent) . ' ' . htmlspecialchars($delimiter) . '' . - '
' . "\n"; + addInput('new_name', $old_name, 25) . '
' . "\n"; if ( $isfolder ) { - echo ''; + echo addHidden('isfolder', 'true'); } -printf("\n", htmlspecialchars($old)); -printf("\n", htmlspecialchars($old_name)); -echo '\n". +echo addHidden('orig', $old). + addHidden('old_name', $old_name). + '\n". '

'; ?> diff --git a/src/options.php b/src/options.php index 44c2279e..7e509326 100644 --- a/src/options.php +++ b/src/options.php @@ -24,6 +24,7 @@ require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/options.php'); require_once(SM_PATH . 'functions/strings.php'); require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/forms.php'); /*********************************/ /*** Build the resultant page. ***/ @@ -390,7 +391,7 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* If we are not looking at the main option page, display the page here. */ /*************************************************************************/ } else { - echo '

' . "\n" + echo addForm('options.php', 'POST', 'f') . create_optpage_element($optpage) . create_optmode_element(SMOPT_MODE_SUBMIT) . html_tag( 'table', '', '', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) . "\n" diff --git a/src/options_highlight.php b/src/options_highlight.php index fde299f3..0fd3d4cb 100644 --- a/src/options_highlight.php +++ b/src/options_highlight.php @@ -22,32 +22,17 @@ require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'functions/plugin.php'); require_once(SM_PATH . 'functions/strings.php'); require_once(SM_PATH . 'functions/html.php'); +require_once(SM_PATH . 'functions/forms.php'); /* get globals */ -if (isset($_GET['action'])) { - $action = $_GET['action']; -} -if (isset($_GET['theid'])) { - $theid = $_GET['theid']; -} -if (isset($_GET['identname'])) { - $identname = $_GET['identname']; -} -if (isset($_GET['newcolor_choose'])) { - $newcolor_choose = $_GET['newcolor_choose']; -} -if (isset($_GET['newcolor_input'])) { - $newcolor_input = $_GET['newcolor_input']; -} -if (isset($_GET['color_type'])) { - $color_type = $_GET['color_type']; -} -if (isset($_GET['match_type'])) { - $match_type = $_GET['match_type']; -} -if (isset($_GET['value'])) { - $value = $_GET['value']; -} +sqGetGlobalVar('action', $action); +sqGetGlobalVar('theid', $theid); +sqGetGlobalVar('identname', $identname); +sqGetGlobalVar('newcolor_choose', $newcolor_choose); +sqGetGlobalVar('newcolor_input', $newcolor_input); +sqGetGlobalVar('color_type', $color_type); +sqGetGlobalVar('match_type', $match_type); +sqGetGlobalVar('value', $value); /* end of get globals */ @@ -329,8 +314,10 @@ if ($action == 'edit' || $action == 'add') { $new_color_list["18,3"] = 'ff33ff'; $new_color_list["18,4"] = 'ff00ff'; - $selected_input = ''; - $selected_choose = ''; + $selected_input = FALSE; + $selected_i = null; + $selected_choose = FALSE; + $selected_predefined = FALSE; for ($i=0; $i < 14; $i++) { ${"selected".$i} = ''; @@ -338,8 +325,8 @@ if ($action == 'edit' || $action == 'add') { if ($action == 'edit' && isset($theid) && isset($message_highlight_list[$theid]['color'])) { for ($i=0; $i < 14; $i++) { if ($color_list[$i] == $message_highlight_list[$theid]['color']) { - $selected_choose = ' checked'; - ${"selected".$i} = ' selected'; + $selected_choose = TRUE; + $selected_i = $color_list[$i]; continue; } } @@ -365,16 +352,17 @@ if ($action == 'edit' || $action == 'add') { } if (isset($theid) && !isset($message_highlight_list[$theid]['color'])) - $selected_choose = ' checked'; + $selected_choose = TRUE; else if ($pre_defined_color) - $selected_predefined = ' checked'; + $selected_predefined = TRUE; else if ($selected_choose == '') - $selected_input = ' checked'; + $selected_input = TRUE; - echo '' . "\n"; - echo '' . "\n"; - if($action == 'edit') - echo '' . "\n"; + echo addForm('options_highlight.php', 'POST', 'f'). + addHidden('action', 'save'); + if($action == 'edit') { + echo addHidden('theid', (isset($theid)?$theid:'')); + } echo html_tag( 'table', '', 'center', '', 'width="80%" cellpadding="3" cellspacing="0" border="0"' ) . "\n"; echo html_tag( 'tr', '', '', $color[0] ) . "\n"; echo html_tag( 'td', '', 'right', '', 'nowrap' ) . "\n"; @@ -385,33 +373,40 @@ if ($action == 'edit' || $action == 'add') { $disp = $message_highlight_list[$theid]['name']; else $disp = ''; - $disp = htmlspecialchars($disp); - echo " "; + echo " ".addInput('identname', $disp); echo " \n"; echo " \n"; echo html_tag( 'tr', html_tag( 'td', ' ', 'left' ) ) ."\n"; echo html_tag( 'tr', '', '', $color[0] ) . "\n"; echo html_tag( 'td', ''. _("Color") . ':', 'right' ); echo html_tag( 'td', '', 'left' ); - echo "  
\n"; - echo "  ". _("Other:") ." '._("Ex: 63aa7f")."
\n"; + echo ' '.addRadioBox('color_type', $selected_choose, '1'); + + $selops = array ( + $color_list[0] => _("Dark Blue"), + $color_list[1] => _("Dark Green"), + $color_list[2] => _("Dark Yellow"), + $color_list[3] => _("Dark Cyan"), + $color_list[4] => _("Dark Magenta"), + $color_list[5] => _("Light Blue"), + $color_list[6] => _("Light Green"), + $color_list[7] => _("Light Yellow"), + $color_list[8] => _("Light Cyan"), + $color_list[9] => _("Light Magenta"), + $color_list[10] => _("Dark Gray"), + $color_list[11] => _("Medium Gray"), + $color_list[12] => _("Light Gray"), + $color_list[13] => _("White") ); + + echo addSelect('newcolor_choose', $selops, $selected_i, TRUE); + echo "
\n"; + + echo ' '.addRadioBox('color_type', $selected_input, 2). + '  '. _("Other:") . + addInput('newcolor_input', + (($selected_input && isset($theid)) ? $message_highlight_list[$theid]['color'] : ''), + '7'); + echo _("Ex: 63aa7f")."
\n"; echo " \n"; echo " \n"; @@ -425,8 +420,8 @@ if ($action == 'edit' || $action == 'add') { for($y = 0; $y < 19; $y++) { $gridindex = "$y,$x"; $gridcolor = $new_color_list[$gridindex]; - $selected = ($gridcolor == $current_color) ? ' checked' : '' ; - echo html_tag( 'td', '', 'left', $gridcolor, 'colspan="2"' ); + echo html_tag( 'td', addRadioBox('color_type', ($gridcolor == $current_color), '#'.$gridcolor), + 'left', $gridcolor, 'colspan="2"' ); } echo "\n"; } @@ -458,9 +453,7 @@ if ($action == 'edit' || $action == 'add') { $disp = $message_highlight_list[$theid]['value']; else $disp = ''; - $disp = htmlspecialchars($disp); - echo ' '; + echo ' '.addInput('value', $disp, 40); echo " \n"; echo " \n"; echo "\n"; -- 2.25.1