603 lines
20 KiB
PHP
603 lines
20 KiB
PHP
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
|
|
<?php
|
|
// 检查权限
|
|
if (!Typecho_Widget::widget('Widget_User')->pass('administrator')) {
|
|
exit;
|
|
}
|
|
|
|
// 获取数据库连接
|
|
$db = Typecho_Db::get();
|
|
|
|
// 分页设置
|
|
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
|
if ($page < 1) $page = 1;
|
|
$pageSize = 20;
|
|
$offset = ($page - 1) * $pageSize;
|
|
|
|
// 获取总记录数
|
|
$totalCount = $db->fetchRow($db->select('COUNT(*) as count')->from('table.edit_history'))['count'];
|
|
$totalPages = ceil($totalCount / $pageSize);
|
|
if ($totalPages < 1) $totalPages = 1;
|
|
if ($page > $totalPages) $page = $totalPages;
|
|
|
|
// 获取编辑记录,按时间倒序排列
|
|
$records = $db->fetchAll($db->select()
|
|
->from('table.edit_history')
|
|
->order('edit_time', Typecho_Db::SORT_DESC)
|
|
->limit($pageSize)
|
|
->offset($offset));
|
|
|
|
// 获取用户信息
|
|
$userIds = [];
|
|
$postIds = [];
|
|
foreach ($records as $record) {
|
|
if ($record['editor']) {
|
|
$userIds[$record['editor']] = $record['editor'];
|
|
}
|
|
$postIds[$record['cid']] = $record['cid'];
|
|
}
|
|
|
|
$users = [];
|
|
if (!empty($userIds)) {
|
|
$userResults = $db->fetchAll($db->select('uid', 'screenName', 'name')
|
|
->from('table.users')
|
|
->where('uid IN (' . implode(',', $userIds) . ')'));
|
|
|
|
foreach ($userResults as $user) {
|
|
$users[$user['uid']] = $user;
|
|
}
|
|
}
|
|
|
|
// 获取文章标题和slug
|
|
$posts = [];
|
|
if (!empty($postIds)) {
|
|
$postResults = $db->fetchAll($db->select('cid', 'title', 'slug')
|
|
->from('table.contents')
|
|
->where('cid IN (' . implode(',', $postIds) . ')'));
|
|
|
|
foreach ($postResults as $post) {
|
|
$posts[$post['cid']] = $post;
|
|
}
|
|
}
|
|
|
|
// 获取选项
|
|
$options = Typecho_Widget::widget('Widget_Options');
|
|
$adminUrl = rtrim($options->adminUrl, '/');
|
|
$siteUrl = rtrim($options->siteUrl, '/');
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>编辑记录管理 - <?php echo $options->title; ?></title>
|
|
<link rel="stylesheet" href="<?php $options->adminStaticUrl('css', 'normalize.css'); ?>">
|
|
<link rel="stylesheet" href="<?php $options->adminStaticUrl('css', 'grid.css'); ?>">
|
|
<link rel="stylesheet" href="<?php $options->adminStaticUrl('css', 'style.css'); ?>">
|
|
<style>
|
|
* {
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.typecho-page-title {
|
|
margin-bottom: 20px;
|
|
padding-bottom: 15px;
|
|
border-bottom: 1px solid #e9ecef;
|
|
}
|
|
|
|
.typecho-page-title h2 {
|
|
margin: 0;
|
|
color: #343a40;
|
|
font-size: 24px;
|
|
}
|
|
|
|
.edit-history-stats {
|
|
background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
|
|
border-radius: 10px;
|
|
padding: 20px;
|
|
margin-bottom: 25px;
|
|
color: white;
|
|
box-shadow: 0 4px 15px rgba(106, 17, 203, 0.15);
|
|
}
|
|
|
|
.edit-history-stats .stat-item {
|
|
display: inline-block;
|
|
margin-right: 30px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.edit-history-stats .stat-value {
|
|
font-weight: 700;
|
|
font-size: 18px;
|
|
background: rgba(255, 255, 255, 0.2);
|
|
padding: 4px 12px;
|
|
border-radius: 20px;
|
|
margin-left: 8px;
|
|
}
|
|
|
|
/* 列表容器 */
|
|
.edit-history-list-container {
|
|
margin-bottom: 30px;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
/* 列表标题 */
|
|
.list-header {
|
|
display: flex;
|
|
background-color: #f8f9fa;
|
|
border-bottom: 2px solid #dee2e6;
|
|
padding: 16px 20px;
|
|
font-weight: 600;
|
|
color: #495057;
|
|
background: linear-gradient(to right, #f8f9fa, #e9ecef);
|
|
}
|
|
|
|
.header-time {
|
|
width: 160px;
|
|
flex-shrink: 0;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.header-user {
|
|
width: 120px;
|
|
flex-shrink: 0;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.header-post {
|
|
flex: 1;
|
|
min-width: 250px;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.header-summary {
|
|
flex: 2;
|
|
min-width: 350px;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.header-actions {
|
|
width: 150px;
|
|
flex-shrink: 0;
|
|
text-align: center;
|
|
}
|
|
|
|
/* 列表项 */
|
|
.history-item {
|
|
display: flex;
|
|
align-items: center;
|
|
border-bottom: 1px solid #f1f3f5;
|
|
padding: 16px 20px;
|
|
background: white;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.history-item:hover {
|
|
background-color: #f8fafc;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.history-item:last-child {
|
|
border-bottom: none;
|
|
}
|
|
|
|
.item-time {
|
|
width: 160px;
|
|
flex-shrink: 0;
|
|
font-size: 13px;
|
|
color: #6c757d;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.item-user {
|
|
width: 120px;
|
|
flex-shrink: 0;
|
|
font-weight: 500;
|
|
color: #495057;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.item-post {
|
|
flex: 1;
|
|
min-width: 250px;
|
|
padding-right: 15px;
|
|
}
|
|
|
|
.post-link {
|
|
color: #1890ff;
|
|
text-decoration: none;
|
|
font-weight: 500;
|
|
transition: color 0.2s;
|
|
display: inline-block;
|
|
max-width: 100%;
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.post-link:hover {
|
|
color: #0056b3;
|
|
text-decoration: underline;
|
|
}
|
|
|
|
.item-summary {
|
|
flex: 2;
|
|
min-width: 350px;
|
|
padding-right: 15px;
|
|
font-size: 14px;
|
|
line-height: 1.5;
|
|
}
|
|
|
|
.item-summary.user-summary {
|
|
color: #1890ff;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.item-summary .no-summary {
|
|
color: #adb5bd;
|
|
font-style: italic;
|
|
}
|
|
|
|
.item-actions {
|
|
width: 150px;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.action-buttons {
|
|
display: flex;
|
|
gap: 8px;
|
|
justify-content: center;
|
|
flex-wrap: nowrap;
|
|
}
|
|
|
|
.typecho-pager {
|
|
margin-top: 30px;
|
|
}
|
|
|
|
.empty-message {
|
|
text-align: center;
|
|
padding: 80px 20px;
|
|
background: white;
|
|
border-radius: 8px;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
|
|
}
|
|
|
|
.empty-message-icon {
|
|
font-size: 60px;
|
|
margin-bottom: 20px;
|
|
display: block;
|
|
color: #adb5bd;
|
|
opacity: 0.6;
|
|
}
|
|
|
|
.empty-message p {
|
|
color: #6c757d;
|
|
font-size: 16px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
/* 按钮样式 */
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 6px 12px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 12px;
|
|
font-weight: 500;
|
|
text-decoration: none;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
white-space: nowrap;
|
|
min-width: 50px;
|
|
height: 32px;
|
|
}
|
|
|
|
.btn:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
}
|
|
|
|
.btn:active {
|
|
transform: translateY(0);
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, #007bff, #0056b3);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: linear-gradient(135deg, #0069d9, #004085);
|
|
}
|
|
|
|
.btn-view {
|
|
background: linear-gradient(135deg, #28a745, #1e7e34);
|
|
color: white;
|
|
}
|
|
|
|
.btn-view:hover {
|
|
background: linear-gradient(135deg, #218838, #155724);
|
|
}
|
|
|
|
.btn-edit {
|
|
background: linear-gradient(135deg, #ffc107, #e0a800);
|
|
color: #212529;
|
|
}
|
|
|
|
.btn-edit:hover {
|
|
background: linear-gradient(135deg, #e0a800, #b38f00);
|
|
}
|
|
|
|
.pager-container {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
gap: 10px;
|
|
margin-top: 30px;
|
|
padding-top: 20px;
|
|
border-top: 1px solid #e9ecef;
|
|
}
|
|
|
|
.pager-info {
|
|
color: #6c757d;
|
|
font-size: 14px;
|
|
}
|
|
|
|
@media (max-width: 1024px) {
|
|
.list-header,
|
|
.history-item {
|
|
padding: 12px 15px;
|
|
}
|
|
|
|
.header-time, .item-time {
|
|
width: 140px;
|
|
}
|
|
|
|
.header-user, .item-user {
|
|
width: 100px;
|
|
}
|
|
|
|
.header-actions, .item-actions {
|
|
width: 140px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.list-header {
|
|
display: none;
|
|
}
|
|
|
|
.history-item {
|
|
flex-direction: column;
|
|
align-items: stretch;
|
|
padding: 20px;
|
|
margin-bottom: 15px;
|
|
border: 1px solid #e9ecef;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.item-time,
|
|
.item-user,
|
|
.item-post,
|
|
.item-summary,
|
|
.item-actions {
|
|
width: 100%;
|
|
padding: 5px 0;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.item-actions {
|
|
margin-top: 10px;
|
|
padding-top: 15px;
|
|
border-top: 1px dashed #e9ecef;
|
|
}
|
|
|
|
.action-buttons {
|
|
justify-content: flex-start;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.edit-history-stats .stat-item {
|
|
display: block;
|
|
margin-bottom: 10px;
|
|
margin-right: 0;
|
|
}
|
|
|
|
.header-time,
|
|
.header-user,
|
|
.header-post,
|
|
.header-summary,
|
|
.header-actions {
|
|
display: none;
|
|
}
|
|
|
|
.mobile-label {
|
|
display: inline-block;
|
|
min-width: 80px;
|
|
color: #6c757d;
|
|
font-weight: 500;
|
|
margin-right: 10px;
|
|
}
|
|
}
|
|
|
|
/* 移动端标签 */
|
|
.mobile-label {
|
|
display: none;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.mobile-label {
|
|
display: inline-block;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="body-100">
|
|
<div class="container typecho-page-main">
|
|
<div class="row typecho-page-title">
|
|
<div class="col-mb-12">
|
|
<h2></h2>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-mb-12">
|
|
<div class="edit-history-stats">
|
|
<span class="stat-item">总记录数:<span class="stat-value"><?php echo $totalCount; ?></span> 条</span>
|
|
<span class="stat-item">当前页数:<span class="stat-value"><?php echo $page; ?> / <?php echo $totalPages; ?></span></span>
|
|
</div>
|
|
|
|
<?php if (empty($records)): ?>
|
|
<div class="empty-message">
|
|
<span class="empty-message-icon">📄</span>
|
|
<p>暂无编辑记录</p>
|
|
<a href="<?php echo $adminUrl; ?>/manage-posts.php" class="btn btn-primary" target="_blank">返回文章管理</a>
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="edit-history-list-container">
|
|
<!-- 列表标题 -->
|
|
<div class="list-header">
|
|
<div class="header-time">编辑时间</div>
|
|
<div class="header-user">编辑用户</div>
|
|
<div class="header-post">文章标题</div>
|
|
<div class="header-summary">编辑备注</div>
|
|
<div class="header-actions">常用操作</div>
|
|
</div>
|
|
|
|
<!-- 列表内容 -->
|
|
<?php foreach ($records as $record): ?>
|
|
<?php
|
|
// 获取用户名称
|
|
$userName = '系统';
|
|
if ($record['editor'] && isset($users[$record['editor']])) {
|
|
$user = $users[$record['editor']];
|
|
if (!empty($user['screenName'])) {
|
|
$userName = htmlspecialchars($user['screenName']);
|
|
} elseif (!empty($user['name'])) {
|
|
$userName = htmlspecialchars($user['name']);
|
|
}
|
|
}
|
|
|
|
// 获取文章信息
|
|
$postTitle = '文章已删除';
|
|
$editUrl = '#'; // 编辑链接
|
|
$viewUrl = '#'; // 查看链接
|
|
|
|
if (isset($posts[$record['cid']])) {
|
|
$post = $posts[$record['cid']];
|
|
$postTitle = htmlspecialchars($post['title']);
|
|
|
|
// 文章编辑链接(新窗口打开)
|
|
$editUrl = $adminUrl . '/write-post.php?cid=' . $record['cid'];
|
|
|
|
// 文章查看链接(新窗口打开)
|
|
if (!empty($post['slug'])) {
|
|
$viewUrl = $siteUrl . '/' . $post['slug'] . '.html';
|
|
}
|
|
}
|
|
|
|
// 格式化时间
|
|
$editTime = date('Y年m月d日 H:i', $record['edit_time']);
|
|
|
|
// 编辑说明
|
|
$summary = htmlspecialchars($record['edit_content']);
|
|
$isUserSummary = ($summary != '未填写编辑说明');
|
|
$displaySummary = $isUserSummary ? $summary : '<span class="no-summary">' . $summary . '</span>';
|
|
?>
|
|
|
|
<div class="history-item">
|
|
<div class="item-time">
|
|
<span class="mobile-label">编辑时间:</span>
|
|
<?php echo $editTime; ?>
|
|
</div>
|
|
<div class="item-user">
|
|
<span class="mobile-label">用户:</span>
|
|
<?php echo $userName; ?>
|
|
</div>
|
|
<div class="item-post">
|
|
<span class="mobile-label">文章:</span>
|
|
<?php if ($editUrl != '#'): ?>
|
|
<a href="<?php echo $editUrl; ?>" class="post-link" target="_blank" title="点击编辑文章(新窗口打开)">
|
|
<?php echo $postTitle; ?>
|
|
</a>
|
|
<?php else: ?>
|
|
<?php echo $postTitle; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
<div class="item-summary <?php echo $isUserSummary ? 'user-summary' : ''; ?>">
|
|
<span class="mobile-label">编辑备注:</span>
|
|
<?php echo $displaySummary; ?>
|
|
</div>
|
|
<div class="item-actions">
|
|
<div class="action-buttons">
|
|
<?php if ($viewUrl != '#'): ?>
|
|
<a href="<?php echo $viewUrl; ?>" class="btn btn-view" target="_blank" title="查看文章">
|
|
<span>👁️ 查看</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
|
|
<?php if ($editUrl != '#'): ?>
|
|
<a href="<?php echo $editUrl; ?>" class="btn btn-edit" target="_blank" title="编辑文章">
|
|
<span>✏️ 编辑</span>
|
|
</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<?php if ($totalPages > 1): ?>
|
|
<div class="pager-container">
|
|
<div class="pager-info">
|
|
第 <?php echo $page; ?> 页 / 共 <?php echo $totalPages; ?> 页
|
|
</div>
|
|
<div class="typecho-pager">
|
|
<ul class="typecho-pager">
|
|
<?php if ($page > 1): ?>
|
|
<li><a class="extend prev" href="?page=1">首页</a></li>
|
|
<li><a class="extend prev" href="?page=<?php echo $page - 1; ?>">上一页</a></li>
|
|
<?php else: ?>
|
|
<li><span class="extend prev disabled">首页</span></li>
|
|
<li><span class="extend prev disabled">上一页</span></li>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
// 显示页码
|
|
$startPage = max(1, $page - 2);
|
|
$endPage = min($totalPages, $page + 2);
|
|
|
|
for ($i = $startPage; $i <= $endPage; $i++):
|
|
if ($i == $page):
|
|
?>
|
|
<li><span class="page-number current"><?php echo $i; ?></span></li>
|
|
<?php else: ?>
|
|
<li><a class="page-number" href="?page=<?php echo $i; ?>"><?php echo $i; ?></a></li>
|
|
<?php endif; endfor; ?>
|
|
|
|
<?php if ($page < $totalPages): ?>
|
|
<li><a class="extend next" href="?page=<?php echo $page + 1; ?>">下一页</a></li>
|
|
<li><a class="extend next" href="?page=<?php echo $totalPages; ?>">尾页</a></li>
|
|
<?php else: ?>
|
|
<li><span class="extend next disabled">下一页</span></li>
|
|
<li><span class="extend next disabled">尾页</span></li>
|
|
<?php endif; ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!--<div style="text-align: center; margin-top: 30px;">
|
|
<a href="<?php echo $adminUrl; ?>/manage-posts.php" class="btn btn-primary" target="_blank">返回文章管理</a>
|
|
</div>-->
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|