Ahhhh. I hate having to aim for checkboxes
[squirrelmail.git] / templates / default / message_list.tpl
index 9badaa59b7c4d9470a94d46616166e59d7f9cef2..0752f1e2623f7abd053b51a33eda61e1197bf45c 100644 (file)
@@ -5,6 +5,66 @@
  *
  * Template for viewing a messages list
  *
+ * 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
+ *    $provider_link
+ *    $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_uri
+ *    $thread_name
+ *    $php_self
+ *    $mailbox
+ *    $enablesort
+ *    $icon_theme
+ *    $use_icons
+ *    $alt_index_colors
+ *    $fancy_index_highlite
+ *    $aSortSupported
+ *    $show_label_columns
+ *    $compact_paginator
+ *    $aErrors
+ *    $checkall
+ *    $preselected
+ *
  * @copyright © 1999-2006 The SquirrelMail Project Team
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @subpackage templates
  */
 
+
 /** add required includes */
-include_once(SM_PATH . 'templates/util_message_list.php');
+include_once(SM_PATH . 'functions/template/message_list_util.php');
+
 
 /* retrieve the template vars */
 extract($t);
 
-do_hook('mailbox_index_before');
+
+if (!empty($plugin_output['mailbox_index_before'])) echo $plugin_output['mailbox_index_before'];
+
 
 /**
  * Calculate string "Viewing message x to y (z total)"
@@ -26,77 +90,26 @@ do_hook('mailbox_index_before');
 $msg_cnt_str = '';
 if ($pageOffset < $end_msg) {
     $msg_cnt_str = sprintf(_("Viewing Messages: %s to %s (%s total)"),
-                    '<em>'.$pageOffset.'</em>', '<em>'.$end_msg.'</em>', $iNumberOfMessages);
+                           '<em>' . $pageOffset . '</em>',
+                           '<em>' . $end_msg . '</em>',
+                           $iNumberOfMessages);
 } else if ($pageOffset == $end_msg) {
-    $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"), '<em>'.$pageOffset.'</em>', $iNumberOfMessages);
-}
-
-
-
-if (!($sort & SQSORT_THREAD) && $enablesort) {
-    $aSortSupported = array(SQM_COL_SUBJ =>     array(SQSORT_SUBJ_ASC     , SQSORT_SUBJ_DESC),
-                            SQM_COL_DATE =>     array(SQSORT_DATE_DESC    , SQSORT_DATE_ASC),
-                            SQM_COL_INT_DATE => array(SQSORT_INT_DATE_DESC, SQSORT_INT_DATE_ASC),
-                            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();
+    $msg_cnt_str = sprintf(_("Viewing Message: %s (%s total)"),
+                           '<em>' . $pageOffset . '</em>',
+                           $iNumberOfMessages);
 }
 
-// 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;
-    }
-}
 
 /**
- * Check usage of images for attachments, flags and priority
+ * All icon functionality is now handled through $icon_theme_path.
+ * $icon_theme_path will contain the path to the user-selected theme.  If it is
+ * NULL, the user and/or admin have turned off icons.
  */
-$bIcons = ($use_icons && $icon_theme) ? true : false;
 
-/**
- * Location of icon images
- */
-if ($bIcons) {
-    $sImageLocation = SM_PATH . 'images/themes/' . $icon_theme . '/';
-}
 
-// set this to an empty string to turn off extra
-// highlighting of checked rows
-//
-//$clickedColor = '';
-$clickedColor = (empty($color[16])) ? $color[2] : $color[16];
-       
 ?>
 <div id="message_list">
-<form id="<?php echo $form_id;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
+<form id="<?php echo $form_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
 <table class="table_empty" cellspacing="0">
   <tr>
    <td>
@@ -108,11 +121,14 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
               <td class="links_paginator">
 <!-- paginator and thread link string -->
                   <?php
