From: pdontthink Date: Tue, 2 Jan 2007 22:06:39 +0000 (+0000) Subject: Move another template util file, strip HTML out of paginator utility fxns. X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=8409c786d068de8c1ce75d75586c6a718e52e433 Move another template util file, strip HTML out of paginator utility fxns. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12047 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/templates/util_paginator.php b/functions/template/paginator_util.php similarity index 77% rename from templates/util_paginator.php rename to functions/template/paginator_util.php index b01dd0de..11972d7a 100644 --- a/templates/util_paginator.php +++ b/functions/template/paginator_util.php @@ -1,10 +1,10 @@ $text"; - - return ($result); + return create_hyperlink("$php_self?startMessage=$start_msg&mailbox=$box", $text); } + /** * This function computes the comapact paginator string. * - * @param string $box mailbox name - * @param integer $iOffset offset in total number of messages - * @param integer $iTotal total number of messages - * @param integer $iLimit maximum number of messages to show on a page - * @param bool $bShowAll show all messages at once (non paginate mode) + * @param string $box mailbox name + * @param integer $iOffset offset in total number of messages + * @param integer $iTotal total number of messages + * @param integer $iLimit maximum number of messages to show on a page + * @param bool $bShowAll whether or not to show all messages at once + * ("show all" == non paginate mode) + * @param bool $javascript_on whether or not javascript is currently enabled + * @param bool $page_selector whether or not to show the page selection widget + * * @return string $result paginate string with links to pages + * */ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $javascript_on, $page_selector) { + global $oTemplate; sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER); /* Initialize paginator string chunks. */ @@ -54,8 +60,10 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $box = urlencode($box); /* Create simple strings that will be creating the paginator. */ - $spc = ' '; /* This will be used as a space. */ - $sep = '|'; /* This will be used as a seperator. */ + /* This will be used as a space. */ + $spc = $oTemplate->fetch('non_breaking_space.tpl'); + /* This will be used as a seperator. */ + $sep = '|'; /* Make sure that our start message number is not too big. */ $iOffset = min($iOffset, $iTotal); @@ -88,9 +96,7 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $last_grp = (($tot_pgs - 1) * $iLimit) + 1; } } else { - $pg_str = "" ._("Paginate") . ''; + $pg_str = create_hyperlink("$php_self?showall=0&startMessage=1&mailbox=$box", _("Paginate")); } /* Put all the pieces of the paginator string together. */ @@ -102,9 +108,7 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, if ( $prv_str || $nxt_str ) { /* Compute the 'show all' string. */ - $all_str = "" . _("Show All") . ''; + $all_str = create_hyperlink("$php_self?showall=1&startMessage=1&mailbox=$box", _("Show All")); $result .= '[' . get_paginator_link($box, 1, '<<') . ']'; $result .= '[' . $prv_str . ']'; @@ -115,26 +119,24 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $result .= '[' . get_paginator_link($box, $last_grp, '>>') . ']'; if ($page_selector) { - $result .= $spc . ''; + $result .= $spc . addSelect('startMessage', $options, + ((($cur_pg-1)*$iLimit)+1), + TRUE, + ($javascript_on ? array('onchange' => 'JavaScript:SubmitOnSelect(this, \'' . $pg_url . '&startMessage=\')') : array())); if ($javascript_on) { - $result .= ''; +//FIXME: What in the world? Two issues here: for one, $javascript_on is supposed +// to have already detected whether or not JavaScript is available and enabled. +// Secondly, we need to rid ourselves of any HTML output in the core. This +// is being removed (but left in case the original author points out why it +// should not be) and we'll trust $javascript_on to do the right thing. +// $result .= ''; } else { $result .= addSubmit(_("Go")); } @@ -152,18 +154,25 @@ function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, return ($result); } + /** * This function computes the paginator string. * - * @param string $box mailbox name - * @param integer $iOffset offset in total number of messages - * @param integer $iTotal total number of messages - * @param integer $iLimit maximum number of messages to show on a page - * @param bool $bShowAll show all messages at once (non paginate mode) + * @param string $box mailbox name + * @param integer $iOffset offset in total number of messages + * @param integer $iTotal total number of messages + * @param integer $iLimit maximum number of messages to show on a page + * @param bool $bShowAll whether or not to show all messages at once + * ("show all" == non paginate mode) + * @param bool $page_selector whether or not to show the page selection widget + * @param integer $page_selector_max maximum number of pages to show on the screen + * * @return string $result paginate string with links to pages + * */ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_selector, $page_selector_max) { + global $oTemplate; sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER); /* Initialize paginator string chunks. */ @@ -175,8 +184,10 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel $box = urlencode($box); /* Create simple strings that will be creating the paginator. */ - $spc = ' '; /* This will be used as a space. */ - $sep = '|'; /* This will be used as a seperator. */ + /* This will be used as a space. */ + $spc = $oTemplate->fetch('non_breaking_space.tpl'); + /* This will be used as a seperator. */ + $sep = '|'; /* Make sure that our start message number is not too big. */ $iOffset = min($iOffset, $iTotal); @@ -317,9 +328,7 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel $last_grp = (($tot_pgs - 1) * $iLimit) + 1; } } else { - $pg_str = "" ._("Paginate") . ''; + $pg_str = create_hyperlink("$php_self?showall=0&startMessage=1&mailbox=$box", _("Paginate")); } /* Put all the pieces of the paginator string together. */ @@ -331,9 +340,7 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel if ( $prv_str || $nxt_str ) { /* Compute the 'show all' string. */ - $all_str = "" . _("Show All") . ''; + $all_str = create_hyperlink("$php_self?showall=1&startMessage=1&mailbox=$box", _("Show All")); $result .= '['; $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : ''); @@ -346,8 +353,10 @@ function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_sel /* If the resulting string is blank, return a non-breaking space. */ if ($result == '') { - $result = ' '; + $result = $oTemplate->fetch('non_breaking_space.tpl'); } /* Return our final magical compact paginator string. */ return ($result); } + + diff --git a/templates/default/paginator.tpl b/templates/default/paginator.tpl index 4557594d..7f2400d5 100644 --- a/templates/default/paginator.tpl +++ b/templates/default/paginator.tpl @@ -5,6 +5,63 @@ * * Template and utility functions to create a paginator * + * The following variables are available in this template: +//FIXME: need to clean (and document) this list, it is just a dump of the array keys of $t + * $sTemplateID + * $icon_theme_path + * $javascript_on + * $delayed_errors + * $frames + * $lang + * $page_title + * $header_tags + * $plugin_output + * $header_sent + * $body_tag_js + * $shortBoxName + * $sm_attribute_str + * $frame_top + * $urlMailbox + * $startMessage + * $hide_sm_attributions + * $uri + * $text + * $onclick + * $class + * $id + * $target + * $color + * $form_name + * $form_id + * $page_selector + * $page_selector_max + * $messagesPerPage + * $showall + * $end_msg + * $align + * $iNumberOfMessages + * $aOrder + * $aFormElements + * $sort + * $pageOffset + * $baseurl + * $aMessages + * $trash_folder + * $sent_folder + * $draft_folder + * $thread_link_str + * $php_self + * $mailbox + * $enablesort + * $icon_theme + * $use_icons + * $alt_index_colors + * $fancy_index_highlite + * $aSortSupported + * $show_label_columns + * $compact_paginator + * $aErrors + * * @copyright © 1999-2006 The SquirrelMail Project Team * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id$ @@ -13,13 +70,13 @@ */ /** include functions */ -include_once(SM_PATH.'templates/util_paginator.php'); +include_once(SM_PATH . 'functions/template/paginator_util.php'); static $bScriptAdded; extract($t); -if ($javascript_on && $compact_paginator &&!isset($bScriptAdded)) { +if ($javascript_on && $compact_paginator && !isset($bScriptAdded)) { $bScriptAdded = true; ?>