From 64033e1c54e52d462f6dbb93c3bb06a5c0050865 Mon Sep 17 00:00:00 2001 From: stevetruckstuff Date: Thu, 17 Aug 2006 19:35:27 +0000 Subject: [PATCH] Iniitial option templating. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@11608 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- src/options.php | 90 +++++++++++--------- templates/default/option_groups.tpl | 122 ++++++++++------------------ templates/default/options.tpl | 43 ++++++++-- templates/default/stylesheet.tpl | 83 ++++++++++++++++++- 4 files changed, 214 insertions(+), 124 deletions(-) diff --git a/src/options.php b/src/options.php index 3968e121..6ef511f0 100644 --- a/src/options.php +++ b/src/options.php @@ -148,7 +148,7 @@ switch ($optpage) { if ( !@is_file( $optpage_file ) ) { $optpage = SMOPT_PAGE_MAIN; -} else if ($optpage != SMOPT_PAGE_MAIN ) { +} elseif ($optpage != SMOPT_PAGE_MAIN ) { /* Include the file for this optionpage. */ require_once($optpage_file); @@ -157,8 +157,7 @@ if ( !@is_file( $optpage_file ) ) { $optpage_data = array(); $optpage_data = $optpage_loader(); do_hook($optpage_loadhook); - $optpage_data['options'] = - create_option_groups($optpage_data['grps'], $optpage_data['vals']); + $optpage_data['options'] = create_option_groups($optpage_data['grps'], $optpage_data['vals']); } /***********************************************************/ @@ -229,14 +228,6 @@ if ($optmode == SMOPT_MODE_SUBMIT) { displayPageHeader($color, 'None', (isset($optpage_data['xtra']) ? $optpage_data['xtra'] : '')); -echo html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . "\n" . - html_tag( 'tr' ) . "\n" . - html_tag( 'td', '', 'center' ) . - "$optpage_title
\n". - html_tag( 'table', '', '', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . "\n" . - html_tag( 'tr' ) . "\n" . - html_tag( 'td', '', 'center', $color[4] ) . "\n"; - /* * The main option page has a different layout then the rest of the option * pages. Therefore, we create it here first, then the others below. @@ -252,16 +243,14 @@ if ($optpage == SMOPT_PAGE_MAIN) { } if (isset($optpage_save_error) && $optpage_save_error!=array()) { - $notice = "" . _("Error(s) occurred while saving your options") . "
\n" - ."\n" . _("Some of your preference changes were not applied.") . "\n"; } else { /* Display a message indicating a successful save. */ - $notice = '' . _("Successfully Saved Options") . ": $optpage_name
\n"; + $notice = _("Successfully Saved Options") . ": $optpage_name
\n"; } /* If $max_refresh != SMOPT_REFRESH_NONE, provide a refresh link. */ @@ -272,8 +261,12 @@ if ($optpage == SMOPT_PAGE_MAIN) { $notice .= '' . _("Refresh Page") . '
'; } } - $oTemplate->assign('notice',$notice); - + + if (!empty($notice)) { + $oTemplate->assign('note', $notice); + $oTemplate->display('note.tpl'); + } + /******************************************/ /* Build our array of Option Page Blocks. */ /******************************************/ @@ -347,11 +340,11 @@ if ($optpage == SMOPT_PAGE_MAIN) { /********************************************/ /* Now, print out each option page section. */ /********************************************/ + $oTemplate->assign('page_title', $optpage_title); + $oTemplate->assign('options', $optpage_blocks); - $oTemplate->assign('color',$color); - $oTemplate->assign('optpage_blocks',$optpage_blocks); $oTemplate->display('option_groups.tpl'); - + do_hook('options_link_and_description'); @@ -359,14 +352,6 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* If we are not looking at the main option page, display the page here. */ /*************************************************************************/ } else { - 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"; - - /* Output the option groups for this page. */ - print_option_groups($optpage_data['options']); - /* Set the inside_hook_name and submit_name. */ switch ($optpage) { case SMOPT_PAGE_PERSONAL: @@ -405,6 +390,41 @@ if ($optpage == SMOPT_PAGE_MAIN) { $submit_name = 'submit'; } + // Begin output form + echo addForm('options.php', 'post', 'f') + . create_optpage_element($optpage) + . create_optmode_element(SMOPT_MODE_SUBMIT); + + // Wrap the template in a table to keep from breaking the hooks below + echo "\n" . + " \n" . + " \n" . + " \n"; + /* If it is not empty, trigger the inside hook. */ if ($inside_hook_name != '') { do_hook($inside_hook_name); @@ -412,19 +432,15 @@ if ($optpage == SMOPT_PAGE_MAIN) { /* Spit out a submit button. */ OptionSubmit($submit_name); - echo '
\n"; + + // This is the only variable that is needed by *just* the template. + $oTemplate->assign('options', $optpage_data['options']); + + /** + * The variables below should not be needed by the template since all plugin + * hooks are called here, not in the template. If we find otherwise, these + * variables can be passed to the template. Commenting out for not. + */ +/* + $oTemplate->assign('max_refresh', isset($max_refresh) ? $max_refresh : NULL); + $oTemplate->assign('page_title', $optpage_title); + $oTemplate->assign('optpage',$optpage); + $oTemplate->assign('optpage_name',$optpage_name); + $oTemplate->assign('optmode',$optmode); + $oTemplate->assign('optpage_data',$optpage_data); +*/ + /** + * END comment block + */ + + $oTemplate->display('options.tpl'); + + echo "
'; + echo "\n" . + "\n"; /* If it is not empty, trigger the bottom hook. */ if ($bottom_hook_name != '') { do_hook($bottom_hook_name); } - if (isset($max_refresh)) $oTemplate->assign('max_refresh',$max_refresh); - $oTemplate->assign('color',$color); - $oTemplate->assign('optpage',$optpage); - $oTemplate->assign('optpage_name',$optpage_name); - $oTemplate->assign('optpage_data',$optpage_data); - $oTemplate->assign('optmode',$optmode); - $oTemplate->display('options.tpl'); + } $oTemplate->display('footer.tpl'); +?> \ No newline at end of file diff --git a/templates/default/option_groups.tpl b/templates/default/option_groups.tpl index c883a3fc..c1a8acfb 100644 --- a/templates/default/option_groups.tpl +++ b/templates/default/option_groups.tpl @@ -3,6 +3,15 @@ * option_groups.tpl * * Template for rendering main option page blocks + * + * The following variables are available to this template: + * $page_title - string containing the title element for this page + * $options - array containing option blocks to be displayed. Each + * element in the array will contain the following fields: + * $el['url'] - The URL of the link to display that option page + * $el['name'] - The name of the option page + * $el['desc'] - string containing the description of that option block + * $el['js'] - boolean TRUE if the element requires javascript being enabled. * * @copyright © 2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License @@ -11,87 +20,40 @@ * @subpackage templates */ -/** - * This function prints out an option page row. - * FIXME: remove function from template - */ -function print_optionpages_row($leftopt, $rightopt = false) { - global $color; - - if ($rightopt) { - $rightopt_name = html_tag( 'td', '' . $rightopt['name'] . '', 'left', $color[9], 'valign="top" width="49%"' ); - $rightopt_desc = html_tag( 'td', $rightopt['desc'], 'left', $color[0], 'valign="top" width="49%"' ); - } else { - $rightopt_name = html_tag( 'td', ' ', 'left', $color[4], 'valign="top" width="49%"' ); - $rightopt_desc = html_tag( 'td', ' ', 'left', $color[4], 'valign="top" width="49%"' ); - } - - echo - html_tag( 'table', "\n" . - html_tag( 'tr', "\n" . - html_tag( 'td', "\n" . - html_tag( 'table', "\n" . - html_tag( 'tr', "\n" . - html_tag( 'td', - '' . $leftopt['name'] . '' , - 'left', $color[9], 'valign="top" width="49%"' ) . - html_tag( 'td', - ' ' , - 'left', $color[4], 'valign="top" width="2%"' ) . "\n" . - $rightopt_name - ) . "\n" . - html_tag( 'tr', "\n" . - html_tag( 'td', - $leftopt['desc'] , - 'left', $color[0], 'valign="top" width="49%"' ) . - html_tag( 'td', - ' ' , - 'left', $color[4], 'valign="top" width="2%"' ) . "\n" . - $rightopt_desc - ) , - '', '', 'width="100%" cellpadding="2" cellspacing="0" border="0"' ) , - 'left', '', 'valign="top"' ) - ) , - '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"' ); -} - /** extract variables */ extract($t); - -/** - * Display error notices and other messages - * Maybe formating should be moved from src/options.php - */ -echo $notice; - -/********************************************/ -/* Now, print out each option page section. */ -/********************************************/ -$first_optpage = false; -echo html_tag( 'table', '', '', $color[4], 'width="100%" cellpadding="0" cellspacing="5" border="0"' ) . "\n" . - html_tag( 'tr' ) . "\n" . - html_tag( 'td', '', 'left', '', 'valign="top"' ) . - html_tag( 'table', '', '', $color[4], 'width="100%" cellpadding="3" cellspacing="0" border="0"' ) . "\n" . - html_tag( 'tr' ) . "\n" . - html_tag( 'td', '', 'left' ); - -foreach ($optpage_blocks as $next_optpage) { - if ($first_optpage == false) { - $first_optpage = $next_optpage; - } else { - print_optionpages_row($first_optpage, $next_optpage); - $first_optpage = false; - } -} - -if ($first_optpage != false) { - print_optionpages_row($first_optpage); -} -echo "\n"; - - ?> - - - +
+ + + + + + $option) { + ?> + + \n \n"; + } + } + ?> +
+ +
+ + + + + + + +
+ > +
+ +
+
+
diff --git a/templates/default/options.tpl b/templates/default/options.tpl index 95b2732e..24652335 100644 --- a/templates/default/options.tpl +++ b/templates/default/options.tpl @@ -3,6 +3,12 @@ * options.tpl * * Template for rendering the options page + * + * The following variables are available to this template: + * $options - array of options as built by SquirrelMail. Important fields + * in this array include (but are not limited to): + * $el['name'] - The name of the option group + * $el['options'] - array of squirrelOption objects * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License @@ -13,13 +19,38 @@ /** add required includes */ - /** extract variables */ extract($t); - ?> - - - - +
+\n"; + if (!empty($option['name'])) { + echo " \n" . + " \n" . + " ".$option['name']."\n" . + " \n" . + " \n"; + } + + foreach ($option['options'] as $opt) { + if ($opt->type != SMOPT_TYPE_HIDDEN) { + echo "\n" . + " \n" . + " ".$opt->caption."\n" . + " \n" . + " \n" . + " ".$opt->createHTMLWidget()."\n" . + " \n" . + "\n"; + } else { + echo $opt->createHTMLWidget(); + } + } + + echo "\n"; +} +?> +
\ No newline at end of file diff --git a/templates/default/stylesheet.tpl b/templates/default/stylesheet.tpl index b6481526..e43d58a6 100644 --- a/templates/default/stylesheet.tpl +++ b/templates/default/stylesheet.tpl @@ -1,5 +1,4 @@ ; } +table.table_empty, table.table_blank { + margin: 0; + padding: 0; + border: 0; + width: 100%; +} td.header1 { background: ; @@ -449,4 +454,80 @@ tr.odd { #addrAddEdit select { font-size: 75%; +} + +#optionGroups { + text-align: center; +} + +#optionGroups table { + border: 1px solid ; + margin-left: auto; + margin-right: auto; + padding: 0; + width: 95%; +} + +#optionGroups td { + width: 50%; + padding: 2px; + vertical-align: top; +} + +#optionGroups td.title { + background: ; + text-align: center; + font-weight: bold; +} + +#optionGroups td.optionElement { + height: 100%; + padding: 10px; +} + +#optionGroups td.optionElement table { + border:1px solid ; + height: 100%; +} + + +#optionGroups td.optionName { + background: ; + text-align: left; + height: 1%; +} + +#optionGroups td.optionDesc { + text-align: left; + background: ; +} + +#optionDisplay { + text-align:center; +} + +#optionDisplay table { + margin-left: auto; + margin-right: auto; + margin-top: 8px; + margin-bottom: 8px; + width: 95%; + border: 1px solid +} + +#optionDisplay td { + width: 50%; + padding-top: 2px; + padding-bottom: 2px; + padding-left: 4px; + padding-right: 4px; + white-space: nowrap; +} + +#optionDisplay td.optionName { + text-align: right; +} + +#optionDisplay td.optionValue { + text-align: left; } \ No newline at end of file -- 2.25.1