Changeset 526 in svn


Ignore:
Timestamp:
2008-02-18T14:28:31+01:00 (7 years ago)
Author:
Xuefer
Message:

allow user decide to show used or free blocks/percent

Location:
trunk/admin
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/common-zh-simplified-utf-8.lang.php

    r522 r526  
    2424        'Compiling'
    2525        => '编译中',
    26         '%'
    27         => '%',
     26        '% Free'
     27        => '% 剩余',
     28        '% Used'
     29        => '% 已用',
    2830        'Hits'
    2931        => '命中',
  • trunk/admin/common-zh-traditional-utf-8.lang.php

    r522 r526  
    2424        'Compiling'
    2525        => '編譯中',
    26         '%'
    27         => '%',
     26        '% Free'
     27        => '% 剩余',
     28        '% Used'
     29        => '% 已用',
    2830        'Hits'
    2931        => '命中',
  • trunk/admin/common.php

    r517 r526  
    109109    $lang = 'en-us';
    110110}
    111 if (!isset($free_graph_width)) {
    112     $free_graph_width = 120;
     111if (!isset($usage_graph_width) && !isset($free_graph_width)) {
     112    $usage_graph_width = 120;
    113113}
     114$graph_width = isset($free_graph_width) ? $free_graph_width : $usage_graph_width;
    114115
    115116?>
  • trunk/admin/config.php.example

    r523 r526  
    1212$show_todo_strings = false;
    1313
    14 // width of graph for free blocks
    15 $free_graph_width = 120;
     14// width of graph for free or usage blocks
     15$usage_graph_width = 120;
     16// do not define both with
     17// $free_graph_width = 120;
    1618
    1719// this function is detected by xcache.tpl.php, and enabled if function_exists
  • trunk/admin/xcache.css

    r522 r526  
    2020form {margin: 0; padding: 0}
    2121
    22 .percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; border-top: 0px; border-bottom: 0px; }
     22.percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; }
    2323.percent div { float: left; height: 100%; }
    24 .percent .pavail { background: green; }
     24.percent .pvalue { background: limegreen; }
    2525
    26 .freeblockgraph { height: 16px; }
    27 .freeblockgraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
    28 .freeblockgraph { border: 1px solid gray; border-bottom: 0px; }
     26.blocksgraph { height: 16px; }
     27.blocksgraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
     28.blocksgraph { border: 1px solid gray; border-bottom: 0px; }
    2929
    3030.hitsgraph { height: 20px; border: solid gray; border-width: 1px 0 1px 0; margin: auto; }
  • trunk/admin/xcache.php

    r522 r526  
    7777function freeblock_to_graph($freeblocks, $size)
    7878{
    79     global $free_graph_width;
     79    global $graph_width, $usage_graph_width, $free_graph_width;
    8080
    8181    // cached in static variable
    8282    static $graph_initial;
    8383    if (!isset($graph_initial)) {
    84         for ($i = 0; $i < $free_graph_width; $i ++) {
    85             $graph_initial[$i] = 0;
    86         }
     84        $graph_initial = array_fill(0, $graph_width, 0);
    8785    }
    8886    $graph = $graph_initial;
    8987    foreach ($freeblocks as $b) {
    90         $begin = $b['offset'] / $size * $free_graph_width;
    91         $end = ($b['offset'] + $b['size']) / $size * $free_graph_width;
     88        $begin = $b['offset'] / $size * $graph_width;
     89        $end = ($b['offset'] + $b['size']) / $size * $graph_width;
    9290
    9391        if ((int) $begin == (int) $end) {
     
    106104    $c = 255;
    107105    foreach ($graph as $k => $v) {
     106        if (!isset($free_graph_width)) {
     107            $v = 1 - $v;
     108        }
    108109        $v = (int) ($v * $c);
    109110        $r = $g = $c - $v;
  • trunk/admin/xcache.tpl.php

    r522 r526  
    3131        <th><?php echo _T('Size'); ?></th>
    3232        <th><?php echo _T('Avail'); ?></th>
    33         <th><?php echo _T('%'); ?></th>
     33        <th><?php echo _T(isset($free_graph_width) ? '% Free' : '% Used'); ?></th>
    3434        <th><?php echo _T('Clear'); ?></th>
    3535        <th><?php echo _T('Compiling'); ?></th>
     
    5454        echo "
    5555        <tr ", $a->next(), ">";
    56         $pavail = (int) ($ci['avail'] / $ci['size'] * 100);
    57         $pused = 100 - $pavail;
    58 
    59         $w = $free_graph_width;
     56        $pvalue = (int) ($ci['avail'] / $ci['size'] * 100);
     57        $pempty = 100 - $pvalue;
     58        if (!isset($free_graph_width)) {
     59            // swap
     60            $tmp = $pvalue;
     61            $pvalue = $pempty;
     62            $pempty = $tmp;
     63        }
     64
     65        $w = $graph_width;
    6066        $tdwidth = $w + 2;
    6167        if (empty($ci['istotal'])) {
    6268            $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
    63             $freeblockgraph = "<div class=\"freeblockgraph\" style=\"width: {$w}px\">{$graph}</div>";
     69            $blocksgraph = "<div class=\"blocksgraph\" style=\"width: {$w}px\">{$graph}</div>";
    6470        }
    6571        else {
    66             $freeblockgraph = '';
     72            $blocksgraph = '';
    6773        }
    6874
     
    9096        <td title="{$ci['size']}">{$ci_size}</td>
    9197        <td title="{$ci['avail']}">{$ci_avail}</td>
    92         <td title="{$pavail} %" width="{$tdwidth}"
     98        <td title="{$pvalue} %" width="{$tdwidth}"
    9399            ><div class="percent" style="width: {$w}px"
    94                 ><div style="width: {$pavail}%" class="pavail"></div
    95                 ><div style="width: {$pused}%" class="pused"></div
     100                ><div style="width: {$pvalue}%" class="pvalue"></div
     101                ><div style="width: {$pempty}%" class="pempty"></div
    96102            ></div
    97         >{$freeblockgraph}</td>
     103        >{$blocksgraph}</td>
    98104        <td
    99105            ><form method="post"
Note: See TracChangeset for help on using the changeset viewer.