Source for file util_message_list.php

Documentation is available at util_message_list.php

  1. <?php
  2.  
  3. /**
  4.  * Template logic
  5.  *
  6.  * The following functions are utility functions for this template. Do not
  7.  * echo output in those functions.
  8.  *
  9.  * @copyright &copy; 2005-2006 The SquirrelMail Project Team
  10.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  11.  * @version $Id: util_message_list.php,v 1.8 2006/07/15 12:01:19 tokul Exp $
  12.  * @package squirrelmail
  13.  */
  14.  
  15. /**
  16.  * @param array $aOrder 
  17.  * @return array 
  18.  */
  19. function calcMessageListColumnWidth($aOrder{
  20.     /**
  21.      * Width of the displayed columns
  22.      */
  23.     $aWidthTpl array(
  24.         SQM_COL_CHECK => 1,
  25.         SQM_COL_FROM =>  25,
  26.         SQM_COL_DATE => 10,
  27.         SQM_COL_SUBJ  => 100,
  28.         SQM_COL_FLAGS => 2,
  29.         SQM_COL_SIZE  => 5,
  30.         SQM_COL_PRIO => 1,
  31.         SQM_COL_ATTACHMENT => 1,
  32.         SQM_COL_INT_DATE => 10,
  33.         SQM_COL_TO => 25,
  34.         SQM_COL_CC => 25,
  35.         SQM_COL_BCC => 25
  36.     );
  37.  
  38.     /**
  39.      * Calculate the width of the subject column based on the
  40.      * widths of the other columns
  41.      */
  42.     if (isset($aOrder[SQM_COL_SUBJ])) {
  43.         foreach($aOrder as $iCol{
  44.             if ($iCol != SQM_COL_SUBJ{
  45.                 $aWidthTpl[SQM_COL_SUBJ-= $aWidthTpl[$iCol];
  46.             }
  47.         }
  48.     }
  49.     foreach($aOrder as $iCol{
  50.         $aWidth[$iCol$aWidthTpl[$iCol];
  51.     }
  52.  
  53.     $iCheckTotalWidth $iTotalWidth 0;
  54.     foreach($aOrder as $iCol$iTotalWidth += $aWidth[$iCol];}
  55.  
  56.     $iTotalWidth ($iTotalWidth$iTotalWidth 100// divide by zero check. shouldn't be needed
  57.     // correct the width to 100%
  58.     foreach($aOrder as $iCol{
  59.         $aWidth[$iColround( (100 $iTotalWidth$aWidth[$iCol0);
  60.         $iCheckTotalWidth += $aWidth[$iCol];
  61.     }
  62.     if ($iCheckTotalWidth 100// correction needed
  63.        $iCol array_search(max($aWidth),$aWidth);
  64.        $aWidth[$iCol-= $iCheckTotalWidth-100;
  65.     }
  66.     return $aWidth;
  67. }
  68.  
  69. /**
  70.  * Function to retrieve correct icon based on provided message flags.  This is
  71.  * a merge/replacement for getFlagIcon() and getFlagText() functions.
  72.  * 
  73.  * @param array $aFlags associative array with seen,deleted,anwered and flag keys.
  74.  * @param string $icon_theme_path path to user's currently selected icon theme.
  75.  * @return string $icon full HTML img tag or text icon, depending on of user prefs
  76.  * @author Steve Brown
  77.  */
  78. function getFlagIcon ($aFlags$icon_theme_path{
  79.     /**
  80.      * 0  = unseen
  81.      * 1  = seen
  82.      * 2  = deleted
  83.      * 3  = deleted seen
  84.      * 4  = answered
  85.      * 5  = answered seen
  86.      * 6  = answered deleted
  87.      * 7  = answered deleted seen
  88.      * 8  = flagged
  89.      * 9  = flagged seen
  90.      * 10 = flagged deleted
  91.      * 11 = flagged deleted seen
  92.      * 12 = flagged answered
  93.      * 13 = flagged aswered seen
  94.      * 14 = flagged answered deleted
  95.      * 15 = flagged anserwed deleted seen
  96.      */
  97.  
  98.     /**
  99.      * Use static vars to avoid initialisation of the array on each displayed row
  100.      */
  101.     static $flag_icons$flag_values;
  102.     if (!isset($flag_icons)) {
  103.         // This is by no means complete...
  104.         $flag_icons array (   //     Image icon name               Text Icon  Alt/Title Text
  105.                                 array ('msg_new.png',                '&nbsp;',  '('._("New").')',
  106.                                 array ('msg_read.png',               '&nbsp;',  '('._("Read").')'),
  107.                                 array ('msg_new_deleted.png',        _("D"),    '('._("Deleted").')'),
  108.                                 array ('msg_read_deleted.png',       _("D"),    '('._("Deleted").')'),
  109.                                 array ('msg_new_reply.png',          _("A"),    '('._("Answered").')'),
  110.                                 array ('msg_read_reply.png',         _("A"),    '('._("Answered").')'),
  111.                                 array ('msg_read_deleted_reply.png'_("D"),    '('._("Answered").')'),
  112.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  113.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  114.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  115.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  116.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  117.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  118.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  119.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')'),
  120.                                 array ('flagged.png',                _("F"),    '('._("Flagged").')')
  121.                             );
  122.         
  123.         $flag_values array('seen'     => 1,
  124.                              'deleted'  => 2,
  125.                              'answered' => 4,
  126.                              'flagged'  => 8,
  127.                              'draft'    => 16);
  128.     }
  129.  
  130.     /**
  131.      * The flags entry contain all items displayed in the flag column.
  132.      */
  133.     $icon '';
  134.  
  135.     $index 0;
  136.     foreach ($aFlags as $flag => $flagvalue{
  137.          switch ($flag{
  138.             case 'deleted':
  139.             case 'answered':
  140.             case 'seen':
  141.             case 'flagged'if ($flagvalue$index += $flag_values[$flag]break;
  142.             defaultbreak;
  143.         }
  144.     }
  145.     
  146.     if (isset($flag_icons[$index])) {
  147.         $data $flag_icons[$index];
  148.     else {
  149.         $data end($flag_icons);
  150.     }
  151.  
  152.     $icon getIcon($icon_theme_path$data[0]$data[1]$data[2]);
  153.     return $icon;
  154. }
  155.  
  156.  
  157. /**
  158.  * Function to retrieve correct priority icon based on user prefs
  159.  * 
  160.  * @param integer $priority priority value of message
  161.  * @param string $icon_theme_path path to user's currently selected icon theme.
  162.  * @return string $icon full HTML img tag or text icon, depending on of user prefs
  163.  * @author Steve Brown
  164.  */
  165. function getPriorityIcon ($priority$icon_theme_path{
  166.     $icon '';
  167.  
  168.     switch ($priority{
  169.         case 1:
  170.         case 2:
  171.             $icon getIcon($icon_theme_path'prio_high.png''<span class="high_priority">!</span>');
  172.             break;
  173.         case 5:
  174.             $icon getIcon($icon_theme_path'prio_low.png''<span class="low_priority">&#8595;</span>');
  175.             break;
  176.         default:
  177.             $icon getIcon($icon_theme_path'transparent.png'''''5);
  178.             break;
  179.     }
  180.     
  181.     return $icon;
  182. }
  183.  
  184. /**
  185.  * Function to retrieve correct attchment icon based on user prefs
  186.  * 
  187.  * @param boolean $attach TRUE if the message has an attachment
  188.  * @param string $icon_theme_path path to user's currently selected icon theme.
  189.  * @return string $icon full HTML img tag or text icon, depending on of user prefs
  190.  * @author Steve Brown
  191.  */
  192. function getAttachmentIcon ($attach$icon_theme_path{
  193.     $icon '';
  194.     
  195.     $icon_file $attach 'attach.png' 'transparent.png';
  196.     $text $attach '+' '';
  197.     $icon getIcon($icon_theme_path$icon_file$text);
  198.  
  199.     return $icon;
  200. }

Documentation generated on Sat, 07 Oct 2006 16:14:05 +0300 by phpDocumentor 1.3.0RC6