finish translate support
This commit is contained in:
+38
-47
@@ -303,7 +303,7 @@ function install_run($input) {
|
||||
'errors' => array(t('install.error_delete_privilege')),
|
||||
'steps' => $steps);
|
||||
}
|
||||
$steps[] = array('success', t('install.step_privileges'));
|
||||
$steps[] = array('success', t('install.step_privileges_ok'));
|
||||
|
||||
$administrator = install_create_administrator(
|
||||
$connection, $input['admin_username'], $input['admin_password']);
|
||||
@@ -344,7 +344,7 @@ form { padding:1.35rem;border:1px solid var(--line);border-radius:.9rem;backgrou
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>PHP Git 服务器安装</h1>
|
||||
<h1>__INSTALL_HEADING__</h1>
|
||||
HTML;
|
||||
echo i18n_language_switcher(install_page_url())."\n";
|
||||
}
|
||||
@@ -352,23 +352,19 @@ HTML;
|
||||
function install_send_form($input, $errors) {
|
||||
$token = install_csrf_token();
|
||||
if ($token === FALSE) {
|
||||
echo '<p class="notice notice-error">当前无法初始化安全会话,无法继续安装。</p>' ."\n";
|
||||
echo '<p class="notice notice-error">'.install_escape(t('install.session_unavailable')).'</p>' ."\n";
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<p class="lead">检测到项目根目录没有 <code>config.php</code>。请先准备好一个空数据库'
|
||||
.'和对应账号,填写以下信息即可导入表结构、创建首个管理员账号并生成配置文件。</p>' ."\n";
|
||||
echo '<p class="lead">'.t('install.lead').'</p>' ."\n";
|
||||
if (!install_request_is_https()) {
|
||||
echo '<p class="notice notice-warning">当前不是 HTTPS 连接。密码将以明文传输,'
|
||||
.'建议改用 HTTPS 或仅从本机访问安装页面。</p>' ."\n";
|
||||
echo '<p class="notice notice-warning">'.t('install.warning_http').'</p>' ."\n";
|
||||
}
|
||||
if (!extension_loaded('pdo_mysql')) {
|
||||
echo '<p class="notice notice-error">PHP 未启用 <code>pdo_mysql</code> 扩展,'
|
||||
.'安装无法继续。请先安装该扩展并重启 PHP。</p>' ."\n";
|
||||
echo '<p class="notice notice-error">'.t('install.error_no_pdo_mysql').'</p>' ."\n";
|
||||
}
|
||||
if (!is_writable(__DIR__)) {
|
||||
echo '<p class="notice notice-error">项目目录不可写,无法生成 <code>config.php</code>。'
|
||||
.'请调整目录权限后刷新。</p>' ."\n";
|
||||
echo '<p class="notice notice-error">'.t('install.error_not_writable').'</p>' ."\n";
|
||||
}
|
||||
if (!empty($errors)) {
|
||||
echo '<div class="notice notice-error"><ul>' ."\n";
|
||||
@@ -381,87 +377,82 @@ function install_send_form($input, $errors) {
|
||||
echo '<form method="post" action="'.install_escape(install_page_url()).'">' ."\n";
|
||||
echo '<input type="hidden" name="csrf_token" value="'.install_escape($token).'">' ."\n";
|
||||
|
||||
echo '<fieldset><legend>应用</legend><div class="grid">' ."\n";
|
||||
echo '<div><label for="url_base">基础路径</label>'
|
||||
echo '<fieldset><legend>'.install_escape(t('install.legend_application')).'</legend><div class="grid">' ."\n";
|
||||
echo '<div><label for="url_base">'.install_escape(t('install.label_url_base')).'</label>'
|
||||
.'<input id="url_base" name="url_base" type="text" value="'
|
||||
.install_escape($input['url_base']).'" placeholder="/php-git-server">'
|
||||
.'<p class="hint">部署在域名根路径时留空。</p></div>' ."\n";
|
||||
echo '<div><label for="git_executable">Git 可执行文件</label>'
|
||||
.'<p class="hint">'.t('install.hint_url_base').'</p></div>' ."\n";
|
||||
echo '<div><label for="git_executable">'.install_escape(t('install.label_git_executable')).'</label>'
|
||||
.'<input id="git_executable" name="git_executable" type="text" value="'
|
||||
.install_escape($input['git_executable']).'" required>'
|
||||
.'<p class="hint">不可用时会回退到纯 PHP 实现。</p></div>' ."\n";
|
||||
.'<p class="hint">'.t('install.hint_git_executable').'</p></div>' ."\n";
|
||||
echo '<div><label for="language">'.install_escape(t('install.label_language')).'</label>'
|
||||
.'<select id="language" name="language">'
|
||||
.'<option value=""'.($input['language'] === '' ? ' selected' : '').'>'
|
||||
.install_escape(t('install.language_auto')).'</option>'
|
||||
.'<option value="en"'.($input['language'] === 'en' ? ' selected' : '').'>English</option>'
|
||||
.'<option value="zh"'.($input['language'] === 'zh' ? ' selected' : '').'>中文</option>'
|
||||
.'<option value="en"'.($input['language'] === 'en' ? ' selected' : '').'>'.install_escape(t('install.language_en')).'</option>'
|
||||
.'<option value="zh"'.($input['language'] === 'zh' ? ' selected' : '').'>'.install_escape(t('install.language_zh')).'</option>'
|
||||
.'</select></div>' ."\n";
|
||||
echo '</div><div class="check"><input id="registration_enabled" name="registration_enabled" '
|
||||
.'type="checkbox" value="1"'.($input['registration_enabled'] ? ' checked' : '').'>'
|
||||
.'<label for="registration_enabled">允许公开注册新账号</label></div>' ."\n";
|
||||
.'<label for="registration_enabled">'.install_escape(t('install.label_registration_enabled')).'</label></div>' ."\n";
|
||||
echo '<div class="check"><input id="session_cookie_secure" name="session_cookie_secure" '
|
||||
.'type="checkbox" value="1"'.($input['session_cookie_secure'] ? ' checked' : '').'>'
|
||||
.'<label for="session_cookie_secure">HTTPS 在可信反向代理终止(设置 Secure Cookie)</label>'
|
||||
.'<label for="session_cookie_secure">'.install_escape(t('install.label_session_cookie_secure')).'</label>'
|
||||
.'</div></fieldset>' ."\n";
|
||||
|
||||
echo '<fieldset><legend>数据库</legend>' ."\n";
|
||||
echo '<p class="hint">请先自行创建好数据库和账号,安装器不会创建它们,也不需要 root 权限。'
|
||||
.'账号需对该库具有 SELECT、INSERT、UPDATE 和 DELETE 权限;'
|
||||
.'若还具有建表权限,安装器会自动导入表结构。</p>' ."\n";
|
||||
echo '<fieldset><legend>'.install_escape(t('install.legend_database')).'</legend>' ."\n";
|
||||
echo '<p class="hint">'.t('install.hint_database').'</p>' ."\n";
|
||||
echo '<div class="grid">' ."\n";
|
||||
echo '<div><label for="db_host">主机</label><input id="db_host" name="db_host" type="text" '
|
||||
echo '<div><label for="db_host">'.install_escape(t('install.label_db_host')).'</label><input id="db_host" name="db_host" type="text" '
|
||||
.'value="'.install_escape($input['db_host']).'" required>'
|
||||
.'<p class="hint">共享主机通常是 <code>localhost</code>。</p></div>' ."\n";
|
||||
echo '<div><label for="db_port">端口</label><input id="db_port" name="db_port" '
|
||||
.'<p class="hint">'.t('install.hint_db_host').'</p></div>' ."\n";
|
||||
echo '<div><label for="db_port">'.install_escape(t('install.label_db_port')).'</label><input id="db_port" name="db_port" '
|
||||
.'type="number" min="1" max="65535" value="'.install_escape($input['db_port'])
|
||||
.'" required></div>' ."\n";
|
||||
echo '<div><label for="db_name">数据库名</label><input id="db_name" name="db_name" '
|
||||
echo '<div><label for="db_name">'.install_escape(t('install.label_db_name')).'</label><input id="db_name" name="db_name" '
|
||||
.'type="text" value="'.install_escape($input['db_name']).'" required>'
|
||||
.'<p class="hint">面板生成的名称通常带前缀,例如 <code>cpuser_git</code>。</p></div>' ."\n";
|
||||
echo '<div><label for="db_user">数据库账号</label><input id="db_user" name="db_user" '
|
||||
.'<p class="hint">'.t('install.hint_db_name').'</p></div>' ."\n";
|
||||
echo '<div><label for="db_user">'.install_escape(t('install.label_db_user')).'</label><input id="db_user" name="db_user" '
|
||||
.'type="text" value="'.install_escape($input['db_user']).'" required></div>' ."\n";
|
||||
echo '<div><label for="db_password">数据库账号密码</label><input id="db_password" '
|
||||
echo '<div><label for="db_password">'.install_escape(t('install.label_db_password')).'</label><input id="db_password" '
|
||||
.'name="db_password" type="password" autocomplete="new-password" required></div>' ."\n";
|
||||
echo '</div>' ."\n";
|
||||
echo '<p class="hint">若该账号没有建表权限,请先用面板的 phpMyAdmin 导入 '
|
||||
.'<code>schema.mysql.sql</code>,再提交本页面;已存在的表会被自动跳过。</p>' ."\n";
|
||||
echo '<p class="hint">'.t('install.hint_schema_import').'</p>' ."\n";
|
||||
echo '</fieldset>' ."\n";
|
||||
|
||||
echo '<fieldset><legend>管理员账号</legend>' ."\n";
|
||||
echo '<p class="hint">该账号会写入 <code>$auth[\'administrators\']</code>,'
|
||||
.'安装完成后即可访问管理界面。</p>' ."\n";
|
||||
echo '<fieldset><legend>'.install_escape(t('install.legend_administrator')).'</legend>' ."\n";
|
||||
echo '<p class="hint">'.t('install.hint_administrator').'</p>' ."\n";
|
||||
echo '<div class="grid">' ."\n";
|
||||
echo '<div><label for="admin_username">用户名</label><input id="admin_username" '
|
||||
echo '<div><label for="admin_username">'.install_escape(t('install.label_admin_username')).'</label><input id="admin_username" '
|
||||
.'name="admin_username" type="text" minlength="3" maxlength="64" value="'
|
||||
.install_escape($input['admin_username']).'" autocomplete="off" required></div>' ."\n";
|
||||
echo '<div><label for="admin_password">密码</label><input id="admin_password" '
|
||||
echo '<div><label for="admin_password">'.install_escape(t('install.label_admin_password')).'</label><input id="admin_password" '
|
||||
.'name="admin_password" type="password" minlength="8" maxlength="72" '
|
||||
.'autocomplete="new-password" required></div>' ."\n";
|
||||
echo '<div><label for="admin_password_confirmation">确认密码</label>'
|
||||
echo '<div><label for="admin_password_confirmation">'.install_escape(t('install.label_admin_password_confirmation')).'</label>'
|
||||
.'<input id="admin_password_confirmation" name="admin_password_confirmation" '
|
||||
.'type="password" minlength="8" maxlength="72" autocomplete="new-password" required>'
|
||||
.'</div>' ."\n";
|
||||
echo '</div></fieldset>' ."\n";
|
||||
|
||||
echo '<button type="submit">开始安装</button>' ."\n";
|
||||
echo '<button type="submit">'.install_escape(t('install.button_submit')).'</button>' ."\n";
|
||||
echo '</form>' ."\n";
|
||||
}
|
||||
|
||||
function install_send_result($steps) {
|
||||
echo '<p class="notice notice-success">安装完成。</p>' ."\n";
|
||||
echo '<p class="notice notice-success">'.install_escape(t('install.complete')).'</p>' ."\n";
|
||||
foreach ($steps as $step) {
|
||||
echo '<p class="notice notice-'.install_escape($step[0]).'">'
|
||||
.install_escape($step[1]).'</p>' ."\n";
|
||||
}
|
||||
|
||||
echo '<h2>请立即完成以下操作</h2>' ."\n";
|
||||
echo '<p>删除安装脚本,避免它在配置被移除后再次可用。有 shell 时执行:</p>' ."\n";
|
||||
echo '<h2>'.install_escape(t('install.next_steps_title')).'</h2>' ."\n";
|
||||
echo '<p>'.install_escape(t('install.next_steps_remove')).'</p>' ."\n";
|
||||
echo '<pre><code>rm install.php</code></pre>' ."\n";
|
||||
echo '<p>共享主机可用面板的文件管理器或 FTP 直接删除 <code>install.php</code>。</p>' ."\n";
|
||||
echo '<p>确认 <code>config.php</code> 仅应用进程可读,并检查 <code>repos</code> 目录权限。'
|
||||
.'详细说明见 <code>usage.md</code>。</p>' ."\n";
|
||||
echo '<p><a href="'.install_escape(install_home_url()).'">进入首页并登录</a></p>' ."\n";
|
||||
echo '<p>'.t('install.next_steps_shared_hosting').'</p>' ."\n";
|
||||
echo '<p>'.t('install.next_steps_permissions').'</p>' ."\n";
|
||||
echo '<p><a href="'.install_escape(install_home_url()).'">'.install_escape(t('install.link_home')).'</a></p>' ."\n";
|
||||
}
|
||||
|
||||
function install_send_foot() {
|
||||
|
||||
@@ -166,6 +166,7 @@ function i18n_language_switcher($url) {
|
||||
function i18n_translate_markup($markup) {
|
||||
$markup = str_replace('__LANG__', htmlspecialchars(i18n_html_lang(), ENT_QUOTES, 'UTF-8'), $markup);
|
||||
$markup = str_replace('__TITLE__', htmlspecialchars(t('install.title'), ENT_QUOTES, 'UTF-8'), $markup);
|
||||
$markup = str_replace('__INSTALL_HEADING__', htmlspecialchars(t('install.heading'), ENT_QUOTES, 'UTF-8'), $markup);
|
||||
if (i18n_language() === 'en') {
|
||||
$catalog = i18n_catalog_zh();
|
||||
$english = i18n_catalog_en();
|
||||
|
||||
+54
-54
@@ -279,29 +279,29 @@ details { min-width: 15rem; } summary { cursor: pointer; font-weight: 700; } det
|
||||
</head>
|
||||
<body>
|
||||
HTML;
|
||||
echo '<header><div class="header-inner"><div><h1>PHP Git 服务器 / 管理</h1>' ."\n";
|
||||
echo '<p class="identity">管理员:<strong>'.manage_escape($administrator['username'])
|
||||
echo '<header><div class="header-inner"><div><h1>'.manage_escape(t('manage.heading')).'</h1>' ."\n";
|
||||
echo '<p class="identity">'.manage_escape(t('manage.administrator_label')).':<strong>'.manage_escape($administrator['username'])
|
||||
.'</strong></p></div>' ."\n";
|
||||
echo '<nav><a href="'.manage_escape(manage_home_url($url_base)).'">返回仓库首页</a> '
|
||||
echo '<nav><a href="'.manage_escape(manage_home_url($url_base)).'">'.manage_escape(t('manage.back_to_home')).'</a> '
|
||||
.i18n_language_switcher(manage_page_url($url_base));
|
||||
echo '</nav></div></header>' ."\n";
|
||||
}
|
||||
|
||||
function manage_send_create_user($url_base, $csrf_token) {
|
||||
echo '<section aria-labelledby="create-user-title"><h2 id="create-user-title">创建用户</h2>' ."\n";
|
||||
echo '<p class="section-lead">管理员创建的账号会立即启用。</p>' ."\n";
|
||||
echo '<section aria-labelledby="create-user-title"><h2 id="create-user-title">'.manage_escape(t('manage.create_user_title')).'</h2>' ."\n";
|
||||
echo '<p class="section-lead">'.manage_escape(t('manage.create_user_lead')).'</p>' ."\n";
|
||||
echo '<form class="create-user" method="post" action="'
|
||||
.manage_escape(manage_page_url($url_base)).'">' ."\n";
|
||||
echo '<input type="hidden" name="csrf_token" value="'.manage_escape($csrf_token).'">' ."\n";
|
||||
echo '<input type="hidden" name="action" value="create_user">' ."\n";
|
||||
echo '<div><label for="new-username">用户名</label><input id="new-username" name="username" '
|
||||
echo '<div><label for="new-username">'.manage_escape(t('manage.label_username')).'</label><input id="new-username" name="username" '
|
||||
.'minlength="3" maxlength="64" autocomplete="off" required></div>' ."\n";
|
||||
echo '<div><label for="new-password">初始密码</label><input id="new-password" name="password" '
|
||||
echo '<div><label for="new-password">'.manage_escape(t('manage.label_initial_password')).'</label><input id="new-password" name="password" '
|
||||
.'type="password" minlength="8" maxlength="72" autocomplete="new-password" required></div>' ."\n";
|
||||
echo '<div><label for="new-password-confirmation">确认密码</label>'
|
||||
echo '<div><label for="new-password-confirmation">'.manage_escape(t('manage.label_password_confirmation')).'</label>'
|
||||
.'<input id="new-password-confirmation" name="password_confirmation" type="password" '
|
||||
.'minlength="8" maxlength="72" autocomplete="new-password" required></div>' ."\n";
|
||||
echo '<button type="submit">创建用户</button></form></section>' ."\n";
|
||||
echo '<button type="submit">'.manage_escape(t('manage.button_create_user')).'</button></form></section>' ."\n";
|
||||
}
|
||||
|
||||
function manage_hidden_fields($csrf_token, $action, $user_id=NULL) {
|
||||
@@ -317,32 +317,32 @@ function manage_hidden_fields($csrf_token, $action, $user_id=NULL) {
|
||||
}
|
||||
|
||||
function manage_send_users($url_base, $csrf_token, $users, $administrator) {
|
||||
echo '<section aria-labelledby="users-title"><h2 id="users-title">用户</h2>' ."\n";
|
||||
echo '<p class="section-lead">停用会立即阻止网页登录和 Access Token 认证。删除用户前必须先处理其仓库。</p>' ."\n";
|
||||
echo '<section aria-labelledby="users-title"><h2 id="users-title">'.manage_escape(t('manage.users_title')).'</h2>' ."\n";
|
||||
echo '<p class="section-lead">'.manage_escape(t('manage.users_lead')).'</p>' ."\n";
|
||||
if ($users === FALSE) {
|
||||
echo '<p class="notice notice-error">当前无法读取用户列表。</p></section>' ."\n";
|
||||
echo '<p class="notice notice-error">'.manage_escape(t('manage.users_unavailable')).'</p></section>' ."\n";
|
||||
return;
|
||||
}
|
||||
if (empty($users)) {
|
||||
echo '<p class="empty">当前没有用户。</p></section>' ."\n";
|
||||
echo '<p class="empty">'.manage_escape(t('manage.users_empty')).'</p></section>' ."\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$action_url = manage_escape(manage_page_url($url_base));
|
||||
echo '<div class="table-wrap"><table><thead><tr><th>用户</th><th>状态</th><th>仓库</th>'
|
||||
.'<th>有效 Token</th><th>创建时间</th><th>账号操作</th><th>密码</th></tr></thead><tbody>' ."\n";
|
||||
echo '<div class="table-wrap"><table><thead><tr><th>'.manage_escape(t('manage.th_user')).'</th><th>'.manage_escape(t('manage.th_status')).'</th><th>'.manage_escape(t('manage.th_repositories')).'</th>'
|
||||
.'<th>'.manage_escape(t('manage.th_active_tokens')).'</th><th>'.manage_escape(t('manage.th_created_at')).'</th><th>'.manage_escape(t('manage.th_account_actions')).'</th><th>'.manage_escape(t('manage.th_password')).'</th></tr></thead><tbody>' ."\n";
|
||||
foreach ($users as $user) {
|
||||
$active = (int) $user['is_active'] === 1;
|
||||
$is_administrator = auth_user_is_administrator($user);
|
||||
$is_self = (int) $user['id'] === (int) $administrator['id'];
|
||||
echo '<tr><td><code>'.manage_escape($user['username']).'</code><br>';
|
||||
if ($is_administrator) {
|
||||
echo '<span class="badge badge-good">管理员</span>';
|
||||
echo '<span class="badge badge-good">'.manage_escape(t('manage.badge_administrator')).'</span>';
|
||||
} else if ($is_self) {
|
||||
echo '<span class="badge badge-muted">当前账号</span>';
|
||||
echo '<span class="badge badge-muted">'.manage_escape(t('manage.badge_current_account')).'</span>';
|
||||
}
|
||||
echo '</td><td><span class="badge '.($active ? 'badge-good' : 'badge-warning').'">'
|
||||
.($active ? '启用' : '停用').'</span></td>';
|
||||
.manage_escape($active ? t('manage.badge_active') : t('manage.badge_inactive')).'</span></td>';
|
||||
echo '<td>'.manage_escape($user['repository_count']).'</td>';
|
||||
echo '<td>'.manage_escape($user['active_token_count']).'</td>';
|
||||
echo '<td>'.manage_escape($user['created_at']).'</td><td><div class="stack">';
|
||||
@@ -351,28 +351,28 @@ function manage_send_users($url_base, $csrf_token, $users, $administrator) {
|
||||
echo '<form method="post" action="'.$action_url.'">'
|
||||
.manage_hidden_fields($csrf_token, 'set_user_status', $user['id']);
|
||||
echo '<input type="hidden" name="active" value="'.($active ? '0' : '1').'">';
|
||||
echo '<button class="button-muted" type="submit">'.($active ? '停用' : '启用').'</button></form>';
|
||||
echo '<button class="button-muted" type="submit">'.manage_escape($active ? t('manage.button_deactivate') : t('manage.button_activate')).'</button></form>';
|
||||
}
|
||||
|
||||
echo '<form method="post" action="'.$action_url.'">'
|
||||
.manage_hidden_fields($csrf_token, 'revoke_user_tokens', $user['id']);
|
||||
echo '<button class="button-muted" type="submit">撤销全部 Token</button></form>';
|
||||
echo '<button class="button-muted" type="submit">'.manage_escape(t('manage.button_revoke_all_tokens')).'</button></form>';
|
||||
|
||||
if (!$is_administrator && !$is_self && (int) $user['repository_count'] === 0) {
|
||||
echo '<form class="stack" method="post" action="'.$action_url.'">'
|
||||
.manage_hidden_fields($csrf_token, 'delete_user', $user['id']);
|
||||
echo '<label class="confirm"><input name="confirmation" type="checkbox" value="'
|
||||
.manage_escape($user['username']).'" required> 确认删除账号</label>';
|
||||
echo '<button class="button-danger" type="submit">删除用户</button></form>';
|
||||
.manage_escape($user['username']).'" required> '.manage_escape(t('manage.confirm_delete_account')).'</label>';
|
||||
echo '<button class="button-danger" type="submit">'.manage_escape(t('manage.button_delete_user')).'</button></form>';
|
||||
}
|
||||
echo '</div></td><td><details><summary>重置密码</summary>';
|
||||
echo '</div></td><td><details><summary>'.manage_escape(t('manage.summary_reset_password')).'</summary>';
|
||||
echo '<form method="post" action="'.$action_url.'">'
|
||||
.manage_hidden_fields($csrf_token, 'reset_user_password', $user['id']);
|
||||
echo '<input name="password" type="password" minlength="8" maxlength="72" '
|
||||
.'autocomplete="new-password" aria-label="新密码" placeholder="新密码" required>';
|
||||
.'autocomplete="new-password" aria-label="'.manage_escape(t('manage.placeholder_new_password')).'" placeholder="'.manage_escape(t('manage.placeholder_new_password')).'" required>';
|
||||
echo '<input name="password_confirmation" type="password" minlength="8" maxlength="72" '
|
||||
.'autocomplete="new-password" aria-label="确认新密码" placeholder="确认新密码" required>';
|
||||
echo '<button type="submit">保存新密码</button></form></details></td></tr>' ."\n";
|
||||
.'autocomplete="new-password" aria-label="'.manage_escape(t('manage.placeholder_confirm_new_password')).'" placeholder="'.manage_escape(t('manage.placeholder_confirm_new_password')).'" required>';
|
||||
echo '<button type="submit">'.manage_escape(t('manage.button_save_password')).'</button></form></details></td></tr>' ."\n";
|
||||
}
|
||||
echo '</tbody></table></div></section>' ."\n";
|
||||
}
|
||||
@@ -380,21 +380,21 @@ function manage_send_users($url_base, $csrf_token, $users, $administrator) {
|
||||
function manage_repository_state($repository, $configuration, $definitions, $url_base) {
|
||||
$root = managed_repository_root($configuration);
|
||||
if ($root === FALSE) {
|
||||
return array('badge-warning', '根目录不可用', FALSE);
|
||||
return array('badge-warning', t('manage.state_root_unavailable'), FALSE);
|
||||
}
|
||||
|
||||
$path = $root.DIRECTORY_SEPARATOR.$repository['repository_name'];
|
||||
if (managed_repository_path_is_configured($definitions, $url_base, $path)) {
|
||||
return array('badge-warning', '静态配置', FALSE);
|
||||
return array('badge-warning', t('manage.state_configured'), FALSE);
|
||||
}
|
||||
if (!managed_repository_is_bare($path)) {
|
||||
return array('badge-warning', '仅记录', TRUE);
|
||||
return array('badge-warning', t('manage.state_record_only'), TRUE);
|
||||
}
|
||||
if ((int) $repository['is_ready'] !== 1) {
|
||||
return array('badge-warning', '未完成', TRUE);
|
||||
return array('badge-warning', t('manage.state_incomplete'), TRUE);
|
||||
}
|
||||
|
||||
return array('badge-good', '可用', TRUE);
|
||||
return array('badge-good', t('manage.state_ready'), TRUE);
|
||||
}
|
||||
|
||||
function manage_send_repositories(
|
||||
@@ -404,20 +404,20 @@ function manage_send_repositories(
|
||||
$users,
|
||||
$configuration,
|
||||
$definitions) {
|
||||
echo '<section aria-labelledby="repositories-title"><h2 id="repositories-title">托管仓库</h2>' ."\n";
|
||||
echo '<p class="section-lead">此处操作数据库记录与 <code>repos</code> 目录中的受管 bare 仓库。</p>' ."\n";
|
||||
echo '<section aria-labelledby="repositories-title"><h2 id="repositories-title">'.manage_escape(t('manage.repositories_title')).'</h2>' ."\n";
|
||||
echo '<p class="section-lead">'.t('manage.repositories_lead').'</p>' ."\n";
|
||||
if ($repositories === FALSE) {
|
||||
echo '<p class="notice notice-error">当前无法读取托管仓库列表。</p></section>' ."\n";
|
||||
echo '<p class="notice notice-error">'.manage_escape(t('manage.repositories_unavailable')).'</p></section>' ."\n";
|
||||
return;
|
||||
}
|
||||
if (empty($repositories)) {
|
||||
echo '<p class="empty">当前没有托管仓库。</p></section>' ."\n";
|
||||
echo '<p class="empty">'.manage_escape(t('manage.repositories_empty')).'</p></section>' ."\n";
|
||||
return;
|
||||
}
|
||||
|
||||
$action_url = manage_escape(manage_page_url($url_base));
|
||||
echo '<div class="table-wrap"><table><thead><tr><th>仓库</th><th>状态</th><th>所有者与可见性</th>'
|
||||
.'<th>创建时间</th><th>删除</th></tr></thead><tbody>' ."\n";
|
||||
echo '<div class="table-wrap"><table><thead><tr><th>'.manage_escape(t('manage.th_repository')).'</th><th>'.manage_escape(t('manage.th_status')).'</th><th>'.manage_escape(t('manage.th_owner_visibility')).'</th>'
|
||||
.'<th>'.manage_escape(t('manage.th_created_at')).'</th><th>'.manage_escape(t('manage.th_delete')).'</th></tr></thead><tbody>' ."\n";
|
||||
foreach ($repositories as $repository) {
|
||||
$state = manage_repository_state(
|
||||
$repository, $configuration, $definitions, $url_base);
|
||||
@@ -429,7 +429,7 @@ function manage_send_repositories(
|
||||
echo '<input type="hidden" name="action" value="update_repository">';
|
||||
echo '<input type="hidden" name="repository_id" value="'
|
||||
.manage_escape($repository['id']).'">';
|
||||
echo '<select name="owner_user_id" aria-label="仓库所有者">';
|
||||
echo '<select name="owner_user_id" aria-label="'.manage_escape(t('manage.aria_repository_owner')).'">';
|
||||
foreach ($users === FALSE ? array() : $users as $user) {
|
||||
if ((int) $user['is_active'] !== 1
|
||||
&& (int) $user['id'] !== (int) $repository['owner_user_id']) {
|
||||
@@ -437,17 +437,17 @@ function manage_send_repositories(
|
||||
}
|
||||
echo '<option value="'.manage_escape($user['id']).'"'
|
||||
.((int) $user['id'] === (int) $repository['owner_user_id'] ? ' selected' : '').'>'
|
||||
.manage_escape($user['username']).((int) $user['is_active'] === 1 ? '' : '(已停用)')
|
||||
.manage_escape($user['username']).((int) $user['is_active'] === 1 ? '' : manage_escape(t('manage.user_deactivated_suffix')))
|
||||
.'</option>';
|
||||
}
|
||||
echo '</select><select name="visibility" aria-label="仓库可见性">';
|
||||
echo '</select><select name="visibility" aria-label="'.manage_escape(t('manage.aria_repository_visibility')).'">';
|
||||
echo '<option value="public"'.((int) $repository['is_private'] === 0 ? ' selected' : '')
|
||||
.'>公开</option>';
|
||||
.'>'.manage_escape(t('manage.public')).'</option>';
|
||||
echo '<option value="private"'.((int) $repository['is_private'] === 1 ? ' selected' : '')
|
||||
.'>私有</option></select><button type="submit">保存</button></form></td>';
|
||||
.'>'.manage_escape(t('manage.private')).'</option></select><button type="submit">'.manage_escape(t('manage.button_save')).'</button></form></td>';
|
||||
echo '<td>'.manage_escape($repository['created_at']).'</td><td>';
|
||||
if (!$state[2]) {
|
||||
echo '<span class="badge badge-muted">不可删除</span>';
|
||||
echo '<span class="badge badge-muted">'.manage_escape(t('manage.badge_not_deletable')).'</span>';
|
||||
} else {
|
||||
echo '<form class="stack" method="post" action="'.$action_url.'">';
|
||||
echo '<input type="hidden" name="csrf_token" value="'.manage_escape($csrf_token).'">';
|
||||
@@ -455,8 +455,8 @@ function manage_send_repositories(
|
||||
echo '<input type="hidden" name="repository_name" value="'
|
||||
.manage_escape($repository['repository_name']).'">';
|
||||
echo '<label class="confirm"><input name="confirmation" type="checkbox" value="'
|
||||
.manage_escape($repository['repository_name']).'" required> 确认永久删除</label>';
|
||||
echo '<button class="button-danger" type="submit">删除仓库</button></form>';
|
||||
.manage_escape($repository['repository_name']).'" required> '.manage_escape(t('manage.confirm_permanent_delete')).'</label>';
|
||||
echo '<button class="button-danger" type="submit">'.manage_escape(t('manage.button_delete_repository')).'</button></form>';
|
||||
}
|
||||
echo '</td></tr>' ."\n";
|
||||
}
|
||||
@@ -464,8 +464,8 @@ function manage_send_repositories(
|
||||
}
|
||||
|
||||
function manage_send_configured_repositories($url_base, $definitions) {
|
||||
echo '<section aria-labelledby="configured-title"><h2 id="configured-title">配置仓库</h2>' ."\n";
|
||||
echo '<p class="section-lead">这些仓库来自 <code>config.php</code>,管理界面只读显示,不修改配置或文件。</p>' ."\n";
|
||||
echo '<section aria-labelledby="configured-title"><h2 id="configured-title">'.manage_escape(t('manage.configured_title')).'</h2>' ."\n";
|
||||
echo '<p class="section-lead">'.t('manage.configured_lead').'</p>' ."\n";
|
||||
$repositories = array();
|
||||
foreach ($definitions as $definition) {
|
||||
$repository = normalize_repository($definition, $url_base);
|
||||
@@ -474,21 +474,21 @@ function manage_send_configured_repositories($url_base, $definitions) {
|
||||
}
|
||||
}
|
||||
if (empty($repositories)) {
|
||||
echo '<p class="empty">当前没有配置仓库。</p></section>' ."\n";
|
||||
echo '<p class="empty">'.manage_escape(t('manage.configured_empty')).'</p></section>' ."\n";
|
||||
return;
|
||||
}
|
||||
|
||||
echo '<div class="table-wrap"><table><thead><tr><th>URL</th><th>路径</th><th>所有者</th>'
|
||||
.'<th>可见性</th><th>读 / 写</th></tr></thead><tbody>' ."\n";
|
||||
echo '<div class="table-wrap"><table><thead><tr><th>'.manage_escape(t('manage.th_url')).'</th><th>'.manage_escape(t('manage.th_path')).'</th><th>'.manage_escape(t('manage.th_owner_visibility')).'</th>'
|
||||
.'<th>'.manage_escape(t('manage.th_visibility')).'</th><th>'.manage_escape(t('manage.th_read_write')).'</th></tr></thead><tbody>' ."\n";
|
||||
foreach ($repositories as $repository) {
|
||||
$owner = $repository['options']['owner'] === NULL
|
||||
? '未设置' : $repository['options']['owner'];
|
||||
? t('manage.value_unset') : $repository['options']['owner'];
|
||||
echo '<tr><td><code>'.manage_escape($repository['url']).'</code></td>';
|
||||
echo '<td><code>'.manage_escape($repository['path']).'</code></td>';
|
||||
echo '<td><code>'.manage_escape($owner).'</code></td>';
|
||||
echo '<td>'.(repository_is_private($repository) ? '私有' : '公开').'</td>';
|
||||
echo '<td>'.($repository['options']['read'] ? '读' : '禁用读取').' / '
|
||||
.($repository['options']['push'] ? '写' : '只读').'</td></tr>' ."\n";
|
||||
echo '<td>'.manage_escape(repository_is_private($repository) ? t('manage.private') : t('manage.public')).'</td>';
|
||||
echo '<td>'.manage_escape($repository['options']['read'] ? t('manage.value_read') : t('manage.value_read_disabled')).' / '
|
||||
.manage_escape($repository['options']['push'] ? t('manage.value_write') : t('manage.value_read_only')).'</td></tr>' ."\n";
|
||||
}
|
||||
echo '</tbody></table></div></section>' ."\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user