From 551c7b5377aaf071ad86df4259a2783e69da4a65 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Sun, 6 Jan 2008 06:01:10 +0000 Subject: [PATCH] A few output elements are used often, so just retrieve them once and make them globally available git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12877 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/mime.php | 4 +- functions/template/paginator_util.php | 44 ++++++++++----------- include/init.php | 6 +++ include/options/folder.php | 3 +- plugins/bug_report/setup.php | 3 +- plugins/calendar/functions.php | 3 +- plugins/demo/functions.php | 3 +- plugins/mail_fetch/functions.php | 3 +- plugins/squirrelspell/sqspell_functions.php | 3 +- plugins/test/functions.php | 3 +- templates/default/line_break.tpl | 19 +++++++++ 11 files changed, 54 insertions(+), 40 deletions(-) create mode 100644 templates/default/line_break.tpl diff --git a/functions/mime.php b/functions/mime.php index bf9701ee..f2e111c8 100644 --- a/functions/mime.php +++ b/functions/mime.php @@ -354,9 +354,7 @@ function formatBody($imap_stream, $message, $color, $wrap_at, $ent_num, $id, $ma $show_html_default, $sort, $has_unsafe_images, $passed_ent_id, $use_iframe, $iframe_height, $download_and_unsafe_link, $download_href, $unsafe_image_toggle_href, $unsafe_image_toggle_text, - $oTemplate; - - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); + $oTemplate, $nbsp; // workaround for not updated config.php if (! isset($use_iframe)) $use_iframe = false; diff --git a/functions/template/paginator_util.php b/functions/template/paginator_util.php index c43b845b..cf892075 100644 --- a/functions/template/paginator_util.php +++ b/functions/template/paginator_util.php @@ -48,7 +48,8 @@ function get_paginator_link($box, $start_msg, $text) { */ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $javascript_on, $page_selector) { - global $oTemplate; + /* This will be used as a space. */ + global $oTemplate, $nbsp; // keeps count of how many times // the paginator is used, avoids @@ -68,8 +69,6 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $box = urlencode($box); /* Create simple strings that will be creating the paginator. */ - /* This will be used as a space. */ - $spc = $oTemplate->fetch('non_breaking_space.tpl'); /* This will be used as a seperator. */ $sep = '|'; @@ -131,7 +130,7 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, for ($p = 0; $p < $tot_pgs; $p++) { $options[(($p*$iLimit)+1) . '_' . $box] = ($p+1) . "/$tot_pgs"; } - $result .= $spc . addSelect('startMessage_' . $display_iterations, + $result .= $nbsp . addSelect('startMessage_' . $display_iterations, $options, ((($cur_pg-1)*$iLimit)+1), TRUE, @@ -152,8 +151,8 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, } } - $result .= ($pg_str != '' ? '['.$pg_str.']' . $spc : ''); - $result .= ($all_str != '' ? $spc . '['.$all_str.']' . $spc . $spc : ''); + $result .= ($pg_str != '' ? '['.$pg_str.']' . $nbsp : ''); + $result .= ($all_str != '' ? $nbsp . '['.$all_str.']' . $nbsp . $nbsp : ''); /* If the resulting string is blank, return a non-breaking space. */ if ($result == '') { @@ -181,7 +180,8 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, */ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_selector, $page_selector_max) { - global $oTemplate; + /* This will be used as a space. */ + global $oTemplate, $nbsp; sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER); /* Initialize paginator string chunks. */ @@ -193,8 +193,6 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel $box = urlencode($box); /* Create simple strings that will be creating the paginator. */ - /* This will be used as a space. */ - $spc = $oTemplate->fetch('non_breaking_space.tpl'); /* This will be used as a seperator. */ $sep = '|'; @@ -295,42 +293,42 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel /* Start with the first quarter. */ if (($q1_pgs == 0) && ($cur_pg > 1)) { - $pg_str .= "...$spc"; + $pg_str .= "...$nbsp"; } else { for ($pg = 1; $pg <= $q1_pgs; ++$pg) { $start = (($pg-1) * $iLimit) + 1; - $pg_str .= get_paginator_link($box, $start, $pg) . $spc; + $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp; } if ($cur_pg - $q2_pgs - $q1_pgs > 1) { - $pg_str .= "...$spc"; + $pg_str .= "...$nbsp"; } } /* Continue with the second quarter. */ for ($pg = $cur_pg - $q2_pgs; $pg < $cur_pg; ++$pg) { $start = (($pg-1) * $iLimit) + 1; - $pg_str .= get_paginator_link($box, $start, $pg) . $spc; + $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp; } /* Now print the current page. */ - $pg_str .= $cur_pg . $spc; + $pg_str .= $cur_pg . $nbsp; /* Next comes the third quarter. */ for ($pg = $cur_pg + 1; $pg <= $cur_pg + $q3_pgs; ++$pg) { $start = (($pg-1) * $iLimit) + 1; - $pg_str .= get_paginator_link($box, $start, $pg) . $spc; + $pg_str .= get_paginator_link($box, $start, $pg) . $nbsp; } /* And last, print the forth quarter page links. */ if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) { - $pg_str .= "...$spc"; + $pg_str .= "...$nbsp"; } else { if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) { - $pg_str .= "...$spc"; + $pg_str .= "...$nbsp"; } for ($pg = $tot_pgs - $q4_pgs + 1; $pg <= $tot_pgs; ++$pg) { $start = (($pg-1) * $iLimit) + 1; - $pg_str .= get_paginator_link($box, $start,$pg) . $spc; + $pg_str .= get_paginator_link($box, $start,$pg) . $nbsp; } } @@ -352,17 +350,17 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel $all_str = create_hyperlink("$php_self?showall=1&startMessage=1&mailbox=$box", _("Show All")); $result .= '['; - $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : ''); + $result .= ($prv_str != '' ? $prv_str . $nbsp . $sep . $nbsp : ''); $result .= ($nxt_str != '' ? $nxt_str : ''); - $result .= ']' . $spc ; + $result .= ']' . $nbsp ; } - $result .= ($pg_str != '' ? $spc . '['.$spc.$pg_str.']' . $spc : ''); - $result .= ($all_str != '' ? $spc . '['.$all_str.']' . $spc . $spc : ''); + $result .= ($pg_str != '' ? $nbsp . '['.$nbsp.$pg_str.']' . $nbsp : ''); + $result .= ($all_str != '' ? $nbsp . '['.$all_str.']' . $nbsp . $nbsp : ''); /* If the resulting string is blank, return a non-breaking space. */ if ($result == '') { - $result = $oTemplate->fetch('non_breaking_space.tpl'); + $result = $nbsp; } /* Return our final magical compact paginator string. */ return ($result); diff --git a/include/init.php b/include/init.php index c6bb2d23..d12b71d8 100644 --- a/include/init.php +++ b/include/init.php @@ -667,6 +667,7 @@ if (empty($oTemplate)) { } // We want some variables to always be available to the template +// $oTemplate->assign('javascript_on', (sqGetGlobalVar('user_is_logged_in', $user_is_logged_in, SQ_SESSION) ? checkForJavascript() : 0)); @@ -676,6 +677,11 @@ foreach ($always_include as $var) { $oTemplate->assign($var, (isset($$var) ? $$var : NULL)); } +// A few output elements are used often, so just get them once here +// +$nbsp = $oTemplate->fetch('non_breaking_space.tpl'); +$br = $oTemplate->fetch('line_break.tpl'); + /** * Initialize our custom error handler object */ diff --git a/include/options/folder.php b/include/options/folder.php index c2f7639e..811a0adf 100644 --- a/include/options/folder.php +++ b/include/options/folder.php @@ -33,7 +33,7 @@ define('SMOPT_GRP_FOLDERSELECT', 2); * @return array all option information */ function load_optpage_data_folder() { - global $username, $imapServerAddress, $imapPort, $oTemplate, + global $username, $imapServerAddress, $imapPort, $oTemplate, $nbsp, $folder_prefix, $default_folder_prefix, $show_prefix_option; /* Get some imap data we need later. */ @@ -227,7 +227,6 @@ function load_optpage_data_folder() { $optgrps[SMOPT_GRP_FOLDERSELECT] = _("Folder Selection Options"); $optvals[SMOPT_GRP_FOLDERSELECT] = array(); - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); $delim = sqimap_get_delimiter($imapConnection); $optvals[SMOPT_GRP_FOLDERSELECT][] = array( 'name' => 'mailbox_select_style', diff --git a/plugins/bug_report/setup.php b/plugins/bug_report/setup.php index 4c520f74..291707e3 100644 --- a/plugins/bug_report/setup.php +++ b/plugins/bug_report/setup.php @@ -35,8 +35,7 @@ function bug_report_button() { return; } - global $oTemplate; - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); + global $oTemplate, $nbsp; $output = makeInternalLink('plugins/bug_report/bug_report.php', _("Bug"), '') . $nbsp . $nbsp; return array('menuline' => $output); diff --git a/plugins/calendar/functions.php b/plugins/calendar/functions.php index 16d83720..bda182c5 100644 --- a/plugins/calendar/functions.php +++ b/plugins/calendar/functions.php @@ -18,8 +18,7 @@ */ function calendar_do() { - global $oTemplate; - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); + global $oTemplate, $nbsp; $output = makeInternalLink('plugins/calendar/calendar.php',_("Calendar"),'right') . $nbsp . $nbsp; return array('menuline' => $output); diff --git a/plugins/demo/functions.php b/plugins/demo/functions.php index 04bacc28..d0a5558e 100644 --- a/plugins/demo/functions.php +++ b/plugins/demo/functions.php @@ -20,10 +20,9 @@ */ function demo_page_header_template_do() { - global $oTemplate; + global $oTemplate, $nbsp; sq_change_text_domain('demo'); - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); $output = makeInternalLink('plugins/demo/demo.php', _("Demo"), '') . $nbsp . $nbsp; sq_change_text_domain('squirrelmail'); diff --git a/plugins/mail_fetch/functions.php b/plugins/mail_fetch/functions.php index 565e867b..6d48541c 100644 --- a/plugins/mail_fetch/functions.php +++ b/plugins/mail_fetch/functions.php @@ -32,8 +32,7 @@ global $mail_fetch_allow_unsubscribed; */ function mail_fetch_link_do() { - global $oTemplate; - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); + global $oTemplate, $nbsp; $output = makeInternalLink('plugins/mail_fetch/fetch.php', _("Fetch"), '') . $nbsp . $nbsp; return array('menuline' => $output); diff --git a/plugins/squirrelspell/sqspell_functions.php b/plugins/squirrelspell/sqspell_functions.php index 4fbd42e1..66adcc59 100644 --- a/plugins/squirrelspell/sqspell_functions.php +++ b/plugins/squirrelspell/sqspell_functions.php @@ -63,8 +63,7 @@ function squirrelspell_setup_function() { */ if (checkForJavascript()) { - global $oTemplate, $base_uri; - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); + global $oTemplate, $base_uri, $nbsp; $output = addButton(_("Check Spelling"), 'check_spelling', diff --git a/plugins/test/functions.php b/plugins/test/functions.php index 543a941d..303f5f95 100644 --- a/plugins/test/functions.php +++ b/plugins/test/functions.php @@ -17,8 +17,7 @@ */ function test_menuline_do() { - global $oTemplate; - $nbsp = $oTemplate->fetch('non_breaking_space.tpl'); + global $oTemplate, $nbsp; $output = makeInternalLink('plugins/test/test.php', 'Test', 'right') . $nbsp . $nbsp; return array('menuline' => $output); diff --git a/templates/default/line_break.tpl b/templates/default/line_break.tpl new file mode 100644 index 00000000..89196d92 --- /dev/null +++ b/templates/default/line_break.tpl @@ -0,0 +1,19 @@ +
-- 2.25.1