Exemplo n.º 1
0
            $a->form = false;
            $a->generate_auto = false;
            $db = DB::instance();
            if (isset($rc[4])) {
                $Page->content(h::{'p.cs-test-result'}($db->test([$rc[3], $rc[4]]) ? $L->success : $L->failed));
            } elseif (isset($rc[3])) {
                $Page->content(h::{'p.cs-test-result'}($db->test([$rc[3]]) ? $L->success : $L->failed));
            } else {
                $Page->content(h::{'p.cs-test-result'}($db->test($_POST['db']) ? $L->success : $L->failed));
            }
    }
} else {
    $test_dialog = true;
    $db_list = [];
    $databases = $Config->db;
    if (!empty($databases)) {
        foreach ($databases as $i => &$db_data) {
            $db_list[] = [[[h::{'a.cs-button-compact'}([h::icon('plus'), ['href' => "{$a->action}/add/{$i}", 'data-title' => "{$L->add} {$L->mirror} {$L->of_db}"]], $i ? [h::icon('pencil'), ['href' => "{$a->action}/edit/{$i}", 'data-title' => "{$L->edit} {$L->db}"]] : false, $i ? [h::icon('trash-o'), ['href' => "{$a->action}/delete/{$i}", 'data-title' => $L->delete . ' ' . $L->db]] : false, [h::icon('signal'), ['onMouseDown' => "cs.db_test('{$a->action}/test/{$i}', true);", 'data-title' => $L->test_connection]]), ['class' => 'cs-left-all']], $i ? $db_data['host'] : $Core->db_host, $i ? $db_data['type'] : $Core->db_type, $i ? $db_data['prefix'] : $Core->db_prefix, $i ? $db_data['name'] : $Core->db_name, $i ? $db_data['user'] : '******', $i ? $db_data['charset'] : $Core->db_charset], ['class' => $i ? '' : 'text-primary']];
            foreach ($Config->db[$i]['mirrors'] as $m => &$mirror) {
                if (is_array($mirror) && !empty($mirror)) {
                    $db_list[] = [[h::{'a.cs-button-compact'}([h::icon('pencil'), ['href' => "admin/System/{$rc['0']}/{$rc['1']}/edit/{$i}/{$m}", 'data-title' => "{$L->edit} {$L->mirror} {$L->of_db}"]], [h::icon('trash-o'), ['href' => "admin/System/{$rc['0']}/{$rc['1']}/delete/{$i}/{$m}", 'data-title' => "{$L->delete} {$L->mirror} {$L->of_db}"]], [h::icon('signal'), ['onMouseDown' => "cs.db_test('{$a->action}/test/{$i}/{$m}', true);", 'data-title' => $L->test_connection]]), ['class' => 'cs-right-all']], $mirror['host'], $mirror['type'], $mirror['prefix'], $mirror['name'], $mirror['user'], $mirror['charset']];
                }
            }
            unset($m, $mirror);
        }
        unset($i, $db_data);
    }
    unset($databases);
    $a->content(h::{'table.cs-table'}(h::{'thead tr th'}($L->action, $L->db_host, $L->db_type, $L->db_prefix, $L->db_name, $L->db_user, $L->db_charset) . h::tbody(h::{'tr| td'}([$db_list]))) . h::{'table.cs-table-borderless.cs-left-even.cs-right-odd tr| td'}([[h::info('db_balance'), h::{'input[type=radio]'}(['name' => 'core[db_balance]', 'checked' => $Config->core['db_balance'], 'value' => [0, 1], 'in' => [$L->off, $L->on]])], [h::info('maindb_for_write'), h::{'input[type=radio]'}(['name' => 'core[maindb_for_write]', 'checked' => $Config->core['maindb_for_write'], 'value' => [0, 1], 'in' => [$L->off, $L->on]])]]) . h::{'p a.cs-button'}($L->add_database, ['href' => "admin/System/{$rc['0']}/{$rc['1']}/add"]) . h::{'input[type=hidden]'}(['name' => 'mode', 'value' => 'config']));
}
$test_dialog && $a->content(h::{'div#cs-db-test.uk-modal div'}(h::h3($L->test_connection) . h::div()));