-                      /**
-                       * because the template is included in the display function we refer to $oTemplate with $this
+                     /**
+                       * The following line gets the output from a separate 
+                       * template altogether (called "paginator.tpl").
+                       * $this is the Template class object.
                        */
                       $paginator_str = $this->fetch('paginator.tpl');
-                      echo $paginator_str . $thread_link_str ."\n"; ?>
+                      echo $paginator_str . '<small>[<a href="' . $thread_link_uri
+                                          . '">' . $thread_name . '</a>]</small>'; ?>
 <!-- end paginator and thread link string -->
               </td>
 <!-- message count string -->
@@ -126,73 +142,16 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
     if (count($aFormElements)) {
 ?>
 <!-- start message list form control -->
-      <tr class="message_list_controls" cellspacing="0">
+      <tr class="message_list_controls">
         <td>
-          <table class="table_empty" cellspacing="0">
-            <tr>
-              <td class="message_control_buttons" cellspacing="0">
-
-<?php
-        foreach ($aFormElements as $key => $value) {
-            switch ($value[1]) {
-            case 'submit':
-                if ($key != 'moveButton' && $key != 'delete' && $key != 'undeleteButton') { // add move in a different table cell
-?>
-                  <input type="submit" name="<?php echo $key; ?>" value="<?php echo $value[0]; ?>" class="message_control_button" />&nbsp;
-<?php
-                }
-                break;
-            case 'checkbox':
-                if ($key != 'bypass_trash') {
-?>
-                  <input type="checkbox" name="<?php echo $key; ?>" /><?php echo $value[0]; ?>&nbsp;
-<?php
-                }
-                break;
-            case 'hidden':
-                 echo '<input type="hidden" name="'.$key.'" value="'. $value[0]."\">\n";
-                 break;
-            default: break;
-            }
-        }
-?>
-              </td>
-              <td class="message_control_delete">
-
-
-<?php
-        if (isset($aFormElements['delete'])) {
-?>
-                  <input type="submit" name="delete" value="<?php echo $aFormElements['delete'][0]; ?>" class="message_control_button" />&nbsp;
- <?php
-            if (isset($aFormElements['bypass_trash'])) {
-?>
-                  <input type="checkbox" name="bypass_trash" /><?php echo $aFormElements['bypass_trash'][0]; ?>&nbsp;
-<?php
-            }
-            if (isset($aFormElements['undeleteButton'])) {
-?>
-                  <input type="submit" name="undeleteButton" value="<?php echo $aFormElements['undeleteButton'][0]; ?>" class="message_control_button" />&nbsp;
-<?php
-            }
-?>
-              </td>
-<?php
-        } // if (isset($aFormElements['delete']))
-        if (isset($aFormElements['moveButton'])) {
-?>
-              <td class="message_control_move">
-                    <select name="targetMailbox">
-                       <?php echo $aFormElements['targetMailbox'][0];?>
-                    </select>
-                  <input type="submit" name="moveButton" value="<?php echo $aFormElements['moveButton'][0]; ?>" class="message_control_button" />
-              </td>
-
-<?php
-        } // if (isset($aFormElements['move']))
-?>
-            </tr>
-          </table>
+                  <?php
+                     /**
+                       * The following line gets the output from a separate
+                       * template altogether (called "message_list_controls.tpl").
+                       * $this is the Template class object.
+                       */
+                      $message_list_controls = $this->fetch('message_list_controls.tpl');
+                      echo $message_list_controls ."\n"; ?>
         </td>
       </tr>
 <!-- end message list form control -->
@@ -200,9 +159,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
     } // if (count($aFormElements))
 ?>
     </table>
-<?php
-    do_hook('mailbox_form_before');
-?>
+<?php if (!empty($plugin_output['mailbox_form_before'])) echo $plugin_output['mailbox_form_before']; ?>
     </td>
   </tr>
   <tr><td class="spacer"></td></tr>
