Ahhhh. I hate having to aim for checkboxes
[squirrelmail.git] / templates / default / message_list.tpl
index a8623307935564670181d86986e9fb80892cc9aa..0752f1e2623f7abd053b51a33eda61e1197bf45c 100644 (file)
@@ -19,7 +19,7 @@
  *    $header_sent
  *    $body_tag_js
  *    $shortBoxName
- *    $sm_attribute_str
+ *    $provider_link
  *    $frame_top
  *    $urlMailbox
  *    $startMessage
@@ -49,7 +49,8 @@
  *    $trash_folder
  *    $sent_folder
  *    $draft_folder
- *    $thread_link_str
+ *    $thread_link_uri
+ *    $thread_name
  *    $php_self
  *    $mailbox
  *    $enablesort
@@ -61,6 +62,8 @@
  *    $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
@@ -104,13 +107,6 @@ if ($pageOffset < $end_msg) {
  */
 
 
-// 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_name;?>" name="<?php echo $form_name;?>" method="post" action="<?php echo $php_self;?>">
@@ -131,7 +127,8 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
                        * $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 -->
@@ -147,69 +144,14 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
 <!-- start message list form control -->
       <tr class="message_list_controls">
         <td>
-          <table class="table_empty" cellspacing="0">
-            <tr>
-              <td class="message_control_buttons">
-
-<?php
-        foreach ($aFormElements as $widget_name => $widget_attrs) {
-            switch ($widget_attrs['type']) {
-            case 'submit':
-                if ($widget_name != 'moveButton' && $widget_name != 'copyButton' && $widget_name != 'delete' && $widget_name != 'undeleteButton') { // add these later in another table cell
-                    echo '<input type="submit" name="' . $widget_name . '" value="' . $widget_attrs['value'] . '" class="message_control_button" />&nbsp;';
-                }
-                break;
-            case 'checkbox':
-                if ($widget_name != 'bypass_trash') {
-                    echo '<input type="checkbox" name="' . $widget_name . '" id="' . $widget_name . '" /><label for="' . $widget_name . '">' . $widget_attrs['value'] . '</label>&nbsp;';
-                }
-                break;
-            case 'hidden':
-                echo '<input type="hidden" name="'.$widget_name.'" value="'. $widget_attrs['value']."\">\n";
-                break;
-            default: break;
-            }
-        }
-?>
-              </td>
-              <td class="message_control_delete">
-<?php
-        if (isset($aFormElements['delete'])) {
-            echo '<input type="submit" name="delete" value="' . $aFormElements['delete']['value'] . '" class="message_control_button" />&nbsp;';
-            if (isset($aFormElements['bypass_trash'])) {
-                echo '<input type="checkbox" name="bypass_trash" id="bypass_trash" /><label for="bypass_trash">' . $aFormElements['bypass_trash']['value'] . '</label>&nbsp;';
-            }
-            if (isset($aFormElements['undeleteButton'])) {
-                echo '<input type="submit" name="undeleteButton" value="' . $aFormElements['undeleteButton']['value'] . '" class="message_control_button" />&nbsp;';
-            }
-?>
-
-              </td>
-
-<?php
-        } // if (isset($aFormElements['delete']))
-        if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton'])) {
-?>
-              <td class="message_control_move">
-                    <select name="targetMailbox">
-                       <?php echo $aFormElements['targetMailbox']['options_list'];?>
-                    </select>
-<?php         
-            if (isset($aFormElements['moveButton'])) { 
-                echo '<input type="submit" name="moveButton" value="' . $aFormElements['moveButton']['value'] . '" class="message_control_button" />';
-            }
-            if (isset($aFormElements['copyButton'])) {
-                echo '<input type="submit" name="copyButton" value="' . $aFormElements['copyButton']['value'] . '" class="message_control_button" />';
-            } 
-?>
-
-              </td>
-
-<?php
-        } // if (isset($aFormElements['moveButton']) || isset($aFormElements['copyButton']))
-?>
-            </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 -->
@@ -249,34 +191,34 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
         switch ($iCol) {
           case SQM_COL_CHECK:
               if ($javascript_on) {
-                  echo '<input type="checkbox" name="toggleAll" title="'._("Toggle All").'" onclick="toggle_all(\''.$form_name."',".$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;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:
                 echo getIcon($icon_theme_path, 'msg_new.png', '&nbsp;', _("Message Flags")) . "\n";
                 break;
-          case SQM_COL_SIZE:       echo  _("Size")."\n";    break;
+          case SQM_COL_SIZE:       echo  _("Size") . "\n";    break;
           case SQM_COL_PRIO:
                 echo getIcon($icon_theme_path, 'prio_high.png', '!', _("Priority")) . "\n";
                 break;
           case SQM_COL_ATTACHMENT:
                 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;
+          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
@@ -309,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
 *
@@ -366,29 +308,48 @@ $clickedColor = (empty($color[16])) ? $color[2] : $color[16];
         $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
@@ -396,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">
@@ -414,6 +377,19 @@ if ($class != 'even' && $class != 'odd')
 </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
@@ -450,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) {
@@ -460,13 +435,13 @@ if ($class != 'even' && $class != 'odd')
 
         switch ($iCol) {
           case SQM_COL_CHECK:
+            $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;?> /></td>
+                <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">';
-                $checked = ($checkall) ? " checked=checked " : " ";
                 echo "<input type=\"checkbox\" name=\"msg[".$i."]\" id=\"".$form_id."_msg$i\" value=\"$iUid\" $checked/></td>";
             }
             break;
@@ -483,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);
             }
@@ -495,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:
@@ -522,9 +496,8 @@ if ($class != 'even' && $class != 'odd')
             break;
         }
     }
-?>
-                  </tr>
-<?php
+
+            echo '</tr>';
             $sLine = "<tr><td colspan=\"$iColCnt\" class=\"spacer\"></td></tr>\n";
             ++$i;
 
@@ -549,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>
@@ -559,10 +540,14 @@ if ($class != 'even' && $class != 'odd')
         </td>
       </tr>
       <tr>
-        <td>
-        <?php /* FIXME: no hooks in templates!! */ do_hook('mailbox_index_after', $null); ?>
+        <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; ?>