diff --git a/admin/common-zh-simplified-utf-8.lang.php b/admin/common-zh-simplified-utf-8.lang.php index d2cfc1c..6bafc39 100644 --- a/admin/common-zh-simplified-utf-8.lang.php +++ b/admin/common-zh-simplified-utf-8.lang.php @@ -70,6 +70,8 @@ $strings = array( => '建议参考', 'GC' => 'GC', + 'Total' + => '总共', 'Cache' => '缓冲区', 'Caches' diff --git a/admin/common-zh-traditional-utf-8.lang.php b/admin/common-zh-traditional-utf-8.lang.php index c9724ce..d536c42 100644 --- a/admin/common-zh-traditional-utf-8.lang.php +++ b/admin/common-zh-traditional-utf-8.lang.php @@ -70,6 +70,8 @@ $strings = array( => '建議參考', 'GC' => 'GC', + 'Total' + => '总共', 'Cache' => '快取', 'Caches' diff --git a/admin/xcache.css b/admin/xcache.css index eaa5065..2a0c82f 100644 --- a/admin/xcache.css +++ b/admin/xcache.css @@ -17,17 +17,15 @@ th { font-size: 12px; } .moduleinfo .v {background-color: #cccccc; color: #000000;} .button { } span.sortarrow { color: white; text-decoration: none; } -.freeblocks { float: left; margin-right: 4px;} -.freeblocks td { text-align: right; } form {margin: 0; padding: 0} .percent { height: 3px; margin-bottom: 1px; background: gray; border: 1px solid gray; border-top: 0px; border-bottom: 0px; } .percent div { float: left; height: 100%; } .percent .pavail { background: green; } -.usagegraph { height: 16px; } -.usagegraph div { float: left; height: 3px; width: 4px; border: solid gray; border-width: 0 0px 1px 0; } -.usagegraph { border: 1px solid gray; border-bottom: 0px; } +.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; } .switcher, h1, h2 { text-align: center; display: block; } .switcher * { color: blue; } diff --git a/admin/xcache.php b/admin/xcache.php index 400707b..de15cf8 100644 --- a/admin/xcache.php +++ b/admin/xcache.php @@ -168,7 +168,15 @@ function processClear() if (isset($type)) { $cacheid = (int) (isset($_POST['cacheid']) ? $_POST['cacheid'] : 0); if (isset($_POST['clearcache'])) { - xcache_clear_cache($type, $cacheid); + $count = xcache_count($type); + if ($cacheid == $count) { + for ($cacheid = 0; $cacheid < $count; $cacheid ++) { + xcache_clear_cache($type, $cacheid); + } + } + else { + xcache_clear_cache($type, $cacheid); + } } } } @@ -176,6 +184,7 @@ processClear(); // }}} // {{{ load info/list $cacheinfos = array(); +$total = array(); for ($i = 0; $i < $pcnt; $i ++) { $data = xcache_info(XC_TYPE_PHP, $i); if ($type === XC_TYPE_PHP) { @@ -185,7 +194,35 @@ for ($i = 0; $i < $pcnt; $i ++) { $data['cache_name'] = "php#$i"; $data['cacheid'] = $i; $cacheinfos[] = $data; + if ($pcnt >= 2) { + foreach ($data as $k => $v) { + switch ($k) { + case 'type': + case 'cache_name': + case 'cacheid': + case 'free_blocks': + continue 2; + } + if (!isset($total[$k])) { + $total[$k] = $v; + } + else { + $total[$k] += $v; + } + } + } +} + +if ($pcnt >= 2) { + $total['type'] = XC_TYPE_PHP; + $total['cache_name'] = _T('Total'); + $total['cacheid'] = $pcnt; + $total['gc'] = null; + $total['istotal'] = true; + $cacheinfos[] = $total; } + +$total = array(); for ($i = 0; $i < $vcnt; $i ++) { $data = xcache_info(XC_TYPE_VAR, $i); if ($type === XC_TYPE_VAR) { @@ -195,6 +232,33 @@ for ($i = 0; $i < $vcnt; $i ++) { $data['cache_name'] = "var#$i"; $data['cacheid'] = $i; $cacheinfos[] = $data; + if ($pcnt >= 2) { + foreach ($data as $k => $v) { + switch ($k) { + case 'type': + case 'cache_name': + case 'cacheid': + case 'free_blocks': + case 'gc': + continue 2; + } + if (!isset($total[$k])) { + $total[$k] = $v; + } + else { + $total[$k] += $v; + } + } + } +} + +if ($vcnt >= 2) { + $total['type'] = XC_TYPE_VAR; + $total['cache_name'] = _T('Total'); + $total['cacheid'] = $vcnt; + $total['gc'] = null; + $total['istotal'] = true; + $cacheinfos[] = $total; } // }}} // {{{ merge the list @@ -209,6 +273,9 @@ case XC_TYPE_VAR: $cachelist['type_name'] = 'php'; } foreach ($cacheinfos as $i => $c) { + if (!empty($c['istotal'])) { + continue; + } if ($c['type'] == $type && isset($c['cache_list'])) { foreach ($c['cache_list'] as $e) { $e['cache_name'] = $c['cache_name']; diff --git a/admin/xcache.tpl.php b/admin/xcache.tpl.php index 8dc8f19..0d4940e 100644 --- a/admin/xcache.tpl.php +++ b/admin/xcache.tpl.php @@ -50,16 +50,28 @@ $b = new Cycle('class="col1"', 'class="col2"'); $pavail = (int) ($ci['avail'] / $ci['size'] * 100); $pused = 100 - $pavail; - $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']); $w = $free_graph_width; $tdwidth = $w + 2; + if (empty($ci['istotal'])) { + $graph = freeblock_to_graph($ci['free_blocks'], $ci['size']); + $freeblockgraph = "
{$graph}
"; + } + else { + $freeblockgraph = ''; + } $ci_slots = size($ci['slots']); $ci_size = size($ci['size']); $ci_avail = size($ci['avail']); $ci = number_formats($ci, $numkeys); - $ci['compiling'] = $ci['type'] == $type_php ? ($ci['compiling'] ? 'yes' : 'no') : '-'; - $ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no'; + if (!empty($ci['istotal'])) { + $ci['compiling'] = '-'; + $ci['can_readonly'] = '-'; + } + else { + $ci['compiling'] = $ci['type'] == $type_php ? ($ci['compiling'] ? 'yes' : 'no') : '-'; + $ci['can_readonly'] = $ci['can_readonly'] ? 'yes' : 'no'; + } echo <<{$ci['cache_name']} {$ci_slots} @@ -70,8 +82,7 @@ $b = new Cycle('class="col1"', 'class="col2"'); >
{$graph}
+ >{$freeblockgraph}