@@ -216,79 +173,73 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
 <?php
 /*
  * As an FYI, Firefox on Windows seems to have an issue w/ putting wierd breaks while
- * rendering this table if we use THEAD and TH tags.  No other browser or platform has 
+ * rendering this table if we use THEAD and TH tags.  No other browser or platform has
  * this issue.  We will use TR/TD w/ another CSS class to work around this.
  */
 ?>
+
               <tr class="headerRow">
+
 <?php
     $aWidth = calcMessageListColumnWidth($aOrder);
     foreach($aOrder as $iCol) {
 ?>
+
                     <td style="width:<?php echo $aWidth[$iCol]; ?>%">
+
 <?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.')" />'."\n";
+                  $checked = ($checkall ? ' checked="checked" ' : '');
+                  echo '<input type="checkbox" name="toggleAll" id="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$fancy_index_highlite.')" ' . $checked . '/>'."\n";
               } else {
-                  $link = $baseurl . "&amp;startMessage=$pageOffset&amp;&amp;checkall=";
-                  if (sqgetGlobalVar('checkall',$checkall,SQ_GET)) {
-                      $link .= ($checkall) ? '0' : '1';
-                  } else {
-                      $link .= '1';
-                  }
+                  $link = $baseurl 
+                        . "&amp;startMessage=$pageOffset&amp;checkall=" 
+                        . ($checkall ? '0' : '1');
                   echo "<a href=\"$link\">"._("All").'</a>';
               }
               break;
-          case SQM_COL_FROM:       echo _("From")."\n";     break;
-          case SQM_COL_DATE:       echo _("Date")."\n";     break;
-          case SQM_COL_SUBJ:       echo _("Subject")."\n";  break;
+          case SQM_COL_FROM:       
+              echo '<label for="toggleAll">' . _("From") . "</label>\n";
+              break;
+          case SQM_COL_DATE:       echo _("Date") . "\n";     break;
+          case SQM_COL_SUBJ:       echo _("Subject") . "\n";  break;
           case SQM_COL_FLAGS:
-               if ($bIcons) {
-                  echo '<img src="' . $sImageLocation. 'msg_new.png" border="0" height="12" width="18" alt="!" title="'. _("Message Flags") . '" />'."\n";
-               } else {
-                  echo  '&nbsp;'."\n";
-               }
-               break;
-          case SQM_COL_SIZE:       echo  _("Size")."\n";    break;
+                echo getIcon($icon_theme_path, 'msg_new.png', '&nbsp;', _("Message Flags")) . "\n";
+                break;
+          case SQM_COL_SIZE:       echo  _("Size") . "\n";    break;
           case SQM_COL_PRIO:
-               if ($bIcons) {
-                  echo '<img src="' . $sImageLocation. 'prio_high.png" border="0" height="10" width="5" alt="!" title="'. _("Priority") . '" />'."\n";
-               } else {
-                  echo  '!'."\n";
-               }
-               break;
+                echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
+                break;
           case SQM_COL_ATTACHMENT:
