--- /dev/null
+/**
+ * This array is used to remember mark status of rows in browse mode
+ */
+var marked_row = new Array;
+var orig_row_colors = new Array();
+
+
+/*
+ * (un)Checks checkbox for the row that the current table cell is in
+ * when it gets clicked.
+ *
+ * @param string the name of the checkbox that should be (un)checked
+ */
+function row_click(chkboxName) {
+ chkbox = document.getElementById(chkboxName);
+ if (chkbox) {
+ // initialize orig_row_color if not defined already
+ if (!orig_row_colors[chkboxName]) {
+ orig_row_colors[chkboxName] = chkbox.parentNode.getAttribute('bgcolor');
+ }
+ chkbox.checked = (chkbox.checked ? false : true);
+ }
+}
+/*
+ * This function is used to initialize the orig_row_color array so we do not
+ * need to predefine the entire array
+ */
+function rowOver(chkboxName, overColor, clickedColor) {
+ chkbox = document.getElementById(chkboxName);
+ if (chkbox) {
+ if (!orig_row_colors[chkboxName]) {
+ bgColor = chkbox.parentNode.getAttribute('bgcolor');
+ orig_row_colors[chkboxName] = bgColor;
+ } else {
+ bgColor = orig_row_colors[chkboxName];
+ }
+ j = chkbox.name.length - 1
+ setPointer(chkbox.parentNode.parentNode, j,'over' , bgColor, overColor, clickedColor);
+ }
+}
+
+/*
+ * (un)Checks all checkboxes for the message list from a specific form
+ * when it gets clicked.
+ *
+ * @param string the id of the form where all checkboxes should be (un)checked
+ * @param boolean use fancy row coloring when a checkbox is checked
+ * @param string new color of the checked rows
+ */
+function toggle_all(formname, fancy, clickedColor) {
+ TargetForm = document.getElementById(formname);
+ j = 0;
+ for (var i = 0; i < TargetForm.elements.length; i++) {
+ if (TargetForm.elements[i].type == 'checkbox' && TargetForm.elements[i].name.substring(0,3) == 'msg') {
+ if (fancy) {
+ array_key = TargetForm.elements[i].getAttribute('id');
+ if (TargetForm.elements[i].checked == false) {
+ // initialize orig_row_color if not defined already
+ if (!orig_row_colors[array_key]) {
+ orig_row_colors[array_key] = TargetForm.elements[i].parentNode.getAttribute('bgcolor');
+ }
+ }
+ origColor = orig_row_colors[array_key];
+ setPointer(TargetForm.elements[i].parentNode.parentNode, j,'click' , origColor, origColor, clickedColor);
+ j++
+ }
+ TargetForm.elements[i].checked = !(TargetForm.elements[i].checked);
+ }
+ }
+}
+
+/*
+ * Sets/unsets the pointer and marker in browse mode
+ *
+ * @param object the table row
+ * @param integer the row number
+ * @param string the action calling this script (over, out or click)
+ * @param string the default background color
+ * @param string the color to use for mouseover
+ * @param string the color to use for marking a row
+ *
+ * @return boolean whether pointer is set or not
+ */
+function setPointer(theRow, theRowNum, theAction, theDefaultColor, thePointerColor, theMarkColor)
+{
+ var theCells = null;
+
+ // 1. Pointer and mark feature are disabled or the browser can't get the
+ // row -> exits
+ if ((thePointerColor == '' && theMarkColor == '')
+ || typeof(theRow.style) == 'undefined') {
+ return false;
+ }
+
+ // 2. Gets the current row and exits if the browser can't get it
+ if (typeof(document.getElementsByTagName) != 'undefined') {
+ theCells = theRow.getElementsByTagName('td');
+ }
+ else if (typeof(theRow.cells) != 'undefined') {
+ theCells = theRow.cells;
+ }
+ else {
+ return false;
+ }
+
+ // 3. Gets the current color...
+ var rowCellsCnt = theCells.length;
+ var domDetect = null;
+ var currentColor = null;
+ var newColor = null;
+ // 3.1 ... with DOM compatible browsers except Opera that does not return
+ // valid values with "getAttribute"
+ if (typeof(window.opera) == 'undefined'
+ && typeof(theCells[0].getAttribute) != 'undefined') {
+ currentColor = theCells[0].getAttribute('bgcolor');
+ domDetect = true;
+ }
+ // 3.2 ... with other browsers
+ else {
+ currentColor = theCells[0].style.backgroundColor;
+ domDetect = false;
+ } // end 3
+
+ // 3.3 ... Opera changes colors set via HTML to rgb(r,g,b) format so fix it
+ if (currentColor.indexOf("rgb") >= 0)
+ {
+ var rgbStr = currentColor.slice(currentColor.indexOf('(') + 1,
+ currentColor.indexOf(')'));
+ var rgbValues = rgbStr.split(",");
+ currentColor = "#";
+ var hexChars = "0123456789ABCDEF";
+ for (var i = 0; i < 3; i++)
+ {
+ var v = rgbValues[i].valueOf();
+ currentColor += hexChars.charAt(v/16) + hexChars.charAt(v%16);
+ }
+ }
+
+ // 4. Defines the new color
+ // 4.1 Current color is the default one
+ if (currentColor == ''
+ || currentColor.toLowerCase() == theDefaultColor.toLowerCase()) {
+ if (theAction == 'over' && thePointerColor != '') {
+ newColor = thePointerColor;
+ }
+ else if (theAction == 'click' && theMarkColor != '') {
+ newColor = theMarkColor;
+ marked_row[theRowNum] = true;
+ // deactivated onclick marking of the checkbox because it's also executed
+ // when an action (clicking on the checkbox itself) on a single item is
+ // performed. Then the checkbox would get deactived, even though we need
+ // it activated. Maybe there is a way to detect if the row was clicked,
+ // and not an item therein...
+ //document.getElementById('msg[' + theRowNum + ']').checked = true;
+ }
+ }
+ // 4.1.2 Current color is the pointer one
+ else if (currentColor.toLowerCase() == thePointerColor.toLowerCase()
+ && (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])) {
+ if (theAction == 'out') {
+ newColor = theDefaultColor;
+ }
+ else if (theAction == 'click' && theMarkColor != '') {
+ newColor = theMarkColor;
+ marked_row[theRowNum] = true;
+ //document.getElementById('msg[' + theRowNum + ']').checked = true;
+ }
+ }
+ // 4.1.3 Current color is the marker one
+ else if (currentColor.toLowerCase() == theMarkColor.toLowerCase()) {
+ if (theAction == 'click') {
+ newColor = (thePointerColor != '')
+ ? thePointerColor
+ : theDefaultColor;
+ marked_row[theRowNum] = (typeof(marked_row[theRowNum]) == 'undefined' || !marked_row[theRowNum])
+ ? true
+ : null;
+ //document.getElementById('msg[' + theRowNum + ']').checked = false;
+ }
+ } // end 4
+
+ // 5. Sets the new color...
+ if (newColor) {
+ var c = null;
+ // 5.1 ... with DOM compatible browsers except Opera
+ if (domDetect) {
+ for (c = 0; c < rowCellsCnt; c++) {
+ theCells[c].setAttribute('bgcolor', newColor, 0);
+ } // end for
+ }
+ // 5.2 ... with other browsers
+ else {
+ for (c = 0; c < rowCellsCnt; c++) {
+ theCells[c].style.backgroundColor = newColor;
+ }
+ }
+ } // end 5
+
+ return true;
+} // end of the 'setPointer()' function
+
+function comp_in_new_form(comp_uri, button, myform, iWidth, iHeight) {
+ comp_uri += "&" + button.name + "=1";
+ for ( var i=0; i < myform.elements.length; i++ ) {
+ if ( myform.elements[i].type == "checkbox" && myform.elements[i].checked )
+ comp_uri += "&" + myform.elements[i].name + "=1";
+ }
+ if (!iWidth) iWidth = 640;
+ if (!iHeight) iHeight = 550;
+ sArg = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes,resizable=yes,status=yes";
+ var newwin = window.open(comp_uri, "_blank", sArg);
+}
+
+function comp_in_new(comp_uri, iWidth, iHeight) {
+ if (!iWidth) iWidth = 640;
+ if (!iHeight) iHeight = 550;
+ sArg = "width=" + iWidth + ",height=" + iHeight + ",scrollbars=yes,resizable=yes,status=yes";
+ var newwin = window.open(comp_uri , "_blank", sArg);
+}
+
+/*
+ * Reload the read_body screen on sending an mdn receipt
+ */
+function sendMDN() {
+ mdnuri=window.location+'&sendreceipt=1';
+ var newwin = window.open(mdnuri,'right');
+}
+
+function checkForm(smaction) {
+ /*
+ * this part is used for setting the focus in the compose screen
+ */
+ if (smaction) {
+ if (smaction == "select") {
+ document.forms['compose'].body.select();
+ } else if (smaction == "focus") {
+ document.forms['compose'].body.focus();
+ }
+ } else {
+ /*
+ * All other forms that need to set the focus
+ */
+ var f = document.forms.length;
+ var i = 0;
+ var pos = -1;
+ while( pos == -1 && i < f ) {
+ var e = document.forms[i].elements.length;
+ var j = 0;
+ while( pos == -1 && j < e ) {
+ if ( document.forms[i].elements[j].type == 'text' || document.forms[i].elements[j].type == 'password' ) {
+ pos = j;
+ }
+ j++;
+ }
+ i++;
+ }
+ if( pos >= 0 ) {
+ document.forms[i-1].elements[pos].focus();
+ }
+ }
+}
--- /dev/null
+<?php
+
+/**
+ * message_list.tpl
+ *
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Template for viewing a messages list
+ *
+ * @version $Id$
+ * @package squirrelmail
+ */
+
+include_once(SM_PATH . 'templates/util_message_list.php');
+
+/* retrieve the template vars */
+extract($t);
+
+do_hook('mailbox_index_before');
+
+/**
+ * Calculate string "Viewing message x to y (z total)"
+ */
+$msg_cnt_str = '';
+if ($pageOffset < $end_msg) {
+ $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
+ '<b>'.$pageOffset.'</b>', '<b>'.$end_msg.'</b>', $iNumberOfMessages);
+} else if ($pageOffset == $end_msg) {
+ $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<b>'.$pageOffset.'</b>', $iNumberOfMessages);
+}
+
+
+
+if (!($sort & SQSORT_THREAD) && $enablesort) {
+ $aSortSupported = array(SQM_COL_SUBJ => array(SQSORT_SUBJ_ASC , SQSORT_SUBJ_DESC),
+ SQM_COL_DATE => array(SQSORT_DATE_ASC , SQSORT_DATE_DESC),
+ SQM_COL_INT_DATE => array(SQSORT_INT_DATE_ASC, SQSORT_INT_DATE_DESC),
+ SQM_COL_FROM => array(SQSORT_FROM_ASC , SQSORT_FROM_DESC),
+ SQM_COL_TO => array(SQSORT_TO_ASC , SQSORT_TO_DESC),
+ SQM_COL_CC => array(SQSORT_CC_ASC , SQSORT_CC_DESC),
+ SQM_COL_SIZE => array(SQSORT_SIZE_ASC , SQSORT_SIZE_DESC));
+} else {
+ $aSortSupported = array();
+}
+
+// figure out which columns should serve as labels for checkbox:
+// we try to grab the two columns before and after the checkbox,
+// except the subject column, since it is the link that opens
+// the message view
+//
+// if $javascript_on is set, then the highlighting code takes
+// care of this; just skip it
+//
+$show_label_columns = array();
+$index_order_part = array();
+if (!($javascript_on && $fancy_index_highlite)) {
+ $get_next_two = 0;
+ $last_order_part = 0;
+ $last_last_order_part = 0;
+ foreach ($aOrder as $index_order_part) {
+ if ($index_order_part == SQM_COL_CHECK) {
+ $get_next_two = 1;
+ if ($last_last_order_part != SQM_COL_SUBJ)
+ $show_label_columns[] = $last_last_order_part;
+ if ($last_order_part != SQM_COL_SUBJ)
+ $show_label_columns[] = $last_order_part;
+
+ } else if ($get_next_two > 0 && $get_next_two < 3 && $index_order_part != SQM_COL_SUBJ) {
+ $show_label_columns[] = $index_order_part;
+ $get_next_two++;
+ }
+ $last_last_order_part = $last_order_part;
+ $last_order_part = $index_order_part;
+ }
+}
+
+// set this to an empty string to turn off extra
+// highlighting of checked rows
+//
+//$clickedColor = '';
+if (!empty($color[16]))
+ $clickedColor = $color[16];
+else
+ $clickedColor = $color[2];
+
+
+?>
+<form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
+<table border="0" width="100%" cellpadding="0" cellspacing="0">
+ <tr>
+ <td>
+ <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
+ <tr>
+ <td>
+ <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
+ <tr>
+ <td align="<?php echo $align['left']; ?>">
+ <small>
+<!-- paginator and thread link string -->
+ <?php
+ /**
+ * because the template is included in the display function we refer to $oTemplate with $this
+ */
+ $paginator_str = $this->fetch('paginator.tpl');
+ echo $paginator_str . $thread_link_str ."\n"; ?>
+<!-- end paginator and thread link string -->
+ </small>
+ </td>
+<!-- message count string -->
+ <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
+<!-- end message count string -->
+ </tr>
+ </table>
+ </td>
+ </tr>
+<?php
+ if (count($aFormElements)) {
+?>
+<!-- start message list form control -->
+ <tr bgcolor="<?php echo $color[0]; ?>">
+ <td>
+ <table border="0" width="100%" cellpadding="1" cellspacing="0">
+ <tr>
+ <td align="<?php echo $align['left']; ?>">
+ <small>
+
+<?php
+ foreach ($aFormElements as $key => $value) {
+ switch ($value[1]) {
+ case 'submit':
+ if ($key != 'moveButton') { // add move in a different table cell
+?>
+ <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" style="padding: 0px; margin: 0px" />
+<?php
+ }
+ break;
+ case 'checkbox':
+?>
+ <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>
+<?php
+ break;
+ case 'hidden':
+ echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
+ break;
+ default: break;
+ }
+ }
+?>
+ </small>
+ </td>
+ <td align="<?php echo $align['right']; ?>">
+
+
+<?php
+ if (isset($aFormElements['moveButton'])) {
+?> <small>
+ <tt>
+ <select name="targetMailbox">
+ <?php echo $aFormElements['targetMailbox'][0];?>
+ </select>
+ </tt>
+ <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" style="padding: 0px; margin: 0px" />
+ </small>
+<?php
+ } // if (isset($aFormElements['move']))
+?>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+<!-- end message list form control -->
+<?php
+ } // if (count($aFormElements))
+?>
+ </table>
+<?php
+ do_hook('mailbox_form_before');
+?>
+ </td>
+ </tr>
+ <tr><td height="5" bgcolor="<?php echo $color[4]; ?>"></td></tr>
+ <tr>
+ <td>
+ <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[9]; ?>">
+ <tr>
+ <td>
+ <table width="100%" cellpadding="1" cellspacing="0" align="center" border="0" bgcolor="<?php echo $color[5]; ?>">
+ <tr>
+ <td>
+<!-- table header start -->
+ <tr>
+<?php
+ $aWidth = calcMessageListColumnWidth($aOrder);
+ foreach($aOrder as $iCol) {
+
+?>
+ <td align="<?php echo $align['left']; ?>" width="<?php echo $aWidth[$iCol]; ?>%">
+ <b>
+<?php
+ switch ($iCol) {
+ case SQM_COL_CHECK:
+ if ($javascript_on) {
+ echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_id."','".$fancy_index_highlite."','".$clickedColor.'\');" />';
+ } else {
+ $link = $baseurl . "&startMessage=$pageOffset&&checkall=";
+ if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
+ $link .= ($checkall) ? '0' : '1';
+ } else {
+ $link .= '1';
+ }
+ echo "<a href=\"$link\">"._("All").'</a>';
+ }
+ break;
+ case SQM_COL_FROM: echo _("From"); break;
+ case SQM_COL_DATE: echo _("Date"); break;
+ case SQM_COL_SUBJ: echo _("Subject"); break;
+ case SQM_COL_FLAGS: echo ' '; break;
+ case SQM_COL_SIZE: echo _("Size"); break;
+ case SQM_COL_PRIO: echo '!'; break;
+ case SQM_COL_ATTACHMENT: echo '+'; break;
+ case SQM_COL_INT_DATE: echo _("Received"); break;
+ case SQM_COL_TO: echo _("To"); break;
+ case SQM_COL_CC: echo _("Cc"); break;
+ case SQM_COL_BCC: echo _("Bcc"); break;
+ default: break;
+ }
+ // add the sort buttons
+ if (isset($aSortSupported[$iCol])) {
+ if ($sort == $aSortSupported[$iCol][0]) {
+ $newsort = $aSortSupported[$iCol][1];
+ $img = 'up_pointer.png';
+ } else if ($sort == $aSortSupported[$iCol][1]) {
+ $newsort = 0;
+ $img = 'down_pointer.png';
+ } else {
+ $newsort = $aSortSupported[$iCol][0];
+ $img = 'sort_none.png';
+ }
+ /* Now that we have everything figured out, show the actual button. */
+ echo " <a href=\"$baseurl&startMessage=1&srt=$newsort\">";
+ echo '<img src="../images/' . $img
+ . '" border="0" width="12" height="10" alt="sort" title="'
+ . _("Click here to change the sorting of the message list") .'" /></a>';
+ }
+?>
+ </b>
+ </td>
+<?php
+ }
+?>
+ </tr>
+
+<!-- Message headers start -->
+<?php
+ $i = 0;
+ $iColCnt = count($aOrder);
+ $sLine = '';
+
+ // this stuff does the auto row highlighting on mouseover
+ //
+ if ($javascript_on && $fancy_index_highlite) {
+
+ $mouseoverColor = $color[5];
+
+ // set this to an empty string to turn off extra
+ // highlighting of checked rows
+ //
+ //$clickedColor = '';
+ $clickedColor = (!empty($color[16])) ? $color[16] : $color[2];
+ }
+ if ($javascript_on) {
+ $checkbox_javascript = ' onClick="this.checked = !this.checked;"';
+ }
+ foreach ($aMessages as $iUid => $aMsg) {
+ echo $sLine;
+
+/**
+* Display message header row in messages list
+*
+*/
+
+ $aColumns = $aMsg['columns'];
+
+ /**
+ * Check usage of images for attachments, flags and priority
+ * Aaaaaaaaaah fix me. DO NOT USE the string "None" if you mean FALSE, no icon theme
+ */
+ $bIcons = ($use_icons && $icon_theme) ? true : false;
+
+ /**
+ * Location of icon images
+ */
+ if ($bIcons) {
+ $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
+ }
+
+ /**
+ * Check the flags and set a class var.
+ */
+ if (isset($aColumns[SQM_COL_FLAGS])) {
+ $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
+ if ($bIcons) {
+
+ $sFlags = getFlagIcon($aFlags, $sImageLocation);
+ } else {
+ $sFlags = getFlagText($aFlags);
+ }
+ /* add the flag string to the value index */
+ $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
+ }
+ /**
+ * Check the priority column
+ */
+ if (isset($aColumns[SQM_COL_PRIO])) {
+ /* FIX ME, we should use separate templates for icons */
+ if ($bIcons) {
+ $sValue = '<img src="' . $sImageLocation;
+ switch ($aColumns[SQM_COL_PRIO]['value']) {
+ case 1:
+ case 2: $sValue .= 'prio_high.png" border="0" height="10" width="5" alt="" /> ' ; break;
+ case 5: $sValue .= 'prio_low.png" border="0" height="10" width="5" alt="" /> ' ; break;
+ default: $sValue .= 'transparent.png" border="0" width="5" alt="" /> ' ; break;
+ }
+ } else {
+ $sValue = '';
+ switch ($aColumns[SQM_COL_PRIO]['value']) {
+ case 1:
+ case 2: $sValue .= "<font color=\"$color[1]\">!</font>"; break;
+ case 5: $sValue .= "<font color=\"$color[8]\">?</font>"; break;
+ default: break;
+ }
+ }
+ $aColumns[SQM_COL_PRIO]['value'] = $sValue;
+ }
+
+ /**
+ * Check the attachment column
+ */
+ if (isset($aColumns[SQM_COL_ATTACHMENT])) {
+ /* FIX ME, we should use separate templates for icons */
+ if ($bIcons) {
+ $sValue = '<img src="' . $sImageLocation;
+ $sValue .= ($aColumns[SQM_COL_ATTACHMENT]['value'])
+ ? 'attach.png" border="0" height="10" width="6" alt=""/>'
+ : 'transparent.png" border="0" width="6" alt="" />';
+ } else {
+ $sValue = ($aColumns[SQM_COL_ATTACHMENT]['value']) ? '+' : '';
+ }
+ $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
+ }
+
+
+ $bgcolor = $color[4];
+
+ /**
+ * If alternating row colors is set, adapt the bgcolor
+ */
+ if (isset($alt_index_colors) && $alt_index_colors) {
+ if (!($i % 2)) {
+ if (!isset($color[12])) {
+ $color[12] = '#EAEAEA';
+ }
+ $bgcolor = $color[12];
+ }
+
+ }
+ $bgcolor = (isset($aMsg['row']['color'])) ? $aMsg['row']['color']: $bgcolor;
+ $class = 'msg_row';
+
+ $row_extra = '';
+
+ // this stuff does the auto row highlighting on mouseover
+ //
+ if ($javascript_on && $fancy_index_highlite) {
+ $row_extra .= ' onmouseover="rowOver(\''.$form_id . "_msg$i','". $mouseoverColor . '\', \'' . $clickedColor . '\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' . $clickedColor . '\');"';
+ }
+ // this does the auto-checking of the checkbox no matter
+ // where on the row you click
+ //
+ $javascript_auto_click = '';
+ if ($javascript_on && $fancy_index_highlite) {
+ // include the form_id in order to show multiple messages lists. Otherwise id isn't unique
+ $javascript_auto_click = " onMouseDown=\"row_click('$form_id"."_msg$i')\"";
+ }
+
+?>
+<tr class="<?php echo $class;?>" valign="top" bgcolor="<?php echo $bgcolor; ?>"<?php echo $row_extra;?>>
+<?php
+ // flag style mumbo jumbo
+ $sPre = $sEnd = '';
+ if (!in_array('seen',$aFlags)) {
+ $sPre = '<b>'; $sEnd = '</b>';
+ }
+ if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
+ $sPre = "<font color=\"$color[9]\">" . $sPre;
+ $sEnd .= '</font>';
+ } else {
+ if (in_array('flagged',$aFlags) && $aFlags['flagged']) {
+ $sPre = "<font color=\"$color[2]\">" . $sPre;
+ $sEnd .= '</font>';
+ }
+ }
+ /**
+ * Because the order of the columns and which columns to show is a user preference
+ * we have to do some php coding to display the columns in the right order
+ */
+ foreach ($aOrder as $iCol) {
+ if (in_array($index_order_part, $show_label_columns)) {
+ $sLabelStart = '<label for="msg[' . $i . ']">';
+ $sLabelEnd = '</label>';
+ } else {
+ $sLabelStart = '';
+ $sLabelEnd = '';
+ }
+ $aCol = (isset($aColumns[$iCol])) ? $aColumns[$iCol] : '';
+ $title = (isset($aCol['title'])) ? $aCol['title'] : '';
+ $link = (isset($aCol['link'])) ? $aCol['link'] : '';
+ $value = (isset($aCol['value'])) ? $aCol['value'] : '';
+ $target = (isset($aCol['target'])) ? $aCol['target'] : '';
+ if ($iCol !== SQM_COL_CHECK) {
+ $value = $sLabelStart.$sPre.$value.$sEnd.$sLabelEnd;
+ }
+
+
+ switch ($iCol) {
+ case SQM_COL_CHECK:
+ echo '<td align="' .$align['left'] .'"'. $javascript_auto_click. ' bgcolor="'.$bgcolor.'">' ?>
+ <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
+ <?php
+ break;
+ case SQM_COL_SUBJ:
+ $indent = $aCol['indent'];
+ $sText = " <td class=\"col_subject\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
+ if ($align['left'] == 'left') {
+ $sText .= str_repeat(' ',$indent);
+ }
+ $sText .= "<a href=\"$link\"";
+ if ($target) { $sText .= " target=\"$target\"";}
+ if ($title) { $sText .= " title=\"$title\"" ;}
+ if ($javascript_on && $fancy_index_highlite) {
+ $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
+ 'parentNode.parentNode, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $mouseoverColor . '\', \'' .
+ $clickedColor .'\');"';
+ }
+ $sText .= ">";
+ $sText .= $value . '</a>';
+ if ($align['left'] == 'right') {
+ $sText .= str_repeat(' ',$indent);
+ }
+ echo $sText."</td>\n";
+ break;
+ case SQM_COL_SIZE:
+ case SQM_COL_FLAGS:
+ $sText = " <td class=\"col_\" align=\"$align[right]\" $javascript_auto_click bgcolor=\"$bgcolor\">";
+ $sText .= "<small>$value</small></td>\n";
+ echo $sText;
+ break;
+ case SQM_COL_INT_DATE:
+ case SQM_COL_DATE:
+ $sText = " <td class=\"col_\" align=\"center\" $javascript_auto_click bgcolor=\"$bgcolor\">";
+ $sText .= $value. "</td>\n";
+ echo $sText;
+ break;
+ default:
+ $sText = " <td class=\"col_\" align=\"$align[left]\" $javascript_auto_click bgcolor=\"$bgcolor\"";
+ if ($link) {
+ $sText .= "><a href=\"$link\"";
+ if ($target) { $sText .= " target=\"$target\"";}
+ if ($title) { $sText .= " title=\"$title\"" ;}
+ $sText .= ">";
+ } else {
+ if ($title) {$sText .= " title=\"$title\"";}
+ $sText .= ">";
+ }
+ $sText .= $value;
+ if ($link) { $sText .= '</a>';}
+ echo $sText."</td>\n";
+ break;
+ }
+ }
+?>
+ </tr>
+<?php
+ $sLine = "<tr><td colspan=\"$iColCnt\" height=\"1\" bgcolor=\"$color[0]\"></td></tr>";
+ ++$i;
+
+/*
+ * End displaying row part
+ */
+ }
+
+?>
+<!-- Message headers end -->
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr><td height="5" bgcolor="<?php echo $color[4]; ?>" colspan="1"></td></tr>
+ <tr>
+ <td>
+ <table width="100%" cellpadding="1" cellspacing="0" style="border: 1px solid <?php echo $color[0]; ?>">
+ <tr>
+ <td>
+ <table bgcolor="<?php echo $color[4]; ?>" border="0" width="100%" cellpadding="1" cellspacing="0">
+ <tr>
+ <td align="left"><small><?php echo $paginator_str; ?></small></td>
+ <td align="right"><small><?php echo $msg_cnt_str; ?></small></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <?php do_hook('mailbox_index_after');?>
+ </td>
+ </tr>
+ </table>
+</form>
\ No newline at end of file
--- /dev/null
+<?php
+
+/**
+ * paginator.tpl
+ *
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * Template and utility functions to create a paginator
+ *
+ * @version $Id$
+ * @package squirrelmail
+ */
+
+
+include_once(SM_PATH.'templates/util_paginator.php');
+
+static $bScriptAdded;
+
+extract($t);
+
+if ($javascript_on && $compact_paginator &&!isset($bScriptAdded)) {
+ $bScriptAdded = true;
+?>
+
+<!-- start of compact paginator javascript -->
+<script language="JavaScript">
+ function SubmitOnSelect(select, URL)
+ {
+ URL += select.options[select.selectedIndex].value;
+ window.location.href = URL;
+ }
+</script>
+<!-- end of compact paginator javascript -->
+
+<?php
+}
+
+ if (isset($compact_paginator) && $compact_paginator) {
+ $sPaginator = get_compact_paginator_str($mailbox, $pageOffset, $iNumberOfMessages, $messagesPerPage, $showall, $javascript_on, $page_selector);
+ } else {
+ $sPaginator = get_paginator_str($mailbox, $pageOffset, $iNumberOfMessages, $messagesPerPage, $showall, $page_selector, $page_selector_max);
+ }
+ // display the paginator string.
+ echo $sPaginator;
+
--- /dev/null
+<?php
+
+/**
+ * Template logic
+ *
+ * The following functions are utility functions for this template. Do not
+ * echo output in those functions.
+ */
+
+function calcMessageListColumnWidth($aOrder) {
+ /**
+ * Width of the displayed columns
+ */
+ $aWidthTpl = array(
+ SQM_COL_CHECK => 1,
+ SQM_COL_FROM => 25,
+ SQM_COL_DATE => 10,
+ SQM_COL_SUBJ => 100,
+ SQM_COL_FLAGS => 2,
+ SQM_COL_SIZE => 5,
+ SQM_COL_PRIO => 1,
+ SQM_COL_ATTACHMENT => 1,
+ SQM_COL_INT_DATE => 10,
+ SQM_COL_TO => 25,
+ SQM_COL_CC => 25,
+ SQM_COL_BCC => 25
+ );
+
+ /**
+ * Calculate the width of the subject column based on the
+ * widths of the other columns
+ */
+ if (isset($aOrder[SQM_COL_SUBJ])) {
+ foreach($aOrder as $iCol) {
+ if ($iCol != SQM_COL_SUBJ) {
+ $aWidthTpl[SQM_COL_SUBJ] -= $aWidthTpl[$iCol];
+ }
+ }
+ }
+ foreach($aOrder as $iCol) {
+ $aWidth[$iCol] = $aWidthTpl[$iCol];
+ }
+
+ $iCheckTotalWidth = $iTotalWidth = 0;
+ foreach($aOrder as $iCol) { $iTotalWidth += $aWidth[$iCol];}
+
+ $iTotalWidth = ($iTotalWidth) ? $iTotalWidth : 100; // divide by zero check. shouldn't be needed
+ // correct the width to 100%
+ foreach($aOrder as $iCol) {
+ $aWidth[$iCol] = round( (100 / $iTotalWidth) * $aWidth[$iCol] , 0);
+ $iCheckTotalWidth += $aWidth[$iCol];
+ }
+ if ($iCheckTotalWidth > 100) { // correction needed
+ $iCol = array_search(max($aWidth),$aWidth);
+ $aWidth[$iCol] -= $iCheckTotalWidth-100;
+ }
+ return $aWidth;
+}
+
+/**
+ * Function to retrieve the correct flag icon belonging to the set of
+ * provided flags
+ *
+ * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
+ * @param string $sImageLocation directory location of flagicons
+ * @return string $sFlags string with the correct img html tag
+ * @author Marc Groot Koerkamp
+ */
+function getFlagIcon($aFlags, $sImageLocation) {
+ $sFlags = '';
+
+ /**
+ * 0 = unseen
+ * 1 = seen
+ * 2 = deleted
+ * 3 = deleted seen
+ * 4 = answered
+ * 5 = answered seen
+ * 6 = answered deleted
+ * 7 = answered deleted seen
+ * 8 = flagged
+ * 9 = flagged seen
+ * 10 = flagged deleted
+ * 11 = flagged deleted seen
+ * 12 = flagged answered
+ * 13 = flagged aswered seen
+ * 14 = flagged answered deleted
+ * 15 = flagged anserwed deleted seen
+ */
+
+ /**
+ * Use static vars to avoid initialisation of the array on each displayed row
+ */
+ static $aFlagImages, $aFlagValues;
+ if (!isset($aFlagImages)) {
+ $aFlagImages = array(
+ array('msg_new.png','('._("New").')'),
+ array('msg_read.png','('._("Read").')'),
+ array('msg_new_deleted.png','('._("Deleted").')'),
+ array('msg_read_deleted.png','('._("Deleted").')'),
+ array('msg_new_reply.png','('._("Answered").')'),
+ array('msg_read_reply.png','('._("Answered").')'),
+ array('msg_read_deleted_reply.png','('._("Answered").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')'),
+ array('flagged.png', '('._("Flagged").')')
+ ); // as you see the list is not completed yet.
+ $aFlagValues = array('seen' => 1,
+ 'deleted' => 2,
+ 'answered' => 4,
+ 'flagged' => 8,
+ 'draft' => 16);
+ }
+
+ /**
+ * The flags entry contain all items displayed in the flag column.
+ */
+ $iFlagIndx = 0;
+ foreach ($aFlags as $flag => $flagvalue) {
+ /* FIX ME, we should use separate templates for icons */
+ switch ($flag) {
+ case 'deleted':
+ case 'answered':
+ case 'seen':
+ case 'flagged': if ($flagvalue) $iFlagIndx+=$aFlagValues[$flag]; break;
+ default: break;
+ }
+ }
+ if (isset($aFlagImages[$iFlagIndx])) {
+ $aFlagEntry = $aFlagImages[$iFlagIndx];
+ } else {
+ $aFlagEntry = end($aFlagImages);
+ }
+
+ $sFlags = '<img src="' . $sImageLocation . $aFlagEntry[0].'"'.
+ ' border="0" alt="'.$aFlagEntry[1].'" title="'. $aFlagEntry[1] .'" height="12" width="18" />' ;
+ if (!$sFlags) { $sFlags = ' '; }
+ return $sFlags;
+}
+
+/**
+ * Function to retrieve the correct flag text belonging to the set of
+ * provided flags
+ *
+ * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
+ * @return string $sFlags string with the correct flag text
+ * @author Marc Groot Koerkamp
+ */
+function getFlagText($aFlags) {
+ $sFlags = '';
+
+ /**
+ * 0 = unseen
+ * 1 = seen
+ * 2 = deleted
+ * 3 = deleted seen
+ * 4 = answered
+ * 5 = answered seen
+ * 6 = answered deleted
+ * 7 = answered deleted seen
+ * 8 = flagged
+ * 9 = flagged seen
+ * 10 = flagged deleted
+ * 11 = flagged deleted seen
+ * 12 = flagged answered
+ * 13 = flagged aswered seen
+ * 14 = flagged answered deleted
+ * 15 = flagged anserwed deleted seen
+ */
+ /**
+ * Use static vars to avoid initialisation of the array on each displayed row
+ */
+ static $aFlagText, $aFlagValues;
+ if (!isset($aFlagText)) {
+ $aFlagText = array(
+ array(' ', '('._("New").')'),
+ array(' ', '('._("Read").')'),
+ array(_("D") , '('._("Deleted").')'),
+ array(_("D") , '('._("Deleted").')'),
+ array(_("A") , '('._("Answered").')'),
+ array(_("A") , '('._("Answered").')'),
+ array(_("D") , '('._("Answered").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')'),
+ array(_("F") , '('._("Flagged").')')
+ ); // as you see the list is not completed yet.
+ $aFlagValues = array('seen' => 1,
+ 'deleted' => 2,
+ 'answered' => 4,
+ 'flagged' => 8,
+ 'draft' => 16);
+ }
+
+ /**
+ * The flags entry contain all items displayed in the flag column.
+ */
+ $iFlagIndx = 0;
+ foreach ($aFlags as $flag => $flagvalue) {
+ /* FIX ME, we should use separate templates for icons */
+ switch ($flag) {
+ case 'deleted':
+ case 'answered':
+ case 'seen':
+ case 'flagged': if ($flagvalue) $iFlagIndx+=$aFlagValues[$flag]; break;
+ default: break;
+ }
+ }
+ if (isset($aFlagText[$iFlagIndx])) {
+ $sFlags = $aFlagText[$iFlagIndx][0];
+ } else {
+ $aLast = end($aFlagText);
+ $sFlags = $aLast[0];
+ }
+ if (!$sFlags) { $sFlags = ' '; }
+ return $sFlags;
+}
+?>
--- /dev/null
+<?php
+/**
+ * Template logic
+ *
+ * The following functions are utility functions for this template. Do not
+ * echo output in those functions. Output is generated abbove this comment block
+ */
+
+ /**
+ * Generate a paginator link.
+ *
+ * @param string $box Mailbox name
+ * @param integer $start_msg Message Offset
+ * @param string $text text used for paginator link
+ * @return string
+ */
+function get_paginator_link($box, $start_msg, $text) {
+ sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
+ $result = "<a href=\"$php_self?startMessage=$start_msg&mailbox=$box\" "
+ . ">$text</a>";
+
+ return ($result);
+}
+
+/**
+ * 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)
+ * @return string $result paginate string with links to pages
+ */
+function get_compact_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll, $javascript_on, $page_selector) {
+
+ sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
+
+ /* Initialize paginator string chunks. */
+ $prv_str = '';
+ $nxt_str = '';
+ $pg_str = '';
+ $all_str = '';
+
+ $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. */
+
+ /* Make sure that our start message number is not too big. */
+ $iOffset = min($iOffset, $iTotal);
+
+ /* Compute the starting message of the previous and next page group. */
+ $next_grp = $iOffset + $iLimit;
+ $prev_grp = $iOffset - $iLimit;
+
+ if (!$bShowAll) {
+ /* Compute the basic previous and next strings. */
+ if (($next_grp <= $iTotal) && ($prev_grp >= 0)) {
+ $prv_str = get_paginator_link($box, $prev_grp, '<');
+ $nxt_str = get_paginator_link($box, $next_grp, '>');
+ } else if (($next_grp > $iTotal) && ($prev_grp >= 0)) {
+ $prv_str = get_paginator_link($box, $prev_grp, '<');
+ $nxt_str = '>';
+ } else if (($next_grp <= $iTotal) && ($prev_grp < 0)) {
+ $prv_str = '<';
+ $nxt_str = get_paginator_link($box, $next_grp, '>');
+ }
+
+ /* Page selector block. Following code computes page links. */
+ if ($iLimit != 0 && $page_selector && ($iTotal > $iLimit)) {
+ /* Most importantly, what is the current page!!! */
+ $cur_pg = intval($iOffset / $iLimit) + 1;
+
+ /* Compute total # of pages and # of paginator page links. */
+ $tot_pgs = ceil($iTotal / $iLimit); /* Total number of Pages */
+
+ $last_grp = (($tot_pgs - 1) * $iLimit) + 1;
+ }
+ } else {
+ $pg_str = "<a href=\"$php_self?showall=0"
+ . "&startMessage=1&mailbox=$box\" "
+ . ">" ._("Paginate") . '</a>';
+ }
+
+ /* Put all the pieces of the paginator string together. */
+ /**
+ * Hairy code... But let's leave it like it is since I am not certain
+ * a different approach would be any easier to read. ;)
+ */
+ $result = '';
+ if ( $prv_str || $nxt_str ) {
+
+ /* Compute the 'show all' string. */
+ $all_str = "<a href=\"$php_self?showall=1"
+ . "&startMessage=1&mailbox=$box\" "
+ . ">" . _("Show All") . '</a>';
+
+ $result .= '[' . get_paginator_link($box, 1, '<<') . ']';
+ $result .= '[' . $prv_str . ']';
+
+ $pg_url = $php_self . '?mailbox=' . $box;
+
+ $result .= '[' . $nxt_str . ']';
+ $result .= '[' . get_paginator_link($box, $last_grp, '>>') . ']';
+
+ if ($page_selector) {
+ $result .= $spc . '<select name="startMessage"';
+ if ($javascript_on) {
+ $result .= ' onchange="JavaScript:SubmitOnSelect'
+ . '(this, \'' . $pg_url . '&startMessage=\')"';
+ }
+ $result .='>';
+
+ for ($p = 0; $p < $tot_pgs; $p++) {
+ $result .= '<option ';
+ if (($p+1) == $cur_pg) $result .= 'selected ';
+ $result .= 'value="' . (($p*$iLimit)+1) . '">'
+ . ($p+1) . "/$tot_pgs" . '</option>';
+ }
+
+ $result .= '</select>';
+
+ if ($javascript_on) {
+ $result .= '<noscript language="JavaScript">'
+ . addSubmit(_("Go"))
+ . '</noscript>';
+ } else {
+ $result .= addSubmit(_("Go"));
+ }
+ }
+ }
+
+ $result .= ($pg_str != '' ? '['.$pg_str.']' . $spc : '');
+ $result .= ($all_str != '' ? $spc . '['.$all_str.']' . $spc . $spc : '');
+
+ /* If the resulting string is blank, return a non-breaking space. */
+ if ($result == '') {
+ $result = ' ';
+ }
+ /* Return our final magical paginator string. */
+ 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)
+ * @return string $result paginate string with links to pages
+ */
+function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll,$page_selector, $page_selector_max) {
+
+ sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
+
+ /* Initialize paginator string chunks. */
+ $prv_str = '';
+ $nxt_str = '';
+ $pg_str = '';
+ $all_str = '';
+
+ $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. */
+
+ /* Make sure that our start message number is not too big. */
+ $iOffset = min($iOffset, $iTotal);
+
+ /* Compute the starting message of the previous and next page group. */
+ $next_grp = $iOffset + $iLimit;
+ $prev_grp = $iOffset - $iLimit;
+
+ if (!$bShowAll) {
+ /* Compute the basic previous and next strings. */
+
+ if (($next_grp <= $iTotal) && ($prev_grp >= 0)) {
+ $prv_str = get_paginator_link($box, $prev_grp, _("Previous"));
+ $nxt_str = get_paginator_link($box, $next_grp, _("Next"));
+ } else if (($next_grp > $iTotal) && ($prev_grp >= 0)) {
+ $prv_str = get_paginator_link($box, $prev_grp, _("Previous"));
+ $nxt_str = _("Next");
+ } else if (($next_grp <= $iTotal) && ($prev_grp < 0)) {
+ $prv_str = _("Previous");
+ $nxt_str = get_paginator_link($box, $next_grp, _("Next"));
+ }
+
+ /* Page selector block. Following code computes page links. */
+ if ($iLimit != 0 && $page_selector && ($iTotal > $iLimit)) {
+ /* Most importantly, what is the current page!!! */
+ $cur_pg = intval($iOffset / $iLimit) + 1;
+
+ /* Compute total # of pages and # of paginator page links. */
+ $tot_pgs = ceil($iTotal / $iLimit); /* Total number of Pages */
+
+ $vis_pgs = min($page_selector_max, $tot_pgs - 1); /* Visible Pages */
+
+ /* Compute the size of the four quarters of the page links. */
+
+ /* If we can, just show all the pages. */
+ if (($tot_pgs - 1) <= $page_selector_max) {
+ $q1_pgs = $cur_pg - 1;
+ $q2_pgs = $q3_pgs = 0;
+ $q4_pgs = $tot_pgs - $cur_pg;
+
+ /* Otherwise, compute some magic to choose the four quarters. */
+ } else {
+ /*
+ * Compute the magic base values. Added together,
+ * these values will always equal to the $pag_pgs.
+ * NOTE: These are DEFAULT values and do not take
+ * the current page into account. That is below.
+ */
+ $q1_pgs = floor($vis_pgs/4);
+ $q2_pgs = round($vis_pgs/4, 0);
+ $q3_pgs = ceil($vis_pgs/4);
+ $q4_pgs = round(($vis_pgs - $q2_pgs)/3, 0);
+
+ /* Adjust if the first quarter contains the current page. */
+ if (($cur_pg - $q1_pgs) < 1) {
+ $extra_pgs = ($q1_pgs - ($cur_pg - 1)) + $q2_pgs;
+ $q1_pgs = $cur_pg - 1;
+ $q2_pgs = 0;
+ $q3_pgs += ceil($extra_pgs / 2);
+ $q4_pgs += floor($extra_pgs / 2);
+
+ /* Adjust if the first and second quarters intersect. */
+ } else if (($cur_pg - $q2_pgs - ceil($q2_pgs/3)) <= $q1_pgs) {
+ $extra_pgs = $q2_pgs;
+ $extra_pgs -= ceil(($cur_pg - $q1_pgs - 1) * 3/4);
+ $q2_pgs = ceil(($cur_pg - $q1_pgs - 1) * 3/4);
+ $q3_pgs += ceil($extra_pgs / 2);
+ $q4_pgs += floor($extra_pgs / 2);
+
+ /* Adjust if the fourth quarter contains the current page. */
+ } else if (($cur_pg + $q4_pgs) >= $tot_pgs) {
+ $extra_pgs = ($q4_pgs - ($tot_pgs - $cur_pg)) + $q3_pgs;
+ $q3_pgs = 0;
+ $q4_pgs = $tot_pgs - $cur_pg;
+ $q1_pgs += floor($extra_pgs / 2);
+ $q2_pgs += ceil($extra_pgs / 2);
+
+ /* Adjust if the third and fourth quarter intersect. */
+ } else if (($cur_pg + $q3_pgs + 1) >= ($tot_pgs - $q4_pgs + 1)) {
+ $extra_pgs = $q3_pgs;
+ $extra_pgs -= ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3/4);
+ $q3_pgs = ceil(($tot_pgs - $cur_pg - $q4_pgs) * 3/4);
+ $q1_pgs += floor($extra_pgs / 2);
+ $q2_pgs += ceil($extra_pgs / 2);
+ }
+ }
+
+ /*
+ * I am leaving this debug code here, commented out, because
+ * it is a really nice way to see what the above code is doing.
+ * echo "qts = $q1_pgs/$q2_pgs/$q3_pgs/$q4_pgs = "
+ * . ($q1_pgs + $q2_pgs + $q3_pgs + $q4_pgs) . '<br />';
+ */
+
+ /* Print out the page links from the compute page quarters. */
+
+ /* Start with the first quarter. */
+ if (($q1_pgs == 0) && ($cur_pg > 1)) {
+ $pg_str .= "...$spc";
+ } else {
+ for ($pg = 1; $pg <= $q1_pgs; ++$pg) {
+ $start = (($pg-1) * $iLimit) + 1;
+ $pg_str .= get_paginator_link($box, $start, $pg) . $spc;
+ }
+ if ($cur_pg - $q2_pgs - $q1_pgs > 1) {
+ $pg_str .= "...$spc";
+ }
+ }
+
+ /* 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;
+ }
+
+ /* Now print the current page. */
+ $pg_str .= $cur_pg . $spc;
+
+ /* 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;
+ }
+
+ /* And last, print the forth quarter page links. */
+ if (($q4_pgs == 0) && ($cur_pg < $tot_pgs)) {
+ $pg_str .= "...$spc";
+ } else {
+ if (($tot_pgs - $q4_pgs) > ($cur_pg + $q3_pgs)) {
+ $pg_str .= "...$spc";
+ }
+ 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;
+ }
+ }
+
+ $last_grp = (($tot_pgs - 1) * $iLimit) + 1;
+ }
+ } else {
+ $pg_str = "<a href=\"$php_self?showall=0"
+ . "&startMessage=1&mailbox=$box\" "
+ . ">" ._("Paginate") . '</a>';
+ }
+
+ /* Put all the pieces of the paginator string together. */
+ /**
+ * Hairy code... But let's leave it like it is since I am not certain
+ * a different approach would be any easier to read. ;)
+ */
+ $result = '';
+ if ( $prv_str || $nxt_str ) {
+
+ /* Compute the 'show all' string. */
+ $all_str = "<a href=\"$php_self?showall=1"
+ . "&startMessage=1&mailbox=$box\" "
+ . ">" . _("Show All") . '</a>';
+
+ $result .= '[';
+ $result .= ($prv_str != '' ? $prv_str . $spc . $sep . $spc : '');
+ $result .= ($nxt_str != '' ? $nxt_str : '');
+ $result .= ']' . $spc ;
+ }
+
+ $result .= ($pg_str != '' ? $spc . '['.$spc.$pg_str.']' . $spc : '');
+ $result .= ($all_str != '' ? $spc . '['.$all_str.']' . $spc . $spc : '');
+
+ /* If the resulting string is blank, return a non-breaking space. */
+ if ($result == '') {
+ $result = ' ';
+ }
+ /* Return our final magical compact paginator string. */
+ return ($result);
+}
+?>
\ No newline at end of file