Changeset fda695f in github


Ignore:
Timestamp:
Sep 1, 2006 1:14:51 PM (7 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
bf04525
Parents:
5cd296d
Message:

Finalized quota image

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_imap.inc

    r3ea0e32 rfda695f  
    14641464    { 
    14651465    if ($this->get_capability('QUOTA')) 
    1466       return array('total' => 2048 * 1024, 'used' => 500 * 1024, 'percent' => 32); //iil_C_GetQuota($this->conn); 
     1466      return iil_C_GetQuota($this->conn); 
    14671467         
    14681468    return FALSE; 
  • program/steps/mail/func.inc

    r3ea0e32 rfda695f  
    634634    if ($attrib['display'] == 'image' && function_exists('imagegif')) 
    635635      { 
    636       $quota_text = sprintf('<img src="%s&amp;_action=quotaimg&amp;u=%s&amp;q=%d" alt="%s" width="102" height="15" />', 
     636      $attrib += array('width' => 100, 'height' => 14); 
     637      $quota_text = sprintf('<img src="%s&amp;_action=quotaimg&amp;u=%s&amp;q=%d&amp;w=%d&amp;h=%d" width="%d" height="%d" alt="%s" title="%s / %s" />', 
    637638                            $COMM_PATH, 
    638639                            $quota['used'], $quota['total'], 
    639                             $quota_text); 
     640                            $attrib['width'], $attrib['height'], 
     641                            $attrib['width'], $attrib['height'], 
     642                            $quota_text, 
     643                            show_bytes($quota["used"] * 1024), 
     644                            show_bytes($quota["total"] * 1024)); 
    640645      } 
    641646    } 
  • program/steps/mail/quotaimg.inc

    r3ea0e32 rfda695f  
    2222$used  = ((isset($_GET['u']) && !empty($_GET['u'])) || $_GET['u']=='0')?(int)$_GET['u']:'??'; 
    2323$quota = ((isset($_GET['q']) && !empty($_GET['q'])) || $_GET['q']=='0')?(int)$_GET['q']:'??'; 
     24$width = empty($_GET['w']) ? 100 : (int)$_GET['w']; 
     25$height = empty($_GET['h']) ? 14 : (int)$_GET['h']; 
    2426 
    25  
    26 function genQuota($used, $total) 
     27function genQuota($used, $total, $width, $height) 
    2728{ 
    2829        /** 
     
    5354 
    5455        $unknown = false; 
    55         $border = true; 
     56        $border = 0; 
    5657 
    57         $height = 15; 
    58         $width = 102; 
    5958        $font = 2; 
    60         $padding = 1; 
     59        $padding = 0; 
    6160 
    6261        $limit['high'] = 70; 
     
    6564 
    6665        // Fill Colors 
    67         $color['fill']['high'] = '227, 23, 13'; // Near quota fill color 
     66        $color['fill']['high'] = '215, 13, 13'; // Near quota fill color 
    6867        $color['fill']['mid'] = '126, 192, 238';// Mid-area of quota fill color 
    69         $color['fill']['low'] = '50, 205, 50';  // Far from quota fill color 
     68        $color['fill']['low'] = '147, 225, 100';        // Far from quota fill color 
    7069 
    7170        // Background colors 
    72         $color['bg']['OL'] = '238, 99, 99';             // Over limit bbackground 
     71        $color['bg']['OL'] = '215, 13, 13';             // Over limit bbackground 
    7372        $color['bg']['Unknown'] = '238, 99, 99';// Unknown background 
    7473        $color['bg']['quota'] = '255, 255, 255';// Normal quota background 
     
    7675        // Misc. Colors 
    7776        $color['border'] = '0, 0, 0'; 
    78         $color['text'] = '0, 0, 0'; 
     77        $color['text'] = '102, 102, 102'; 
    7978 
    8079 
     
    9291                } 
    9392 
     93        $im = imagecreate($width, $height); 
     94 
     95        if($border) 
     96                { 
     97                list($r, $g, $b) = explode(',', $color['border']); 
     98                $borderc = imagecolorallocate($im, $r, $g, $b); 
     99                imageline($im, 0, 0, $width, 0, $borderc); 
     100                imageline($im, 0, $height-$border, 0, 0, $borderc); 
     101                imageline($im, $width-1, 0, $width-$border, $height, $borderc); 
     102                imageline($im, $width, $height-$border, 0, $height-$border, $borderc); 
     103                } 
     104                 
     105        list($r, $g, $b) = explode(',', $color['text']); 
     106        $text = imagecolorallocate($im, $r, $g, $b); 
     107 
    94108        if($unknown) 
    95109                { 
    96                 $im = imagecreate($width, $height); 
    97110                list($r, $g, $b) = explode(',', $color['bg']['Unknown']); 
    98111                $background = imagecolorallocate($im, $r, $g, $b); 
    99                 list($r, $g, $b) = explode(',', $color['text']); 
    100                 $text = imagecolorallocate($im, $r, $g, $b); 
     112                imagefilledrectangle($im, 0, 0, $width, $height, $background); 
    101113 
    102                 if($border) 
     114                $string = 'Unknown'; 
     115                $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1; 
     116                imagestring($im, $font, $mid, $padding, $string, $text); 
     117                } 
     118        else if($used > $total) 
     119                { 
     120                list($r, $g, $b) = explode(',', $color['bg']['OL']); 
     121                $background = imagecolorallocate($im, $r, $g, $b); 
     122                imagefilledrectangle($im, 0, 0, $width, $height, $background); 
     123 
     124                $string = 'Over Limit'; 
     125                $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1; 
     126                imagestring($im, $font, $mid, $padding, $string, $text); 
     127                } 
     128        else 
     129                { 
     130                list($r, $g, $b) = explode(',', $color['bg']['quota']); 
     131                $background = imagecolorallocate($im, $r, $b, $g); 
     132                imagefilledrectangle($im, 0, 0, $width, $height, $background); 
     133                 
     134                $quota = ($used==0)?0:(round($used/$total, 2)*100); 
     135 
     136                if($quota >= $limit['high']) 
    103137                        { 
    104                         list($r, $g, $b) = explode(',', $color['border']); 
    105                         $border = imagecolorallocate($im, $r, $g, $b); 
    106                         imageline($im, 0, 0, $width, 0, $border); 
    107                         imageline($im, 0, $height-1, 0, 0, $border); 
    108                         imageline($im, $width-1, 0, $width-1, $height, $border); 
    109                         imageline($im, $width, $height-1, 0, $height-1, $border); 
     138                        list($r, $g, $b) = explode(',', $color['fill']['high']); 
     139                        $fill = imagecolorallocate($im, $r, $g, $b); 
     140                        } 
     141                elseif($quota >= $limit['mid']) 
     142                        { 
     143                        list($r, $g, $b) = explode(',', $color['fill']['mid']); 
     144                        $fill = imagecolorallocate($im, $r, $g, $b); 
     145                        } 
     146                else // if($quota >= $limit['low']) 
     147                        { 
     148                        list($r, $g, $b) = explode(',', $color['fill']['low']); 
     149                        $fill = imagecolorallocate($im, $r, $g, $b); 
    110150                        } 
    111151 
    112                 $string = 'Unknown'; 
     152                $quota_width = $quota / 100 * $width; 
     153                imagefilledrectangle($im, $border, 0, $quota, $height-2*$border, $fill); 
    113154 
    114                 $mid = floor((100-(strlen($string)*imagefontwidth($font)))/2)+1; 
    115  
    116                 imagestring($im, $font, $mid, $padding, $string, $text); 
    117                 header('Content-type: image/gif'); 
    118                 imagegif($im); 
    119                 imagedestroy($im); 
    120                 exit; 
     155                $string = $quota.'%'; 
     156                $mid = floor(($width-(strlen($string)*imagefontwidth($font)))/2)+1; 
     157                imagestring($im, $font, $mid, $padding, $string, $text); // Print percent in black 
    121158                } 
    122159 
    123         if($used > $total) 
    124                 { 
    125                 $im = imagecreate($width, $height); 
    126                 list($r, $g, $b) = explode(',', $color['bg']['OL']); 
    127                 $background = imagecolorallocate($im, $r, $g, $b); 
    128                 list($r, $g, $b) = explode(',', $color['text']); 
    129                 $text = imagecolorallocate($im, $r, $g, $b); 
    130                 list($r, $g, $b) = explode(',', $color['border']); 
    131                 $border = imagecolorallocate($im, $r, $g, $b); 
    132  
    133                 imageline($im, 0, 0, $width, 0, $border); 
    134                 imageline($im, 0, $height-1, 0, 0, $border); 
    135                 imageline($im, $width-1, 0, $width-1, $height, $border); 
    136                 imageline($im, $width, $height-1, 0, $height-1, $border); 
    137  
    138                 $string = 'Over Limit'; 
    139  
    140                 $mid = floor((100-(strlen($string)*imagefontwidth($font)))/2)+1; 
    141  
    142                 imagestring($im, $font, $mid, $padding, $string, $text); 
    143  
    144                 header('Content-type: image/gif'); 
    145                 imagegif($im); 
    146                 exit; 
    147                 } 
    148  
    149         $quota = ($used==0)?0:(round($used/$total, 2)*100); 
    150  
    151         $im = imagecreate($width, $height); 
    152         list($r, $g, $b) = explode(',', $color['bg']['quota']); 
    153         $background = imagecolorallocate($im, $r, $b, $g); 
    154         list($r, $g, $b) = explode(',', $color['border']); 
    155         $border = imagecolorallocate($im, $r, $g, $b); 
    156         list($r, $g, $b) = explode(',', $color['text']); 
    157         $text = imagecolorallocate($im, $r, $g, $b); 
    158         if($quota >= $limit['high']) 
    159                 { 
    160                 list($r, $g, $b) = explode(',', $color['fill']['high']); 
    161                 $fill = imagecolorallocate($im, $r, $g, $b); 
    162                 } 
    163         elseif($quota >= $limit['mid']) 
    164                 { 
    165                 list($r, $g, $b) = explode(',', $color['fill']['mid']); 
    166                 $fill = imagecolorallocate($im, $r, $g, $b); 
    167                 } 
    168         else // if($quota >= $limit['low']) 
    169                 { 
    170                 list($r, $g, $b) = explode(',', $color['fill']['low']); 
    171                 $fill = imagecolorallocate($im, $r, $g, $b); 
    172                 } 
    173  
    174  
    175         imagefilledrectangle($im, 1, 0, $quota, $height-2, $fill); 
    176  
    177  
    178         imageline($im, 0, 0, $width-2, 0, $border); 
    179         imageline($im, $width-2, 0, $width-2, $height, $border); 
    180         imageline($im, $width-2, $height-1, 0, $height-1, $border); 
    181         imageline($im, 0, $height, 0, 0, $border); 
    182  
    183  
    184         $string = $quota.'%'; 
    185         $mid = floor((100-(strlen($string)*imagefontwidth($font)))/2)+1; 
    186         imagestring($im, $font, $mid, $padding, $string, $text); // Print percent in black 
    187  
    188160        header('Content-Type: image/gif'); 
     161    header("Expires: ".gmdate("D, d M Y H:i:s", mktime()+86400)." GMT"); 
     162        header("Cache-Control: "); 
     163        header("Pragma: "); 
     164         
    189165        imagegif($im); 
    190166        imagedestroy($im); 
     
    192168 
    193169 
    194 genQuota($used, $quota); 
     170genQuota($used, $quota, $width, $height); 
    195171exit; 
    196172?> 
  • skins/default/mail.css

    r3ea0e32 rfda695f  
    565565{ 
    566566  vertical-align: middle; 
    567   padding-left: 4px; 
     567  margin-left: 4px; 
     568  border: 1px solid #666666; 
    568569} 
    569570 
  • skins/default/templates/mail.html

    r3ea0e32 rfda695f  
    5858<roundcube:button command="select-all" prop="unread" label="unread" classAct="active" />&nbsp; 
    5959<roundcube:button command="select-none" label="none" classAct="active" /> &nbsp;&nbsp;&nbsp; 
    60 <roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="text" id="quotadisplay" /> 
     60<roundcube:label name="quota" />: <roundcube:object name="quotaDisplay" display="image" width="120" id="quotadisplay" /> 
    6161</div> 
    6262 
Note: See TracChangeset for help on using the changeset viewer.