-               if ($bIcons) {
-                  echo '<img src="' . $sImageLocation. 'attach.png" border="0" height="10" width="6" alt="+" title="' . _("Attachment") . '"/>'."\n";
-               } else {
-                  echo  '+'."\n";
-               }
-               break;
-          case SQM_COL_INT_DATE:   echo _("Received")."\n"; break;
-          case SQM_COL_TO:         echo _("To")."\n";       break;
-          case SQM_COL_CC:         echo _("Cc")."\n";       break;
-          case SQM_COL_BCC:        echo _("Bcc")."\n";      break;
+                echo getIcon($icon_theme_path, 'attach.png', '+', _("Attachment")) . "\n";
+                break;
+          case SQM_COL_INT_DATE:   echo _("Received") . "\n"; break;
+          case SQM_COL_TO:         echo _("To") . "\n";       break;
+          case SQM_COL_CC:         echo _("Cc") . "\n";       break;
+          case SQM_COL_BCC:        echo _("Bcc") . "\n";      break;
           default: break;
         }
         // add the sort buttons
         if (isset($aSortSupported[$iCol])) {
             if ($sort == $aSortSupported[$iCol][0]) {
-               $newsort = $aSortSupported[$iCol][1];
-               $img = 'up_pointer.png';
+                $newsort = $aSortSupported[$iCol][1];
+                $img = 'up_pointer.png';
+                $text_icon = '&#8679;';  // U+21E7 UPWARDS WHITE ARROW
             } else if ($sort == $aSortSupported[$iCol][1]) {
-               $newsort = 0;
-               $img = 'down_pointer.png';
+                $newsort = 0;
+                $img = 'down_pointer.png';
+                $text_icon = '&#8681;'; // U+21E9 DOWNWARDS WHITE ARROW
             } else {
-               $newsort = $aSortSupported[$iCol][0];
-               $img = 'sort_none.png';
+                $newsort = $aSortSupported[$iCol][0];
+                $img = 'sort_none.png';
+                $text_icon = '&#9723;'; // U+25FB WHITE MEDIUM SQUARE
             }
             /* Now that we have everything figured out, show the actual button. */
-            echo " <a href=\"$baseurl&amp;startMessage=1&amp;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>'."\n";
+            echo " <a href=\"$baseurl&amp;startMessage=1&amp;srt=$newsort\" style=\"text-decoration:none\">" .
+                 getIcon($icon_theme_path, $img, $text_icon, _("Click here to change the sorting of the message list")) . "\n" .
+                 '</a>';
         }
 ?>
                     </td>
@@ -300,29 +251,29 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
 
 <!-- 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];
-
                 $checkbox_javascript = ' onclick="this.checked = !this.checked;"';
             } else {
                 $checkbox_javascript = '';
             }
+
+
+            /**
+              * main message iteration loop
+              */
             foreach ($aMessages as $iUid => $aMsg) {
+
                 echo $sLine;
 
+
 /**
 * Display message header row in messages list
 *
@@ -336,12 +287,8 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
      */
     if (isset($aColumns[SQM_COL_FLAGS])) {
         $aFlags = $aColumns[SQM_COL_FLAGS]['value'];
-        if ($bIcons) {
+        $sFlags = getFlagIcon($aFlags, $icon_theme_path);
 
-            $sFlags = getFlagIcon($aFlags, $sImageLocation);
-        } else {
-            $sFlags = getFlagText($aFlags);
-        }
         /* add the flag string to the value index */
         $aColumns[SQM_COL_FLAGS]['value'] = $sFlags;
     }
@@ -349,25 +296,7 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
      * 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 .= '<span class="high_priority">!</span>'; break;
-        // use downwards arrow for low priority emails
-                case 5: $sValue .= '<span class="low_priority">&#8595;</span>'; break;
-                default: break;
-            }
-        }
+        $sValue = getPriorityIcon($aColumns[SQM_COL_PRIO]['value'], $icon_theme_path);
         $aColumns[SQM_COL_PRIO]['value'] = $sValue;
     }
 
@@ -375,41 +304,52 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
      * 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']) ? '+' : '';
-        }
+        $sValue = getAttachmentIcon($aColumns[SQM_COL_ATTACHMENT]['value'], $icon_theme_path); 
         $aColumns[SQM_COL_ATTACHMENT]['value'] = $sValue;
     }
 
-       $class = 'even';
+    $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_even' : 'even');
+    $non_clicked_class = 'even';
+
     /**
      * If alternating row colors is set, adapt the CSS class
      */
     if (isset($alt_index_colors) && $alt_index_colors) {
         if (!($i % 2)) {
-               $class = 'odd';
+            $class = (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite ? 'clicked_odd' : 'odd');
+            $non_clicked_class = 'odd';
         }
 
     }
