Changeset 1074 in svn for trunk


Ignore:
Timestamp:
2012-07-29T05:06:57Z (3 years ago)
Author:
Xuefer
Message:

htdocs: split template

Location:
trunk/htdocs/cacher
Files:
3 added
2 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/cacher/cacher-zh-simplified.lang.php

    r1069 r1074  
    4848        'var Deleted'
    4949        => '待删变量',
    50         'Statistics'
    51         => '统计信息',
     50        'Summary'
     51        => '摘要信息',
    5252        'List PHP'
    5353        => '列出PHP',
  • trunk/htdocs/cacher/cacher-zh-traditional.lang.php

    r1069 r1074  
    4848        'var Deleted'
    4949        => '待刪變數',
    50         'Statistics'
    51         => '統計訊息',
     50        'Summary'
     51        => '簡要訊息',
    5252        'List PHP'
    5353        => '列出PHP',
  • trunk/htdocs/cacher/index.php

    r1069 r1074  
    114114    }
    115115    return implode('', $html);
     116}
     117
     118function getModuleInfo()
     119{
     120    ob_start();
     121    phpinfo(INFO_MODULES);
     122    $moduleInfo = ob_get_clean();
     123    if (!preg_match_all('!(XCache[^<>]*)</a></h2>(.*?)<h2>!is', $moduleInfo, $m)) {
     124        return;
     125    }
     126
     127    $moduleInfo = array();
     128    foreach ($m[1] as $i => $dummy) {
     129        $moduleInfo[] = '<h3>' . trim($m[1][$i]) . '</h3>';
     130        $moduleInfo[] = str_replace('<br />', '', trim($m[2][$i]));
     131    }
     132    return implode('', $moduleInfo);
    116133}
    117134
     
    156173}
    157174
    158 $moduleinfo = null;
    159 $type_none = -1;
    160 if (!isset($_GET['type'])) {
    161     $_GET['type'] = $type_none;
    162 }
    163 $_GET['type'] = $type = (int) $_GET['type'];
     175$listTypes = array('' => _('Summary'), 'listphp' => _('List PHP'), 'listvar' => _('List Var Data'));
     176
     177if (!isset($_GET['do'])) {
     178    $_GET['do'] = '';
     179}
    164180
    165181// {{{ process clear, enable, disable
     
    194210for ($i = 0; $i < $pcnt; $i ++) {
    195211    $data = xcache_info(XC_TYPE_PHP, $i);
    196     if ($type === XC_TYPE_PHP) {
     212    if ($_GET['do'] === 'listphp') {
    197213        $data += xcache_list(XC_TYPE_PHP, $i);
    198214    }
     
    220236for ($i = 0; $i < $vcnt; $i ++) {
    221237    $data = xcache_info(XC_TYPE_VAR, $i);
    222     if ($type === XC_TYPE_VAR) {
     238    if ($_GET['do'] === 'listvar') {
    223239        $data += xcache_list(XC_TYPE_VAR, $i);
    224240    }
     
    243259// }}}
    244260// {{{ merge the list
    245 switch ($type) {
    246 case XC_TYPE_PHP:
    247 case XC_TYPE_VAR:
    248     $cachelist = array('type' => $type, 'cache_list' => array(), 'deleted_list' => array());
    249     if ($type == XC_TYPE_VAR) {
     261switch ($_GET['do']) {
     262case 'listphp':
     263case 'listvar':
     264    $cachelist = array('cache_list' => array(), 'deleted_list' => array());
     265    if ($_GET['do'] == 'listphp') {
     266        $cachelist['type_name'] = 'php';
     267        $cachelist['type'] = XC_TYPE_PHP;
     268    }
     269    else {
    250270        $cachelist['type_name'] = 'var';
    251     }
    252     else {
    253         $cachelist['type_name'] = 'php';
     271        $cachelist['type'] = XC_TYPE_VAR;
    254272    }
    255273    foreach ($cacheinfos as $i => $c) {
     
    257275            continue;
    258276        }
    259         if ($c['type'] == $type && isset($c['cache_list'])) {
     277        if ($c['type'] == $cachelist['type'] && isset($c['cache_list'])) {
    260278            foreach ($c['cache_list'] as $e) {
    261279                $e['cache_name'] = $c['cache_name'];
     
    268286        }
    269287    }
    270     if ($type == XC_TYPE_PHP) {
     288    if ($cachelist['type'] == XC_TYPE_PHP) {
    271289        $inodes = array();
    272290        $haveinode = false;
     
    287305    }
    288306    unset($data);
     307    include("./listentries.tpl.php");
    289308    break;
    290309
    291310default:
    292     $_GET['type'] = $type_none;
    293     $cachelist = array();
    294     ob_start();
    295     phpinfo(INFO_MODULES);
    296     $moduleinfo = ob_get_clean();
    297     if (preg_match_all('!(XCache[^<>]*)</a></h2>(.*?)<h2>!is', $moduleinfo, $m)) {
    298         $moduleinfo = array();
    299         foreach ($m[1] as $i => $dummy) {
    300             $moduleinfo[] = '<h3>' . trim($m[1][$i]) . '</h3>';
    301             $moduleinfo[] = str_replace('<br />', '', trim($m[2][$i]));
    302         }
    303         $moduleinfo = implode('', $moduleinfo);
    304     }
    305     else {
    306         $moduleinfo = null;
    307     }
    308     break;
     311    include("./summary.tpl.php");
    309312}
    310313// }}}
    311314
    312 $type_php = XC_TYPE_PHP;
    313 $type_var = XC_TYPE_VAR;
    314 $listTypes = array($type_none => _('Statistics'), $type_php => _('List PHP'), $type_var => _('List Var Data'));
    315 
    316 include("cacher.tpl.php");
    317 
    318315?>
  • trunk/htdocs/cacher/listentries.tpl.php

    r1072 r1074  
    11<?php include("../common/header.tpl.php"); ?>
    2 <div class="switcher"><?php echo switcher("type", $listTypes); ?></div>
    3 <div id="help">
    4     <a href="help.php"><?php echo _("Help") ?> &raquo;</a>
    5 </div>
     2<div class="switcher"><?php echo switcher("do", $listTypes); ?></div>
    63<?php
    7 include "./cacher.summary.tpl.php";
    8 if ($cachelist) {
    9     $isphp = $cachelist['type'] == $type_php;
    10     ob_start($config['path_nicer']);
    114
    12     $listName = 'Cached';
    13     $entries = $cachelist['cache_list'];
    14     include "./cacher.entrylist.tpl.php";
     5include "./sub/summary.tpl.php";
     6$isphp = $cachelist['type'] == 'listphp';
     7ob_start($config['path_nicer']);
    158
    16     $listName = 'Deleted';
    17     $entries = $cachelist['deleted_list'];
    18     include "./cacher.entrylist.tpl.php";
     9$listName = 'Cached';
     10$entries = $cachelist['cache_list'];
     11include "./sub/entrylist.tpl.php";
    1912
    20     ob_end_flush();
    21     unset($isphp);
    22 }
     13$listName = 'Deleted';
     14$entries = $cachelist['deleted_list'];
     15include "./sub/entrylist.tpl.php";
    2316
    24 if ($moduleinfo) {
    25     if (ini_get("xcache.test")) {
    26 ?>
    27 <form method="post" action="">
    28     <div>
    29         <input type="submit" name="coredump" value="Test coredump" class="submit" onclick="return confirm('<?php echo _('Sure?'); ?>');" />
    30     </div>
    31 </form>
    32 <?php
    33     }
    34     $t_moduleinfo = _("Module Info");
    35     echo <<<HTML
    36 <h2>$t_moduleinfo</h2>
    37 <div class="phpinfo">$moduleinfo</div>
    38 HTML;
    39 }
     17ob_end_flush();
     18unset($isphp);
     19
    4020?>
    4121<?php include("../common/footer.tpl.php"); ?>
  • trunk/htdocs/cacher/sub/summary.tpl.php

    r1072 r1074  
    7575                    . sprintf("(%s)", age($ci['disabled']));
    7676            }
    77             else if ($ci['type'] == $type_php) {
     77            else if ($ci['type'] == XC_TYPE_PHP) {
    7878                $ci['status'] = $ci['compiling']
    7979                    ? $l_compiling . sprintf("(%s)", age($ci['compiling']))
Note: See TracChangeset for help on using the changeset viewer.