allow user decide to show used or free blocks/percent
git-svn-id: svn://svn.lighttpd.net/xcache/trunk@526 c26eb9a1-5813-0410-bd6c-c2e55f420ca73.0
parent
0a501c0fd4
commit
fe7a0393ac
|
@ -23,8 +23,10 @@ $strings = array(
|
|||
=> '确认要清除吗?',
|
||||
'Compiling'
|
||||
=> '编译中',
|
||||
'%'
|
||||
=> '%',
|
||||
'% Free'
|
||||
=> '% 剩余',
|
||||
'% Used'
|
||||
=> '% 已用',
|
||||
'Hits'
|
||||
=> '命中',
|
||||
'Hits 24H'
|
||||
|
|
|
@ -23,8 +23,10 @@ $strings = array(
|
|||
=> '確認要清除嗎?',
|
||||
'Compiling'
|
||||
=> '編譯中',
|
||||
'%'
|
||||
=> '%',
|
||||
'% Free'
|
||||
=> '% 剩余',
|
||||
'% Used'
|
||||
=> '% 已用',
|
||||
'Hits'
|
||||
=> '命中',
|
||||
'Hits 24H'
|
||||
|
|
|
@ -108,8 +108,9 @@ include(get_language_file("common"));
|
|||
if (!isset($lang)) {
|
||||
$lang = 'en-us';
|
||||
}
|
||||
if (!isset($free_graph_width)) {
|
||||
$free_graph_width = 120;
|
||||
if (!isset($usage_graph_width) && !isset($free_graph_width)) {
|
||||
$usage_graph_width = 120;
|
||||
}
|
||||
$graph_width = isset($free_graph_width) ? $free_graph_width : $usage_graph_width;
|
||||
|
||||
?>
|
||||
|
|
|
@ -11,8 +11,10 @@ $charset = "UTF-8";
|
|||
// developers only
|
||||
$show_todo_strings = false;
|
||||
|
||||
// width of graph for free blocks
|
||||
$free_graph_width = 120;
|
||||
// width of graph for free or usage blocks
|
||||
$usage_graph_width = 120;
|
||||
// do not define both with
|
||||
// $free_graph_width = 120;
|
||||
|
||||
// this function is detected by xcache.tpl.php, and enabled if function_exists
|
||||
// this ob filter is applied for the cache list, not the whole page
|
||||
|
|
|
@ -19,13 +19,13 @@ th { font-size: 12px; }
|
|||
span.sortarrow { color: white; text-decoration: none; }
|
||||
form {margin: 0; padding: 0}
|
||||
|
||||
.percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; border-top: 0px; border-bottom: 0px; }
|
||||
.percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; }
|
||||
.percent div { float: left; height: 100%; }
|
||||
.percent .pavail { background: green; }
|
||||
.percent .pvalue { background: limegreen; }
|
||||
|
||||
.freeblockgraph { height: 16px; }
|
||||
.freeblockgraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
|
||||
.freeblockgraph { border: 1px solid gray; border-bottom: 0px; }
|
||||
.blocksgraph { height: 16px; }
|
||||
.blocksgraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; }
|
||||
.blocksgraph { border: 1px solid gray; border-bottom: 0px; }
|
||||
|
||||
.hitsgraph { height: 20px; border: solid gray; border-width: 1px 0 1px 0; margin: auto; }
|
||||
.hitsgraph div { float: left; width: 2px; height: 100%; }
|
||||
|
|
|
@ -76,19 +76,17 @@ function age($time)
|
|||
|
||||
function freeblock_to_graph($freeblocks, $size)
|
||||
{
|
||||
global $free_graph_width;
|
||||
global $graph_width, $usage_graph_width, $free_graph_width;
|
||||
|
||||
// cached in static variable
|
||||
static $graph_initial;
|
||||
if (!isset($graph_initial)) {
|
||||
for ($i = 0; $i < $free_graph_width; $i ++) {
|
||||
$graph_initial[$i] = 0;
|
||||
}
|
||||
$graph_initial = array_fill(0, $graph_width, 0);
|
||||
}
|
||||
$graph = $graph_initial;
|
||||
foreach ($freeblocks as $b) {
|
||||
$begin = $b['offset'] / $size * $free_graph_width;
|
||||
$end = ($b['offset'] + $b['size']) / $size * $free_graph_width;
|
||||
$begin = $b['offset'] / $size * $graph_width;
|
||||
$end = ($b['offset'] + $b['size']) / $size * $graph_width;
|
||||
|
||||
if ((int) $begin == (int) $end) {
|
||||
$v = $end - $begin;
|
||||
|
@ -105,6 +103,9 @@ function freeblock_to_graph($freeblocks, $size)
|
|||
$html = array();
|
||||
$c = 255;
|
||||
foreach ($graph as $k => $v) {
|
||||
if (!isset($free_graph_width)) {
|
||||
$v = 1 - $v;
|
||||
}
|
||||
$v = (int) ($v * $c);
|
||||
$r = $g = $c - $v;
|
||||
$b = $c;
|
||||
|
|
|
@ -30,7 +30,7 @@ $b = new Cycle('class="col1"', 'class="col2"');
|
|||
<th><?php echo _T('Slots'); ?></th>
|
||||
<th><?php echo _T('Size'); ?></th>
|
||||
<th><?php echo _T('Avail'); ?></th>
|
||||
<th><?php echo _T('%'); ?></th>
|
||||
<th><?php echo _T(isset($free_graph_width) ? '% Free' : '% Used'); ?></th>
|
||||
<th><?php echo _T('Clear'); ?></th>
|
||||
<th><?php echo _T('Compiling'); ?></th>
|
||||
<th><?php echo _T('Hits'); ?></th>
|
||||
|
@ -53,17 +53,23 @@ $b = new Cycle('class="col1"', 'class="col2"');
|
|||
foreach ($cacheinfos as $i => $ci) {
|
||||
echo "
|
||||
<tr ", $a->next(), ">";
|
||||
$pavail = (int) ($ci['avail'] / $ci['size'] * 100);
|
||||
$pused = 100 - $pavail;
|
||||
$pvalue = (int) ($ci['avail'] / $ci['size'] * 100);
|
||||
$pempty = 100 - $pvalue;
|
||||
if (!isset($free_graph_width)) {
|
||||
// swap
|
||||
$tmp = $pvalue;
|
||||
$pvalue = $pempty;
|
||||
$pempty = $tmp;
|
||||
}
|
||||
|
||||
$w = $free_graph_width;
|
||||
$w = $graph_width;
|
||||
$tdwidth = $w + 2;
|
||||
if (empty($ci['istotal'])) {
|
||||
$graph = freeblock_to_graph($ci['free_blocks'], $ci['size']);
|
||||
$freeblockgraph = "<div class=\"freeblockgraph\" style=\"width: {$w}px\">{$graph}</div>";
|
||||
$blocksgraph = "<div class=\"blocksgraph\" style=\"width: {$w}px\">{$graph}</div>";
|
||||
}
|
||||
else {
|
||||
$freeblockgraph = '';
|
||||
$blocksgraph = '';
|
||||
}
|
||||
|
||||
$ci_slots = size($ci['slots']);
|
||||
|
@ -89,12 +95,12 @@ $b = new Cycle('class="col1"', 'class="col2"');
|
|||
<td title="{$ci['slots']}">{$ci_slots}</td>
|
||||
<td title="{$ci['size']}">{$ci_size}</td>
|
||||
<td title="{$ci['avail']}">{$ci_avail}</td>
|
||||
<td title="{$pavail} %" width="{$tdwidth}"
|
||||
<td title="{$pvalue} %" width="{$tdwidth}"
|
||||
><div class="percent" style="width: {$w}px"
|
||||
><div style="width: {$pavail}%" class="pavail"></div
|
||||
><div style="width: {$pused}%" class="pused"></div
|
||||
><div style="width: {$pvalue}%" class="pvalue"></div
|
||||
><div style="width: {$pempty}%" class="pempty"></div
|
||||
></div
|
||||
>{$freeblockgraph}</td>
|
||||
>{$blocksgraph}</td>
|
||||
<td
|
||||
><form method="post"
|
||||
><div
|
||||
|
|
Loading…
Reference in New Issue