+
+    /**
+     * Message Highlighting Functionality
+     */
     if (isset($aMsg['row']['color']))
     {
-       $bgcolor = $aMsg['row']['color'];
-       $class = 'misc'.$i;
+       if (($checkall || in_array($iUid, $preselected)) && $javascript_on && $fancy_index_highlite) {
+//FIXME: would be best not to use $color directly here; want to move this to be a CSS style-defined value only, but the problem is that this CSS class is being defined on the fly right here
+           $bgcolor = $color[16];
+           $class = 'clicked_misc'.$i;
+        } else {
+            $bgcolor = $aMsg['row']['color'];
+           $class = 'misc'.$i;
+        }
+        $non_clicked_class = 'misc'.$i;
+        $non_clicked_bgcolor = $aMsg['row']['color'];
+    } 
+    else 
+    {
+        $bgcolor = '';
+        $non_clicked_bgcolor = '';
     }
-    else $bgcolor = '';
 
     $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.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $class . '\', \'mouse_over\', \'clicked\');"';
+        $row_extra = ' onmouseover="rowOver(\''.$form_id . '_msg' . $i.'\');" onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $non_clicked_class . '\', \'mouse_over\', \'clicked\');" onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $non_clicked_class . '\', \'mouse_over\', \'clicked\');"';
     }
     // this does the auto-checking of the checkbox no matter
     // where on the row you click
@@ -417,15 +357,17 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
     $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')\"";
+        $javascript_auto_click = " onmousedown=\"row_click('$form_id"."_msg$i')\"";
     }
 
+
 /*
  * Message Highlighting requires a unique CSS class declaration for proper
  * mouseover functionality.  There is no harm in doing this when the mouseover
  * functionality is disabled
  */
-if ($class != 'even' && $class != 'odd')
+if ($class != 'even' && $class != 'odd' 
+ && $class != 'clicked_even' && $class != 'clicked_odd')
 {
 ?>
 <style type="text/css">
@@ -433,15 +375,28 @@ if ($class != 'even' && $class != 'odd')
 .table_messageList     tr.<?php echo $class; ?>        { background:<?php echo $bgcolor; ?> }
 -->
 </style>
-<?
+<?php
 }
+if ($non_clicked_class != 'even' && $non_clicked_class != 'odd' 
+ && $non_clicked_class != 'clicked_even' && $non_clicked_class != 'clicked_odd')
+{
+?>
+<style type="text/css">
+<!--
+.table_messageList     tr.<?php echo $non_clicked_class; ?>    { background:<?php echo $non_clicked_bgcolor; ?> }
+-->
+</style>
+<?php
+}
+
+
 ?>
 <tr <?php echo (empty($class) ? '' : 'class="'.$class.'" ');  echo $row_extra;?>>
 <?php
     // flag style mumbo jumbo
     $sPre = $sEnd = '';
     if (isset($aColumns[SQM_COL_FLAGS])) {
-        if (!in_array('seen',$aFlags)) {
+        if (!in_array('seen',$aFlags) || !$aFlags['seen']) {
             $sPre = '<span class="unread">'; $sEnd = '</span>';
         }
         if (in_array('deleted',$aFlags) && $aFlags['deleted']) {
@@ -471,7 +426,6 @@ if ($class != 'even' && $class != 'odd')
         $link       = (isset($aCol['link']))       ? $aCol['link']       : '';
         $link_extra = (isset($aCol['link_extra'])) ? $aCol['link_extra'] : '';
         $onclick    = (isset($aCol['onclick']))    ? $aCol['onclick']    : '';
-        $link       = (isset($aCol['link']))       ? $aCol['link']       : '';
         $value      = (isset($aCol['value']))      ? $aCol['value']      : '';
         $target     = (isset($aCol['target']))     ? $aCol['target']     : '';
         if ($iCol !== SQM_COL_CHECK) {
@@ -481,9 +435,15 @@ if ($class != 'even' && $class != 'odd')
 
         switch ($iCol) {
           case SQM_COL_CHECK:
-            echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
-            <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript;?> /></td>
+            $checked = (($checkall || in_array($iUid, $preselected)) ? ' checked="checked" ' : '');
+            if ($javascript_on) {
+                echo '<td class="col_check"'. $javascript_auto_click. '>' ?>
+                <input type="checkbox" name="<?php echo "msg[$i]";?>" id="<?php echo $form_id."_msg$i";?>" value="<?php echo $iUid;?>" <?php echo $checkbox_javascript . $checked;?> /></td>
             <?php
+            } else {
+                echo '<td class="col_check">';
+                echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
+            }
             break;
           case SQM_COL_SUBJ:
             $indent = $aCol['indent'];
@@ -498,11 +458,10 @@ if ($class != 'even' && $class != 'odd')
             if ($link_extra) { $sText .= " $link_extra";          }
             if ($javascript_on && $fancy_index_highlite) {
                   $sText .= " onmousedown=\"row_click('$form_id"."_msg$i'); setPointer(this." . (empty($bold) ? '' : 'parentNode.') .
-                            'parentNode.parentNode, ' . $i . ', \'click\', \''. $class. '\', \'mouse_over\', \'' .
-                             $clickedColor .'\');"';
+                            'parentNode.parentNode, ' . $i . ', \'click\', \''. $non_clicked_class. '\', \'mouse_over\', \'clicked\');"';
             }
-            $sText .= ">";
-            $sText .= $value . '</a>';
+            $sText .= ">"
+                   . $value . '</a>';
             if ($align['left'] == 'right') {
                 $sText .= str_repeat('&nbsp;&nbsp;',$indent);
             }
@@ -510,14 +469,14 @@ if ($class != 'even' && $class != 'odd')
             break;
           case SQM_COL_SIZE:
           case SQM_COL_FLAGS:
-            $sText = "    <td class=\"col_flags\" $javascript_auto_click>";
-            $sText .= "$value</td>\n";
+            $sText = "    <td class=\"col_flags\" $javascript_auto_click>"
+                   . "$value</td>\n";
             echo $sText;
             break;
           case SQM_COL_INT_DATE:
           case SQM_COL_DATE:
-            $sText = "    <td class=\"col_date\" $javascript_auto_click>";
-            $sText .= $value. "</td>\n";
+            $sText = "    <td class=\"col_date\" $javascript_auto_click>"
+                   . $value. "</td>\n";
             echo $sText;
             break;
           default:
@@ -537,9 +496,8 @@ if ($class != 'even' && $class != 'odd')
             break;
         }
     }
-?>
-                  </tr>
-<?php
+
+            echo '</tr>';
             $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
             ++$i;
 
@@ -564,7 +522,15 @@ if ($class != 'even' && $class != 'odd')
               <td>
                 <table class="table_empty" cellspacing="0">
                   <tr>
-                    <td class="links_paginator"><?php echo $paginator_str; ?></td>
+                    <td class="links_paginator"><?php 
+                     /**
+                       * The following line gets the output from a separate 
+                       * template altogether (called "paginator.tpl").
+                       * $this is the Template class object.
+                       */
+                      $paginator_str = $this->fetch('paginator.tpl');
+                      echo $paginator_str; 
+                    ?></td>
                     <td class="message_count"><?php echo $msg_cnt_str; ?></td>
                   </tr>
                 </table>
@@ -574,10 +540,14 @@ if ($class != 'even' && $class != 'odd')
         </td>
       </tr>
       <tr>
-        <td>
-        <?php do_hook('mailbox_index_after');?>
+        <td align="right">
+<?php if (!empty($plugin_output['mailbox_index_after'])) echo $plugin_output['mailbox_index_after']; ?>
         </td>
       </tr>
     </table>
 </form>
 </div>
+
+<?php if (!$hide_sm_attributions): ?>
+<p class="sqm_squirrelcopyright">&copy; 1999-2007 The SquirrelMail Project Team - <a href="about.php">About SquirrelMail</a></p>
+<?php endif; ?>